[llvm] [InstCombine] optimize powi(X,Y)/X with Ofast (PR #67236)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 24 05:08:39 PDT 2023
================
@@ -1764,6 +1764,16 @@ Instruction *InstCombinerImpl::visitFDiv(BinaryOperator &I) {
return replaceInstUsesWith(I, Pow);
}
+ if (I.hasAllowReassoc() && I.hasNoInfs() &&
+ match(Op0, m_OneUse(m_Intrinsic<Intrinsic::powi>(m_Specific(Op1),
+ m_Value(Y))))) {
+ Constant *NegOne = ConstantInt::getAllOnesValue(Y->getType());
+ Value *Y1 = Builder.CreateAdd(Y, NegOne);
+ Type *Types[] = {Op1->getType(), Y1->getType()};
+ Value *Pow = Builder.CreateIntrinsic(Intrinsic::powi, Types, {Op1, Y1}, &I);
+ return replaceInstUsesWith(I, Pow);
----------------
dtcxzyw wrote:
I have opened a pull request #67263 to address this.
https://github.com/llvm/llvm-project/pull/67236
More information about the llvm-commits
mailing list