Skip to content

Commit 3d422a9

Browse files
authored
[VPlan] Implement mayHaveSideEffects/mayWriteToMemory for VPInterleav… (#71360)
…eRecipe This helps VPlanTransforms::removeDeadRecipes to work on VPInterleaveRecipe
1 parent 1b531d5 commit 3d422a9

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ extern cl::opt<bool> EnableVPlanNativePath;
4444

4545
bool VPRecipeBase::mayWriteToMemory() const {
4646
switch (getVPDefID()) {
47+
case VPInterleaveSC:
48+
return cast<VPInterleaveRecipe>(this)->getNumStoreOperands() > 0;
4749
case VPWidenMemoryInstructionSC: {
4850
return cast<VPWidenMemoryInstructionRecipe>(this)->isStore();
4951
}
@@ -146,6 +148,8 @@ bool VPRecipeBase::mayHaveSideEffects() const {
146148
"underlying instruction has side-effects");
147149
return false;
148150
}
151+
case VPInterleaveSC:
152+
return mayWriteToMemory();
149153
case VPWidenMemoryInstructionSC:
150154
assert(cast<VPWidenMemoryInstructionRecipe>(this)
151155
->getIngredient()

llvm/test/Transforms/LoopVectorize/vplan-unused-interleave-group.ll

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@ define void @test_unused_interleave(ptr %src, i32 %length) {
1818
; CHECK-EMPTY:
1919
; CHECK-NEXT: <x1> vector loop: {
2020
; CHECK-NEXT: vector.body:
21-
; CHECK-NEXT: EMIT vp<%2> = CANONICAL-INDUCTION ir<0>, vp<%7>
22-
; CHECK-NEXT: vp<%3> = SCALAR-STEPS vp<%2>, ir<1>
23-
; CHECK-NEXT: CLONE ir<%next19.i.i> = getelementptr inbounds ir<%src>, vp<%3>, ir<0>
24-
; CHECK-NEXT: INTERLEAVE-GROUP with factor 2 at %load_p1, ir<%next19.i.i>
25-
; CHECK-NEXT: ir<%load_p1> = load from index 0
26-
; CHECK-NEXT: ir<%load_p2> = load from index 1
27-
; CHECK-NEXT: EMIT vp<%7> = add nuw vp<%2>, vp<%0>
28-
; CHECK-NEXT: EMIT branch-on-count vp<%7>, vp<%1>
21+
; CHECK-NEXT: EMIT vp<%2> = CANONICAL-INDUCTION ir<0>, vp<%3>
22+
; CHECK-NEXT: EMIT vp<%3> = add nuw vp<%2>, vp<%0>
23+
; CHECK-NEXT: EMIT branch-on-count vp<%3>, vp<%1>
2924
; CHECK-NEXT: No successors
3025
; CHECK-NEXT: }
3126
entry:

0 commit comments

Comments
 (0)