]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR target/88474
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Dec 2018 17:04:48 +0000 (17:04 +0000)
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Dec 2018 17:04:48 +0000 (17:04 +0000)
* internal-fn.def (HYPOT): New.
* optabs.def (hypot_optab): New.
* config/i386/i386.md (hypot<mode>3): New expander.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267137 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/internal-fn.def
gcc/optabs.def

index 99f830667cf113a57ba73949ff0f7b2bbf08d89a..99d97db749638a4dd4ec7f4ceb465227f0b7427b 100644 (file)
@@ -1,3 +1,10 @@
+2018-12-14  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/88474
+       * internal-fn.def (HYPOT): New.
+       * optabs.def (hypot_optab): New.
+       * config/i386/i386.md (hypot<mode>3): New expander.
+
 2018-12-14  Jeff Law  <law@redhat.com>
 
        * target.def (post_cfi_startproc): Fix text.
index 5e46bdcdd37478941535f7a54fb1c770ea1b75d4..537b90c3b4b666c2b2c5fffe0462736ac42ad1ce 100644 (file)
    }
 })
 
+(define_expand "hypot<mode>3"
+  [(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>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_extend<mode>xf2 (op2, operands[2]));
+  emit_insn (gen_extend<mode>xf2 (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_truncxf<mode>2 (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))]
index cda314e112155ae638db7cdb60a51df20b96ade3..593eead4ef15d7d2678c76d933f057fa9e2e057d 100644 (file)
@@ -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)
index 5a67f5eed5e457e6dea34f9969534f8497e620f6..2d039e7682b9e1b0cc8bd327bfd0a7bd3e0f9a97 100644 (file)
@@ -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")