[PATCH] D39642: [ValueTracking] readnone is a requirement for converting sqrt to llvm.sqrt; nnan is not
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 6 12:45:52 PST 2017
spatel added a comment.
In https://reviews.llvm.org/D39642#917009, @efriedma wrote:
> I'm not sure how the C standard fits into this? "-ffinite-math-only" mode intentionally doesn't conform to the C standard.
It's moot after this fix, but I was imagining a strict-mode case where we somehow determined that the sqrt does not have nan input or output.
define double @foo(double %x) {
entry:
%cmp.i = fcmp ord double %x, 0.0
br i1 %cmp.i, label %no_nan_input, label %end
no_nan_input:
%sqrt = tail call double @sqrt(double %x) #2 <--- some pass can mark this call with 'nnan' if it knows the libcall won't return nan?
br label %return
end:
%r = phi double [ %sqrt, %no_nan_input ], [ 1.0, %entry ]
ret double %r
}
So if that sqrt got marked with nnan, the vectorizers or whoever else is using getIntrinsicForCallSite() would convert the libcall to the intrinsic, but that wouldn't be correct if %x is a negative number? We would fail to set errno when we should have.
https://reviews.llvm.org/D39642
More information about the llvm-commits
mailing list