[PATCH] D85709: [InstSimplify] Implement Instruction simplification for X/sqrt(X) to sqrt(X).
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 13 11:44:12 PDT 2020
spatel added a comment.
In D85709#2216241 <https://reviews.llvm.org/D85709#2216241>, @venkataramanan.kumar.llvm wrote:
> For x = 0, x/sqrt(0) result in "nan". However when we specify -ffast-math we are setting "nnan" flag. The nnan flag says "Allow optimizations to assume the arguments and result are not NaN" so we can transform x/sqrt(x) to sqrt(x) under -ffast-math. is that the right understanding here?
The transform is allowed here; it's just not advisable as shown by the codegen for a target/type that expands it to an estimate sequence (ie, we should abandon this patch).
The problem with doing this transform early (in IR) is that we cannot recover the knowledge that 0.0 was not a valid input. So we need to give targets the opportunity to create an estimate first, and only if that does not happen, convert to a single sqrt.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85709/new/
https://reviews.llvm.org/D85709
More information about the llvm-commits
mailing list