aboutsummaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-02-23 16:06:05 +0100
committerRichard Biener <rguenther@suse.de>2024-02-26 08:42:44 +0100
commitaf66ad89e8169f44db723813662917cf4cbb78fc (patch)
treed1b2888efc4021881c1206a9a5d48ea8f64bb1a2 /gcc/match.pd
parent6987f16742bd4fc6bb8118b9efde52fb9169b327 (diff)
downloadgcc-af66ad89e8169f44db723813662917cf4cbb78fc.zip
gcc-af66ad89e8169f44db723813662917cf4cbb78fc.tar.gz
gcc-af66ad89e8169f44db723813662917cf4cbb78fc.tar.bz2
middle-end/114070 - folding breaking VEC_COND expansion
The following properly guards the simplifications that move operations into VEC_CONDs, in particular when that changes the type constraints on this operation. This needed a genmatch fix which was recording spurious implicit fors when tcc_comparison is used in a C expression. PR middle-end/114070 * genmatch.cc (parser::parse_c_expr): Do not record operand lists but only mark operators used. * match.pd ((c ? a : b) op (c ? d : e) --> c ? (a op d) : (b op e)): Properly guard the case of tcc_comparison changing the VEC_COND value operand type. * gcc.dg/torture/pr114070.c: New testcase.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd15
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index c5b6540..67007fc 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -5149,15 +5149,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* (c ? a : b) op (c ? d : e) --> c ? (a op d) : (b op e) */
(simplify
(op (vec_cond:s @0 @1 @2) (vec_cond:s @0 @3 @4))
- (vec_cond @0 (op! @1 @3) (op! @2 @4)))
+ (if (TREE_CODE_CLASS (op) != tcc_comparison
+ || types_match (type, TREE_TYPE (@1))
+ || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK))
+ (vec_cond @0 (op! @1 @3) (op! @2 @4))))
/* (c ? a : b) op d --> c ? (a op d) : (b op d) */
(simplify
(op (vec_cond:s @0 @1 @2) @3)
- (vec_cond @0 (op! @1 @3) (op! @2 @3)))
+ (if (TREE_CODE_CLASS (op) != tcc_comparison
+ || types_match (type, TREE_TYPE (@1))
+ || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK))
+ (vec_cond @0 (op! @1 @3) (op! @2 @3))))
(simplify
(op @3 (vec_cond:s @0 @1 @2))
- (vec_cond @0 (op! @3 @1) (op! @3 @2))))
+ (if (TREE_CODE_CLASS (op) != tcc_comparison
+ || types_match (type, TREE_TYPE (@1))
+ || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK))
+ (vec_cond @0 (op! @3 @1) (op! @3 @2)))))
#if GIMPLE
(match (nop_atomic_bit_test_and_p @0 @1 @4)