From 4dd9b6c6bc80f2f1f11a1041b713d9e83a9c7f84 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Fri, 14 Dec 2018 18:04:48 +0100 Subject: [PATCH] re PR target/88474 (Inline built-in hypot for -ffast-math) PR target/88474 * internal-fn.def (HYPOT): New. * optabs.def (hypot_optab): New. * config/i386/i386.md (hypot3): New expander. From-SVN: r267137 --- gcc/ChangeLog | 7 +++++++ gcc/config/i386/i386.md | 26 ++++++++++++++++++++++++++ gcc/internal-fn.def | 1 + gcc/optabs.def | 1 + 4 files changed, 35 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 99f830667cf..99d97db7496 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-12-14 Uros Bizjak + + PR target/88474 + * internal-fn.def (HYPOT): New. + * optabs.def (hypot_optab): New. + * config/i386/i386.md (hypot3): New expander. + 2018-12-14 Jeff Law * target.def (post_cfi_startproc): Fix text. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 5e46bdcdd37..537b90c3b4b 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -15048,6 +15048,32 @@ } }) +(define_expand "hypot3" + [(use (match_operand:MODEF 0 "register_operand")) + (use (match_operand:MODEF 1 "general_operand")) + (use (match_operand:MODEF 2 "general_operand"))] + "TARGET_USE_FANCY_MATH_387 + && (!(SSE_FLOAT_MODE_P (mode) && TARGET_SSE_MATH) + || TARGET_MIX_SSE_I387) + && flag_finite_math_only + && flag_unsafe_math_optimizations" +{ + rtx op0 = gen_reg_rtx (XFmode); + rtx op1 = gen_reg_rtx (XFmode); + rtx op2 = gen_reg_rtx (XFmode); + + emit_insn (gen_extendxf2 (op2, operands[2])); + emit_insn (gen_extendxf2 (op1, operands[1])); + + emit_insn (gen_mulxf3 (op1, op1, op1)); + emit_insn (gen_mulxf3 (op2, op2, op2)); + emit_insn (gen_addxf3 (op0, op2, op1)); + emit_insn (gen_sqrtxf2 (op0, op0)); + + emit_insn (gen_truncxf2 (operands[0], op0)); + DONE; +}) + (define_insn "x86_fnstsw_1" [(set (match_operand:HI 0 "register_operand" "=a") (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))] diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def index cda314e1121..593eead4ef1 100644 --- a/gcc/internal-fn.def +++ b/gcc/internal-fn.def @@ -230,6 +230,7 @@ DEF_INTERNAL_FLT_FLOATN_FN (TRUNC, ECF_CONST, btrunc, unary) DEF_INTERNAL_FLT_FN (ATAN2, ECF_CONST, atan2, binary) DEF_INTERNAL_FLT_FLOATN_FN (COPYSIGN, ECF_CONST, copysign, binary) DEF_INTERNAL_FLT_FN (FMOD, ECF_CONST, fmod, binary) +DEF_INTERNAL_FLT_FN (HYPOT, ECF_CONST, hypot, binary) DEF_INTERNAL_FLT_FN (POW, ECF_CONST, pow, binary) DEF_INTERNAL_FLT_FN (REMAINDER, ECF_CONST, remainder, binary) DEF_INTERNAL_FLT_FN (SCALB, ECF_CONST, scalb, binary) diff --git a/gcc/optabs.def b/gcc/optabs.def index 5a67f5eed5e..2d039e7682b 100644 --- a/gcc/optabs.def +++ b/gcc/optabs.def @@ -284,6 +284,7 @@ OPTAB_D (exp2_optab, "exp2$a2") OPTAB_D (exp_optab, "exp$a2") OPTAB_D (expm1_optab, "expm1$a2") OPTAB_D (fmod_optab, "fmod$a3") +OPTAB_D (hypot_optab, "hypot$a3") OPTAB_D (ilogb_optab, "ilogb$a2") OPTAB_D (isinf_optab, "isinf$a2") OPTAB_D (ldexp_optab, "ldexp$a3") -- 2.30.2