Hello, Please consider this little snippett of code:
----- 8< ---------------------- 8< -------------- #define AU1000_INTC0_INT_BASE 8 #define IC0_FALLINGCLR 0xb0400078 #define IC0_RISINGCLR 0xb040007c static inline void au_writel(unsigned long d, unsigned long a) { *(unsigned long *)(a) = d; } void au1x_ic0_ack(unsigned int irq_nr) { unsigned int bit = irq_nr - AU1000_INTC0_INT_BASE; au_writel(1 << bit, IC0_FALLINGCLR); au_writel(1 << bit, IC0_RISINGCLR); } ----- 8< ---------------------- 8< -------------- cross-compiled for a MIPS32 environment (linux-kernel source), the following output is generated: Dump of assembler code for function au1x_ic0_ack: 0x80101140 <au1x_ic0_ack+0>: addiu a0,a0,-8 0x80101144 <au1x_ic0_ack+4>: lui v0,0xb040 0x80101148 <au1x_ic0_ack+8>: li v1,1 0x8010114c <au1x_ic0_ack+12>: sllv v1,v1,a0 0x80101150 <au1x_ic0_ack+16>: ori a0,v0,0x78 0x80101154 <au1x_ic0_ack+20>: ori v0,v0,0x7c 0x80101158 <au1x_ic0_ack+24>: sw v1,0(v0) 0x8010115c <au1x_ic0_ack+28>: sw v1,0(a0) 0x80101160 <au1x_ic0_ack+32>: jr ra 0x80101164 <au1x_ic0_ack+36>: nop My question is why does it generate the two ori instructions at +16 and +20 when it could just as easily add the offsets to the sw instructions? Versions 4.3.2, 4.2.4 and even 3.4.6 generate this sequence; there's no difference between -O2 and -Os. Admittedly my understanding of mips assembly is not yet very advanced, am I missing something or is this a bug? For reference, the full commandline is: mipsel-softfloat-linux-gnu-gcc -Wp,-MD,arch/mips/alchemy/common/.irq.o.d -nostdinc -isystem /usr/lib/gcc/mipsel-softfloat-linux-gnu/4.3.2/include -D__KERNEL__ -Iinclude -Iinclude2 -I/mnt/work/au1200/kernel/linux-2.6.git/include -I/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include -include include/linux/autoconf.h -I/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/alchemy/common -Iarch/mips/alchemy/common -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Os -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=mips32 -Wa,-mips32 -Wa,--trap -I/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include/asm/mach-au1x00 -I/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include/asm/mach-exm1200 -Iarch/mips/include/asm/mach-exm1200 -I/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include/asm/mach-generic -D"VMLINUX_LOAD_ADDRESS=0xffffffff80100000" -fno-stack-protector -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign -Werror -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(irq)" -D"KBUILD_MODNAME=KBUILD_STR(irq)" -c -o arch/mips/alchemy/common/irq.o /mnt/work/au1200/kernel/linux-2.6.git/arch/mips/alchemy/common/irq.c Target: mipsel-softfloat-linux-gnu Configured with: /tmp-ram/portage/cross-mipsel-softfloat-linux-gnu/gcc-4.3.2/work/gcc-4.3.2/configure --prefix=/usr/ --bindir=/usr/x86_64-pc-linux-gnu/mipsel-softfloat-linux-gnu/gcc-bin/4.3.2 --includedir=/usr/lib/gcc/mipsel-softfloat-linux-gnu/4.3.2/include/ --datadir=/usr/share/gcc-data/mipsel-softfloat-linux-gnu/4.3.2 --mandir=/usr/share/gcc-data/mipsel-softfloat-linux-gnu/4.3.2/man/ --infodir=/usr/share/gcc-data/mipsel-softfloat-linux-gnu/4.3.2/info --with-gxx-include-dir=/usr/lib/gcc/mipsel-softfloat-linux-gnu/4.3.2/include/g++-v4/ --host=x86_64-pc-linux-gnu --target=mipsel-softfloat-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --with-float=soft/ --disable-nls --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-multilib --disable-libmudflap --disable-libssp/ --enable-cld --disable-libgcj --enable-languages=c,c++ --with-sysroot=/usr/mipsel-softfloat-linux-gnu --disable-bootstrap/ --disable-libgomp --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.2 p1.0' Thread model: posix gcc version 4.3.2 (Gentoo 4.3.2 p1.0) Thanks, Manuel Lauss