]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-simplify: unify simple_comparison ops in vec_cond for bit and/or/xor [PR119196]
authorIcen Zeyada <Icen.Zeyada2@arm.com>
Wed, 9 Jul 2025 11:57:11 +0000 (12:57 +0100)
committerVictor Do Nascimento <victor.donascimento@arm.com>
Wed, 9 Jul 2025 12:10:25 +0000 (13:10 +0100)
Merge simple_comparison patterns under a single vec_cond_expr for bit_and,
bit_ior, and bit_xor in the simplify pass.

Ensure that when both operands of a bit_and, bit_or, or bit_xor are simple_comparison
results, they reside within the same vec_cond_expr rather than separate ones.
This prepares the AST so that subsequent transformations (e.g., folding the
comparisons if possible) can take effect.

gcc/ChangeLog:

PR tree-optimization/119196
* match.pd: Merge multiple vec_cond_expr in a single one for
bit_and, bit_ior and bit_xor.

Signed-off-by: Icen Zeyada <Icen.Zeyada2@arm.com>
gcc/match.pd

index ec2f5603d9c06fea5caf0e584ec5e8310026a7df..99d218ea048a414efa00c253a759a203cfec0ef4 100644 (file)
@@ -5981,6 +5981,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
               && !expand_vec_cond_expr_p (TREE_TYPE (@1), TREE_TYPE (@0)))))
    (vec_cond @0 (op! @1 @3) (op! @2 @4))))
 
+/* (@0 ? @2 : @3) lop (@1 ? @2 : @3)  -->  (@0 lop @1) ? @2 : @3.  */
+(for lop (bit_and bit_ior bit_xor)
+   (simplify
+   (lop
+      (vec_cond @0 integer_minus_onep@2 integer_zerop@3)
+      (vec_cond @1 @2 @3))
+      (if (target_supports_op_p (TREE_TYPE (@0), lop, optab_vector))
+   (vec_cond (lop @0 @1) @2 @3))))
+
 /* (c ? a : b) op d  -->  c ? (a op d) : (b op d) */
  (simplify
   (op (vec_cond:s @0 @1 @2) @3)