[llvm-dev] [RFC] FP Contract = fast?

Sebastian Pop via llvm-dev
2017-03-15T15:35:20Z

On 03/15/2017 09:58 AM, Hal Finkel wrote:
> On 03/15/2017 08:27 AM, Renato Golin wrote:
>
>> Folks,
>>
>> I've been asking around people about the state of FP contract,
which
>> seems to be "on" but it's not really behaving like it, at
least not as
>> I would expect:
>>
>> int foo(float a, float b, float c) { return a*b+c; }
>>
>> $ clang -target aarch64-linux-gnu -O2 -S fma.c -ffp-contract=on -o -
>> (...)
>> fmul s0, s0, s1
>> fadd s0, s0, s2
>> (...)
>
> When you reverted  r282259 in 282289, you also reverted the functional
> fix to make the command-line option actually work. Right now it is
> broken. Regardless of what else we do, we should fix this (we should
> probably recommit r282259, with the default flipped, to pick up the
> fixes). If you were to change your source file to:
>
> #pragma STDC FP_CONTRACT ON
> int foo(float a, float b, float c) { return a*b+c; }
>
I would like to see https://reviews.llvm.org/rL282259 re-enabled,
and the few miscompares left in the aarch64 run of the test-suite
fixed by adding the FP_CONTRACT pragma in the source code.

The commit log of r282259 states the problem that it
fixed:
> Clang has the default FP contraction setting of  “-ffp-contract=on”, which
> doesn't really mean “on” in the conventional  sense of the word, but
rather
> really means “according to the per-statement  effective value of the
relevant
> pragma”.

Thanks,
Sebastian