summaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-05-08 10:52:47 +0200
committerJakub Jelinek <jakub@redhat.com>2020-05-08 10:52:47 +0200
commit1595a1cb7bfac8d5a6026d5d6f3a495be0391506 (patch)
tree701be1abe1fbf79e878cf47ce6728b11606b8483 /gcc/match.pd
parenta229f9b3737062c6e853879be6683f3f3e4a6661 (diff)
match.pd: A ^ ((A ^ B) & -(C cmp D)) -> (C cmp D) ? B : A simplification [PR94786]
We already have x - ((x - y) & -(z < w)) and x + ((y - x) & -(z < w)) simplifications, this one adds x ^ ((x ^ y) & -(z < w)) (not merged using for because of the :c that can be present on bit_xor and can't on minus). 2020-05-08 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/94786 * match.pd (A ^ ((A ^ B) & -(C cmp D)) -> (C cmp D) ? B : A): New simplification. * gcc.dg/tree-ssa/pr94786.c: New test.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index e8c53e347f4..58a4ac66414 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -2800,6 +2800,18 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
&& (TYPE_PRECISION (TREE_TYPE (@4)) >= TYPE_PRECISION (type)
|| !TYPE_UNSIGNED (TREE_TYPE (@4)))
&& (GIMPLE || !TREE_SIDE_EFFECTS (@1)))
+ (cond (cmp @2 @3) @1 @0)))
+ /* Similarly with ^ instead of - though in that case with :c. */
+ (simplify
+ (bit_xor:c @0 (bit_and:c (bit_xor:c @0 @1)
+ (convert? (negate@4 (convert? (cmp@5 @2 @3))))))
+ (if (INTEGRAL_TYPE_P (type)
+ && INTEGRAL_TYPE_P (TREE_TYPE (@4))
+ && TREE_CODE (TREE_TYPE (@4)) != BOOLEAN_TYPE
+ && INTEGRAL_TYPE_P (TREE_TYPE (@5))
+ && (TYPE_PRECISION (TREE_TYPE (@4)) >= TYPE_PRECISION (type)
+ || !TYPE_UNSIGNED (TREE_TYPE (@4)))
+ && (GIMPLE || !TREE_SIDE_EFFECTS (@1)))
(cond (cmp @2 @3) @1 @0))))
/* Simplifications of shift and rotates. */