[llvm-branch-commits] [llvm] [LoopVectorize][NFC] Refactor widening decision logic (PR #140722)

David Sherwood via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Nov 10 04:58:29 PST 2025


================
@@ -5617,14 +5618,8 @@ void LoopVectorizationCostModel::setCostBasedWideningDecision(ElementCount VF) {
       }
 
       // We assume that widening is the best solution when possible.
-      if (memoryInstructionCanBeWidened(&I, VF)) {
-        InstructionCost Cost = getConsecutiveMemOpCost(&I, VF);
-        int ConsecutiveStride = Legal->isConsecutivePtr(
-            getLoadStoreType(&I), getLoadStorePointerOperand(&I));
-        assert((ConsecutiveStride == 1 || ConsecutiveStride == -1) &&
-               "Expected consecutive stride.");
-        InstWidening Decision =
-            ConsecutiveStride == 1 ? CM_Widen : CM_Widen_Reverse;
+      if (auto Decision = memoryInstructionCanBeWidened(&I, VF)) {
----------------
david-arm wrote:

I'm a bit worried about assuming CM_Unknown is always 0. I think it's better to be more explicit, i.e.

```
  InstWidening Decision = memoryInstructionCanBeWidened(&I, VF);
  if (Decision != CM_Unknown) {
    ...
```

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


More information about the llvm-branch-commits mailing list