[Bug rtl-optimization/97497] New: gcse wrong code generation with partial register clobbers
krebbel at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Oct 19 16:39:20 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97497
Bug ID: 97497
Summary: gcse wrong code generation with partial register
clobbers
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: krebbel at gcc dot gnu.org
Target Milestone: ---
Compiling the attached testcase produces wrong code on IBM Z:
cc1 t.c -m31 -mzarch -march=z900 -O2 -fpic -o t.s
foo:
stm %r11,%r15,44(%r15)
larl %r12,_GLOBAL_OFFSET_TABLE_
lr %r11,%r2
l %r1,t@GOT(%r12)
ahi %r15,-96
lhi %r2,1
l %r3,0(%r1)
brasl %r14,bar@PLT
ltr %r11,%r11
jne .L8
lhi %r2,1
l %r3,0 <--- dereference address 0
brasl %r14,bar@PLT
l %r4,152(%r15)
lm %r11,%r15,140(%r15)
br %r4
.L8:
lhi %r3,1
l %r2,0 <--- dereference address 0
brasl %r14,baz@PLT
lhi %r2,1
l %r3,0
brasl %r14,bar@PLT
l %r4,152(%r15)
lm %r11,%r15,140(%r15)
br %r4
gcse decides to remove the load from t in the subsequent bbs but does not
generate the load into a temp reg in the first bb leaving the bbs loading from
an uninitialized pseudo.
With -mzarch -m31 we have the GOT pointer marked as partially clobbered. The
loads from t use the GOT pointer explicitly in the RTX. Since this patch r12 is
considered to be fully clobbered by call insns:
commit a4dfaad2e5594d871fe00a1116005e28f95d644e (refs/bisect/bad)
Author: Richard Sandiford <richard.sandiford@arm.com>
Date: Mon Sep 30 16:20:44 2019 +0000
Remove global call sets: gcse.c
This is another case in which we can conservatively treat partial
kills as full kills. Again this is in principle a bug fix for
TARGET_HARD_REGNO_CALL_PART_CLOBBERED targets, but in practice
it probably doesn't make a difference.
2019-09-30 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* gcse.c: Include function-abi.h.
(compute_hash_table_work): Use insn_callee_abi to get the ABI of
the call insn target. Invalidate partially call-clobbered
registers as well as fully call-clobbered ones.
From-SVN: r276323
Now the RTX for t which references r12 is considered to be not available
anymore in the later bbs due to r12 being clobbered by the calls. Hence no load
of the original expression is being emitted.
More information about the Gcc-bugs
mailing list