[llvm] [LV][NFC] Factor out MinBWs of values from the cost model (PR #194492)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 29 05:53:44 PDT 2026
================
@@ -563,6 +563,15 @@ bool VFSelectionContext::runtimeChecksRequired() {
return false;
}
+const MapVector<Instruction *, uint64_t> &
+VFSelectionContext::getMinimalBitwidths() {
+ if (!MinBWsComputed) {
+ MinBWs = computeMinimumValueSizes(TheLoop->getBlocks(), *DB, &TTI);
----------------
david-arm wrote:
Hmm, I see what you mean. I guess the problem with calling `computeMinimumValueSizes` from the constructor means we may do lots of computation, then for some reason we might never actually use `MinBWs`. How about just initialising this explicitly like we do for other things in the context? For example, something like:
```
void LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
assert(OrigLoop->isInnermost() && "Inner loop expected.");
CM.collectValuesToIgnore();
Config.collectElementTypesForWidening(&CM.ValuesToIgnore);
Config.collectMinimumValueSizes();
```
where
```
VFSelectionContext::collectMinimumValueSizes() {
MinBWs = computeMinimumValueSizes(TheLoop->getBlocks(), *DB, &TTI);
}
```
This avoids the lazy lookup and allows you to remove the `MinBWsComputed` variable. You can also then move `VFSelectionContext::getMinimalBitwidths` to the header file.
https://github.com/llvm/llvm-project/pull/194492
More information about the llvm-commits
mailing list