aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorXi Ruoyao <xry111@xry111.site>2024-08-06 17:48:42 +0800
committerXi Ruoyao <xry111@xry111.site>2024-08-07 15:59:03 +0800
commit2083389a18d36684a88d9e2653bacc87ad894b50 (patch)
tree83d0b8a4892ab86159aece0e8aea791485256560 /gcc
parent9426ce98ccb35a43b4f3e8ea14dcbf2f5de5dc48 (diff)
downloadgcc-2083389a18d36684a88d9e2653bacc87ad894b50.zip
gcc-2083389a18d36684a88d9e2653bacc87ad894b50.tar.gz
gcc-2083389a18d36684a88d9e2653bacc87ad894b50.tar.bz2
vect: Fix vect_reduction_def check for odd/even widen mult [PR116142]
The check was implemented incorrectly, so vec_widen_smult_{even,odd}_M was never used. This is not good for targets with native even/odd widening multiplication but not lo/hi multiplication. The fix is actually developed by Richard Biener. gcc/ChangeLog: PR tree-optimization/116142 * tree-vect-stmts.cc (supportable_widening_operation): Remove an redundant and incorrect vect_reduction_def check, and fix the operand of another vect_reduction_def check. gcc/testsuite/ChangeLog: PR tree-optimization/116142 * gcc.target/i386/pr116142.c: New test. Co-authored-by: Richard Biener <rguenther@suse.de>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.target/i386/pr116142.c18
-rw-r--r--gcc/tree-vect-stmts.cc3
2 files changed, 19 insertions, 2 deletions
diff --git a/gcc/testsuite/gcc.target/i386/pr116142.c b/gcc/testsuite/gcc.target/i386/pr116142.c
new file mode 100644
index 0000000..d288a50
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr116142.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx512f -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump "WIDEN_MULT_EVEN_EXPR" "optimized" } } */
+/* { dg-final { scan-tree-dump "WIDEN_MULT_ODD_EXPR" "optimized" } } */
+
+typedef __INT32_TYPE__ i32;
+typedef __INT64_TYPE__ i64;
+
+i32 x[16], y[16];
+
+i64
+test (void)
+{
+ i64 ret = 0;
+ for (int i = 0; i < 16; i++)
+ ret ^= (i64) x[i] * y[i];
+ return ret;
+}
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 20cae83..385e631 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -14179,7 +14179,6 @@ supportable_widening_operation (vec_info *vinfo,
are properly set up for the caller. If we fail, we'll continue with
a VEC_WIDEN_MULT_LO/HI_EXPR check. */
if (vect_loop
- && STMT_VINFO_RELEVANT (stmt_info) == vect_used_by_reduction
&& !nested_in_vect_loop_p (vect_loop, stmt_info)
&& supportable_widening_operation (vinfo, VEC_WIDEN_MULT_EVEN_EXPR,
stmt_info, vectype_out,
@@ -14192,7 +14191,7 @@ supportable_widening_operation (vec_info *vinfo,
same operation. One such an example is s += a * b, where elements
in a and b cannot be reordered. Here we check if the vector defined
by STMT is only directly used in the reduction statement. */
- tree lhs = gimple_assign_lhs (stmt_info->stmt);
+ tree lhs = gimple_assign_lhs (vect_orig_stmt (stmt_info)->stmt);
stmt_vec_info use_stmt_info = loop_info->lookup_single_use (lhs);
if (use_stmt_info
&& STMT_VINFO_DEF_TYPE (use_stmt_info) == vect_reduction_def)