[llvm] [InstCombine] optimize powi(X,Y) * X with Ofast (PR #69998)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 22:46:18 PDT 2023


================
@@ -716,6 +716,18 @@ Instruction *InstCombinerImpl::visitFMul(BinaryOperator &I) {
       return replaceInstUsesWith(I, Pow);
     }
 
+    // powi(X, Y) * X --> powi(X, Y+1)
+    // X * powi(X, Y) --> powi(X, Y+1)
+    if (match(&I, m_c_FMul(m_OneUse(m_Intrinsic<Intrinsic::powi>(m_Value(X),
----------------
arsenm wrote:

The reassoc check is really hard to find, this whole if (reassoc) should probably be split to a helper function.

Also, should check the reason on the inner operation too?

https://github.com/llvm/llvm-project/pull/69998


More information about the llvm-commits mailing list