-mm: i386 i8259.c simplify i8259A_irq_real()
PATCH 1/1 -mm: i386 i8259.c simplify i8259A_irq_real()
Hello all,
I noticed the very "non-nice" asymmetry of i8259A_irq_real(),
so I decided to fix the weirdly aligned branches.
While doing this, I noticed that it could be streamlined much more, resulting in an astonishing 208 byte object code saving for such a tiny code fragment! (gcc 3.2.3)
Review appreciated, I believe it's correct but I've only tested it shortly and it's slowpath anyway.
Patch against 2.6.17-rc2-mm1.
Thanks!
arch/i386/kernel/i8259.c +11 -8
@@ -145,17 +145,20 @@static inline int i8259A_irq_real (unsigned int irq) {int value; -int irqmask =1 <<irq; +int irqmask; +int reg;if (irq <8 ) { -outb (0x0B ,PIC_MASTER_CMD );/* ISR register */ - value =inb (PIC_MASTER_CMD ) & irqmask; -outb (0x0A ,PIC_MASTER_CMD );/* back to the IRR register */ -return value; + reg =PIC_MASTER_CMD ; + irqmask =1 << irq; + }else { + reg =PIC_SLAVE_CMD ; + irqmask =1 << (irq -8 ); } -outb (0x0B ,PIC_SLAVE_CMD );/* ISR register */ - value =inb (PIC_SLAVE_CMD ) & (irqmask >>8 ); -outb (0x0A ,PIC_SLAVE_CMD );/* back to the IRR register */ + +outb (0x0B , reg);/* ISR register */ + value =inb (reg) & irqmask; +outb (0x0A , reg);/* back to the IRR register */ return value; }
Quoted 8 lines · Andreas Mohr
Hello all,
I noticed the very "non-nice" asymmetry of
i8259A_irq_real(),
so I decided to fix the weirdly aligned branches.
While doing this, I noticed that it could be streamlined much more, resulting in an astonishing 208 byte object code saving for such a tiny code fragment! (gcc 3.2.3)
It saves an astonishing two bytes here, with gcc-3.2.1
text data bss dec hex filename
1302 388 10 1700 6a4 arch/i386/kernel/i8259.o
1300 388 10 1698 6a2 arch/i386/kernel/i8259.o
;)
And with gcc-4.2.0:
bix:/usr/src/25> size arch/i386/kernel/i8259.o
text data bss dec hex filename
1340 356 12 1708 6ac arch/i386/kernel/i8259.o
1335 356 12 1703 6a7 arch/i386/kernel/i8259.o