PR debug/64511
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Jan 2015 21:59:34 +0000 (21:59 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Jan 2015 21:59:34 +0000 (21:59 +0000)
* simplify-rtx.c (simplify_relational_operation_1): Don't try to
optimize (eq/ne (and (side_effects) (const_int 0)) (const_int 0))
into (eq/ne (and (not (side_effects)) (const_int 0)) (const_int 0)).

* gcc.dg/pr64511.c: New test.

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

gcc/ChangeLog
gcc/simplify-rtx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr64511.c [new file with mode: 0644]

index e96a9e1..190fdfd 100644 (file)
@@ -1,5 +1,10 @@
 2015-01-21  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/64511
+       * simplify-rtx.c (simplify_relational_operation_1): Don't try to
+       optimize (eq/ne (and (side_effects) (const_int 0)) (const_int 0))
+       into (eq/ne (and (not (side_effects)) (const_int 0)) (const_int 0)).
+
        PR sanitizer/64706
        * doc/invoke.texi (-fsanitize=vptr): Document.
 
index d26267d..5c9e3bf 100644 (file)
@@ -4589,7 +4589,8 @@ simplify_relational_operation_1 (enum rtx_code code, machine_mode mode,
   if ((code == EQ || code == NE)
       && op0code == AND
       && rtx_equal_p (XEXP (op0, 0), op1)
-      && !side_effects_p (op1))
+      && !side_effects_p (op1)
+      && op1 != CONST0_RTX (cmp_mode))
     {
       rtx not_y = simplify_gen_unary (NOT, cmp_mode, XEXP (op0, 1), cmp_mode);
       rtx lhs = simplify_gen_binary (AND, cmp_mode, not_y, XEXP (op0, 0));
@@ -4602,7 +4603,8 @@ simplify_relational_operation_1 (enum rtx_code code, machine_mode mode,
   if ((code == EQ || code == NE)
       && op0code == AND
       && rtx_equal_p (XEXP (op0, 1), op1)
-      && !side_effects_p (op1))
+      && !side_effects_p (op1)
+      && op1 != CONST0_RTX (cmp_mode))
     {
       rtx not_x = simplify_gen_unary (NOT, cmp_mode, XEXP (op0, 0), cmp_mode);
       rtx lhs = simplify_gen_binary (AND, cmp_mode, not_x, XEXP (op0, 1));
index 057f0ca..f093c78 100644 (file)
@@ -1,5 +1,8 @@
 2015-01-21  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/64511
+       * gcc.dg/pr64511.c: New test.
+
        PR rtl-optimization/62078
        * g++.dg/opt/pr62078.C: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr64511.c b/gcc/testsuite/gcc.dg/pr64511.c
new file mode 100644 (file)
index 0000000..83cb5af
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR debug/64511 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -g" } */
+
+int a, c;
+int *volatile b;
+
+void
+foo (int p)
+{
+  int d;
+  int *e = &a;
+  d = ((p == 0) & *e) != 0;
+  b = e;
+  for (; c;)
+    ;
+}
+
+void
+bar (void)
+{
+  foo (1);
+}