]> git.ipfire.org Git - thirdparty/gcc.git/commit
Add peephole to eliminate redundant comparison after cmpccxadd.
authorliuhongt <hongtao.liu@intel.com>
Mon, 10 Jul 2023 06:12:07 +0000 (14:12 +0800)
committerliuhongt <hongtao.liu@intel.com>
Tue, 18 Jul 2023 03:31:25 +0000 (11:31 +0800)
commit06cc38c1c350b34cbd6dde23aefca32442c07a73
treed45959c82e53ea9daf252dd64816a9b6a25e5455
parente6a1b23872995d5344a81cff1857bc861ffee71d
Add peephole to eliminate redundant comparison after cmpccxadd.

Similar like we did for cmpxchg, but extended to all
ix86_comparison_int_operator since cmpccxadd set EFLAGS exactly same
as CMP.

When operand order in compare insn is same as that in cmpccxadd,
compare insn can be eliminated directly.

When operand order is swapped in compare insn, only optimize cmpccxadd
+ cmpl + jcc/setcc to cmpccxadd + jcc/setcc when FLAGS_REG is dead
after jcc/setcc.

gcc/ChangeLog:

PR target/110591
* config/i386/sync.md (cmpccxadd_<mode>): Adjust the pattern
to explicitly set FLAGS_REG like *cmp<mode>_1, also add extra
3 define_peephole2 after the pattern.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr110591.c: New test.
* gcc.target/i386/pr110591-2.c: New test.
gcc/config/i386/sync.md
gcc/testsuite/gcc.target/i386/pr110591-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr110591.c [new file with mode: 0644]