[llvm] [InstCombine] optimize powi(X,Y)/X with Ofast (PR #67236)

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 8 00:32:33 PDT 2023


================
@@ -1764,6 +1764,19 @@ Instruction *InstCombinerImpl::visitFDiv(BinaryOperator &I) {
     return replaceInstUsesWith(I, Pow);
   }
 
+  // powi(X, Y) / X --> powi(X, Y-1)
+  // Require 'ninf' assuming that makes powi(X, -INT_MIN) acceptable
+  // Todo: Multi-use may be also better off creating Powi(x,y-1)
+  if (I.hasNoInfs() && I.hasAllowReassoc() &&
----------------
vfdff wrote:

Thanks @dtcxzyw  , added **nnan** flag.

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


More information about the llvm-commits mailing list