i386: Optimize double-word negation [PR51954]
commit59119253b3133b30114194a04171f9d353b5c7f7
authorUros Bizjak <ubizjak@gmail.com>
Fri, 29 Apr 2022 11:27:48 +0000 (29 13:27 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Fri, 29 Apr 2022 11:31:12 +0000 (29 13:31 +0200)
tree105aa73678b251a054964c0602875c73a40ef3f7
parentc090743b2ae0095f792371c7cbeb3cf6e2978f5d
i386: Optimize double-word negation [PR51954]

Introduce peephole2 pattern to convert from:

   mov %esi, %edx
   negl %eax
   adcl $0, %edx
   negl %edx
 to:
   xorl %edx, %edx
   negl %eax
   sbbl %esi, %edx

This conversion is profitable only when initial move is found.  Otherwise,
additional move to a temporary together with clearing xor is needed.

2022-04-29  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

PR target/51954
* config/i386/i386.md (adcl/neg -> sbb peephole): New peephole2.
gcc/testsuite/ChangeLog:

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