diff options
author | Richard Biener <rguenther@suse.de> | 2023-11-10 09:56:01 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2023-11-10 11:58:47 +0100 |
commit | 20aa06490ab57da7729a24bae7c4ec2f5918ec91 (patch) | |
tree | b8af9f65479b1f63fd0b2b7afdc786a7e193b17c | |
parent | 8da8b9225762126ca41b12243d6531cd41a831b3 (diff) | |
download | gcc-20aa06490ab57da7729a24bae7c4ec2f5918ec91.zip gcc-20aa06490ab57da7729a24bae7c4ec2f5918ec91.tar.gz gcc-20aa06490ab57da7729a24bae7c4ec2f5918ec91.tar.bz2 |
middle-end/112469 - fix missing converts in vec_cond_expr simplification
The following avoids type inconsistencies in .COND_op generated by
simplifications of VEC_COND_EXPRs.
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.
-rw-r--r-- | gcc/match.pd | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr112469.c | 12 |
2 files changed, 16 insertions, 4 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index f559bfa..281c6c0 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 0000000..9978bcd --- /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; + } +} |