]> git.ipfire.org Git - thirdparty/gcc.git/commit
Optimize x < 0 ? ~y : y to (x >> 31) ^ y in match.pd
authorAndrew Pinski <apinski@marvell.com>
Sat, 22 May 2021 19:49:50 +0000 (19:49 +0000)
committerAndrew Pinski <apinski@marvell.com>
Wed, 26 May 2021 00:46:31 +0000 (00:46 +0000)
commit1fd76b24306ed4df4cf9e797d900699ed59ce7f7
tree21638bbbf36429bc99662ceafab24dc0cda85ae0
parentb6bdd7a4cb41ee057f2d064fffcb00f23ce6b497
Optimize x < 0 ? ~y : y to (x >> 31) ^ y in match.pd

This copies the optimization that is done in phiopt for
"x < 0 ? ~y : y to (x >> 31) ^ y" into match.pd. The code
for phiopt is kept around until phiopt uses match.pd (which
I am working towards).

Note the original testcase is now optimized early on and I added a
new testcase to optimize during phiopt.

OK?  Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

Differences from v1:
V2: Add check for integeral type to make sure vector types are not done.

gcc:
* match.pd (x < 0 ? ~y : y): New patterns.

gcc/testsuite:
* gcc.dg/tree-ssa/pr96928.c: Update test for slightly different IR.
* gcc.dg/tree-ssa/pr96928-1.c: New testcase.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/pr96928-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr96928.c