[llvm] [InstCombine] optimize powi(X,Y) * X with Ofast (PR #69998)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 4 00:47:35 PST 2024
================
@@ -571,6 +571,55 @@ Instruction *InstCombinerImpl::foldFPSignBitOps(BinaryOperator &I) {
return nullptr;
}
+Instruction *InstCombinerImpl::foldPowiReassoc(BinaryOperator &I) {
+ Value *X, *Y, *Z;
+
+ // Make sure all operands have reassoc flag if they are powi.
+ if (!all_of(I.operands(), [](Value *V) {
+ if (match(V, m_Intrinsic<Intrinsic::powi>(m_Value(), m_Value()))) {
+ Instruction *Powi = cast<Instruction>(V);
+ return Powi->hasAllowReassoc();
+ }
+ return true;
+ }))
+ return nullptr;
----------------
arsenm wrote:
I think it would be easier to follow if you checked the reassoc flag below where you're already matching the actual powi call, instead of this pre-check of the operands
https://github.com/llvm/llvm-project/pull/69998
More information about the llvm-commits
mailing list