> And also please mention https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77724 
> and perhaps
> add its testcase, too.
> 

Patch according to Richard's suggestion, included test case. The test
case works unpatched on x86-64 but fails on s390. Is gcc.dg/vect the
proper place for it? (I didn't manage to run it independently in this
directory via RUNTESTFLAGS=vect.exp=... or otherwise)

Bootstrapped on x86 and s390.

--

gcc/ChangeLog:

2016-09-26  Robin Dapp  <rd...@linux.vnet.ibm.com>

        * tree-vect-loop-manip.c (create_intersect_range_checks_index):
        Add tree_fits_shwi_p check.


gcc/testsuite/ChangeLog:

2016-09-26  Robin Dapp  <rd...@linux.vnet.ibm.com>

        * gcc.dg/vect/pr77724.c: New test.
diff --git a/gcc/testsuite/gcc.dg/vect/pr77724.c b/gcc/testsuite/gcc.dg/vect/pr77724.c
new file mode 100644
index 0000000..3039b5a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr77724.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
+/* { dg-options "-O3 -march=z13" { target s390*-*-* } } */
+
+int a[81];
+int b, c;
+
+void
+fn1()
+{
+  int d = b;
+  for (; c; --c)
+    a[c + d] = a[c];
+}
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 8203040..147a90f 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -2301,6 +2301,9 @@ create_intersect_range_checks_index (loop_vec_info loop_vinfo, tree *cond_expr,
   if (!tree_fits_uhwi_p (dr_a.seg_len) || !tree_fits_uhwi_p (dr_b.seg_len))
     return false;
 
+  if (!tree_fits_shwi_p (DR_STEP (dr_a.dr)))
+    return false;
+
   if (!operand_equal_p (DR_BASE_OBJECT (dr_a.dr), DR_BASE_OBJECT (dr_b.dr), 0))
     return false;
 
@@ -2310,7 +2313,8 @@ create_intersect_range_checks_index (loop_vec_info loop_vinfo, tree *cond_expr,
   gcc_assert (TREE_CODE (DR_STEP (dr_a.dr)) == INTEGER_CST);
 
   bool neg_step = tree_int_cst_compare (DR_STEP (dr_a.dr), size_zero_node) < 0;
-  unsigned HOST_WIDE_INT abs_step = tree_to_uhwi (DR_STEP (dr_a.dr));
+  unsigned HOST_WIDE_INT abs_step =
+    absu_hwi (tree_to_shwi (DR_STEP (dr_a.dr)));
   if (neg_step)
     abs_step = -abs_step;
 

Reply via email to