aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-ch.cc
diff options
context:
space:
mode:
authorRoger Sayle <roger@nextmovesoftware.com>2023-07-12 14:12:34 +0100
committerRoger Sayle <roger@nextmovesoftware.com>2023-07-12 14:12:34 +0100
commitd2c18b4a16f9e1a6ed271ec1efaf94533d1c4a94 (patch)
tree1742aa675fa78ff1cfb56bb6f159d8912a1e365a /gcc/tree-ssa-loop-ch.cc
parent46ade8c9cc860170ab4253cffd24169efa46ca70 (diff)
downloadgcc-d2c18b4a16f9e1a6ed271ec1efaf94533d1c4a94.zip
gcc-d2c18b4a16f9e1a6ed271ec1efaf94533d1c4a94.tar.gz
gcc-d2c18b4a16f9e1a6ed271ec1efaf94533d1c4a94.tar.bz2
PR target/110598: Fix rega = 0; rega ^= rega regression in i386.md
This patch fixes the regression PR target/110598 caused by my recent addition of a peephole2. The intention of that optimization was to simplify zeroing a register, followed by an IOR, XOR or PLUS operation on it into a move, or as described in the comment: ;; Peephole2 rega = 0; rega op= regb into rega = regb. The issue is that I'd failed to consider the (rare and unusual) case, where regb is rega, where the transformation leads to the incorrect "rega = rega", when it should be "rega = 0". The minimal fix is to add a !reg_mentioned_p check to the recent peephole2. In addition to resolving the regression, I've added a second peephole2 to optimize the problematic case above, which contains a false dependency and is therefore tricky to optimize elsewhere. This is an improvement over GCC 13, for example, that generates the redundant: xorl %edx, %edx xorq %rdx, %rdx 2023-07-12 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog PR target/110598 * config/i386/i386.md (peephole2): Check !reg_mentioned_p when optimizing rega = 0; rega op= regb for op in [XOR,IOR,PLUS]. (peephole2): Simplify rega = 0; rega op= rega cases. gcc/testsuite/ChangeLog PR target/110598 * gcc.target/i386/pr110598.c: New test case.
Diffstat (limited to 'gcc/tree-ssa-loop-ch.cc')
0 files changed, 0 insertions, 0 deletions