This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/69195] [4.9/5/6 Regression] gcc.dg/torture/pr44913.c FAILs with -O3 -fno-dce -fno-forward-propagate
- From: "bergner at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 29 Jan 2016 23:00:52 +0000
- Subject: [Bug rtl-optimization/69195] [4.9/5/6 Regression] gcc.dg/torture/pr44913.c FAILs with -O3 -fno-dce -fno-forward-propagate
- Auto-submitted: auto-generated
- References: <bug-69195-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69195
--- Comment #9 from Peter Bergner <bergner at gcc dot gnu.org> ---
I think we have another bug in addition to the bug where we reuse a register
that is already in use. We have the rtl below which is used to initialize a[]
before the call to foo:
(insn 5 39 40 2 (set (reg/f:DI 172)
(unspec:DI [
(symbol_ref:DI ("*.LANCHOR0") [flags 0x182])
(reg:DI 2 2)
] UNSPEC_TOCREL)) bug.c:6 622 {*tocrefdi}
(expr_list:REG_EQUAL (symbol_ref:DI ("*.LANCHOR0") [flags 0x182])
(nil)))
(insn 40 5 6 2 (set (reg:DI 3 3)
(plus:DI (reg/f:DI 113 sfp)
(const_int 96 [0x60]))) bug.c:9 81 {*adddi3}
(nil))
(insn 6 40 8 2 (set (reg:DI 173)
(mem/u/c:DI (reg/f:DI 172) [0 S8 A32])) bug.c:6 540
{*movdi_internal64}
(nil))
(insn 8 6 10 2 (set (reg:DI 174)
(mem/u/c:DI (plus:DI (reg/f:DI 172)
(const_int 8 [0x8])) [0 S8 A32])) bug.c:6 540
{*movdi_internal64}
(nil))
(insn 10 8 12 2 (set (reg:DI 175)
(mem/u/c:DI (plus:DI (reg/f:DI 172)
(const_int 16 [0x10])) [0 S8 A32])) bug.c:6 540
{*movdi_internal64}
(nil))
.....
(insn 7 29 9 2 (set (mem/c:DI (plus:DI (reg/f:DI 113 sfp)
(const_int 96 [0x60])) [1 aD.2356+0 S8 A128])
(reg:DI 173)) bug.c:6 540 {*movdi_internal64}
(expr_list:REG_DEAD (reg:DI 173)
(nil)))
(insn 9 7 11 2 (set (mem/c:DI (plus:DI (reg/f:DI 113 sfp)
(const_int 104 [0x68])) [1 aD.2356+8 S8 A64])
(reg:DI 174)) bug.c:6 540 {*movdi_internal64}
(expr_list:REG_DEAD (reg:DI 174)
(nil)))
(insn 11 9 13 2 (set (mem/c:DI (plus:DI (reg/f:DI 113 sfp)
(const_int 112 [0x70])) [1 aD.2356+16 S8 A128])
(reg:DI 175)) bug.c:6 540 {*movdi_internal64}
(expr_list:REG_DEAD (reg:DI 175)
(nil)))
During allocation, we happily allocate volatiles to the above pseudos until run
out...when trying to allocate pseudos 173 and 174. Having run out of volatile
regs, we allocate non-volatiles to pseudos 173 and 174. However, in
assign_hard_reg(), we think it's cheaper to use memory than to use a
non-volatile, so we proactively spill 173 and 174:
Popping a34(r174,l0) -- (memory is more profitable 0 vs 7) spill!
Popping a35(r173,l0) -- (memory is more profitable 0 vs 7) spill!
The above says the cost of using memory is zero, which doesn't seem correct to
me. In fact, all of the pseudos being used to initialize a[] have a zero
memory cost, but since the volatile regs also have zero cost, we don't spill
them. It doesn't seem correct to me, that these pseudos have a zero memory
cost. I'll try to track down where that occurs.