[llvm] 197332a - [DSE] Add extra test for loop invariant store in loop, update comments.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 29 09:00:32 PDT 2022
Author: Florian Hahn
Date: 2022-08-29T17:00:00+01:00
New Revision: 197332a1f80db7cbe2bb43d3f5bd45282245dd28
URL: https://github.com/llvm/llvm-project/commit/197332a1f80db7cbe2bb43d3f5bd45282245dd28
DIFF: https://github.com/llvm/llvm-project/commit/197332a1f80db7cbe2bb43d3f5bd45282245dd28.diff
LOG: [DSE] Add extra test for loop invariant store in loop, update comments.
Add extra test coverage and updates some slightly stale comments as
pointed out in D132365.
Added:
Modified:
llvm/test/Transforms/DeadStoreElimination/multiblock-loop-carried-dependence.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/DeadStoreElimination/multiblock-loop-carried-dependence.ll b/llvm/test/Transforms/DeadStoreElimination/multiblock-loop-carried-dependence.ll
index 5f20841b6cffd..3f2b007905014 100644
--- a/llvm/test/Transforms/DeadStoreElimination/multiblock-loop-carried-dependence.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/multiblock-loop-carried-dependence.ll
@@ -6,10 +6,9 @@ target datalayout = "e-m:e-i64:64-n32:64-v256:256:256-v512:512:512"
declare void @use(i32)
-; Test cases with a loop carried dependence in %loop.2, where %l.2 reads the
-; value stored by the previous iteration. Hence, the store in %loop.2 is not
-; dead at the end of the function or after the call to lifetime.end().
-
+; Test cases with a loop carried dependence in %loop.2, where both %l.0 and
+; %l.1 read the value stored by the previous iteration. Hence, the store in
+; %loop.2 is not dead at the end of the function.
define void @test.1() {
; CHECK-LABEL: @test.1(
; CHECK-NEXT: entry:
@@ -73,6 +72,9 @@ exit:
ret void
}
+; Test cases with a loop carried dependence in %loop.2, where both %l.0 and
+; %l.1 read the value stored by the previous iteration. Hence, the store in
+; %loop.2 is not dead at the end of the function or after the call to lifetime.end().
define void @test.2() {
; CHECK-LABEL: @test.2(
; CHECK-NEXT: entry:
@@ -209,4 +211,41 @@ cleanup: ; preds = %while.body, %while.
ret void
}
+define void @store_to_invariant_loc() {
+; CHECK-LABEL: @store_to_invariant_loc(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[A:%.*]] = alloca [100 x i32], align 4
+; CHECK-NEXT: [[PTR_20:%.*]] = getelementptr inbounds [100 x i32], [100 x i32]* [[A]], i64 0, i64 20
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LOOP]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT: [[PTR_IV:%.*]] = getelementptr inbounds [100 x i32], [100 x i32]* [[A]], i64 0, i64 [[IV]]
+; CHECK-NEXT: [[L_0:%.*]] = load i32, i32* [[PTR_IV]], align 4
+; CHECK-NEXT: call void @use(i32 [[L_0]])
+; CHECK-NEXT: store i32 10, i32* [[PTR_20]], align 4
+; CHECK-NEXT: [[IV_NEXT]] = add nsw i64 [[IV]], 1
+; CHECK-NEXT: [[C:%.*]] = icmp slt i64 [[IV_NEXT]], 100
+; CHECK-NEXT: br i1 [[C]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ %A = alloca [100 x i32], align 4
+ %ptr.20 = getelementptr inbounds [100 x i32], [100 x i32]* %A, i64 0, i64 20
+ br label %loop
+
+loop:
+ %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]
+ %ptr.iv = getelementptr inbounds [100 x i32], [100 x i32]* %A, i64 0, i64 %iv
+ %l.0 = load i32, i32* %ptr.iv, align 4
+ call void @use(i32 %l.0)
+ store i32 10, i32* %ptr.20, align 4
+ %iv.next = add nsw i64 %iv, 1
+ %c = icmp slt i64 %iv.next, 100
+ br i1 %c, label %loop , label %exit
+
+exit:
+ ret void
+}
+
declare i1 @cond(i32)
More information about the llvm-commits
mailing list