[llvm] [VPlan] Replace ExtractFromEnd with Extract(Last|Penultimate)Lane (NFC). (PR #137030)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 16:01:14 PDT 2025


================
@@ -337,14 +337,19 @@ void UnrollState::unrollBlock(VPBlockBase *VPB) {
       continue;
     }
     VPValue *Op0;
-    if (match(&R, m_VPInstruction<VPInstruction::ExtractFromEnd>(
-                      m_VPValue(Op0), m_VPValue(Op1)))) {
+    if (match(&R, m_VPInstruction<VPInstruction::ExtractLastLane>(
+                      m_VPValue(Op0))) ||
+        match(&R, m_VPInstruction<VPInstruction::ExtractPenultimateLane>(
+                      m_VPValue(Op0)))) {
       addUniformForAllParts(cast<VPSingleDefRecipe>(&R));
       if (Plan.hasScalarVFOnly()) {
         // Extracting from end with VF = 1 implies retrieving the scalar part UF
         // - Op1.
         unsigned Offset =
----------------
ayalz wrote:

Trying to simplify:
```suggestion
        auto *I = dyn_cast<VPInstruction>(&R); // Place above for reuse. Similar to H below.
        unsigned Offset = I->getOpcode() == VPInstruction::ExtractLast ? 1 : 2;
```
consistent with how VPInstruction::generate() computes Offset?

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


More information about the llvm-commits mailing list