[llvm] [WIP] [InstCombine] Div ceil optimizations (PR #190175)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 2 06:26:59 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- llvm/lib/Analysis/ValueTracking.cpp llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp llvm/lib/Transforms/InstCombine/InstCombineInternal.h --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 2460397cb..53e8ff15f 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -10362,9 +10362,8 @@ ConstantRange llvm::computeConstantRange(const Value *V, bool ForSigned,
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);
+ ConstantRange SrcCR = computeConstantRange(
+ TI->getOperand(0), ForSigned, UseInstrInfo, AC, CtxI, DT, Depth + 1);
CR = SrcCR.truncate(BitWidth);
} else if (isa<FPToUIInst>(V) || isa<FPToSIInst>(V)) {
APInt Lower = APInt(BitWidth, 0);
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index fc39de2a1..7b7ec22b3 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1533,7 +1533,7 @@ static Instruction *foldBoxMultiply(BinaryOperator &I) {
// Note: computeConstantRangeIncludingKnownBits does not forward AC/DT to
// computeConstantRange, so it won't pick up llvm.assume; call the full form.
static bool checkDivCeilNUW(Value *X, Value *Y, BinaryOperator &I,
- AssumptionCache &AC, DominatorTree &DT) {
+ AssumptionCache &AC, DominatorTree &DT) {
ConstantRange CRX = computeConstantRange(X, /*ForSigned=*/false,
/*UseInstrInfo=*/true, &AC, &I, &DT);
ConstantRange CRY = computeConstantRange(Y, /*ForSigned=*/false,
@@ -1584,8 +1584,9 @@ Instruction *InstCombinerImpl::foldNarrowDivCeil(BinaryOperator &I) {
auto ZExtDivPat = m_OneUse(m_ZExt(UDivPat));
auto ZExtCmpPat = m_OneUse(m_ZExt(ICmpPat));
- if (!match(&I, m_c_Add(ZExtDivPat, ZExtCmpPat)) || Pred != ICmpInst::ICMP_NE ||
- X != X2 || Y != Y2 || !checkDivCeilNUW(X, Y, I, AC, DT))
+ if (!match(&I, m_c_Add(ZExtDivPat, ZExtCmpPat)) ||
+ Pred != ICmpInst::ICMP_NE || X != X2 || Y != Y2 ||
+ !checkDivCeilNUW(X, Y, I, AC, DT))
return nullptr;
Value *YMinusOne = Builder.CreateSub(Y, ConstantInt::get(Y->getType(), 1));
``````````
</details>
https://github.com/llvm/llvm-project/pull/190175
More information about the llvm-commits
mailing list