[Bug target/36090] New: [4.3/4.4 Regression] ppc64 cacoshl miscompilation

jakub at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Apr 30 20:16:00 GMT 2008


extern void abort (void);

long double __attribute__ ((noinline)) foo (long double x)
{
  return __builtin_signbit (x) ? 3.1415926535897932384626433832795029L : 0.0;
}

int
main (void)
{
  if (foo (-1.0L) != 3.1415926535897932384626433832795029L)
    abort ();
  return 0;
}

is miscompiled with -O2 -m64 -mlong-double-128.
Both doubles of the long double return value from foo as the high double
of PI.
The assembly loads this long double value into 0/11 register pair using:
        ld 11,.LC1@toc(2)
        ld 0,.LC1@toc(2)
In RTL there is actually the +8 for the first insn present, but with double
negation:
(insn:TI 40 20 39 t.c:5 (set (reg:DI 11 11 [orig:132 D.1237+8 ] [132])
        (mem/u/c/i:DI (plus:DI (reg:DI 2 2)
                (const:DI (minus:DI (symbol_ref/u:DI ("*.LC1") [flags 0x2])
                        (const:DI (plus:DI (symbol_ref:DI ("*.LCTOC1"))
                                (const_int -8 [0xfffffffffffffff8])))))) [2 S8
A64])) 334 {*movdi_internal64} (nil))

(insn 39 40 23 t.c:5 (set (reg:DI 0 0 [orig:131 D.1237 ] [131])
        (mem/u/c/i:DI (plus:DI (reg:DI 2 2)
                (const:DI (minus:DI (symbol_ref/u:DI ("*.LC1") [flags 0x2])
                        (symbol_ref:DI ("*.LCTOC1"))))) [2 S8 A128])) 334
{*movdi_internal64} (expr_list:REG_DEAD (reg:DI 2 2)
        (nil)))
So, either the output routines need to be fixed to handle even this weirdo
addressing correctly and output 8+.LC1@toc(2), or the pass that generate this
needs to be changed to generate something better.


-- 
           Summary: [4.3/4.4 Regression] ppc64 cacoshl miscompilation
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org
GCC target triplet: powerpc64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36090



More information about the Gcc-bugs mailing list