re PR tree-optimization/55350 (verify_gimple failed with invalid (pointer) operands...
authorAldy Hernandez <aldyh@redhat.com>
Tue, 20 Nov 2012 18:28:09 +0000 (18:28 +0000)
committerAldy Hernandez <aldyh@gcc.gnu.org>
Tue, 20 Nov 2012 18:28:09 +0000 (18:28 +0000)
PR tree-optimization/55350
* gimple-ssa-strength-reduction.c (replace_dependent): Handle
POINTER_{PLUS,MINUS}_EXPR correctly.

From-SVN: r193672

gcc/ChangeLog
gcc/gimple-ssa-strength-reduction.c
gcc/testsuite/gcc.c-torture/compile/pr55350.c [new file with mode: 0644]

index cc6441c657bd338de1cbfa900dd0680aff0b81a3..09ab535d6a6907da70ad2978988bda93e10d02a1 100644 (file)
@@ -1,3 +1,9 @@
+2012-11-20  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR tree-optimization/55350
+       * gimple-ssa-strength-reduction.c (replace_dependent): Handle
+       POINTER_PLUS_EXPR correctly.
+
 2012-11-20  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.md (fix_trunc<MODEF:mode><SWI48:mode>_sse): Macroize
index 8e2a24758ddc3cf8ef3763c1de364a9b012a73c6..65fc6b148593749e5ef1608b4b0b82853a691249 100644 (file)
@@ -1643,10 +1643,19 @@ replace_dependent (slsr_cand_t c, enum tree_code cand_code)
 
   basis = lookup_cand (c->basis);
   basis_name = gimple_assign_lhs (basis->cand_stmt);
-  incr_type = TREE_TYPE (gimple_assign_rhs1 (c->cand_stmt));
-  code = PLUS_EXPR;
+  if (cand_code == POINTER_PLUS_EXPR)
+    {
+      incr_type = sizetype;
+      code = cand_code;
+    }
+  else
+    {
+      incr_type = TREE_TYPE (gimple_assign_rhs1 (c->cand_stmt));
+      code = PLUS_EXPR;
+    }
 
-  if (bump.is_negative ())
+  if (bump.is_negative ()
+      && cand_code != POINTER_PLUS_EXPR)
     {
       code = MINUS_EXPR;
       bump = -bump;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr55350.c b/gcc/testsuite/gcc.c-torture/compile/pr55350.c
new file mode 100644 (file)
index 0000000..f10daea
--- /dev/null
@@ -0,0 +1,8 @@
+void
+foo (__INTPTR_TYPE__ x, __INTPTR_TYPE__ y)
+{
+  int i;
+  void **a = (void *)  (8UL * (x / 8UL));
+  for (i = 0; i < x; i++)
+    a[i] = (void *) y;
+}