From 82a6a7583c61ea85cbe36170cab00b2bdab8cf03 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Fri, 9 Apr 2004 01:36:49 +0000 Subject: [PATCH] re PR target/14888 (ICE with -O2 -ffast-math in final_scan_insn()) 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 | 6 +++++ gcc/config/i386/i386.md | 36 +++++++++++++++++++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/opt/pr14888.C | 22 ++++++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/opt/pr14888.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7aef7fc5f74..7a1823a323e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-04-08 Roger Sayle + + PR target/14888 + * config/i386/i386.md (truncdfsf2_noop, truncxfsf2_noop, + truncxfdf2_noop): Provide dummy "fmov" implementations. + 2004-04-08 Ian Lance Taylor * gcc.c (default_compilers): Add missing initializers. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index e9afa773066..a9d8eedf141 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -3677,7 +3677,17 @@ [(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") @@ -3920,7 +3930,17 @@ [(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") @@ -3999,7 +4019,17 @@ [(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") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 65dfd9e4ff6..d581c800a76 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-04-08 Roger Sayle + + PR target/14888 + * g++.dg/opt/pr14888.C: New test case. + 2004-04-08 Geoffrey Keating * 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 index 00000000000..e5c56aaabf2 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr14888.C @@ -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; +} + -- 2.30.2