https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127948
liu zhenyu <lzy20000419 at outlook dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lzy20000419 at outlook dot com
--- Comment #3 from liu zhenyu <lzy20000419 at outlook dot com> ---
The REE same-register path ignores partial call clobbers in general, not only
for SSE registers. A scalar example on s390 -m31 -mzarch, where r6-r15 have
only bits 32-63 call-saved and s390_hard_regno_call_part_clobbered returns true
for DImode:
void g(void);
void f1(int *p, long long *q)
{
int x = *p;
g();
q[0] = (long long)x * q[1];
}
$ s390x-linux-gnu-gcc -m31 -mzarch -O2 -free -S t.c
lgf %r11,0(%r2) # sign extension merged into the load, before the
call
brasl %r14,g@PLT # an -m31 callee saves/restores only the low 32
bits of r11
msg %r11,8(%r10) # uses all 64 bits
Without -free the code is l %r11,0(%r2); brasl g; lgfr %r0,%r11, which is
correct. Seen with 11.2.0, 14.2.0, 15.2.0 and 16.1.0. Run under qemu-s390x with
an ordinary non-leaf -m31 callee, I get 12884901873 instead of -15. Godbolt has
no s390x trunk; gcc/ree.cc on trunk (20261113) still has no partial-clobber
check on this path.
Godbolt (s390x 16.1, with and without -free): https://godbolt.org/z/Kdxo6nT13
combine_reaching_defs (ree.cc, !copy_needed path) widens the def without
checking whether a call between the def and the extension part-clobbers the
register in the wider mode. The copy_needed path is safe because
reg_set_between_p consults insn_callee_abi. Rejecting the same-register merge
when any intervening call has insn_callee_abi (call).clobbers_reg_p
(cand->mode, REGNO (dest)) fixes both this and the ymm case.
Disclaimer: This test case was found with LLM-assisted targeted testing, and
the report was written with LLM assistance.