aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-patterns.cc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-02-28 15:34:27 +0100
committerRichard Biener <rguenther@suse.de>2023-03-01 08:37:34 +0100
commite3837b6f6c28a1d2cea3a69efbda795ea3fb8816 (patch)
treee537856071b444cea9f477bc15a9ddffb768c62d /gcc/tree-vect-patterns.cc
parent392f399ae0595e6b4433c18900cc67991fb140f4 (diff)
downloadgcc-e3837b6f6c28a1d2cea3a69efbda795ea3fb8816.zip
gcc-e3837b6f6c28a1d2cea3a69efbda795ea3fb8816.tar.gz
gcc-e3837b6f6c28a1d2cea3a69efbda795ea3fb8816.tar.bz2
tree-optimization/108950 - widen-sum reduction ICE
When we end up with a widen-sum with an invariant smaller operand the reduction code uses a wrong vector type for it, causing IL checking ICEs. The following fixes that and the inefficiency of using a widen-sum with a widenend invariant operand as well by actually performing the check the following comment wants. PR tree-optimization/108950 * tree-vect-patterns.cc (vect_recog_widen_sum_pattern): Check oprnd0 is defined in the loop. * tree-vect-loop.cc (vectorizable_reduction): Record all operands vector types, compute that of invariants and properly update their SLP nodes. * gcc.dg/vect/pr108950.c: New testcase.
Diffstat (limited to 'gcc/tree-vect-patterns.cc')
-rw-r--r--gcc/tree-vect-patterns.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index cefe331..dd585e5 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -1821,7 +1821,9 @@ vect_recog_widen_sum_pattern (vec_info *vinfo,
of the above pattern. */
if (!vect_reassociating_reduction_p (vinfo, stmt_vinfo, PLUS_EXPR,
- &oprnd0, &oprnd1))
+ &oprnd0, &oprnd1)
+ || TREE_CODE (oprnd0) != SSA_NAME
+ || !vinfo->lookup_def (oprnd0))
return NULL;
type = TREE_TYPE (gimple_get_lhs (last_stmt));