ix86: Add peephole2 for *add<mode>3_cc_overflow_1 followed by matching memory store...
authorJakub Jelinek <jakub@redhat.com>
Fri, 8 May 2020 08:03:56 +0000 (10:03 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 8 May 2020 08:03:56 +0000 (10:03 +0200)
commita229f9b3737062c6e853879be6683f3f3e4a6661
tree31fa0f21442170ed14bc6e3f755c2f0a08010653
parenta139bc2b492de8a761890a5d299951dede3d8f7b
ix86: Add peephole2 for *add<mode>3_cc_overflow_1 followed by matching memory store [PR94857]

The following peephole2 changes:
- addl (%rdi), %esi
+ xorl %eax, %eax
+ addl %esi, (%rdi)
  setc %al
- movl %esi, (%rdi)
- movzbl %al, %eax
  ret
on the testcase.  *add<mode>3_cc_overflow_1, being an add{l,q} insn, is
commutative, so if TARGET_READ_MODIFY_WRITE we can replace
addl (%rdi), %esi; movl %esi, (%rdi)
with
addl %esi, (%rdi)
if %esi is dead after those two insns.

2020-05-08  Jakub Jelinek  <jakub@redhat.com>

PR target/94857
* config/i386/i386.md (peephole2 after *add<mode>3_cc_overflow_1): New
define_peephole2.

* gcc.target/i386/pr94857.c: New test.
gcc/ChangeLog
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr94857.c [new file with mode: 0644]