[llvm-dev] Fusing contract fadd/fsub with normal fmul

Hal Finkel via llvm-dev llvm-dev at lists.llvm.org
Mon Jun 12 06:36:48 PDT 2017


It seems like the contract flag is underspecified in this regard. I'd 
lean, however, toward requiring it on both instructions in order to 
contract them. That way inlining a function where contraction was 
prohibited into a function where contraction was permitted would not be 
able to effectively remove the final-result rounding from the callee.

  -Hal


On 06/09/2017 10:04 PM, Yichao Yu via llvm-dev wrote:
> Hi,
>
> On LLVM 5.0 (current trunk), fadd/fsub and fmul that are both marked
> with `contract` or `fast` can be merged to a fma instruction by the
> backend.
>
> I'm wondering about the exact semantic of this new flag as well as
> `fast` and in particular, would it be valid to do this when only the
> `fadd`/`fsub` (and not the `fmul`) is marked with `contract` or at
> least `fast`. The reasoning is that doing this will have a similar
> effect as if the `fadd`/`fsub` is performed not to IEEE spec so a
> single flag on this instruction should be enough for the
> transformation.
>
> The particular case I'm interested in is vectorized loop with
> reduction like in pseudo C code `s += a[i] * b[i]`. Our front end will
> recognize this and mark the `+` as `fast` to enable vectorization.
> It'll be great if this can enable the reduction to be done with `fma`
> instructions.
>
> Yichao Yu
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-dev mailing list