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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 7 21:29:50 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() &&
----------------
dtcxzyw wrote:

Should we need `nnan` flag here? The simplification `X * Y / Y -> X` in InstSimplify requires this flag.
https://github.com/llvm/llvm-project/blob/76fc871552c28b37b81c67f411a90065077816a0/llvm/lib/Analysis/InstructionSimplify.cpp#L5860-L5869

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


More information about the llvm-commits mailing list