]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PR123121, LRA]: Fix wrong rematerialization of insns with several outputs
authorVladimir N. Makarov <vmakarov@redhat.com>
Fri, 9 Jan 2026 15:36:29 +0000 (10:36 -0500)
committerVladimir N. Makarov <vmakarov@redhat.com>
Fri, 9 Jan 2026 15:37:11 +0000 (10:37 -0500)
commitc10076b34d3ede485bfb306b2a91feeee8368cd5
tree06e3dd7d4835fa25374ea2c91f34dcfd57b2a9b4
parentb8634a0b929cdd6b37275828d6a9fd390b5900c7
[PR123121, LRA]: Fix wrong rematerialization of insns with several outputs

LRA in the test case, rematerialize insn with div/mod where div result
is not used.  Still div result requires ax which is used by different
pseudos at point of rematerialization and this clobbers the pseudo
value.  The patch solves the problem by constraining to single set
insns as we always rematerialize only one pseudo value.  Also there is
no sense to rematerialize div/mod as usually their latency is more
than load value from CPU cache.  The patch explicitly excludes such
insns from rematerialization.

gcc/ChangeLog:

PR rtl-optimization/123121
* lra-remat.cc (bad_for_rematerialization_p): Consider div/mod ops.
(operand_to_remat): Exclude rematerialization of insns with
multiple sets.

gcc/testsuite/ChangeLog:

PR rtl-optimization/123121
* gcc.target/i386/pr123121.c: New.
gcc/lra-remat.cc
gcc/testsuite/gcc.target/i386/pr123121.c [new file with mode: 0644]