This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/16195] Miscompilation of GCC 3.3.x by 3.4.x


------- Additional Comments From jakub at gcc dot gnu dot org  2004-06-25 12:01 -------
At lreg time there is:
(insn 38 66 39 3 (set (reg:DF 127 [ x ])
        (mem/u/f:DF (plus:DI (reg:DI 30 30)
                (const:DI (minus:DI (symbol_ref/u:DI ("*.LC1") [flags 0x2])
                        (symbol_ref:DI ("*.LCTOC1"))))) [0 S8 A64])) 312
{*movdf_hardfloat64} (nil)
    (expr_list:REG_DEAD (reg:DI 30 30)
        (expr_list:REG_EQUAL (const_double:DF 7.0e+1 [0x0.8cp+7])
            (nil))))
...
(insn 40 67 42 4 (set (mem/f:DF (plus:DI (reg/f:DI 31 31)
                (const_int 112 [0x70])) [0 x+0 S8 A64])
        (reg:DF 127 [ x ])) 312 {*movdf_hardfloat64} (nil)
    (expr_list:REG_DEAD (reg:DF 127 [ x ])
        (nil)))
...
(insn 43 42 44 4 (set (reg:DF 132)
        (const_double:DF 3.0e+1 [0x0.fp+5])) 312 {*movdf_hardfloat64} (nil)
    (nil))

As insn 38 is the last one which uses the PIC register at lreg time, global alloc
decides to put DF 127 into DF 30:
Reloads for insn # 38
Reload 0: reload_out (DF) = (reg:DF 127 [ x ])
        GENERAL_REGS, RELOAD_FOR_OUTPUT (opnum = 0)
        reload_out_reg: (reg:DF 127 [ x ])
        reload_reg_rtx: (reg:DF 30 30)

which would be fine if insn 43 was not reloaded into:
(insn 43 42 44 4 (set (reg:DF 32 0 [132])
        (mem/u/f:DF (plus:DI (reg:DI 30 30)
                (const:DI (minus:DI (symbol_ref/u:DI ("*.LC3") [flags 0x2])
                        (symbol_ref:DI ("*.LCTOC1"))))) [0 S8 A64])) 312
{*movdf_hardfloat64} (nil)
    (nil))

RS6000_PIC_OFFSET_TABLE_REGNUM is not a fixed reg on ppc64 and insn 43 at lreg
time has no (use (reg:DI 30 30)) or something similar, so there is nothing that
prevents this.  In GCC 3.3.4 the situation is the same, but the testcase works,
as register f0 is chosen instead of r30.  In 3.4 without -mminimal-toc, but with
-fpic or -fPIC the situation is very similar, s/r30/r2/, but r0 is chosen instead
of r2 and thus the testcase doesn't fail, still I don't see what would prevent
under bigger register preasure using that register.

Given that rs6000_legitimize_reload_address on TARGET_TOC architectures can
reference TOC_REGISTER at any time (call create_TOC_reference ()), I don't see
other solution than to:
if (TARGET_TOC)
  {
    fixed_regs[TOC_REGISTER] = call_used_regs[TOC_REGISTER] = 1;
  }
in CONDITIONAL_REGISTER_USAGE (resp. rs6000_conditional_register_usage in 3.5),
do you agree?  Dunno if it should be call_really_used_regs[TOC_REGISTER] = 1
as well or not.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dje at watson dot ibm dot
                   |                            |com, amodra at bigpond dot
                   |                            |net dot au


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]