OSDN Git Service

2011-09-27 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Sep 2011 08:53:08 +0000 (08:53 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Sep 2011 08:53:08 +0000 (08:53 +0000)
PR tree-optimization/50363
* tree-ssa-pre.c (create_expression_by_pieces): Handle
pointer conversions in POINTER_PLUS_EXPRs properly.

* gcc.dg/torture/pr50363.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179247 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr50363.c [new file with mode: 0644]
gcc/tree-ssa-pre.c

index 1abfbba..57d5bfd 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-27  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/50363
+       * tree-ssa-pre.c (create_expression_by_pieces): Handle
+       pointer conversions in POINTER_PLUS_EXPRs properly.
+
 2011-09-27  Richard Sandiford  <richard.sandiford@linaro.org>
 
        * config/arm/neon.md (neon_vget_highv16qi, neon_vget_highv8hi)
 2011-09-27  Richard Sandiford  <richard.sandiford@linaro.org>
 
        * config/arm/neon.md (neon_vget_highv16qi, neon_vget_highv8hi)
index b5a73a3..b1e8477 100644 (file)
@@ -1,3 +1,8 @@
+2011-09-27  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/50363
+       * gcc.dg/torture/pr50363.c: New testcase.
+
 2011-09-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/45012
 2011-09-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/45012
diff --git a/gcc/testsuite/gcc.dg/torture/pr50363.c b/gcc/testsuite/gcc.dg/torture/pr50363.c
new file mode 100644 (file)
index 0000000..eb35019
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-tree-ch -fno-tree-fre" } */
+
+void
+foo (int *__restrict__ * r, int n)
+{
+  int *p;
+  for (p = *r; p < *r + n; p++)
+    ;
+}
index bee6ef5..5c112c0 100644 (file)
@@ -3085,11 +3085,15 @@ create_expression_by_pieces (basic_block block, pre_expr expr,
                                                    stmts, domstmt);
            if (!genop[i])
              return NULL_TREE;
                                                    stmts, domstmt);
            if (!genop[i])
              return NULL_TREE;
-           /* Ensure genop[1] is a ptrofftype for POINTER_PLUS_EXPR.  It
-              may be a constant with the wrong type.  */
-           if (i == 1
-               && nary->opcode == POINTER_PLUS_EXPR)
-             genop[i] = convert_to_ptrofftype (genop[i]);
+           /* Ensure genop[] is properly typed for POINTER_PLUS_EXPR.  It
+              may have conversions stripped.  */
+           if (nary->opcode == POINTER_PLUS_EXPR)
+             {
+               if (i == 0)
+                 genop[i] = fold_convert (nary->type, genop[i]);
+               else if (i == 1)
+                 genop[i] = convert_to_ptrofftype (genop[i]);
+             }
            else
              genop[i] = fold_convert (TREE_TYPE (nary->op[i]), genop[i]);
          }
            else
              genop[i] = fold_convert (TREE_TYPE (nary->op[i]), genop[i]);
          }