[PATCH] D22104: [SimplifyLibCalls] pow(x, 0.5) -> fabs(sqrt(x)) (finite-only-mode)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 09:24:32 PDT 2016


spatel added a comment.

Sorry - didn't mean to back-channel a review. I just noticed that the test case starts with an LLVM intrinsic and ends with libcalls. That means we've artificially (if it's ok for scalars, then it's ok for vectors) excluded the vector variant of an 'llvm.pow' from this transform. There was also a proposal to change all libcalls to intrinsics when possible, so I think we're just creating extra work for that pass if we create libcalls here.

Possible changes to make this transform more general:

1. Switch the dyn_cast check for ConstantFP to "match(X, m_SpecificFP(0.5))" (this should work with a vector splat constant).
2. Use llvm.fabs/sqrt intrinsics so the transform works with vectors.
3. Check the 'nsz' FMF too; ie, for the case that James and Eli noted, 'nsz' should let us eliminate the fabs.


https://reviews.llvm.org/D22104





More information about the llvm-commits mailing list