]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
simplify-rtx.c (simplify_relational_operation): Don't simplify address == constant...
authorJakub Jelinek <jakub@redhat.com>
Sat, 24 Jan 2004 11:01:29 +0000 (12:01 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 24 Jan 2004 11:01:29 +0000 (12:01 +0100)
* simplify-rtx.c (simplify_relational_operation): Don't
simplify address == constant into address + -constant == 0.

* gcc.dg/20040123-1.c: New test.

From-SVN: r76490

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

index edb692249795dda32ec7102718eafdc93e4707a7..77bfc8784c81189f7c071756212325070cb5e065 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-24  Jakub Jelinek  <jakub@redhat.com>
+
+       * simplify-rtx.c (simplify_relational_operation): Don't
+       simplify address == constant into address + -constant == 0.
+
 2004-01-24  Kazu Hirata  <kazu@cs.umass.edu>
 
        * gcc.c (process_command): Don't internationalize the
index cebbf04b4601861b0cf7c91dbc001cf339a06491..7f6b549b0fbd2da710ba7d7249af5d46874707d6 100644 (file)
@@ -2530,6 +2530,8 @@ simplify_relational_operation (enum rtx_code code, enum machine_mode mode,
       && ! ((GET_CODE (op0) == REG || GET_CODE (trueop0) == CONST_INT)
            && (GET_CODE (op1) == REG || GET_CODE (trueop1) == CONST_INT))
       && 0 != (tem = simplify_binary_operation (MINUS, mode, op0, op1))
+      /* We cannot do this for == or != if tem is a nonzero address.  */
+      && ((code != EQ && code != NE) || ! nonzero_address_p (tem))
       && code != GTU && code != GEU && code != LTU && code != LEU)
     return simplify_relational_operation (signed_condition (code),
                                          mode, tem, const0_rtx);
index 370c1aa63e3c5daf6b53d6030f3454e5b4d2748e..ed7cb61ae4c2df7376bb5a085705cd07e89693c1 100644 (file)
@@ -1,3 +1,7 @@
+2004-01-24  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/20040123-1.c: New test.
+
 2004-01-23  Zack Weinberg  <zack@codesourcery.com>
 
        * gcc.dg/builtins-30.c: Move dg-warning marks to the proper lines.
diff --git a/gcc/testsuite/gcc.dg/20040123-1.c b/gcc/testsuite/gcc.dg/20040123-1.c
new file mode 100644 (file)
index 0000000..2a73382
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler "abort" } } */
+
+extern void abort (void);
+extern char a[];
+
+void foo (void)
+{
+  if ((void *) a == (void *) 0x4000UL)
+    abort ();
+}