[LLVMdev] [RFC] How to fix sqrt vs llvm.sqrt optimization asymmetry
Chris Lattner
clattner at apple.com
Tue Nov 12 09:23:37 PST 2013
On Nov 11, 2013, at 10:44 PM, Hal Finkel <hfinkel at anl.gov> wrote:
>> "Unlike sqrt in libm, however, llvm.sqrt has undefined behavior for
>> ..."
>>
>> to "... produces an undefined value", with a link back to
>> ##undefined-values.
>
> I'm not sure that helps, because it will prevents sqrt + -fno-math-errno (a readnone sqrt) -> llvm.sqrt -- and thus still prevents the use of llvm.sqrt to vectorize sqrt. I think what will help is just saying something like this:
>
> "Unlike sqrt in libm, after calling llvm.sqrt with a negative argument (except for -0.0), the state of errno, and any other portions of the floating-point environment that are used to record errors, is undefined.”
Makes sense to me.
>
> FWIW, we may want to make a similar change for the other llvm.<libm function> intrinsics, at least for the vector versions (as vector ops on many ISAs don't affect the FP state bits like the scalar ops do).
Yep.
>
>>
>> Transformations that apply to sqrt() should generally apply to
>> llvm.sqrt as well.
>
> And the intent is for this to be true for all of the other llvm.<libm function> intrinsics as well, right?
Yep!
-Chris
More information about the llvm-dev
mailing list