2008-02-17 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 17 Feb 2008 14:00:48 +0000 (14:00 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 17 Feb 2008 14:00:48 +0000 (14:00 +0000)
PR tree-optimization/35231
* tree-vrp.c (register_edge_assert_for): Do not assume A == 0
if A | B != 1.

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

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr35231.c [new file with mode: 0644]
gcc/tree-vrp.c

index b75e608..946eb6a 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-17  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/35231
+       * tree-vrp.c (register_edge_assert_for): Do not assume A == 0
+       if A | B != 1.
+
 2008-02-17  Uros Bizjak  <ubizjak@gmail.com>
 
        Revert:
index 8bfa223..c167949 100644 (file)
@@ -1,3 +1,8 @@
+2008-02-17  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/35231
+       * gcc.c-torture/execute/pr35231.c: New testcase.
+
 2008-02-17  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/pr32268.c (test_lt): Add noinline attribute.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr35231.c b/gcc/testsuite/gcc.c-torture/execute/pr35231.c
new file mode 100644 (file)
index 0000000..e0327eb
--- /dev/null
@@ -0,0 +1,16 @@
+extern void abort(void);
+
+int __attribute__((noinline))
+foo(int bits_per_pixel, int depth)
+{
+  if ((bits_per_pixel | depth) == 1)
+    abort ();
+  return bits_per_pixel;
+}
+
+int main()
+{
+  if (foo(2, 0) != 2)
+    abort ();
+  return 0;
+}
index 5f9a327..f9615d1 100644 (file)
@@ -3753,7 +3753,11 @@ register_edge_assert_for (tree name, edge e, block_stmt_iterator si, tree cond)
 
       if (TREE_CODE (def_stmt) == GIMPLE_MODIFY_STMT
          && (TREE_CODE (GIMPLE_STMT_OPERAND (def_stmt, 1)) == TRUTH_OR_EXPR
-             || TREE_CODE (GIMPLE_STMT_OPERAND (def_stmt, 1)) == BIT_IOR_EXPR))
+             /* For BIT_IOR_EXPR only if NAME == 0 both operands have
+                necessarily zero value.  */
+             || (comp_code == EQ_EXPR
+                 && (TREE_CODE (GIMPLE_STMT_OPERAND (def_stmt, 1))
+                       == BIT_IOR_EXPR))))
        {
          tree op0 = TREE_OPERAND (GIMPLE_STMT_OPERAND (def_stmt, 1), 0);
          tree op1 = TREE_OPERAND (GIMPLE_STMT_OPERAND (def_stmt, 1), 1);