re PR tree-optimization/89536 (wrong code at -Os and above on x86_64-linux-gnu)
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 28 Feb 2019 23:03:01 +0000 (23:03 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 28 Feb 2019 23:03:01 +0000 (23:03 +0000)
PR tree-optimization/89536
* tree-ssa-dom.c (edge_info::derive_equivalences) <BIT_NOT_EXPR>: Test
only whether bit #0 of the value is 0 instead of the entire value.

From-SVN: r269289

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20190228-1.c [new file with mode: 0644]
gcc/tree-ssa-dom.c

index 3ee63704fd5029d61be7eebf0dc2b71374d23017..4c57ead4d614ae65457f968190350a27586818db 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR tree-optimization/89536
+       * tree-ssa-dom.c (edge_info::derive_equivalences) <BIT_NOT_EXPR>: Test
+       only whether bit #0 of the value is 0 instead of the entire value.
+
 2019-02-28  Marek Polacek  <polacek@redhat.com>
 
        PR c++/87068 - missing diagnostic with fallthrough statement.
index 423591d3a8db0eddf5346f131f8ed679573b1bd2..cf4f06eb88d62fd722aff5947bc465b2b7dc2899 100644 (file)
@@ -1,3 +1,7 @@
+2019-02-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.c-torture/execute/20190228-1.c: New test.
+
 2019-02-28  Marek Polacek  <polacek@redhat.com>
 
        PR c++/87068 - missing diagnostic with fallthrough statement.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20190228-1.c b/gcc/testsuite/gcc.c-torture/execute/20190228-1.c
new file mode 100644 (file)
index 0000000..e71f33a
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR tree-optimization/89536 */
+/* Testcase by Zhendong Su <su@cs.ucdavis.edu> */
+
+int a = 1;
+
+int main (void)
+{
+  a = ~(a && 1); 
+  if (a < -1)
+    a = ~a;
+  
+  if (!a)
+    __builtin_abort ();
+
+  return 0;
+}
index 4f4b7db21896813ff9b204c6eae16b92a567e900..aa4e24bc358cc6905ddae2688cd3a7733991916a 100644 (file)
@@ -348,7 +348,7 @@ edge_info::derive_equivalences (tree name, tree value, int recursion_limit)
                && TREE_CODE (rhs) == SSA_NAME
                && ssa_name_has_boolean_range (rhs))
              {
-               if (integer_zerop (value))
+               if ((TREE_INT_CST_LOW (value) & 1) == 0)
                  res = build_one_cst (TREE_TYPE (rhs));
                else
                  res = build_zero_cst (TREE_TYPE (rhs));