[llvm] [CodeGenPrepare] Folding `urem` with loop invariant value as remainder (PR #96625)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 08:16:54 PDT 2024


================
@@ -1974,6 +1975,165 @@ static bool foldFCmpToFPClassTest(CmpInst *Cmp, const TargetLowering &TLI,
   return true;
 }
 
+static bool isRemOfLoopIncrementWithLoopInvariant(
+    Value *Rem, const LoopInfo *LI, Value *&RemAmtOut,
+    std::optional<bool> &AddOrSubOut, Value *&AddOrSubOffsetOut,
+    PHINode *&LoopIncrPNOut) {
+  Value *Incr, *RemAmt;
+  if (!isa<Instruction>(Rem))
----------------
nikic wrote:

Why doesn't this function accept an `Instruction` instead? It's an Instruction in the caller.

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


More information about the llvm-commits mailing list