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

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 05:30:34 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;
----------------
vfdff wrote:

Apply your comment, thanks

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


More information about the llvm-commits mailing list