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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 26 06:24:37 PDT 2023


================
@@ -1764,6 +1764,19 @@ Instruction *InstCombinerImpl::visitFDiv(BinaryOperator &I) {
     return replaceInstUsesWith(I, Pow);
   }
 
+  // powi(X, Y) / X --> powi(X, Y-1)
+  // Todo: Multi-use may be also better off creating Powi(x,y-1)
+  if (I.hasNoInfs() && I.isFast() &&
----------------
nikic wrote:

No, you should check specific flags liked at https://llvm.org/docs/LangRef.html#fast-math-flags, not the aggregate `fast` flag.

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


More information about the llvm-commits mailing list