]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/43629 (Struct to register optimization fails)
authorRichard Guenther <rguenther@suse.de>
Tue, 20 Apr 2010 13:08:01 +0000 (13:08 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 20 Apr 2010 13:08:01 +0000 (13:08 +0000)
2010-04-20  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/43629
* tree-ssa-ccp.c (likely_value): Scan for literal constants
as well.  Reset all_undefined_operands if we have seen a
constant value.

* gcc.c-torture/execute/pr43629.c: New testcase.

From-SVN: r158554

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr43629.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c

index 3126b7d086a18e2fad17f862c8bfac43a4f6ef5c..c8d59b35b91c5bbc269014cfbe6c779fade5131d 100644 (file)
@@ -1,3 +1,10 @@
+2010-04-20  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/43629
+       * tree-ssa-ccp.c (likely_value): Scan for literal constants
+       as well.  Reset all_undefined_operands if we have seen a
+       constant value.
+
 2010-04-18  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR tree-optimization/43769
index e0a2d40effbd74a1fe66cf93883fc0e3ae064d23..bbbee43d98602504cd65d1b6769a4923848fd030 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-20  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/43629
+       * gcc.c-torture/execute/pr43629.c: New testcase.
+
 2010-04-18  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/rep_clause5.ad[sb]: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr43629.c b/gcc/testsuite/gcc.c-torture/execute/pr43629.c
new file mode 100644 (file)
index 0000000..10c0196
--- /dev/null
@@ -0,0 +1,13 @@
+int flag;
+extern void abort (void);
+int main()
+{
+  int x;
+  if (flag)
+    x = -1;
+  else 
+    x &= 0xff;
+  if (x & ~0xff)
+    abort ();
+  return 0;
+}
index 08a9ae4d2794d8aac62d2de6e12ad1ebac9dc1d4..41eed535d50ef8c06585b2c3af9ab058a2f01257 100644 (file)
@@ -569,6 +569,34 @@ likely_value (tree stmt)
        has_constant_operand = true;
     }
 
+  if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT)
+    {
+      tree rhs = GIMPLE_STMT_OPERAND (stmt, 1);
+      if (REFERENCE_CLASS_P (rhs))
+       {
+         if (is_gimple_min_invariant (TREE_OPERAND (rhs, 0)))
+           has_constant_operand = true;
+       }
+      else if (EXPR_P (rhs))
+       {
+         unsigned i;
+         for (i = 0; i < TREE_CODE_LENGTH (TREE_CODE (rhs)); ++i)
+           if (TREE_OPERAND (rhs, i)
+               && is_gimple_min_invariant (TREE_OPERAND (rhs, i)))
+             has_constant_operand = true;
+       }
+    }
+  else if (TREE_CODE (stmt) == CALL_EXPR)
+    {
+      unsigned i;
+      for (i = 0; i < call_expr_nargs (stmt); ++i)
+       if (is_gimple_min_invariant (CALL_EXPR_ARG (stmt, i)))
+         has_constant_operand = true;
+    }
+
+  if (has_constant_operand)
+    all_undefined_operands = false;
+
   /* If the operation combines operands like COMPLEX_EXPR make sure to
      not mark the result UNDEFINED if only one part of the result is
      undefined.  */