Fwd: Issue with __builtin_remainder expansion on i386

Uros Bizjak ubizjak@gmail.com
Mon Sep 29 14:34:00 GMT 2014


I forgot to CC following message to fortran-dev list.

Uros.

---------- Forwarded message ----------
From: FX <fxcoudert@gmail.com>
Date: Mon, Sep 29, 2014 at 11:45 AM
Subject: Re: Issue with __builtin_remainder expansion on i386
To: Uros Bizjak <ubizjak@gmail.com>
Cc: GCC Development <gcc@gcc.gnu.org>


> 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);



More information about the Fortran mailing list