https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92294
--- Comment #6 from Marius Hillenbrand <mhillen at linux dot ibm.com> ---
Same behavior on s390x: the testcase always calls abort(). As on aarch64,
-fno-section-anchors avoids the issue.
the first cse pass already makes a mistake -- on both aarch64 and s390x, the
compare looses its memory-read for the current value of b and instead reuses
the constant 1 assigned to b earlier.
on aarch64 that looks like
(insn # # # 2 (set (reg:SI 110)
(mem:SI (plus:DI (mult:DI (reg:DI 109)
(const_int 4 [0x4]))
(reg/f:DI 107)) [1 b[off.0_1]+0 S4 A32])) "alias-2.c":9:6#
{*movsi_aarch64}
(nil))
(insn # # # 2 (set (reg:CC 66 cc)
(compare:CC (reg:SI 110)
(const_int 2 [0x2]))) "alias-2.c":9:6# {cmpsi}
(nil))
... becomes ...
(insn # # # 2 (set (reg:SI 100)
(const_int 1 [0x1])) "alias-2.c":7:9# {*movsi_aarch64}
(nil)) [from the write to b]
...
(insn # # # 2 (set (reg:CC 66 cc)
(compare:CC (reg:SI 100)
(const_int 2 [0x2]))) "alias-2.c":9:6# {cmpsi}
(expr_list:REG_DEAD (reg:SI 110 [ b[off.0_1] ])
(nil)))