<div dir="ltr"><div><div>For reference, the FMF 'contract' patches are listed here:<br><a href="https://bugs.llvm.org/show_bug.cgi?id=25721#c6">https://bugs.llvm.org/show_bug.cgi?id=25721#c6</a><br><br></div>If we can make the documentation better, that would certainly be a welcome patch.<br><br></div>It would be better to see the IR for your example(s), but I think you'd need 'contract' on both the fmul and fadd to generate an FMA. Conservatively, we wouldn't alter the result if either component somehow required strict FP. To vectorize, you probably need 'fast' on both ops because vectorization would be changing the order of operations (reassociation).<br><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 9, 2017 at 9:04 PM, Yichao Yu via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
On LLVM 5.0 (current trunk), fadd/fsub and fmul that are both marked<br>
with `contract` or `fast` can be merged to a fma instruction by the<br>
backend.<br>
<br>
I'm wondering about the exact semantic of this new flag as well as<br>
`fast` and in particular, would it be valid to do this when only the<br>
`fadd`/`fsub` (and not the `fmul`) is marked with `contract` or at<br>
least `fast`. The reasoning is that doing this will have a similar<br>
effect as if the `fadd`/`fsub` is performed not to IEEE spec so a<br>
single flag on this instruction should be enough for the<br>
transformation.<br>
<br>
The particular case I'm interested in is vectorized loop with<br>
reduction like in pseudo C code `s += a[i] * b[i]`. Our front end will<br>
recognize this and mark the `+` as `fast` to enable vectorization.<br>
It'll be great if this can enable the reduction to be done with `fma`<br>
instructions.<br>
<br>
Yichao Yu<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>