The following avoids type inconsistencies in .COND_op generated by simplifications of VEC_COND_EXPRs.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR middle-end/112469 * match.pd (cond ? op a : b -> .COND_op (cond, a, b)): Add missing view_converts. * gcc.dg/torture/pr112469.c: New testcase. --- gcc/match.pd | 8 ++++---- gcc/testsuite/gcc.dg/torture/pr112469.c | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr112469.c diff --git a/gcc/match.pd b/gcc/match.pd index f559bfa4f2b..281c6c087e6 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -8959,13 +8959,13 @@ and, (with { tree op_type = TREE_TYPE (@3); } (if (vectorized_internal_fn_supported_p (as_internal_fn (cond_op), op_type) && is_truth_type_for (op_type, TREE_TYPE (@0))) - (cond_op @0 @1 @2)))) + (cond_op @0 (view_convert @1) @2)))) (simplify (vec_cond @0 @1 (view_convert? (uncond_op@3 @2))) (with { tree op_type = TREE_TYPE (@3); } (if (vectorized_internal_fn_supported_p (as_internal_fn (cond_op), op_type) && is_truth_type_for (op_type, TREE_TYPE (@0))) - (cond_op (bit_not @0) @2 @1))))) + (cond_op (bit_not @0) (view_convert @2) @1))))) (for uncond_op (UNCOND_UNARY) cond_op (COND_LEN_UNARY) @@ -8974,13 +8974,13 @@ and, (with { tree op_type = TREE_TYPE (@3); } (if (vectorized_internal_fn_supported_p (as_internal_fn (cond_op), op_type) && is_truth_type_for (op_type, TREE_TYPE (@0))) - (cond_op @0 @1 @2 @4 @5)))) + (cond_op @0 (view_convert @1) @2 @4 @5)))) (simplify (IFN_VCOND_MASK_LEN @0 @1 (view_convert? (uncond_op@3 @2)) @4 @5) (with { tree op_type = TREE_TYPE (@3); } (if (vectorized_internal_fn_supported_p (as_internal_fn (cond_op), op_type) && is_truth_type_for (op_type, TREE_TYPE (@0))) - (cond_op (bit_not @0) @2 @1 @4 @5))))) + (cond_op (bit_not @0) (view_convert @2) @1 @4 @5))))) /* `(a ? -1 : 0) ^ b` can be converted into a conditional not. */ (simplify diff --git a/gcc/testsuite/gcc.dg/torture/pr112469.c b/gcc/testsuite/gcc.dg/torture/pr112469.c new file mode 100644 index 00000000000..9978bcd4560 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr112469.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +int a, b, c; +static int *d = &a; +int e(int f) { return f == 0 ? 1 : f; } +void g() { + a = 1; + for (; a <= 8; a++) { + b = e(*d); + c = -b; + } +} -- 2.35.3