]> git.ipfire.org Git - thirdparty/gcc.git/commit
ifcombine field merge: handle masks with sign extensions
authorAlexandre Oliva <oliva@adacore.com>
Thu, 19 Dec 2024 01:17:31 +0000 (22:17 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Thu, 19 Dec 2024 01:19:35 +0000 (22:19 -0300)
commit87f97ffba93a2de17eca3927af901e3b3a103df7
tree9cb2f76f8c10cfbc39609638247943ea877bc848
parent6d5df5133c5dd8f9ec8f213d0e51b77958a54d28
ifcombine field merge: handle masks with sign extensions

When a loaded field is sign extended, masked and compared, we used to
drop from the mask the bits past the original field width, which is
not correct.

Take note of the fact that the mask covered copies of the sign bit,
before clipping it, and arrange to test the sign bit if we're
comparing with zero.  Punt in other cases.

If bits_test fail recoverably, try other ifcombine strategies.

for  gcc/ChangeLog

* gimple-fold.cc (decode_field_reference): Add psignbit
parameter.  Set it if the mask references sign-extending
bits.
(fold_truth_andor_for_ifcombine): Adjust calls with new
variables.  Swap them along with other r?_* variables.  Handle
extended sign bit compares with zero.
* tree-ssa-ifcombine.cc (ifcombine_ifandif): If bits_test
fails in a way that doesn't prevent other ifcombine strategies
from passing, give them a try.

for  gcc/testsuite/ChangeLog

* gcc.dg/field-merge-16.c: New.
gcc/gimple-fold.cc
gcc/testsuite/gcc.dg/field-merge-16.c [new file with mode: 0644]
gcc/tree-ssa-ifcombine.cc