This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Fix ICE in slsr (PR tree-optimization/83293)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 6 Dec 2017 20:32:45 +0100
- Subject: [committed] Fix ICE in slsr (PR tree-optimization/83293)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
We don't really care about gsi after this statement, and GSI_SAME_STMT
on gsi_insert_after is wrong if the bb we're inserting into is empty.
So, either we'd need to use the gsi_insert_before with GSI_SAME_STMT in that
case by tweaking the if, or we just tweak the last argument.
Bootstrapped/regtested on x86_64-linux and i686-linux, acked by Richard in
the PR, committed to trunk.
2017-12-06 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/83293
* gimple-ssa-strength-reduction.c (insert_initializers): Use
GSI_NEW_STMT instead of GSI_SAME_STMT in gsi_insert_after that
might insert into empty bb.
* g++.dg/torture/pr83293.C: New test.
--- gcc/gimple-ssa-strength-reduction.c.jj 2017-09-29 19:43:49.000000000 +0200
+++ gcc/gimple-ssa-strength-reduction.c 2017-12-06 09:59:37.297580426 +0100
@@ -3418,7 +3418,7 @@ insert_initializers (slsr_cand_t c)
gsi_insert_after (&gsi, cast_stmt, GSI_NEW_STMT);
gimple_set_location (cast_stmt, loc);
}
- gsi_insert_after (&gsi, init_stmt, GSI_SAME_STMT);
+ gsi_insert_after (&gsi, init_stmt, GSI_NEW_STMT);
}
gimple_set_location (init_stmt, gimple_location (basis_stmt));
--- gcc/testsuite/g++.dg/torture/pr83293.C.jj 2017-12-06 10:05:50.540961244 +0100
+++ gcc/testsuite/g++.dg/torture/pr83293.C 2017-12-06 10:05:24.000000000 +0100
@@ -0,0 +1,39 @@
+// PR tree-optimization/83293
+
+typedef __SIZE_TYPE__ size_t;
+template <typename T, typename> struct A {
+ T a;
+ A (T x) : a(x) {}
+ T foo () { return a; }
+};
+
+template <typename T, typename U, typename V>
+int
+operator==(A<T, V> x, A<U, V> p2)
+{
+ return x.foo () == p2.foo ();
+}
+
+struct B { struct { int *b, *c; } d; };
+struct C : B {
+ A<int *, int> bar () { return d.b; }
+ A<int *, int> baz () { return d.c; }
+ size_t boo () { return d.c - d.b; }
+ int zoo () { return bar () == baz (); }
+};
+struct D { C e; } a;
+size_t b;
+
+size_t
+test (int x)
+{
+ size_t c (x * b);
+ if (!a.e.zoo ())
+ {
+ x += 2;
+ for (size_t d = 0, e = a.e.boo (); d < e; ++d)
+ c += test (0);
+ }
+ c += (x - 1) * b;
+ return c;
+}
Jakub