]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cse.c (fold_rtx): Don't optimize if SUBREG changes mode class.
authorJakub Jelinek <jakub@redhat.com>
Sun, 26 May 2002 19:58:07 +0000 (21:58 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 26 May 2002 19:58:07 +0000 (21:58 +0200)
* cse.c (fold_rtx): Don't optimize if SUBREG changes mode class.

* g++.dg/opt/cse2.C: New test.

From-SVN: r53904

gcc/ChangeLog
gcc/cse.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/cse2.C [new file with mode: 0644]

index 8531a6bd706eba3c0ee87adc4b5433df70fd3e39..89dc8cb13f033929f0aea10ed0a922fb906e63fd 100644 (file)
@@ -1,3 +1,7 @@
+2002-05-26  Jakub Jelinek  <jakub@redhat.com>
+
+       * cse.c (fold_rtx): Don't optimize if SUBREG changes mode class.
+
 2002-05-25  Richard Henderson  <rth@redhat.com>
 
        PR target/6788
index 570c61c3e2cc651523c7257016128b61734a7ca4..0ac44c52d83a03a892ee0a566c06913663754581 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -3477,7 +3477,9 @@ fold_rtx (x, insn)
                  && GET_CODE (elt->exp) != SIGN_EXTEND
                  && GET_CODE (elt->exp) != ZERO_EXTEND
                  && GET_CODE (XEXP (elt->exp, 0)) == SUBREG
-                 && GET_MODE (SUBREG_REG (XEXP (elt->exp, 0))) == mode)
+                 && GET_MODE (SUBREG_REG (XEXP (elt->exp, 0))) == mode
+                 && (GET_MODE_CLASS (mode)
+                     == GET_MODE_CLASS (GET_MODE (XEXP (elt->exp, 0)))))
                {
                  rtx op0 = SUBREG_REG (XEXP (elt->exp, 0));
 
index 24cc0dbf6ed0279339022f0812f55c29ab7ec704..1f8e2f1fad1f67418013c9d4d84b8b52e56900c0 100644 (file)
@@ -1,3 +1,7 @@
+2002-05-26  Jakub Jelinek  <jakub@redhat.com>
+
+       * g++.dg/opt/cse2.C: New test.
+
 2002-05-24  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.dg/verbose-asm.c: New test.
diff --git a/gcc/testsuite/g++.dg/opt/cse2.C b/gcc/testsuite/g++.dg/opt/cse2.C
new file mode 100644 (file)
index 0000000..5a04bf5
--- /dev/null
@@ -0,0 +1,39 @@
+// This testcase caused ICE on IA-32 in simplify_unary_operation
+// CSE did not assume SUBREGs changing mode from integral to floating.
+// { dg-do run { target i?86-*-* sparc*-*-* } }
+// { dg-options "-O2" }
+
+struct A
+{
+  union
+    {
+      float f;
+      unsigned int w;
+    } a;
+
+  static inline const A foo (void)
+    {
+      return A ((unsigned int) (__extension__ ((union { unsigned l; float d; })
+                                              { l: 0x3f800000 }).d));
+    }
+  inline A (float f) { a.f = f; }
+  A ();
+  inline A (unsigned int w) { a.w = w; }
+};
+
+A::A()
+{
+  *this = foo ();
+}
+
+A a;
+
+extern "C" void abort (void);
+extern "C" void exit (int);
+
+int main ()
+{
+  if (a.a.w != 1)
+    abort ();
+  exit (0);
+}