[llvm] [SCEV] Use makeExactNoWrapRegion for constant operands. (NFC) (PR #223973)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 03:44:26 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Florian Hahn (fhahn)
<details>
<summary>Changes</summary>
Use makeExactNoWrapRegion when constant is available.
Together with https://github.com/llvm/llvm-project/pull/223969, this reduces compile-time in SCEV heavy workloads:
stage1-O3: -0.08%
stage1-ReleaseThinLTO: -0.07%
stage1-ReleaseLTO-g: -0.08%
stage1-aarch64-O3: -0.08%
stage2-O3: -0.07%
https://llvm-compile-time-tracker.com/compare.php?from=e78970f80f1041de8948cb0b665a9aaae682f6c6&to=eeb18333a66b5df7fa3702d6f996260785d96a94&stat=instructions%3Au
---
Full diff: https://github.com/llvm/llvm-project/pull/223973.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/ScalarEvolution.cpp (+4-4)
``````````diff
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 689a8741af983..ae9fcf9a115c7 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -2472,16 +2472,16 @@ static SCEV::NoWrapFlags StrengthenNoWrapFlags(ScalarEvolution *SE,
// (A <opcode> C) --> (A <opcode> C)<nsw> if the op doesn't sign overflow.
if (!(SignOrUnsignWrap & SCEV::FlagNSW)) {
- auto NSWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
- Opcode, C, OBO::NoSignedWrap);
+ auto NSWRegion =
+ ConstantRange::makeExactNoWrapRegion(Opcode, C, OBO::NoSignedWrap);
if (NSWRegion.contains(SE->getSignedRange(Ops[1])))
Flags = ScalarEvolution::setFlags(Flags, SCEV::FlagNSW);
}
// (A <opcode> C) --> (A <opcode> C)<nuw> if the op doesn't unsign overflow.
if (!(SignOrUnsignWrap & SCEV::FlagNUW)) {
- auto NUWRegion = ConstantRange::makeGuaranteedNoWrapRegion(
- Opcode, C, OBO::NoUnsignedWrap);
+ auto NUWRegion =
+ ConstantRange::makeExactNoWrapRegion(Opcode, C, OBO::NoUnsignedWrap);
if (NUWRegion.contains(SE->getUnsignedRange(Ops[1])))
Flags = ScalarEvolution::setFlags(Flags, SCEV::FlagNUW);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/223973
More information about the llvm-commits
mailing list