On 02/22/2017 09:32 AM, Dominique d'Humières wrote:
Let me stand up an i686 linux instance and see if I can twiddle things without
compromising the test.
Also darwin is a -fpic platform.
Which is the key here :-) The test works fine without PIC, but once PIC
is introduced, it blows up.
It's pretty easy to see in the assembly code and the dumps.
Prior to IRA we have:
bb3 (loop header):
[ ... ]
(insn 8 7 9 3 (set (mem:SI (pre_dec:SI (reg/f:SI 7 sp)) [1 S4 A32])
(reg/v:SI 89 [ e ])) "j.c":9 56 {*pushsi2}
(expr_list:REG_ARGS_SIZE (const_int 8 [0x8])
(nil)))
[ ... ]
bb5 (conditional within the loop):
(insn 28 26 30 5 (set (reg/v:SI 89 [ e ])
(mem/u:SI (plus:SI (reg:SI 87)
(const:SI (plus:SI (unspec:SI [
(symbol_ref:SI ("d") [flags 0x2]
<var_decl 0xb72e70fc d>)
] UNSPEC_GOTOFF)
(const_int 331350016 [0x13c00000])))) [1
d+331350016 S4 A32])) "j.c":11 75 {*movsi_internal}
(expr_list:REG_DEAD (reg:SI 87)
(nil)))
After IRA we have:
bb3 (loop header)
(insn 8 7 9 3 (set (mem:SI (pre_dec:SI (reg/f:SI 7 sp)) [1 S4 A32])
(mem/u:SI (plus:SI (reg:SI 87)
(const:SI (plus:SI (unspec:SI [
(symbol_ref:SI ("d") [flags 0x2]
<var_decl 0xb72e70fc d>)
] UNSPEC_GOTOFF)
(const_int 331350016 [0x13c00000])))) [1
d+331350016 S4 A32])) "j.c":9 56 {*pushsi2}
(expr_list:REG_ARGS_SIZE (const_int 8 [0x8])
(nil)))
And of course that goes boom.
Note that we don't have a REG_EQUAL prior to IRA. That allows us to
zero in on this code within IRA which adds the note to insn 28:
3485 /* cse sometimes generates function invariants, but
doesn't put a
3486 REG_EQUAL note on the insn. Since this note would
be redundant,
3487 there's no point creating it earlier than here. */
3488 if (! note && ! rtx_varies_p (src, 0))
3489 note = set_unique_reg_note (insn, REG_EQUAL,
copy_rtx (src));
may_trap_p returns false for the note:
expr_list:REG_EQUAL (mem/u:SI (plus:SI (reg:SI 87)
(const:SI (plus:SI (unspec:SI [
(symbol_ref:SI ("d") [flags 0x2] <var_decl
0xb79450fc d>)
] UNSPEC_GOTOFF)
(const_int 331350016 [0x13c00000])))) [1
d+331350016 S4 A32])
And thus we keep the equivalence. Ultimately may_trap_p considers a PIC
memory reference as non-trapping.
I really wonder if we should just drop the may_trap_p test and always do
the domination check.
jeff