diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2018-12-17 16:46:20 +0100 |
---|---|---|
committer | Uros Bizjak <uros@gcc.gnu.org> | 2018-12-17 16:46:20 +0100 |
commit | a81037cea642bb6a7e037b9a421ed5dde9c0465b (patch) | |
tree | 055afdd6a3cdc9b124aa092b6b0c592e50e92a43 | |
parent | 61c43d82f2cd0ae82ea54e072ece7f4d22299d85 (diff) | |
download | gcc-a81037cea642bb6a7e037b9a421ed5dde9c0465b.zip gcc-a81037cea642bb6a7e037b9a421ed5dde9c0465b.tar.gz gcc-a81037cea642bb6a7e037b9a421ed5dde9c0465b.tar.bz2 |
re PR target/88502 (Inline built-in asinh, acosh, atanh for -ffast-math)
PR target/88502
* internal-fn.def (ACOSH): New.
(ASINH): Ditto.
(ATANH): Ditto.
* optabs.def (acosh_optab): New.
(asinh_optab): Ditto.
(atanh_optab): Ditto.
* config/i386/i386-protos.h (ix86_emit_i387_asinh): New prototype.
(ix86_emit_i387_acosh): Ditto.
(ix86_emit_i387_atanh): Ditto.
* config/i386/i386.c (ix86_emit_i387_asinh): New function.
(ix86_emit_i387_acosh): Ditto.
(ix86_emit_i387_atanh): Ditto.
* config/i386/i386.md (asinhxf2): New expander.
(asinh<mode>2): Ditto.
(acoshxf2): Ditto.
(acosh<mode>2): Ditto.
(atanhxf2): Ditto.
(atanh<mode>2): Ditto.
From-SVN: r267204
-rw-r--r-- | gcc/ChangeLog | 22 | ||||
-rw-r--r-- | gcc/config/i386/i386-protos.h | 3 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 129 | ||||
-rw-r--r-- | gcc/config/i386/i386.md | 83 | ||||
-rw-r--r-- | gcc/internal-fn.def | 3 | ||||
-rw-r--r-- | gcc/optabs.def | 3 |
6 files changed, 243 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1227085..8f79e1d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,25 @@ +2018-12-17 Uros Bizjak <ubizjak@gmail.com> + + PR target/88502 + * internal-fn.def (ACOSH): New. + (ASINH): Ditto. + (ATANH): Ditto. + * optabs.def (acosh_optab): New. + (asinh_optab): Ditto. + (atanh_optab): Ditto. + * config/i386/i386-protos.h (ix86_emit_i387_asinh): New prototype. + (ix86_emit_i387_acosh): Ditto. + (ix86_emit_i387_atanh): Ditto. + * config/i386/i386.c (ix86_emit_i387_asinh): New function. + (ix86_emit_i387_acosh): Ditto. + (ix86_emit_i387_atanh): Ditto. + * config/i386/i386.md (asinhxf2): New expander. + (asinh<mode>2): Ditto. + (acoshxf2): Ditto. + (acosh<mode>2): Ditto. + (atanhxf2): Ditto. + (atanh<mode>2): Ditto. + 2018-12-17 David Edelsohn <dje.gcc@gmail.com> * config.gcc (powerpc-ibm-aix6.*): Delete extra_headers. diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 258bdd1..ae11807 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -170,6 +170,9 @@ extern void x86_function_profiler (FILE *, int); extern void x86_emit_floatuns (rtx [2]); extern void ix86_emit_fp_unordered_jump (rtx); +extern void ix86_emit_i387_asinh (rtx, rtx); +extern void ix86_emit_i387_acosh (rtx, rtx); +extern void ix86_emit_i387_atanh (rtx, rtx); extern void ix86_emit_i387_log1p (rtx, rtx); extern void ix86_emit_i387_round (rtx, rtx); extern void ix86_emit_swdivsf (rtx, rtx, rtx, machine_mode); diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 4ba2361..b9c4591 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -44054,6 +44054,135 @@ ix86_emit_fp_unordered_jump (rtx label) JUMP_LABEL (insn) = label; } +/* Output code to perform an asinh XFmode calculation. */ + +void ix86_emit_i387_asinh (rtx op0, rtx op1) +{ + rtx e1 = gen_reg_rtx (XFmode); + rtx e2 = gen_reg_rtx (XFmode); + rtx scratch = gen_reg_rtx (HImode); + rtx flags = gen_rtx_REG (CCNOmode, FLAGS_REG); + rtx cst1, tmp; + rtx_code_label *jump_label = gen_label_rtx (); + rtx_insn *insn; + + /* e2 = sqrt (op1^2 + 1.0) + 1.0 */ + emit_insn (gen_mulxf3 (e1, op1, op1)); + cst1 = force_reg (XFmode, CONST1_RTX (XFmode)); + emit_insn (gen_addxf3 (e2, e1, cst1)); + emit_insn (gen_sqrtxf2 (e2, e2)); + emit_insn (gen_addxf3 (e2, e2, cst1)); + + /* e1 = e1 / e2 */ + emit_insn (gen_divxf3 (e1, e1, e2)); + + /* scratch = fxam (op1) */ + emit_insn (gen_fxamxf2_i387 (scratch, op1)); + + /* e1 = e1 + |op1| */ + emit_insn (gen_absxf2 (e2, op1)); + emit_insn (gen_addxf3 (e1, e1, e2)); + + /* e2 = log1p (e1) */ + ix86_emit_i387_log1p (e2, e1); + + /* flags = signbit (op1) */ + emit_insn (gen_testqi_ext_1_ccno (scratch, GEN_INT (0x02))); + + /* if (flags) then e2 = -e2 */ + tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, + gen_rtx_EQ (VOIDmode, flags, const0_rtx), + gen_rtx_LABEL_REF (VOIDmode, jump_label), + pc_rtx); + insn = emit_jump_insn (gen_rtx_SET (pc_rtx, tmp)); + predict_jump (REG_BR_PROB_BASE * 50 / 100); + JUMP_LABEL (insn) = jump_label; + + emit_insn (gen_negxf2 (e2, e2)); + + emit_label (jump_label); + LABEL_NUSES (jump_label) = 1; + + emit_move_insn (op0, e2); +} + +/* Output code to perform an acosh XFmode calculation. */ + +void ix86_emit_i387_acosh (rtx op0, rtx op1) +{ + rtx e1 = gen_reg_rtx (XFmode); + rtx e2 = gen_reg_rtx (XFmode); + rtx cst1 = force_reg (XFmode, CONST1_RTX (XFmode)); + + /* e2 = sqrt (op1 + 1.0) */ + emit_insn (gen_addxf3 (e2, op1, cst1)); + emit_insn (gen_sqrtxf2 (e2, e2)); + + /* e1 = sqrt (op1 - 1.0) */ + emit_insn (gen_subxf3 (e1, op1, cst1)); + emit_insn (gen_sqrtxf2 (e1, e1)); + + /* e1 = e1 * e2 */ + emit_insn (gen_mulxf3 (e1, e1, e2)); + + /* e1 = e1 + op1 */ + emit_insn (gen_addxf3 (e1, e1, op1)); + + /* op0 = log (e1) */ + emit_insn (gen_logxf2 (op0, e1)); +} + +/* Output code to perform an atanh XFmode calculation. */ + +void ix86_emit_i387_atanh (rtx op0, rtx op1) +{ + rtx e1 = gen_reg_rtx (XFmode); + rtx e2 = gen_reg_rtx (XFmode); + rtx scratch = gen_reg_rtx (HImode); + rtx flags = gen_rtx_REG (CCNOmode, FLAGS_REG); + rtx half = const_double_from_real_value (dconsthalf, XFmode); + rtx cst1, tmp; + rtx_code_label *jump_label = gen_label_rtx (); + rtx_insn *insn; + + /* scratch = fxam (op1) */ + emit_insn (gen_fxamxf2_i387 (scratch, op1)); + + /* e2 = |op1| */ + emit_insn (gen_absxf2 (e2, op1)); + + /* e1 = -(e2 + e2) / (e2 + 1.0) */ + cst1 = force_reg (XFmode, CONST1_RTX (XFmode)); + emit_insn (gen_addxf3 (e1, e2, cst1)); + emit_insn (gen_addxf3 (e2, e2, e2)); + emit_insn (gen_negxf2 (e2, e2)); + emit_insn (gen_divxf3 (e1, e2, e1)); + + /* e2 = log1p (e1) */ + ix86_emit_i387_log1p (e2, e1); + + /* flags = signbit (op1) */ + emit_insn (gen_testqi_ext_1_ccno (scratch, GEN_INT (0x02))); + + /* if (!flags) then e2 = -e2 */ + tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, + gen_rtx_NE (VOIDmode, flags, const0_rtx), + gen_rtx_LABEL_REF (VOIDmode, jump_label), + pc_rtx); + insn = emit_jump_insn (gen_rtx_SET (pc_rtx, tmp)); + predict_jump (REG_BR_PROB_BASE * 50 / 100); + JUMP_LABEL (insn) = jump_label; + + emit_insn (gen_negxf2 (e2, e2)); + + emit_label (jump_label); + LABEL_NUSES (jump_label) = 1; + + /* op0 = 0.5 * e2) */ + half = force_reg (XFmode, half); + emit_insn (gen_mulxf3 (op0, e2, half)); +} + /* Output code to perform a log1p XFmode calculation. */ void ix86_emit_i387_log1p (rtx op0, rtx op1) diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 537b90c..6e29427 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -15483,6 +15483,89 @@ DONE; }) +(define_expand "asinhxf2" + [(use (match_operand:XF 0 "register_operand")) + (use (match_operand:XF 1 "register_operand"))] + "TARGET_USE_FANCY_MATH_387 + && flag_finite_math_only + && flag_unsafe_math_optimizations" +{ + ix86_emit_i387_asinh (operands[0], operands[1]); + DONE; +}) + +(define_expand "asinh<mode>2" + [(use (match_operand:MODEF 0 "register_operand")) + (use (match_operand:MODEF 1 "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); + + emit_insn (gen_extend<mode>xf2 (op1, operands[1])); + emit_insn (gen_asinhxf2 (op0, op1)); + emit_insn (gen_truncxf<mode>2 (operands[0], op0)); + DONE; +}) + +(define_expand "acoshxf2" + [(use (match_operand:XF 0 "register_operand")) + (use (match_operand:XF 1 "register_operand"))] + "TARGET_USE_FANCY_MATH_387 + && flag_unsafe_math_optimizations" +{ + ix86_emit_i387_acosh (operands[0], operands[1]); + DONE; +}) + +(define_expand "acosh<mode>2" + [(use (match_operand:MODEF 0 "register_operand")) + (use (match_operand:MODEF 1 "general_operand"))] + "TARGET_USE_FANCY_MATH_387 + && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH) + || TARGET_MIX_SSE_I387) + && flag_unsafe_math_optimizations" +{ + rtx op0 = gen_reg_rtx (XFmode); + rtx op1 = gen_reg_rtx (XFmode); + + emit_insn (gen_extend<mode>xf2 (op1, operands[1])); + emit_insn (gen_acoshxf2 (op0, op1)); + emit_insn (gen_truncxf<mode>2 (operands[0], op0)); + DONE; +}) + +(define_expand "atanhxf2" + [(use (match_operand:XF 0 "register_operand")) + (use (match_operand:XF 1 "register_operand"))] + "TARGET_USE_FANCY_MATH_387 + && flag_unsafe_math_optimizations" +{ + ix86_emit_i387_atanh (operands[0], operands[1]); + DONE; +}) + +(define_expand "atanh<mode>2" + [(use (match_operand:MODEF 0 "register_operand")) + (use (match_operand:MODEF 1 "general_operand"))] + "TARGET_USE_FANCY_MATH_387 + && (!(SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH) + || TARGET_MIX_SSE_I387) + && flag_unsafe_math_optimizations" +{ + rtx op0 = gen_reg_rtx (XFmode); + rtx op1 = gen_reg_rtx (XFmode); + + emit_insn (gen_extend<mode>xf2 (op1, operands[1])); + emit_insn (gen_atanhxf2 (op0, op1)); + emit_insn (gen_truncxf<mode>2 (operands[0], op0)); + DONE; +}) + (define_insn "fyl2xxf3_i387" [(set (match_operand:XF 0 "register_operand" "=f") (unspec:XF [(match_operand:XF 1 "register_operand" "0") diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def index 593eead..8c97625 100644 --- a/gcc/internal-fn.def +++ b/gcc/internal-fn.def @@ -201,8 +201,11 @@ DEF_INTERNAL_OPTAB_FN (FOLD_LEFT_PLUS, ECF_CONST | ECF_NOTHROW, /* Unary math functions. */ DEF_INTERNAL_FLT_FN (ACOS, ECF_CONST, acos, unary) +DEF_INTERNAL_FLT_FN (ACOSH, ECF_CONST, acosh, unary) DEF_INTERNAL_FLT_FN (ASIN, ECF_CONST, asin, unary) +DEF_INTERNAL_FLT_FN (ASINH, ECF_CONST, asinh, unary) DEF_INTERNAL_FLT_FN (ATAN, ECF_CONST, atan, unary) +DEF_INTERNAL_FLT_FN (ATANH, ECF_CONST, atanh, unary) DEF_INTERNAL_FLT_FN (COS, ECF_CONST, cos, unary) DEF_INTERNAL_FLT_FN (EXP, ECF_CONST, exp, unary) DEF_INTERNAL_FLT_FN (EXP10, ECF_CONST, exp10, unary) diff --git a/gcc/optabs.def b/gcc/optabs.def index 2d039e7..007212f 100644 --- a/gcc/optabs.def +++ b/gcc/optabs.def @@ -273,9 +273,12 @@ OPTAB_D (btrunc_optab, "btrunc$a2") OPTAB_D (nearbyint_optab, "nearbyint$a2") OPTAB_D (acos_optab, "acos$a2") +OPTAB_D (acosh_optab, "acosh$a2") OPTAB_D (asin_optab, "asin$a2") +OPTAB_D (asinh_optab, "asinh$a2") OPTAB_D (atan2_optab, "atan2$a3") OPTAB_D (atan_optab, "atan$a2") +OPTAB_D (atanh_optab, "atanh$a2") OPTAB_D (copysign_optab, "copysign$F$a3") OPTAB_D (xorsign_optab, "xorsign$F$a3") OPTAB_D (cos_optab, "cos$a2") |