aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/GVN/atomic.ll
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/GVN/atomic.ll')
-rw-r--r--test/Transforms/GVN/atomic.ll92
1 files changed, 35 insertions, 57 deletions
diff --git a/test/Transforms/GVN/atomic.ll b/test/Transforms/GVN/atomic.ll
index 8c13d20..11b54f3 100644
--- a/test/Transforms/GVN/atomic.ll
+++ b/test/Transforms/GVN/atomic.ll
@@ -11,21 +11,9 @@ define i32 @test1() nounwind uwtable ssp {
; CHECK-LABEL: test1
; CHECK: add i32 %x, %x
entry:
- %x = load i32* @y
+ %x = load i32, i32* @y
store atomic i32 %x, i32* @x unordered, align 4
- %y = load i32* @y
- %z = add i32 %x, %y
- ret i32 %z
-}
-
-; GVN across seq_cst store (allowed)
-define i32 @test2() nounwind uwtable ssp {
-; CHECK-LABEL: test2
-; CHECK: add i32 %x, %x
-entry:
- %x = load i32* @y
- store atomic i32 %x, i32* @x seq_cst, align 4
- %y = load i32* @y
+ %y = load i32, i32* @y
%z = add i32 %x, %y
ret i32 %z
}
@@ -35,35 +23,21 @@ define i32 @test3() nounwind uwtable ssp {
; CHECK-LABEL: test3
; CHECK: add i32 %x, %x
entry:
- %x = load i32* @y
- %y = load atomic i32* @x unordered, align 4
- %z = load i32* @y
+ %x = load i32, i32* @y
+ %y = load atomic i32, i32* @x unordered, align 4
+ %z = load i32, i32* @y
%a = add i32 %x, %z
%b = add i32 %y, %a
ret i32 %b
}
-; GVN across acquire load (allowed as the original load was not atomic)
-define i32 @test4() nounwind uwtable ssp {
-; CHECK-LABEL: test4
-; CHECK: load atomic i32* @x
-; CHECK-NOT: load i32* @y
-entry:
- %x = load i32* @y
- %y = load atomic i32* @x seq_cst, align 4
- %x2 = load i32* @y
- %x3 = add i32 %x, %x2
- %y2 = add i32 %y, %x3
- ret i32 %y2
-}
-
; GVN load to unordered load (allowed)
define i32 @test5() nounwind uwtable ssp {
; CHECK-LABEL: test5
; CHECK: add i32 %x, %x
entry:
- %x = load atomic i32* @x unordered, align 4
- %y = load i32* @x
+ %x = load atomic i32, i32* @x unordered, align 4
+ %y = load i32, i32* @x
%z = add i32 %x, %y
ret i32 %z
}
@@ -71,10 +45,10 @@ entry:
; GVN unordered load to load (unordered load must not be removed)
define i32 @test6() nounwind uwtable ssp {
; CHECK-LABEL: test6
-; CHECK: load atomic i32* @x unordered
+; CHECK: load atomic i32, i32* @x unordered
entry:
- %x = load i32* @x
- %x2 = load atomic i32* @x unordered, align 4
+ %x = load i32, i32* @x
+ %x2 = load atomic i32, i32* @x unordered, align 4
%x3 = add i32 %x, %x2
ret i32 %x3
}
@@ -84,23 +58,10 @@ define i32 @test7() nounwind uwtable ssp {
; CHECK-LABEL: test7
; CHECK: add i32 %x, %y
entry:
- %x = load i32* @y
+ %x = load i32, i32* @y
store atomic i32 %x, i32* @x release, align 4
- %w = load atomic i32* @x acquire, align 4
- %y = load i32* @y
- %z = add i32 %x, %y
- ret i32 %z
-}
-
-; GVN across acquire-release pair (allowed)
-define i32 @test8() nounwind uwtable ssp {
-; CHECK-LABEL: test8
-; CHECK: add i32 %x, %x
-entry:
- %x = load i32* @y
- %w = load atomic i32* @x acquire, align 4
- store atomic i32 %x, i32* @x release, align 4
- %y = load i32* @y
+ %w = load atomic i32, i32* @x acquire, align 4
+ %y = load i32, i32* @y
%z = add i32 %x, %y
ret i32 %z
}
@@ -110,9 +71,9 @@ define i32 @test9() nounwind uwtable ssp {
; CHECK-LABEL: test9
; CHECK: add i32 %x, %x
entry:
- %x = load i32* @y
+ %x = load i32, i32* @y
store atomic i32 %x, i32* @x monotonic, align 4
- %y = load i32* @y
+ %y = load i32, i32* @y
%z = add i32 %x, %y
ret i32 %z
}
@@ -122,10 +83,27 @@ define i32 @test10() nounwind uwtable ssp {
; CHECK-LABEL: test10
; CHECK: add i32 %x, %y
entry:
- %x = load atomic i32* @y unordered, align 4
- %clobber = load atomic i32* @x monotonic, align 4
- %y = load atomic i32* @y monotonic, align 4
+ %x = load atomic i32, i32* @y unordered, align 4
+ %clobber = load atomic i32, i32* @x monotonic, align 4
+ %y = load atomic i32, i32* @y monotonic, align 4
%z = add i32 %x, %y
ret i32 %z
}
+define i32 @PR22708(i1 %flag) {
+; CHECK-LABEL: PR22708
+entry:
+ br i1 %flag, label %if.then, label %if.end
+
+if.then:
+ store i32 43, i32* @y, align 4
+; CHECK: store i32 43, i32* @y, align 4
+ br label %if.end
+
+if.end:
+ load atomic i32, i32* @x acquire, align 4
+ %load = load i32, i32* @y, align 4
+; CHECK: load atomic i32, i32* @x acquire, align 4
+; CHECK: load i32, i32* @y, align 4
+ ret i32 %load
+}