aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.cc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-07-01 10:06:55 +0200
committerRichard Biener <rguenth@gcc.gnu.org>2024-07-01 11:00:04 +0200
commit286cda3461d6f5ce7d911d3f26bd4975ea7ea11d (patch)
treed881230791e8e9396184322f9b605a94478f3fea /gcc/tree-vect-loop.cc
parent382e2123c402edb6123f0c4669fa298d4140edd8 (diff)
downloadgcc-286cda3461d6f5ce7d911d3f26bd4975ea7ea11d.zip
gcc-286cda3461d6f5ce7d911d3f26bd4975ea7ea11d.tar.gz
gcc-286cda3461d6f5ce7d911d3f26bd4975ea7ea11d.tar.bz2
tree-optimization/115723 - ICE with .COND_ADD reduction
The following fixes an ICE with a .COND_ADD discovered as reduction even though its else value isn't the reduction chain link but a constant. This would be wrong-code with --disable-checking I think. PR tree-optimization/115723 * tree-vect-loop.cc (check_reduction_path): For a .COND_ADD verify the else value also refers to the reduction chain op. * gcc.dg/vect/pr115723.c: New testcase.
Diffstat (limited to 'gcc/tree-vect-loop.cc')
-rw-r--r--gcc/tree-vect-loop.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 3095ff5..a64b508 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -4163,15 +4163,19 @@ pop:
FOR_EACH_IMM_USE_STMT (op_use_stmt, imm_iter, op.ops[opi])
{
- /* In case of a COND_OP (mask, op1, op2, op1) reduction we might have
- op1 twice (once as definition, once as else) in the same operation.
- Allow this. */
+ /* In case of a COND_OP (mask, op1, op2, op1) reduction we should
+ have op1 twice (once as definition, once as else) in the same
+ operation. Enforce this. */
if (cond_fn_p && op_use_stmt == use_stmt)
{
gcall *call = as_a<gcall *> (use_stmt);
unsigned else_pos
= internal_fn_else_index (internal_fn (op.code));
-
+ if (gimple_call_arg (call, else_pos) != op.ops[opi])
+ {
+ fail = true;
+ break;
+ }
for (unsigned int j = 0; j < gimple_call_num_args (call); ++j)
{
if (j == else_pos)