This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Issue with __builtin_remainder expansion on i386


> I have just submitted a patch emitting some new floating-point code from the Fortran front-end,
> improving our IEEE support there:
> However, in one of the cases where we emit a call to __builtin_remainderf(), we get wrong code
> generation on i386. It is peculiar because:
>  - the wrong code occurs at all optimization levels, and the following flags (any or all) do not
> affect it:
>  -mfpmath=sse -msse2 -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans
>  - the wrong code does not occur with -ffloat-store
>  - the code generate looks fine by every aspect I could try. I could not generate a direct C
>  testcase, unfortunately, but it is equivalent to:

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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]