This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Issue with __builtin_remainder expansion on i386
- From: FX <fxcoudert at gmail dot com>
- To: Uros Bizjak <ubizjak at gmail dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Mon, 29 Sep 2014 11:45:10 +0200
- Subject: Re: Issue with __builtin_remainder expansion on i386
- Authentication-results: sourceware.org; auth=none
- References: <CAFULd4aPdJ4sX1_uECVwa6jEC813sCdg_xSkr7smZOOGrQqyOQ at mail dot gmail dot com>
> 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);