From e43736ad2e9788b5b02a39f38413c5fe693cb6cb Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Wed, 14 May 2003 21:13:49 +0000 Subject: [PATCH] re PR rtl-optimization/10764 (ICE when using log(), -fast-math and optimization) PR optimization/10764 * config/i386/i386.md (atan2df3, atan2sf3, atan2xf3, atan2tf3): Add an explicit clobber to show that UNSPEC_FPATAN clobbers st(1). (*fyl2x_sfxf3, *fyl2x_dfxf3, *fyl2x_xf3, *fyl2x_tfxf3): Likewise, add an explicit clobber to show that UNSPEC_FYL2X clobbers st(1). (logsf2, logdf2, logxf2, logtf2): Update expander patterns to match the corresponding *fyl2x_?fxf3 instructions. * gcc.dg/builtins-15.c: New test case. From-SVN: r66811 --- gcc/ChangeLog | 10 ++++ gcc/config/i386/i386.md | 100 +++++++++++++++++++++---------------- gcc/testsuite/ChangeLog | 4 ++ gcc/testsuite/gcc.dg/builtins-15.c | 17 +++++++ 4 files changed, 87 insertions(+), 44 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/builtins-15.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d41138f..81d9028 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2003-05-14 Roger Sayle + + PR optimization/10764 + * config/i386/i386.md (atan2df3, atan2sf3, atan2xf3, atan2tf3): + Add an explicit clobber to show that UNSPEC_FPATAN clobbers st(1). + (*fyl2x_sfxf3, *fyl2x_dfxf3, *fyl2x_xf3, *fyl2x_tfxf3): Likewise, + add an explicit clobber to show that UNSPEC_FYL2X clobbers st(1). + (logsf2, logdf2, logxf2, logtf2): Update expander patterns to match + the corresponding *fyl2x_?fxf3 instructions. + 2003-05-14 Richard Henderson * config/ia64/ia64.c (ia64_expand_load_address): Force destination diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index ad8909f..eb03cf2 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -15481,10 +15481,11 @@ (set_attr "mode" "XF")]) (define_insn "atan2df3" - [(set (match_operand:DF 0 "register_operand" "=f") - (unspec:DF [(match_operand:DF 2 "register_operand" "0") - (match_operand:DF 1 "register_operand" "u")] - UNSPEC_FPATAN))] + [(parallel [(set (match_operand:DF 0 "register_operand" "=f") + (unspec:DF [(match_operand:DF 2 "register_operand" "0") + (match_operand:DF 1 "register_operand" "u")] + UNSPEC_FPATAN)) + (clobber (match_dup 1))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" "fpatan" @@ -15492,10 +15493,11 @@ (set_attr "mode" "DF")]) (define_insn "atan2sf3" - [(set (match_operand:SF 0 "register_operand" "=f") - (unspec:SF [(match_operand:SF 2 "register_operand" "0") - (match_operand:SF 1 "register_operand" "u")] - UNSPEC_FPATAN))] + [(parallel [(set (match_operand:SF 0 "register_operand" "=f") + (unspec:SF [(match_operand:SF 2 "register_operand" "0") + (match_operand:SF 1 "register_operand" "u")] + UNSPEC_FPATAN)) + (clobber (match_dup 1))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" "fpatan" @@ -15503,10 +15505,11 @@ (set_attr "mode" "SF")]) (define_insn "atan2xf3" - [(set (match_operand:XF 0 "register_operand" "=f") - (unspec:XF [(match_operand:XF 2 "register_operand" "0") - (match_operand:XF 1 "register_operand" "u")] - UNSPEC_FPATAN))] + [(parallel [(set (match_operand:XF 0 "register_operand" "=f") + (unspec:XF [(match_operand:XF 2 "register_operand" "0") + (match_operand:XF 1 "register_operand" "u")] + UNSPEC_FPATAN)) + (clobber (match_dup 1))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" "fpatan" @@ -15514,10 +15517,11 @@ (set_attr "mode" "XF")]) (define_insn "atan2tf3" - [(set (match_operand:TF 0 "register_operand" "=f") - (unspec:TF [(match_operand:TF 2 "register_operand" "0") - (match_operand:TF 1 "register_operand" "u")] - UNSPEC_FPATAN))] + [(parallel [(set (match_operand:TF 0 "register_operand" "=f") + (unspec:TF [(match_operand:TF 2 "register_operand" "0") + (match_operand:TF 1 "register_operand" "u")] + UNSPEC_FPATAN)) + (clobber (match_dup 1))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" "fpatan" @@ -15525,10 +15529,11 @@ (set_attr "mode" "XF")]) (define_insn "*fyl2x_sfxf3" - [(set (match_operand:SF 0 "register_operand" "=f") - (unspec:SF [(match_operand:SF 2 "register_operand" "0") - (match_operand:XF 1 "register_operand" "u")] - UNSPEC_FYL2X))] + [(parallel [(set (match_operand:SF 0 "register_operand" "=f") + (unspec:SF [(match_operand:SF 2 "register_operand" "0") + (match_operand:XF 1 "register_operand" "u")] + UNSPEC_FYL2X)) + (clobber (match_dup 1))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" "fyl2x" @@ -15536,10 +15541,11 @@ (set_attr "mode" "SF")]) (define_insn "*fyl2x_dfxf3" - [(set (match_operand:DF 0 "register_operand" "=f") - (unspec:DF [(match_operand:DF 2 "register_operand" "0") - (match_operand:XF 1 "register_operand" "u")] - UNSPEC_FYL2X))] + [(parallel [(set (match_operand:DF 0 "register_operand" "=f") + (unspec:DF [(match_operand:DF 2 "register_operand" "0") + (match_operand:XF 1 "register_operand" "u")] + UNSPEC_FYL2X)) + (clobber (match_dup 1))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" "fyl2x" @@ -15547,10 +15553,11 @@ (set_attr "mode" "DF")]) (define_insn "*fyl2x_xf3" - [(set (match_operand:XF 0 "register_operand" "=f") - (unspec:XF [(match_operand:XF 2 "register_operand" "0") - (match_operand:XF 1 "register_operand" "u")] - UNSPEC_FYL2X))] + [(parallel [(set (match_operand:XF 0 "register_operand" "=f") + (unspec:XF [(match_operand:XF 2 "register_operand" "0") + (match_operand:XF 1 "register_operand" "u")] + UNSPEC_FYL2X)) + (clobber (match_dup 1))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" "fyl2x" @@ -15558,10 +15565,11 @@ (set_attr "mode" "XF")]) (define_insn "*fyl2x_tfxf3" - [(set (match_operand:TF 0 "register_operand" "=f") - (unspec:TF [(match_operand:TF 2 "register_operand" "0") - (match_operand:XF 1 "register_operand" "u")] - UNSPEC_FYL2X))] + [(parallel [(set (match_operand:TF 0 "register_operand" "=f") + (unspec:TF [(match_operand:TF 2 "register_operand" "0") + (match_operand:XF 1 "register_operand" "u")] + UNSPEC_FYL2X)) + (clobber (match_dup 1))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" "fyl2x" @@ -15569,9 +15577,10 @@ (set_attr "mode" "XF")]) (define_expand "logsf2" - [(set (match_operand:SF 0 "register_operand" "") - (unspec:SF [(match_operand:SF 1 "register_operand" "") - (match_dup 2)] UNSPEC_FYL2X))] + [(parallel [(set (match_operand:SF 0 "register_operand" "") + (unspec:SF [(match_operand:SF 1 "register_operand" "") + (match_dup 2)] UNSPEC_FYL2X)) + (clobber (match_dup 2))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" { @@ -15583,9 +15592,10 @@ }) (define_expand "logdf2" - [(set (match_operand:DF 0 "register_operand" "") - (unspec:DF [(match_operand:DF 1 "register_operand" "") - (match_dup 2)] UNSPEC_FYL2X))] + [(parallel [(set (match_operand:DF 0 "register_operand" "") + (unspec:DF [(match_operand:DF 1 "register_operand" "") + (match_dup 2)] UNSPEC_FYL2X)) + (clobber (match_dup 2))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" { @@ -15597,9 +15607,10 @@ }) (define_expand "logxf2" - [(set (match_operand:XF 0 "register_operand" "") - (unspec:XF [(match_operand:XF 1 "register_operand" "") - (match_dup 2)] UNSPEC_FYL2X))] + [(parallel [(set (match_operand:XF 0 "register_operand" "") + (unspec:XF [(match_operand:XF 1 "register_operand" "") + (match_dup 2)] UNSPEC_FYL2X)) + (clobber (match_dup 2))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" { @@ -15611,9 +15622,10 @@ }) (define_expand "logtf2" - [(set (match_operand:TF 0 "register_operand" "") - (unspec:TF [(match_operand:TF 1 "register_operand" "") - (match_dup 2)] UNSPEC_FYL2X))] + [(parallel [(set (match_operand:TF 0 "register_operand" "") + (unspec:TF [(match_operand:TF 1 "register_operand" "") + (match_dup 2)] UNSPEC_FYL2X)) + (clobber (match_dup 2))])] "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 && flag_unsafe_math_optimizations" { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ff54f02..be4c765 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-05-14 Roger Sayle + + * gcc.dg/builtins-15.c: New test case. + 2003-05-13 Zack Weinberg * gcc.dg/const-elim-1.c: Tighten scan-assembler-not regexp. diff --git a/gcc/testsuite/gcc.dg/builtins-15.c b/gcc/testsuite/gcc.dg/builtins-15.c new file mode 100644 index 0000000..6d94c7e --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtins-15.c @@ -0,0 +1,17 @@ +/* Derived from PR optimization/10764 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ffast-math" } */ + +double log(double x); + +double ndtri(double y0) +{ + double x; + + x = log(y0); + x = log(x); + + return x; +} + -- 2.7.4