[llvm] [InstCombine] optimize powi(X,Y)/X with Ofast (PR #67236)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 17 05:52:15 PDT 2023
================
@@ -1764,6 +1764,22 @@ Instruction *InstCombinerImpl::visitFDiv(BinaryOperator &I) {
return replaceInstUsesWith(I, Pow);
}
+ // powi(X, Y) / X --> powi(X, Y-1)
+ // This is legal when (Y - 1) can't wraparound, in which case reassoc and nnan
+ // are required.
+ // Todo: Multi-use may be also better off creating Powi(x,y-1)
+ if (I.hasAllowReassoc() && I.hasNoNaNs() &&
+ match(Op0, m_OneUse(m_Intrinsic<Intrinsic::powi>(m_Specific(Op1),
+ m_Value(Y)))) &&
+ computeOverflowForSignedSub(Y, ConstantInt::getAllOnesValue(Y->getType()),
----------------
vfdff wrote:
Apply your comment, thanks @dtcxzyw for your carefully check.
https://github.com/llvm/llvm-project/pull/67236
More information about the llvm-commits
mailing list