[llvm-dev] AVX2 codegen - question reg. FMA generation

Uday Kumar Reddy B via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 3 12:06:17 PDT 2019


On Mon, 2 Sep 2019 at 22:10, Fabian Giesen via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> On 9/2/2019 5:49 AM, Uday Kumar Reddy B via llvm-dev wrote:
> > On Mon, 2 Sep 2019 at 16:59, Roman Lebedev <lebedev.ri at gmail.com> wrote:
> >>
> >> It appears you need 'reassoc' on fmul/fadd:
> >> https://godbolt.org/z/nuTzx2
> >
> > Thanks very much, that was it. Either that or providing
> > -enable-unsafe-fp-math to llc yielded FMAs. I didn't expect this since
> > using FMAs here instead of mul/add appears to be safer (the reverse is
> > unsafe).
> >
> > ~ Uday
>
> It goes in both directions. There are expressions that are more accurate
> when evaluated with FMAs but also cases (albeit less common) where
> replacing a mul-then-add with a FMA causes problems.
>
> One example (due to Kahan) is that x^2 - y^2 evaluated as fma(-y,y,
> fmul(x,x)) can result in a negative value for x=y (if the original
> product rounded down) whereas fsub(fmul(x,x), fmul(y,y)) won't.

Thank you very much, Fabian and others.

~ Uday

>
> -Fabian
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



-- 
Founder and Director, PolyMage Labs


More information about the llvm-dev mailing list