[llvm-branch-commits] [llvm] 6077d55 - [DSE] Add tests with stores of existing values.
Florian Hahn via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jan 13 14:02:24 PST 2021
Author: Florian Hahn
Date: 2021-01-13T21:56:21Z
New Revision: 6077d55381a6aa3e947ef7abdc36a7515c598c8a
URL: https://github.com/llvm/llvm-project/commit/6077d55381a6aa3e947ef7abdc36a7515c598c8a
DIFF: https://github.com/llvm/llvm-project/commit/6077d55381a6aa3e947ef7abdc36a7515c598c8a.diff
LOG: [DSE] Add tests with stores of existing values.
This patch pre-commits test cases with dead stores of
existing values for D90328. It also updates a few tests that had such
stores by accident, to preserve the original spirit of those tests.
Added:
llvm/test/Transforms/DeadStoreElimination/MSSA/stores-of-existing-values.ll
Modified:
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-loops.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memoryphis.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-simple.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-loops.ll b/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-loops.ll
index dc6004bf71d7..9f833b2bd481 100644
--- a/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-loops.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-loops.ll
@@ -183,7 +183,7 @@ define void @loop_multiple_def_uses(i32* noalias %P) {
; CHECK-NEXT: [[C1:%.*]] = call i1 @cond()
; CHECK-NEXT: br i1 [[C1]], label [[FOR_BODY:%.*]], label [[END:%.*]]
; CHECK: for.body:
-; CHECK-NEXT: store i32 1, i32* [[P]], align 4
+; CHECK-NEXT: store i32 2, i32* [[P]], align 4
; CHECK-NEXT: [[LV:%.*]] = load i32, i32* [[P]], align 4
; CHECK-NEXT: br label [[FOR_HEADER]]
; CHECK: end:
@@ -199,7 +199,7 @@ for.header:
br i1 %c1, label %for.body, label %end
for.body:
- store i32 1, i32* %P, align 4
+ store i32 2, i32* %P, align 4
%lv = load i32, i32* %P
br label %for.header
diff --git a/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memoryphis.ll b/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memoryphis.ll
index 1ad2e71f2d59..b3faafd15b3b 100644
--- a/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memoryphis.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memoryphis.ll
@@ -14,7 +14,7 @@ define void @test4(i32* noalias %P) {
; CHECK-NEXT: [[X:%.*]] = load i32, i32* [[P]], align 4
; CHECK-NEXT: br label [[BB3]]
; CHECK: bb3:
-; CHECK-NEXT: store i32 0, i32* [[P]], align 4
+; CHECK-NEXT: store i32 1, i32* [[P]], align 4
; CHECK-NEXT: ret void
;
store i32 0, i32* %P
@@ -25,7 +25,7 @@ bb2:
%x = load i32, i32* %P
br label %bb3
bb3:
- store i32 0, i32* %P
+ store i32 1, i32* %P
ret void
}
diff --git a/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-simple.ll b/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-simple.ll
index 334e080bf8db..e30c78e44e02 100644
--- a/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-simple.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-simple.ll
@@ -33,7 +33,7 @@ define void @test3(i32* noalias %P) {
; CHECK: bb1:
; CHECK-NEXT: br label [[BB3:%.*]]
; CHECK: bb2:
-; CHECK-NEXT: store i32 0, i32* [[P]], align 4
+; CHECK-NEXT: store i32 1, i32* [[P]], align 4
; CHECK-NEXT: br label [[BB3]]
; CHECK: bb3:
; CHECK-NEXT: ret void
@@ -43,7 +43,7 @@ define void @test3(i32* noalias %P) {
bb1:
br label %bb3
bb2:
- store i32 0, i32* %P
+ store i32 1, i32* %P
br label %bb3
bb3:
ret void
@@ -99,7 +99,7 @@ define void @test9(i32* noalias %P) {
; CHECK: bb2:
; CHECK-NEXT: ret void
; CHECK: bb3:
-; CHECK-NEXT: store i32 0, i32* [[P]], align 4
+; CHECK-NEXT: store i32 1, i32* [[P]], align 4
; CHECK-NEXT: ret void
;
store i32 0, i32* %P
@@ -109,7 +109,7 @@ bb1:
bb2:
ret void
bb3:
- store i32 0, i32* %P
+ store i32 1, i32* %P
ret void
}
@@ -153,7 +153,7 @@ define void @test10(i32* %P) {
; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4
; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
-; CHECK-NEXT: store i32 0, i32* [[P]], align 4
+; CHECK-NEXT: store i32 1, i32* [[P]], align 4
; CHECK-NEXT: br label [[BB3:%.*]]
; CHECK: bb2:
; CHECK-NEXT: ret void
@@ -163,7 +163,7 @@ define void @test10(i32* %P) {
store i32 0, i32* %P
br i1 true, label %bb1, label %bb2
bb1:
- store i32 0, i32* %P
+ store i32 1, i32* %P
br label %bb3
bb2:
ret void
diff --git a/llvm/test/Transforms/DeadStoreElimination/MSSA/stores-of-existing-values.ll b/llvm/test/Transforms/DeadStoreElimination/MSSA/stores-of-existing-values.ll
new file mode 100644
index 000000000000..77f006a52454
--- /dev/null
+++ b/llvm/test/Transforms/DeadStoreElimination/MSSA/stores-of-existing-values.ll
@@ -0,0 +1,284 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -basic-aa -dse -S %s | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+
+; Test case for PR16520. The store in %if.then is dead, because the same value
+; has been stored earlier to the same location.
+define void @test1_pr16520(i1 %b, i8* nocapture %r) {
+; CHECK-LABEL: @test1_pr16520(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: store i8 1, i8* [[R:%.*]], align 1
+; CHECK-NEXT: br i1 [[B:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: store i8 1, i8* [[R]], align 1
+; CHECK-NEXT: tail call void @fn_mayread_or_clobber()
+; CHECK-NEXT: br label [[IF_END:%.*]]
+; CHECK: if.else:
+; CHECK-NEXT: tail call void @fn_mayread_or_clobber()
+; CHECK-NEXT: br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT: ret void
+;
+entry:
+ store i8 1, i8* %r, align 1
+ br i1 %b, label %if.then, label %if.else
+
+if.then: ; preds = %entry
+ store i8 1, i8* %r, align 1
+ tail call void @fn_mayread_or_clobber()
+ br label %if.end
+
+if.else: ; preds = %entry
+ tail call void @fn_mayread_or_clobber()
+ br label %if.end
+
+if.end: ; preds = %if.else, %if.then
+ ret void
+}
+
+declare void @fn_mayread_or_clobber()
+
+
+declare void @fn_readonly() readonly
+
+define void @test2(i1 %b, i8* nocapture %r) {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: store i8 1, i8* [[R:%.*]], align 1
+; CHECK-NEXT: br i1 [[B:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: tail call void @fn_readonly()
+; CHECK-NEXT: br label [[IF_END:%.*]]
+; CHECK: if.else:
+; CHECK-NEXT: tail call void @fn_readonly()
+; CHECK-NEXT: br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT: store i8 1, i8* [[R]], align 1
+; CHECK-NEXT: ret void
+;
+entry:
+ store i8 1, i8* %r, align 1
+ br i1 %b, label %if.then, label %if.else
+
+if.then: ; preds = %entry
+ tail call void @fn_readonly()
+ br label %if.end
+
+if.else: ; preds = %entry
+ tail call void @fn_readonly()
+ br label %if.end
+
+if.end: ; preds = %if.else, %if.then
+ store i8 1, i8* %r, align 1
+ ret void
+}
+
+define void @test3(i1 %b, i8* nocapture %r) {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: store i8 1, i8* [[R:%.*]], align 1
+; CHECK-NEXT: br i1 [[B:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: tail call void @fn_mayread_or_clobber()
+; CHECK-NEXT: br label [[IF_END:%.*]]
+; CHECK: if.else:
+; CHECK-NEXT: tail call void @fn_readonly()
+; CHECK-NEXT: br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT: store i8 1, i8* [[R]], align 1
+; CHECK-NEXT: ret void
+;
+entry:
+ store i8 1, i8* %r, align 1
+ br i1 %b, label %if.then, label %if.else
+
+if.then: ; preds = %entry
+ tail call void @fn_mayread_or_clobber()
+ br label %if.end
+
+if.else: ; preds = %entry
+ tail call void @fn_readonly()
+ br label %if.end
+
+if.end: ; preds = %if.else, %if.then
+ store i8 1, i8* %r, align 1
+ ret void
+}
+
+define void @test4(i1 %b, i8* nocapture %r) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: store i8 1, i8* [[R:%.*]], align 1
+; CHECK-NEXT: br i1 [[B:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: tail call void @fn_readonly()
+; CHECK-NEXT: br label [[IF_END:%.*]]
+; CHECK: if.else:
+; CHECK-NEXT: tail call void @fn_mayread_or_clobber()
+; CHECK-NEXT: br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT: store i8 1, i8* [[R]], align 1
+; CHECK-NEXT: ret void
+;
+entry:
+ store i8 1, i8* %r, align 1
+ br i1 %b, label %if.then, label %if.else
+
+if.then: ; preds = %entry
+ tail call void @fn_readonly()
+ br label %if.end
+
+if.else: ; preds = %entry
+ tail call void @fn_mayread_or_clobber()
+ br label %if.end
+
+if.end: ; preds = %if.else, %if.then
+ store i8 1, i8* %r, align 1
+ ret void
+}
+
+define void @test5(i1 %b, i8* nocapture %r) {
+; CHECK-LABEL: @test5(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: store i8 1, i8* [[R:%.*]], align 1
+; CHECK-NEXT: br i1 [[B:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: tail call void @fn_readonly()
+; CHECK-NEXT: br label [[IF_END:%.*]]
+; CHECK: if.else:
+; CHECK-NEXT: tail call void @fn_mayread_or_clobber()
+; CHECK-NEXT: br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT: store i8 1, i8* [[R]], align 1
+; CHECK-NEXT: ret void
+;
+entry:
+ store i8 1, i8* %r, align 1
+ br i1 %b, label %if.then, label %if.else
+
+if.then: ; preds = %entry
+ tail call void @fn_readonly()
+ br label %if.end
+
+if.else: ; preds = %entry
+ tail call void @fn_mayread_or_clobber()
+ br label %if.end
+
+if.end: ; preds = %if.else, %if.then
+ store i8 1, i8* %r, align 1
+ ret void
+}
+
+declare i1 @cond() readnone
+
+define void @test6(i32* noalias %P) {
+; CHECK-LABEL: @test6(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_HEADER:%.*]]
+; CHECK: for.header:
+; CHECK-NEXT: store i32 1, i32* [[P:%.*]], align 4
+; CHECK-NEXT: [[C1:%.*]] = call i1 @cond()
+; CHECK-NEXT: br i1 [[C1]], label [[FOR_BODY:%.*]], label [[END:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: store i32 1, i32* [[P]], align 4
+; CHECK-NEXT: [[LV:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: br label [[FOR_HEADER]]
+; CHECK: end:
+; CHECK-NEXT: store i32 3, i32* [[P]], align 4
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %for.header
+
+for.header:
+ store i32 1, i32* %P, align 4
+ %c1 = call i1 @cond()
+ br i1 %c1, label %for.body, label %end
+
+for.body:
+ store i32 1, i32* %P, align 4
+ %lv = load i32, i32* %P
+ br label %for.header
+
+end:
+ store i32 3, i32* %P, align 4
+ ret void
+}
+
+; Make sure the store in %bb3 can be eliminated in the presences of early returns.
+define void @test7(i32* noalias %P) {
+; CHECK-LABEL: @test7(
+; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4
+; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: br label [[BB3:%.*]]
+; CHECK: bb2:
+; CHECK-NEXT: ret void
+; CHECK: bb3:
+; CHECK-NEXT: store i32 0, i32* [[P]], align 4
+; CHECK-NEXT: ret void
+;
+ store i32 0, i32* %P
+ br i1 true, label %bb1, label %bb2
+bb1:
+ br label %bb3
+bb2:
+ ret void
+bb3:
+ store i32 0, i32* %P
+ ret void
+}
+
+; Make sure the store in %bb3 won't be eliminated because it may be clobbered before.
+define void @test8(i32* noalias %P) {
+; CHECK-LABEL: @test8(
+; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4
+; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: call void @fn_mayread_or_clobber()
+; CHECK-NEXT: br label [[BB3:%.*]]
+; CHECK: bb2:
+; CHECK-NEXT: ret void
+; CHECK: bb3:
+; CHECK-NEXT: store i32 0, i32* [[P]], align 4
+; CHECK-NEXT: ret void
+;
+ store i32 0, i32* %P
+ br i1 true, label %bb1, label %bb2
+bb1:
+ call void @fn_mayread_or_clobber()
+ br label %bb3
+bb2:
+ ret void
+bb3:
+ store i32 0, i32* %P
+ ret void
+}
+
+; Make sure the store in %bb3 will be eliminated because only the early exit path
+; may be clobbered.
+define void @test9(i32* noalias %P) {
+; CHECK-LABEL: @test9(
+; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4
+; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: br label [[BB3:%.*]]
+; CHECK: bb2:
+; CHECK-NEXT: call void @fn_mayread_or_clobber()
+; CHECK-NEXT: ret void
+; CHECK: bb3:
+; CHECK-NEXT: store i32 0, i32* [[P]], align 4
+; CHECK-NEXT: ret void
+;
+ store i32 0, i32* %P
+ br i1 true, label %bb1, label %bb2
+bb1:
+ br label %bb3
+bb2:
+ call void @fn_mayread_or_clobber()
+ ret void
+bb3:
+ store i32 0, i32* %P
+ ret void
+}
More information about the llvm-branch-commits
mailing list