diff options
author | Andrew Pinski <apinski@marvell.com> | 2023-08-23 16:46:10 +0000 |
---|---|---|
committer | Andrew Pinski <apinski@marvell.com> | 2023-08-24 07:20:50 +0000 |
commit | 4aa14ec7d5b25722e4d02c29c8c1e22dcc5a4915 (patch) | |
tree | c7c5c10048aa3dc9a8748fb47a008fcdc396b97e /gcc/match.pd | |
parent | ddd64a6ec3b38e18aefb9fcba50c0d9297e5e711 (diff) | |
download | gcc-4aa14ec7d5b25722e4d02c29c8c1e22dcc5a4915.zip gcc-4aa14ec7d5b25722e4d02c29c8c1e22dcc5a4915.tar.gz gcc-4aa14ec7d5b25722e4d02c29c8c1e22dcc5a4915.tar.bz2 |
MATCH: [PR111109] Fix bit_ior(cond,cond) when comparisons are fp
The patterns that were added in r13-4620-g4d9db4bdd458, missed that
(a > b) and (a <= b) are not inverse of each other for floating point
comparisons (if NaNs are supported). Even though there was a check for
intergal types, it was only for the result of the cond rather for the
type of what is being compared. The fix is to check to see if cmp and
icmp are inverse of each other by using the invert_tree_comparison function.
OK for trunk and GCC 13 branch? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
I added the testcase to execute/ieee as it requires support for NAN.
PR tree-optimization/111109
gcc/ChangeLog:
* match.pd (ior(cond,cond), ior(vec_cond,vec_cond)):
Add check to make sure cmp and icmp are inverse.
gcc/testsuite/ChangeLog:
* gcc.c-torture/execute/ieee/fp-cmp-cond-1.c: New test.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 890f050..cf0bb3a 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2087,6 +2087,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_and:c (convert? (cmp@0 @01 @02)) @3) (bit_and:c (convert? (icmp@4 @01 @02)) @5)) (if (INTEGRAL_TYPE_P (type) + && invert_tree_comparison (cmp, HONOR_NANS (@01)) == icmp /* The scalar version has to be canonicalized after vectorization because it makes unconditional loads conditional ones, which means we lose vectorization because the loads may trap. */ @@ -2101,6 +2102,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cond (cmp@0 @01 @02) @3 zerop) (cond (icmp@4 @01 @02) @5 zerop)) (if (INTEGRAL_TYPE_P (type) + && invert_tree_comparison (cmp, HONOR_NANS (@01)) == icmp /* The scalar version has to be canonicalized after vectorization because it makes unconditional loads conditional ones, which means we lose vectorization because the loads may trap. */ @@ -2113,13 +2115,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_ior (bit_and:c (vec_cond:s (cmp@0 @6 @7) @4 @5) @2) (bit_and:c (vec_cond:s (icmp@1 @6 @7) @4 @5) @3)) - (if (integer_zerop (@5)) + (if (integer_zerop (@5) + && invert_tree_comparison (cmp, HONOR_NANS (@6)) == icmp) (switch (if (integer_onep (@4)) (bit_and (vec_cond @0 @2 @3) @4)) (if (integer_minus_onep (@4)) (vec_cond @0 @2 @3))) - (if (integer_zerop (@4)) + (if (integer_zerop (@4) + && invert_tree_comparison (cmp, HONOR_NANS (@6)) == icmp) (switch (if (integer_onep (@5)) (bit_and (vec_cond @0 @3 @2) @5)) @@ -2132,7 +2136,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_ior (vec_cond:s (cmp@0 @4 @5) @2 integer_zerop) (vec_cond:s (icmp@1 @4 @5) @3 integer_zerop)) - (vec_cond @0 @2 @3))) + (if (invert_tree_comparison (cmp, HONOR_NANS (@4)) == icmp) + (vec_cond @0 @2 @3)))) /* Transform X & -Y into X * Y when Y is { 0 or 1 }. */ (simplify |