russo@M.CS.UIUC.EDU (Vince Russo) (12/19/88)
I think I posted this bug earlier but I'n not sure mail to the gnu mailing lists is ever leaving out site. Since I posted it, however, I have found the bug and a fix for it. I included the fix at the end of this file. --Vince Russo russo@cs.uiuc.edu ----------------------------------------------------------------------- The following program reveals an inconsistency between using inline functions and non-inline functions with gcc-1.31 for the ns32000. /* * The inline function. */ inline unsigned int floor( unsigned int ia ) { ia &= (unsigned int) 0xfffff000; return( ia ); } /* * An identical non-inline version. */ unsigned int X1( unsigned int ia ) { ia &= (unsigned int) 0xfffff000; return( ia ); } /* * A use of the inline version. */ unsigned int X2( unsigned int ia ) { return( floor( ia ) ); } ------------------------------------------------------ When compiled for an Encore Multimax (tm-encore.h nm32k.md and output-ns32k.c), the following (incorrect) code is generated. With or without -0 the same bug appears. ---------------------------------------------------- .text .align 16 .globl _floor _floor: enter [],0 movd 8(fp),r0 andw $61440,r0 exit [] ret 0 .align 16 .globl _X1 _X1: enter [],0 movd 8(fp),r0 andw $61440,r0 exit [] ret 0 .align 16 .globl _X2 _X2: enter [],0 movd 8(fp),r0 andd $61440,r0 <<<<<<< Why did this become andd instead of andw? exit [] ret 0 ---------------------------------------- One a SUN3 the correct code is generated ---------------------------------------- #NO_APP .text .even .globl _floor _floor: link a6,#0 movel a6@(8),d0 andw #61440,d0 unlk a6 rts .even .globl _X1 _X1: link a6,#0 movel a6@(8),d0 andw #61440,d0 unlk a6 rts .even .globl _X2 _X2: link a6,#0 movel a6@(8),d0 andw #61440,d0 <<<<< Still andw here unlk a6 rts ------------BUG FIX INCLUDED BELOW----------------- % diff ns32k.md.AS-DISTRIBUTED ns32k.md 1088c1088,1089 < INTVAL (operands[2]) &= 0xff; --- > operands[2] = gen_rtx (CONST_INT, VOIDmode, > INTVAL (operands[2]) & 0xff); 1095c1096,1097 < INTVAL (operands[2]) &= 0xffff; --- > operands[2] = gen_rtx (CONST_INT, VOIDmode, > INTVAL (operands[2]) & 0xffff); 1114c1116,1117 < INTVAL (operands[2]) &= 0xff; --- > operands[2] = gen_rtx (CONST_INT, VOIDmode, > INTVAL (operands[2]) & 0xff);