[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#105622: Test case



retitle 105622 [m68k] Generates invalid asm instruction with -O2
thanks

OK, here is the test case.  I stripped out everything specific to Hercules, and
removed as many statements as possible.  If I change pretty much any of what's
left, the bug doesn't occur.  To reproduce:

mdz@ipmsun1:/unstable/build/mdz/hercules-2.12$ cc -O2 -c test.c
/tmp/cc23gVSZ.s: Assembler messages:
/tmp/cc23gVSZ.s:69: Error: operands mismatch -- statement `add.l %a4,-20(%a6)' ignored
mdz@ipmsun1:/unstable/build/mdz/hercules-2.12$ cc -O1 -c test.c
mdz@ipmsun1:/unstable/build/mdz/hercules-2.12$ 

The same code compiles fine with -O2 on i386.

Versions used:

gcc		2.95.3-7
gcc-2.95	2.95.4-0.010604
libc6		2.2.3-5
cpp-2.95	2.95.4-0.010604
binutils	2.11.90.0.7-2

-- 
 - mdz
typedef unsigned int U32;
typedef unsigned long long U64;
typedef unsigned char BYTE;
typedef struct _EXTENDED_FLOAT {
        U64     ms_fract, ls_fract;     /* Fraction                  */
        short   expo;                   /* Exponent + 64             */
        BYTE    sign;                   /* Sign                      */
} EXTENDED_FLOAT;

static void func(EXTENDED_FLOAT *p) {};

void mul_ef( EXTENDED_FLOAT *fl, EXTENDED_FLOAT *mul_fl)
{
U64 wk1;
U64 wk2;
U64 wk3;
U64 wk;
U32 wk0;

	/* some function call here is necessary to reproduce the bug */
        func(mul_fl);

        wk0 = ((fl->ls_fract & 0x00000000FFFFFFFFULL) * (mul_fl->ls_fract & 0x00000000FFFFFFFFULL)) >> 32;

        wk = wk0 + (wk1 & 0x00000000FFFFFFFFULL) + (wk2 & 0x00000000FFFFFFFFULL);
        wk = (wk >> 32) + (wk1 >> 32) + (wk2 >> 32);

        wk1 = (fl->ls_fract & 0x00000000FFFFFFFFULL) * (mul_fl->ms_fract & 0x00000000FFFFFFFFULL);
        wk3 = (fl->ms_fract & 0x00000000FFFFFFFFULL) * (mul_fl->ls_fract & 0x00000000FFFFFFFFULL);

        wk2 = (fl->ls_fract >> 32) * (mul_fl->ms_fract & 0x00000000FFFFFFFFULL);

        wk2 = (fl->ms_fract & 0x00000000FFFFFFFFULL) * (mul_fl->ms_fract & 0x00000000FFFFFFFFULL);
        wk += ((wk1 & 0x00000000FFFFFFFFULL) + (wk2 & 0x00000000FFFFFFFFULL) + (wk3 & 0x00000000FFFFFFFFULL));
        fl->ls_fract = wk & 0x00000000FFFFFFFFULL;
} /* end function mul_ef */

/* end of float.c */

Reply to: