This is the mail archive of the gcc-patches@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]

Re: [PATCH] Fix PR target/16195 (ppc64 -mminimal-toc miscompilations)


On Fri, Jun 25, 2004 at 08:01:04PM -0400, David Edelsohn wrote:
> Jakub> The testcase below is miscompiled with -mminimal-toc.
> Jakub> The problem is that TOC_REGISTER (r30) is not fixed, yet references to it
> Jakub> are created during reload (e.g. when changing floating point constants
> Jakub> into constant pool references).  There is nothing that prevents the compiler
> Jakub> from allocating some pseudo(s) into this register, but then all later
> Jakub> created references to the TOC_REGISTER are broken.
> 
> 	I assume that you are referring to a case when the compiler wants
> to load a constant from the TOC, only discovers that it needs the constant
> during reload, and the function previously did not have any TOC
> references.  Materializing the constant in a register probably is

No, in this exact testcase there are some TOC references already before
register allocation:

;; Function test
...
(insn 23 22 24 0 (set (reg:DF 125)
        (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_EQUAL (const_double:DF 7.0e+1 [0x0.8cp+7])
        (nil)))
...
(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))

The important thing the REG_DEAD note, after insn 38 there are no more
TOC reg references at that time.
Register allocator puts reg:DF 127 into the TOC register, since it is
dead at that point according to life analysis, which clobbers the register,
and afterwards when reloading insn 43 the TOC register is used there again.

> difficult.  Given that GCC now operates in at least function-at-a-time
> mode, why can't we just backup and have cgraph recompile the function with
> a flag that says we will need to reference the TOC?

In this case it would be hard to differentiate which uses of r30 are TOC
uses and where it holds some other unrelated value.

	Jakub


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