aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-06-22 09:24:24 +0200
committerRichard Biener <rguenther@suse.de>2021-06-22 11:01:17 +0200
commit7a22d8a764418265680a6bb9a9aec31e984eb015 (patch)
tree7e3d9917951b06a860dc4298e8e829bfb1267fd3 /gcc
parenta5b773d3f86dd4333696cab0fe3a6953d3db74a3 (diff)
downloadgcc-7a22d8a764418265680a6bb9a9aec31e984eb015.zip
gcc-7a22d8a764418265680a6bb9a9aec31e984eb015.tar.gz
gcc-7a22d8a764418265680a6bb9a9aec31e984eb015.tar.bz2
tree-optimization/101158 - adjust SLP call matching sequence
This moves the check for same operands after verifying we're facing compatible calls. 2021-06-22 Richard Biener <rguenther@suse.de> PR tree-optimization/101158 * tree-vect-slp.c (vect_build_slp_tree_1): Move same operand checking after checking for matching operation. * gfortran.dg/pr101158.f90: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gfortran.dg/pr101158.f9025
-rw-r--r--gcc/tree-vect-slp.c31
2 files changed, 41 insertions, 15 deletions
diff --git a/gcc/testsuite/gfortran.dg/pr101158.f90 b/gcc/testsuite/gfortran.dg/pr101158.f90
new file mode 100644
index 0000000..9a4d9a2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr101158.f90
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! { dg-options "-O1 -ftree-slp-vectorize -fwrapv" }
+! { dg-additional-options "-march=armv8-a+sve" { target aarch64-*-* } }
+
+subroutine sprpl5 (left)
+ implicit none
+
+ integer :: left
+ integer :: avail1, avail2, delx1, delx2, i2, ic
+
+ ic = left
+ delx1 = ic / 2
+ delx2 = delx1 + 1
+ i2 = ic + delx2
+ avail1 = i2
+ avail2 = 1
+
+ do delx1 = 1, 2
+ ic = left + nint (real (left) / 2)
+ if (ic .ge. avail1) avail1 = ic + 1
+
+ i2 = ic + delx2
+ if (i2 .le. avail2) avail2 = i2 + 1
+ end do
+end subroutine sprpl5
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index b9f91e7..6c98acb 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -1177,21 +1177,6 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
continue;
}
- if (need_same_oprnds)
- {
- tree other_op1 = (call_stmt
- ? gimple_call_arg (call_stmt, 1)
- : gimple_assign_rhs2 (stmt));
- if (!operand_equal_p (first_op1, other_op1, 0))
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "Build SLP failed: different shift "
- "arguments in %G", stmt);
- /* Mismatch. */
- continue;
- }
- }
if (!load_p
&& first_stmt_code == BIT_FIELD_REF
&& (TREE_OPERAND (gimple_assign_rhs1 (first_stmt_info->stmt), 0)
@@ -1231,6 +1216,22 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
continue;
}
+ if (need_same_oprnds)
+ {
+ tree other_op1 = (call_stmt
+ ? gimple_call_arg (call_stmt, 1)
+ : gimple_assign_rhs2 (stmt));
+ if (!operand_equal_p (first_op1, other_op1, 0))
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "Build SLP failed: different shift "
+ "arguments in %G", stmt);
+ /* Mismatch. */
+ continue;
+ }
+ }
+
if (!types_compatible_p (vectype, *node_vectype))
{
if (dump_enabled_p ())