> The __builtin_remainderf on x86 expands to x87 fprem1 instruction [1]. > According to the table in [1], +inf is not handled, and generates > division-by-zero exception. > > IMO, we have to add "&& flag_finite_math_only" to expander enable > condition of remainder{sf,df,xf}3 expanders in i386.md
I can confirm that the patch below indeed fixes the issue. Index: gcc/config/i386/i386.md =================================================================== --- gcc/config/i386/i386.md (revision 215645) +++ gcc/config/i386/i386.md (working copy) @@ -13893,7 +13893,7 @@ [(use (match_operand:XF 0 "register_operand")) (use (match_operand:XF 1 "general_operand")) (use (match_operand:XF 2 "general_operand"))] - "TARGET_USE_FANCY_MATH_387" + "TARGET_USE_FANCY_MATH_387 && flag_finite_math_only" { rtx_code_label *label = gen_label_rtx (); @@ -13916,7 +13916,7 @@ [(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" + "TARGET_USE_FANCY_MATH_387 && flag_finite_math_only" { rtx (*gen_truncxf) (rtx, rtx);