OSDN Git Service

2010-11-04 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Nov 2010 14:07:48 +0000 (14:07 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Nov 2010 14:07:48 +0000 (14:07 +0000)
PR tree-optimization/45991
* gimplify.c (force_gimple_operand_1): Use the provded test
function in the initial test.

* gcc.dg/pr45991.c: New testcase.

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

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr45991.c [new file with mode: 0644]

index 12f72b8..705c9ff 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-04  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/45991
+       * gimplify.c (force_gimple_operand_1): Use the provded test
+       function in the initial test.
+
 2010-11-04  Jeff Law  <law@redhat.com>
 
        * ira.c (validate_equiv_mem): Remove code to avoid invalidation
index d5a633c..f490349 100644 (file)
@@ -8047,7 +8047,11 @@ force_gimple_operand_1 (tree expr, gimple_seq *stmts,
 
   *stmts = NULL;
 
-  if (is_gimple_val (expr))
+  /* gimple_test_f might be more strict than is_gimple_val, make
+     sure we pass both.  Just checking gimple_test_f doesn't work
+     because most gimple predicates do not work recursively.  */
+  if (is_gimple_val (expr)
+      && (*gimple_test_f) (expr))
     return expr;
 
   push_gimplify_context (&gctx);
index d20cee4..c5ce28b 100644 (file)
@@ -1,5 +1,10 @@
 2010-11-04  Richard Guenther  <rguenther@suse.de>
 
+       PR tree-optimization/45991
+       * gcc.dg/pr45991.c: New testcase.
+
+2010-11-04  Richard Guenther  <rguenther@suse.de>
+
        PR tree-optimization/46154
        * g++.dg/torture/pr46154.C: New testcase.
 
diff --git a/gcc/testsuite/gcc.dg/pr45991.c b/gcc/testsuite/gcc.dg/pr45991.c
new file mode 100644 (file)
index 0000000..eefce44
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fstrict-overflow" } */
+
+struct S
+{
+  int i;
+};
+
+char A[64];
+
+void foo (char **dst, int i)
+{
+  char *p = A + 16;
+  while (i--)
+    {
+      int b = ((struct S *) (&p[i * 16 + 4]))->i;
+      char *c = A + i * 16;
+      dst[i] = c + b;
+    }
+}