On 7/13/24 9:09 AM, Richard Sandiford wrote:
The asm in the testcase has a memory operand and also clobbers ax.
The clobber means that ax cannot be used to hold inputs, which
extends to the address of the memory.

I think I had an implicit assumption that constrain_operands
would enforce this, but in hindsight, that clearly wasn't going
to be true.  constrain_operands only looks at constraints, and
these clobbers are by definition outside the constraint system.
(And that's why they have to be handled conservatively, since there's
no way to distinguish the earlyclobber and non-earlyclobber cases.)

The semantics of hard-coded clobbers are generic enough that I think
they should be handled directly by rtl-ssa, rather than by consumers.
And in the context of rtl-ssa, the easiest way to check for a clash is
to walk the list of input registers, which we already have to hand.
It therefore seemed better not to push this down to a more generic
rtl helper.

The patch detects hard-coded clobbers in the same way as regrename:
by temporarily stubbing out the operands with pc_rtx.

Tested on aarch64-linux-gnu & x86_64-linux-gnu.  OK to install?

Richard


gcc/
        PR rtl-optimization/115891
        * rtl-ssa/changes.cc (find_clobbered_access): New function.
        (recog_level2): Use it to check for overlap between input
        registers and hard-coded clobbers.  Conditionally reset
        recog_data.insn after changing the insn code.

gcc/testsuite/
        PR rtl-optimization/115891
        * gcc.target/i386/pr115891.c: New test.
OK.

jeff

Reply via email to