https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77416
Bug ID: 77416 Summary: LRA rematerializing use of CA reg across function call Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pthaugen at gcc dot gnu.org CC: bergner at gcc dot gnu.org, dje.gcc at gmail dot com, vmakarov at gcc dot gnu.org, wschmidt at gcc dot gnu.org Target Milestone: --- Host: powerpc64-unknown-linux-gnu Target: powerpc64-unknown-linux-gnu Build: powerpc64-unknown-linux-gnu Created attachment 39521 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39521&action=edit reduced testcase CPU2006 benchmark 445.gobmk started failing verification of output starting with r239105 (switch rs6000 port to LRA). I tracked it down to code where LRA is rematerializing the use of the CA reg across a function call, which is not valid since a call can clobber it. Before the switch to LRA we saw the following code: addic 9,9,-1 addze 9,16 stw 9,492(1) ... code with function call(s) lwz 9,492(1) After LRA switch the code looks like this: addic 9,9,-1 addze 9,16 stw 9,492(1) ... code with function call(s) addze 9,16 Compile options for reduced testcase: gcc -S -O2 -m32 -mcpu=power7