]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/77937 (ICE: in replace_one_candidate, at gimple...
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>
Mon, 17 Oct 2016 14:24:21 +0000 (14:24 +0000)
committerWilliam Schmidt <wschmidt@gcc.gnu.org>
Mon, 17 Oct 2016 14:24:21 +0000 (14:24 +0000)
[gcc]

2016-10-17  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

Backport from mainline
2016-10-12  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

PR tree-optimization/77937
* gimple-ssa-strength-reduction.c (analyze_increments): Use
POINTER_TYPE_P on the candidate type to determine whether
candidates in this chain require pointer arithmetic.

2016-10-13  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

PR tree-optimization/77937
* gimple-ssa-strength-reduction.c (analyze_increments): Set cost
to infinite when we have a pointer with an increment of -1.

[gcc/testsuite]

2016-10-17  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

Backport from mainline
2016-10-13  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

PR tree-optimization/77937
* gcc.dg/torture/pr77937-1.c: New.
* gcc.dg/torture/pr77937-2.c: New.

From-SVN: r241244

gcc/ChangeLog
gcc/gimple-ssa-strength-reduction.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr77937-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr77937-2.c [new file with mode: 0644]

index fd9138d1c6e8c7b6b35ce86a608882f7050cb219..bf813f27e8f8c04621db5dcea0babfbc93171cba 100644 (file)
@@ -1,3 +1,19 @@
+2016-10-17  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       Backport from mainline
+       2016-10-12  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       PR tree-optimization/77937
+       * gimple-ssa-strength-reduction.c (analyze_increments): Use
+       POINTER_TYPE_P on the candidate type to determine whether
+       candidates in this chain require pointer arithmetic.
+
+       2016-10-13  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       PR tree-optimization/77937
+       * gimple-ssa-strength-reduction.c (analyze_increments): Set cost
+       to infinite when we have a pointer with an increment of -1.
+
 2016-10-17  Martin Liska  <mliska@suse.cz>
 
        Backported from mainline
index fef5905033aa21d277c0c27d9a54676495230575..cc56a6e86e7dcbe3412ca75a96ad224d4c6dc1b1 100644 (file)
@@ -2854,9 +2854,13 @@ analyze_increments (slsr_cand_t first_dep, machine_mode mode, bool speed)
       else if (incr == 0
               || incr == 1
               || (incr == -1
-                  && (gimple_assign_rhs_code (first_dep->cand_stmt)
-                      != POINTER_PLUS_EXPR)))
+                  && !POINTER_TYPE_P (first_dep->cand_type)))
        incr_vec[i].cost = COST_NEUTRAL;
+
+      /* FIXME: We don't handle pointers with a -1 increment yet.
+         They are usually unprofitable anyway.  */
+      else if (incr == -1 && POINTER_TYPE_P (first_dep->cand_type))
+       incr_vec[i].cost = COST_INFINITE;
       
       /* FORNOW: If we need to add an initializer, give up if a cast from
         the candidate's type to its stride's type can lose precision.
index f4f957203edf52acb9203f83bb76b8a0307198a5..1cdacfeef67a9cae9ec65a537c99aed1a72cb219 100644 (file)
@@ -1,3 +1,12 @@
+2016-10-17  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       Backport from mainline
+       2016-10-13  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       PR tree-optimization/77937
+       * gcc.dg/torture/pr77937-1.c: New.
+       * gcc.dg/torture/pr77937-2.c: New.
+
 2016-10-17  Martin Liska  <mliska@suse.cz>
 
        Backported from mainline
diff --git a/gcc/testsuite/gcc.dg/torture/pr77937-1.c b/gcc/testsuite/gcc.dg/torture/pr77937-1.c
new file mode 100644 (file)
index 0000000..8661d24
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+/* { dg-additional-options "-march=amdfam10" { target i?86-*-* x86_64-*-* } } */
+
+int *a;
+int b, c, d;
+void fn1(char *p1, int p2) {
+  int x;
+  while (1) {
+    x = 0;
+    for (; x < 8; x++)
+      p1[0] = -a[0] * d + p1[0] * c + 1 >> b >> 1;
+    p1 += p2;
+  }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr77937-2.c b/gcc/testsuite/gcc.dg/torture/pr77937-2.c
new file mode 100644 (file)
index 0000000..37b4fd6
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+/* { dg-additional-options "-march=amdfam10" { target i?86-*-* x86_64-*-* } } */
+
+extern int fn2(int);
+extern int fn3(int);
+int a, b, c;
+void fn1(long p1) {
+  char *d;
+  for (;; d += p1) {
+    d[0] = fn2(1 >> a);
+    fn3(0);
+    fn3(c >> a);
+    d[1] = fn3(d[1] * b + c >> a);
+    d[4] = fn3(d[4] * b + c >> a);
+    d[5] = fn3(d[5] * b + c >> a);
+  }
+}