re PR c/5681 (gcc 3.0.3 produces wrong assembler code)
authorJakub Jelinek <jakub@redhat.com>
Wed, 13 Feb 2002 21:49:32 +0000 (22:49 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 13 Feb 2002 21:49:32 +0000 (22:49 +0100)
PR c/5681:
* expr.c (safe_from_p): Pass VOIDmode to true_dependence instead of
GET_MODE (x).

* gcc.c-torture/execute/20020213-1.c: New test.

From-SVN: r49746

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20020213-1.c [new file with mode: 0644]

index ca7c17a..dba5334 100644 (file)
@@ -1,5 +1,11 @@
 2002-02-13  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/5681:
+       * expr.c (safe_from_p): Pass VOIDmode to true_dependence instead of
+       GET_MODE (x).
+
+2002-02-13  Jakub Jelinek  <jakub@redhat.com>
+
        PR optimization/5547:
        * config/i386/i386.c (i386_simplify_dwarf_addr): Simplify
        all valid IA-32 address modes involving non-scaled %ebx and
index 702b689..fe874ce 100644 (file)
@@ -5728,7 +5728,7 @@ safe_from_p (x, exp, top_p)
         are memory and they conflict.  */
       return ! (rtx_equal_p (x, exp_rtl)
                || (GET_CODE (x) == MEM && GET_CODE (exp_rtl) == MEM
-                   && true_dependence (exp_rtl, GET_MODE (x), x,
+                   && true_dependence (exp_rtl, VOIDmode, x,
                                        rtx_addr_varies_p)));
     }
 
index 58118cf..0ae7fc4 100644 (file)
@@ -2,6 +2,8 @@
 
        * g++.dg/other/debug3.C: New test.
 
+       * gcc.c-torture/execute/20020213-1.c: New test.
+
 2002-02-13  Richard Smith <richard@ex-parrot.com>
 
        * g++.old-deja/g++.other/thunk1.C: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20020213-1.c b/gcc/testsuite/gcc.c-torture/execute/20020213-1.c
new file mode 100644 (file)
index 0000000..f9fefee
--- /dev/null
@@ -0,0 +1,34 @@
+/* PR c/5681
+   This testcase failed on IA-32 at -O0, because safe_from_p
+   incorrectly assumed it is safe to first write into a.a2 b-1
+   and then read the original value from it.  */
+
+int bar (float);
+
+struct A {
+  float a1;
+  int a2;
+} a;
+
+int b;
+
+void foo (void)
+{
+  a.a2 = bar (a.a1);
+  a.a2 = a.a2 < b - 1 ? a.a2 : b - 1;
+  if (a.a2 >= b - 1)
+    abort ();
+}
+
+int bar (float x)
+{
+  return 2241;
+}
+
+int main()
+{
+  a.a1 = 1.0f;
+  b = 3384;
+  foo ();
+  return 0;
+}