re PR target/14888 (ICE with -O2 -ffast-math in final_scan_insn())
authorRoger Sayle <roger@eyesopen.com>
Fri, 9 Apr 2004 01:36:49 +0000 (01:36 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Fri, 9 Apr 2004 01:36:49 +0000 (01:36 +0000)
PR target/14888
* config/i386/i386.md (truncdfsf2_noop, truncxfsf2_noop,
truncxfdf2_noop): Provide dummy "fmov" implementations.

* g++.dg/opt/pr14888.C: New test case.

From-SVN: r80539

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr14888.C [new file with mode: 0644]

index 7aef7fc..7a1823a 100644 (file)
@@ -1,3 +1,9 @@
+2004-04-08  Roger Sayle  <roger@eyesopen.com>
+
+       PR target/14888
+       * config/i386/i386.md (truncdfsf2_noop, truncxfsf2_noop,
+       truncxfdf2_noop): Provide dummy "fmov" implementations.
+
 2004-04-08  Ian Lance Taylor  <ian@wasabisystems.com>
 
        * gcc.c (default_compilers): Add missing initializers.
index e9afa77..a9d8eed 100644 (file)
   [(set (match_operand:SF 0 "register_operand" "=f")
        (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
   "TARGET_80387 && flag_unsafe_math_optimizations"
-  "#")
+{
+  if (REG_P (operands[1])
+      && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
+    return "fstp\t%y0";
+  else if (STACK_TOP_P (operands[0]))
+    return "fld%z1\t%y1";
+  else
+    return "fst\t%y0";
+}
+  [(set_attr "type" "fmov")
+   (set_attr "mode" "SF")])
 
 (define_insn "*truncdfsf2_1"
   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
   [(set (match_operand:SF 0 "register_operand" "=f")
        (float_truncate:SF (match_operand:XF 1 "register_operand" "f")))]
   "TARGET_80387 && flag_unsafe_math_optimizations"
-  "#")
+{
+  if (REG_P (operands[1])
+      && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
+    return "fstp\t%y0";
+  else if (STACK_TOP_P (operands[0]))
+    return "fld%z1\t%y1";
+  else
+    return "fst\t%y0";
+}
+  [(set_attr "type" "fmov")
+   (set_attr "mode" "SF")])
 
 (define_insn "*truncxfsf2_1"
   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
   [(set (match_operand:DF 0 "register_operand" "=f")
        (float_truncate:DF (match_operand:XF 1 "register_operand" "f")))]
   "TARGET_80387 && flag_unsafe_math_optimizations"
-  "#")
+{
+  if (REG_P (operands[1])
+      && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
+    return "fstp\t%y0";
+  else if (STACK_TOP_P (operands[0]))
+    return "fld%z1\t%y1";
+  else
+    return "fst\t%y0";
+}
+  [(set_attr "type" "fmov")
+   (set_attr "mode" "DF")])
 
 (define_insn "*truncxfdf2_1"
   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf")
index 65dfd9e..d581c80 100644 (file)
@@ -1,3 +1,8 @@
+2004-04-08  Roger Sayle  <roger@eyesopen.com>
+
+       PR target/14888
+       * g++.dg/opt/pr14888.C: New test case.
+
 2004-04-08  Geoffrey Keating  <geoffk@apple.com>
 
        * gcc.dg/pch/valid-1.c, gcc.dg/pch/valid-2.c, gcc.dg/pch/valid-3.c,
diff --git a/gcc/testsuite/g++.dg/opt/pr14888.C b/gcc/testsuite/g++.dg/opt/pr14888.C
new file mode 100644 (file)
index 0000000..e5c56aa
--- /dev/null
@@ -0,0 +1,22 @@
+// PR target/14888
+// This used to ICE because the truncdfsf2 isn't completely eliminated
+
+// { dg-do compile }
+// { dg-options "-O2 -ffast-math" }
+
+class xcomplex
+{
+public:
+  float re, im;
+
+  xcomplex &operator*= (const float &fact)
+  { re*=fact; im*=fact; return *this; }
+};
+
+void foo (xcomplex &almT, xcomplex &almG)
+{
+  double gb;
+  almT*=gb;
+  almG*=gb*42;
+}
+