diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-11-17 15:09:44 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-11-17 15:09:44 +0100 |
commit | 172a72da368146e0fe34194020eb7a6636db4438 (patch) | |
tree | bc653304a14c63356307aad107f3762e9c88e7cb /gcc/tree-vect-loop.cc | |
parent | 04abafe9831f6867af1211ecae853ff373235b2d (diff) | |
download | gcc-172a72da368146e0fe34194020eb7a6636db4438.zip gcc-172a72da368146e0fe34194020eb7a6636db4438.tar.gz gcc-172a72da368146e0fe34194020eb7a6636db4438.tar.bz2 |
vect: Fix check_reduction_path [PR112374]
As mentioned in the PR, the intent of the r14-5076 changes was that
it doesn't count one of the uses on the use_stmt, but what actually
got implemented is that it does this processing on any op_use_stmt,
even if it is not the use_stmt statement, which means that it
can increase count even on debug stmts (-fcompare-debug failures),
or if there would be some other use stmt with 2+ uses it could count
that as a single use. Though, because it fails whenever cnt != 1
and I believe use_stmt must be one of the uses, it would probably
fail in the latter case anyway.
The following patch fixes that by doing this extra processing only when
op_use_stmt is use_stmt, and using the normal processing otherwise
(so ignore debug stmts, and increase on any uses on the stmt).
2023-11-17 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/112374
* tree-vect-loop.cc (check_reduction_path): Perform the cond_fn_p
special case only if op_use_stmt == use_stmt, use as_a rather than
dyn_cast in that case.
* gcc.dg/pr112374-1.c: New test.
* gcc.dg/pr112374-2.c: New test.
* g++.dg/opt/pr112374.C: New test.
Diffstat (limited to 'gcc/tree-vect-loop.cc')
-rw-r--r-- | gcc/tree-vect-loop.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 3f59139..e8b8be5 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -4118,9 +4118,9 @@ pop: /* 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. */ - if (cond_fn_p) + if (cond_fn_p && op_use_stmt == use_stmt) { - gcall *call = dyn_cast<gcall *> (use_stmt); + gcall *call = as_a<gcall *> (use_stmt); unsigned else_pos = internal_fn_else_index (internal_fn (op.code)); |