Index: optabs.c =================================================================== --- optabs.c (revision 148688) +++ optabs.c (working copy) @@ -6271,6 +6271,7 @@ init_optabs (void) init_optab (expm1_optab, UNKNOWN); init_optab (ldexp_optab, UNKNOWN); init_optab (scalb_optab, UNKNOWN); + init_optab (significand_optab, UNKNOWN); init_optab (logb_optab, UNKNOWN); init_optab (ilogb_optab, UNKNOWN); init_optab (log_optab, UNKNOWN); Index: optabs.h =================================================================== --- optabs.h (revision 148688) +++ optabs.h (working copy) @@ -242,6 +242,8 @@ enum optab_index OTI_ldexp, /* Multiply floating-point number by integral power of radix */ OTI_scalb, + /* Mantissa of a floating-point number */ + OTI_significand, /* Radix-independent exponent */ OTI_logb, OTI_ilogb, @@ -462,6 +464,7 @@ extern struct optab_d optab_table[OTI_MA #define expm1_optab (&optab_table[OTI_expm1]) #define ldexp_optab (&optab_table[OTI_ldexp]) #define scalb_optab (&optab_table[OTI_scalb]) +#define significand_optab (&optab_table[OTI_significand]) #define logb_optab (&optab_table[OTI_logb]) #define ilogb_optab (&optab_table[OTI_ilogb]) #define log_optab (&optab_table[OTI_log]) Index: genopinit.c =================================================================== --- genopinit.c (revision 148688) +++ genopinit.c (working copy) @@ -178,6 +178,7 @@ static const char * const optabs[] = "optab_handler (expm1_optab, $A)->insn_code = CODE_FOR_$(expm1$a2$)", "optab_handler (ldexp_optab, $A)->insn_code = CODE_FOR_$(ldexp$a3$)", "optab_handler (scalb_optab, $A)->insn_code = CODE_FOR_$(scalb$a3$)", + "optab_handler (significand_optab, $A)->insn_code = CODE_FOR_$(significand$a2$)", "optab_handler (logb_optab, $A)->insn_code = CODE_FOR_$(logb$a2$)", "optab_handler (ilogb_optab, $A)->insn_code = CODE_FOR_$(ilogb$a2$)", "optab_handler (log_optab, $A)->insn_code = CODE_FOR_$(log$a2$)", Index: builtins.c =================================================================== --- builtins.c (revision 148688) +++ builtins.c (working copy) @@ -1975,6 +1975,8 @@ expand_builtin_mathfn (tree exp, rtx tar /* Else fallthrough and expand as rint. */ CASE_FLT_FN (BUILT_IN_RINT): builtin_optab = rint_optab; break; + CASE_FLT_FN (BUILT_IN_SIGNIFICAND): + builtin_optab = significand_optab; break; default: gcc_unreachable (); } @@ -6332,6 +6334,7 @@ expand_builtin (tree exp, rtx target, rt CASE_FLT_FN (BUILT_IN_ASIN): CASE_FLT_FN (BUILT_IN_ACOS): CASE_FLT_FN (BUILT_IN_ATAN): + CASE_FLT_FN (BUILT_IN_SIGNIFICAND): /* Treat these like sqrt only if unsafe math optimizations are allowed, because of possible accuracy problems. */ if (! flag_unsafe_math_optimizations) Index: ChangeLog =================================================================== --- ChangeLog (revision 148688) +++ ChangeLog (working copy) @@ -1758,8 +1758,8 @@ * config/rs6000/crtsavgpr.asm: Likewise. * config/rs6000/crtsavfpr.asm: Likewise. - * dwarf2out.c (output_cfi_directive): Pass 1 instead of - 0 to second argument of DWARF2_FRAME_REG_OUT macros. + * dwarf2out.c (output_cfi_directive): Pass 1 instead of 0 to second + argument of DWARF2_FRAME_REG_OUT macros. 2009-06-03 Julian Brown Index: testsuite/gcc.dg/builtins-34.c =================================================================== --- testsuite/gcc.dg/builtins-34.c (revision 148688) +++ testsuite/gcc.dg/builtins-34.c (working copy) @@ -16,6 +16,7 @@ extern double ldexp(double, int); extern double scalb(double, double); extern double scalbn(double, int); extern double scalbln(double, long); +extern double significand(double); extern float exp10f(float); extern float exp2f(float); extern float pow10f(float); @@ -24,6 +25,7 @@ extern float ldexpf(float, int); extern float scalbf(float, float); extern float scalbnf(float, int); extern float scalblnf(float, long); +extern float significandf(float); extern long double exp10l(long double); extern long double exp2l(long double); extern long double pow10l(long double); @@ -32,6 +34,7 @@ extern long double ldexpl(long double, i extern long double scalbl(long double, long double); extern long double scalbnl(long double, int); extern long double scalblnl(long double, long); +extern long double significand(long double); double test1(double x) @@ -74,6 +77,11 @@ double test8(double x, long exp) return scalbln(x, exp); } +double test9(double x) +{ + return significand(x); +} + float test1f(float x) { return exp10f(x); @@ -114,6 +122,11 @@ float test8f(float x, long exp) return scalblnf(x, exp); } +float test9f(float x) +{ + return significandf(x); +} + long double test1l(long double x) { return exp10l(x); @@ -153,3 +166,8 @@ long double test8l(long double x, long e { return scalblnl(x, exp); } + +long double test9l(long double x) +{ + return significandl(x, exp); +} Index: config/i386/i386.md =================================================================== --- config/i386/i386.md (revision 148688) +++ config/i386/i386.md (working copy) @@ -18531,7 +18531,7 @@ (define_expand "scalb3" [(use (match_operand:MODEF 0 "register_operand" "")) (use (match_operand:MODEF 1 "general_operand" "")) - (use (match_operand:MODEF 2 "register_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) @@ -18552,6 +18552,34 @@ emit_insn (gen_truncxf2_i387_noop (operands[0], op0)); DONE; }) + +(define_expand "significandxf2" + [(parallel [(set (match_operand:XF 0 "register_operand" "") + (unspec:XF [(match_operand:XF 1 "register_operand" "")] + UNSPEC_XTRACT_FRACT)) + (set (match_dup 2) + (unspec:XF [(match_dup 1)] UNSPEC_XTRACT_EXP))])] + "TARGET_USE_FANCY_MATH_387 + && flag_unsafe_math_optimizations" +{ + operands[2] = gen_reg_rtx (XFmode); +}) + +(define_expand "significand2" + [(use (match_operand:MODEF 0 "register_operand" "")) + (use (match_operand:MODEF 1 "register_operand" ""))] + "TARGET_USE_FANCY_MATH_387 + && (!(SSE_FLOAT_MODE_P (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_fxtract_extendxf3_i387 (op0, op1, operands[1])); + emit_insn (gen_truncxf2_i387_noop (operands[0], op0)); + DONE; +}) (define_insn "sse4_1_round2"