Previously, SLC was disallowing those optimizations if TLI said there is
no pow() library function.
Change-Id: I01c461df3537760b4919422b5ad3a2f004eb4f0f
Paths
| Differential D68231
[SLC] Allow llvm.pow(x,2.0) -> x*x etc even if no pow() lib func ClosedPublic Authored by foad on Sep 30 2019, 9:32 AM.
Details Summary Previously, SLC was disallowing those optimizations if TLI said there is Change-Id: I01c461df3537760b4919422b5ad3a2f004eb4f0f
Diff Detail
Event TimelineComment Actions @foad pointed out that this fix is wrong. TLI saying pow() is not supported means if we find a call to a function called pow() then we don't know its semantics. So I will push a revised fix. Comment Actions I don't understand what the check is supposed to be doing in the first place. If we're in LibCallSimplifier::optimizePow, we've already checked that the call is actually calling a function with the right semantics, not just the name. Comment Actions Indeed, it seemed to be a coarse check in case the following transformations end up calling pow(). However, the only transformation that calls pow() is when shrinking to powf(), which itself chacks for the availability of this routine. So this patch seems to address this issue the wrong way. It seems that removing this check would be better.
Comment Actions The patch description is only stating the previous status-quo as a fact, Is this really sane? Comment Actions
We're not creating library calls. We're only creating instructions and generic intrinsic calls, neither of which (should) depend on what TLI says about the available library functions. Comment Actions
How about something like: "optimizePow does not create any new calls to pow, so it should work regardless of whether the pow library function is available. This allows it to optimize the llvm.pow intrinsic on targets with no math library." Annoyingly, if I change the commit message, arc diff doesn't propagate that to the web interface.
This revision is now accepted and ready to land.May 4 2020, 2:21 AM Closed by commit rGe737847b8fc3: [SLC] Allow llvm.pow(x,2.0) -> x*x etc even if no pow() lib func (authored by foad). · Explain WhyMay 4 2020, 3:10 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 261757 llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/pow-1.ll
llvm/test/Transforms/InstCombine/pow-3.ll
|
Can you precommit this please?