[llvm] [VPlan] Implement mayHaveSideEffects/mayWriteToMemory for VPInterleav… (PR #71360)

Shih-Po Hung via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 01:41:11 PST 2023


https://github.com/arcbbb updated https://github.com/llvm/llvm-project/pull/71360

>From 88c1ea6bc457fea7ff04d2cb193c438ba770fca7 Mon Sep 17 00:00:00 2001
From: ShihPo Hung <shihpo.hung at sifive.com>
Date: Sun, 5 Nov 2023 23:16:00 -0800
Subject: [PATCH] [VPlan] Implement mayHaveSideEffects/mayWriteToMemory for
 VPInterleaveRecipe

This helps VPlanTransforms::removeDeadRecipes to work on VPInterleaveRecipe
---
 llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp        |  4 ++++
 .../LoopVectorize/vplan-unused-interleave-group.ll    | 11 +++--------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index c23428e2ba34e8..02e400d590bed4 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -44,6 +44,8 @@ extern cl::opt<bool> EnableVPlanNativePath;
 
 bool VPRecipeBase::mayWriteToMemory() const {
   switch (getVPDefID()) {
+  case VPInterleaveSC:
+    return cast<VPInterleaveRecipe>(this)->getNumStoreOperands() > 0;
   case VPWidenMemoryInstructionSC: {
     return cast<VPWidenMemoryInstructionRecipe>(this)->isStore();
   }
@@ -146,6 +148,8 @@ bool VPRecipeBase::mayHaveSideEffects() const {
            "underlying instruction has side-effects");
     return false;
   }
+  case VPInterleaveSC:
+    return mayWriteToMemory();
   case VPWidenMemoryInstructionSC:
     assert(cast<VPWidenMemoryInstructionRecipe>(this)
                    ->getIngredient()
diff --git a/llvm/test/Transforms/LoopVectorize/vplan-unused-interleave-group.ll b/llvm/test/Transforms/LoopVectorize/vplan-unused-interleave-group.ll
index 58ef924040d9a7..c91e54e3036b29 100644
--- a/llvm/test/Transforms/LoopVectorize/vplan-unused-interleave-group.ll
+++ b/llvm/test/Transforms/LoopVectorize/vplan-unused-interleave-group.ll
@@ -17,14 +17,9 @@ define void @test_unused_interleave(ptr %src, i32 %length) {
 ; CHECK-EMPTY:
 ; CHECK-NEXT: <x1> vector loop: {
 ; CHECK-NEXT:   vector.body:
-; CHECK-NEXT:     EMIT vp<%1> = CANONICAL-INDUCTION ir<0>, vp<%6>
-; CHECK-NEXT:     vp<%2> = SCALAR-STEPS vp<%1>, ir<1>
-; CHECK-NEXT:     CLONE ir<%next19.i.i> = getelementptr inbounds ir<%src>, vp<%2>, ir<0>
-; CHECK-NEXT:     INTERLEAVE-GROUP with factor 2 at %load_p1, ir<%next19.i.i>
-; CHECK-NEXT:       ir<%load_p1> = load from index 0
-; CHECK-NEXT:       ir<%load_p2> = load from index 1
-; CHECK-NEXT:     EMIT vp<%6> = VF * UF + nuw vp<%1>
-; CHECK-NEXT:     EMIT branch-on-count vp<%6>, vp<%0>
+; CHECK-NEXT:     EMIT vp<%1> = CANONICAL-INDUCTION ir<0>, vp<%2>
+; CHECK-NEXT:     EMIT vp<%2> = VF * UF + nuw vp<%1>
+; CHECK-NEXT:     EMIT branch-on-count vp<%2>, vp<%0>
 ; CHECK-NEXT:   No successors
 ; CHECK-NEXT: }
 entry:



More information about the llvm-commits mailing list