[llvm] [InstCombine] Div ceil optimizations (PR #190175)

Takashi Idobe via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 5 13:17:01 PDT 2026


================
@@ -10361,6 +10361,10 @@ ConstantRange llvm::computeConstantRange(const Value *V, bool ForSigned,
         SI->getFalseValue(), ForSigned, UseInstrInfo, AC, CtxI, DT, Depth + 1);
     CR = CRTrue.unionWith(CRFalse);
     CR = CR.intersectWith(getRangeForSelectPattern(*SI, IIQ));
+  } else if (auto *TI = dyn_cast<TruncInst>(V)) {
+    ConstantRange SrcCR = computeConstantRange(
+        TI->getOperand(0), ForSigned, UseInstrInfo, AC, CtxI, DT, Depth + 1);
+    CR = SrcCR.truncate(BitWidth);
----------------
Takashiidobe wrote:

I've taken the suggestion. Before I wrote this patch I assumed this was already set up but it wasn't and I needed it for this patch. 

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


More information about the llvm-commits mailing list