xref: /llvm-project/llvm/test/Transforms/EarlyCSE/basic.ll (revision 297c10fd175a2f0ff7cb293fcb2d149b065eaabe)
160147c60SNikita Popov; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2ac696ac4SBjorn Pettersson; RUN: opt < %s -S -passes=early-cse -earlycse-debug-hash | FileCheck %s
3c384b20bSArthur Eubanks; RUN: opt < %s -S -passes='early-cse<memssa>' | FileCheck %s
4cee313d2SEric Christopher; RUN: opt < %s -S -passes=early-cse | FileCheck %s
5cee313d2SEric Christopher
6cee313d2SEric Christopherdeclare void @llvm.assume(i1) nounwind
7cee313d2SEric Christopher
83c514d31SNikita Popovdefine void @test1(i8 %V, ptr%P) {
960147c60SNikita Popov; CHECK-LABEL: @test1(
103c514d31SNikita Popov; CHECK-NEXT:    store i32 23, ptr [[P:%.*]], align 4
1160147c60SNikita Popov; CHECK-NEXT:    [[C:%.*]] = zext i8 [[V:%.*]] to i32
123c514d31SNikita Popov; CHECK-NEXT:    store volatile i32 [[C]], ptr [[P]], align 4
133c514d31SNikita Popov; CHECK-NEXT:    store volatile i32 [[C]], ptr [[P]], align 4
1460147c60SNikita Popov; CHECK-NEXT:    [[E:%.*]] = add i32 [[C]], [[C]]
153c514d31SNikita Popov; CHECK-NEXT:    store volatile i32 [[E]], ptr [[P]], align 4
163c514d31SNikita Popov; CHECK-NEXT:    store volatile i32 [[E]], ptr [[P]], align 4
173c514d31SNikita Popov; CHECK-NEXT:    store volatile i32 [[E]], ptr [[P]], align 4
1860147c60SNikita Popov; CHECK-NEXT:    ret void
1960147c60SNikita Popov;
20cee313d2SEric Christopher  %A = bitcast i64 42 to double  ;; dead
21cee313d2SEric Christopher  %B = add i32 4, 19             ;; constant folds
223c514d31SNikita Popov  store i32 %B, ptr %P
23cee313d2SEric Christopher
24cee313d2SEric Christopher  %C = zext i8 %V to i32
25cee313d2SEric Christopher  %D = zext i8 %V to i32  ;; CSE
263c514d31SNikita Popov  store volatile i32 %C, ptr %P
273c514d31SNikita Popov  store volatile i32 %D, ptr %P
28cee313d2SEric Christopher
29cee313d2SEric Christopher  %E = add i32 %C, %C
30cee313d2SEric Christopher  %F = add i32 %C, %C
313c514d31SNikita Popov  store volatile i32 %E, ptr %P
323c514d31SNikita Popov  store volatile i32 %F, ptr %P
33cee313d2SEric Christopher
34cee313d2SEric Christopher  %G = add nuw i32 %C, %C
353c514d31SNikita Popov  store volatile i32 %G, ptr %P
36cee313d2SEric Christopher  ret void
37cee313d2SEric Christopher}
38cee313d2SEric Christopher
39cee313d2SEric Christopher
40cee313d2SEric Christopher;; Simple load value numbering.
413c514d31SNikita Popovdefine i32 @test2(ptr%P) {
4260147c60SNikita Popov; CHECK-LABEL: @test2(
433c514d31SNikita Popov; CHECK-NEXT:    [[V1:%.*]] = load i32, ptr [[P:%.*]], align 4
4460147c60SNikita Popov; CHECK-NEXT:    ret i32 0
4560147c60SNikita Popov;
463c514d31SNikita Popov  %V1 = load i32, ptr %P
473c514d31SNikita Popov  %V2 = load i32, ptr %P
48cee313d2SEric Christopher  %Diff = sub i32 %V1, %V2
49cee313d2SEric Christopher  ret i32 %Diff
50cee313d2SEric Christopher}
51cee313d2SEric Christopher
523c514d31SNikita Popovdefine i32 @test2a(ptr%P, i1 %b) {
5360147c60SNikita Popov; CHECK-LABEL: @test2a(
543c514d31SNikita Popov; CHECK-NEXT:    [[V1:%.*]] = load i32, ptr [[P:%.*]], align 4
5560147c60SNikita Popov; CHECK-NEXT:    tail call void @llvm.assume(i1 [[B:%.*]])
5660147c60SNikita Popov; CHECK-NEXT:    ret i32 0
5760147c60SNikita Popov;
583c514d31SNikita Popov  %V1 = load i32, ptr %P
59cee313d2SEric Christopher  tail call void @llvm.assume(i1 %b)
603c514d31SNikita Popov  %V2 = load i32, ptr %P
61cee313d2SEric Christopher  %Diff = sub i32 %V1, %V2
62cee313d2SEric Christopher  ret i32 %Diff
63cee313d2SEric Christopher}
64cee313d2SEric Christopher
65cee313d2SEric Christopher;; Cross block load value numbering.
663c514d31SNikita Popovdefine i32 @test3(ptr%P, i1 %Cond) {
6760147c60SNikita Popov; CHECK-LABEL: @test3(
683c514d31SNikita Popov; CHECK-NEXT:    [[V1:%.*]] = load i32, ptr [[P:%.*]], align 4
6960147c60SNikita Popov; CHECK-NEXT:    br i1 [[COND:%.*]], label [[T:%.*]], label [[F:%.*]]
7060147c60SNikita Popov; CHECK:       T:
713c514d31SNikita Popov; CHECK-NEXT:    store i32 4, ptr [[P]], align 4
7260147c60SNikita Popov; CHECK-NEXT:    ret i32 42
7360147c60SNikita Popov; CHECK:       F:
7460147c60SNikita Popov; CHECK-NEXT:    ret i32 0
7560147c60SNikita Popov;
763c514d31SNikita Popov  %V1 = load i32, ptr %P
77cee313d2SEric Christopher  br i1 %Cond, label %T, label %F
78cee313d2SEric ChristopherT:
793c514d31SNikita Popov  store i32 4, ptr %P
80cee313d2SEric Christopher  ret i32 42
81cee313d2SEric ChristopherF:
823c514d31SNikita Popov  %V2 = load i32, ptr %P
83cee313d2SEric Christopher  %Diff = sub i32 %V1, %V2
84cee313d2SEric Christopher  ret i32 %Diff
85cee313d2SEric Christopher}
86cee313d2SEric Christopher
873c514d31SNikita Popovdefine i32 @test3a(ptr%P, i1 %Cond, i1 %b) {
8860147c60SNikita Popov; CHECK-LABEL: @test3a(
893c514d31SNikita Popov; CHECK-NEXT:    [[V1:%.*]] = load i32, ptr [[P:%.*]], align 4
9060147c60SNikita Popov; CHECK-NEXT:    br i1 [[COND:%.*]], label [[T:%.*]], label [[F:%.*]]
9160147c60SNikita Popov; CHECK:       T:
923c514d31SNikita Popov; CHECK-NEXT:    store i32 4, ptr [[P]], align 4
9360147c60SNikita Popov; CHECK-NEXT:    ret i32 42
9460147c60SNikita Popov; CHECK:       F:
9560147c60SNikita Popov; CHECK-NEXT:    tail call void @llvm.assume(i1 [[B:%.*]])
9660147c60SNikita Popov; CHECK-NEXT:    ret i32 0
9760147c60SNikita Popov;
983c514d31SNikita Popov  %V1 = load i32, ptr %P
99cee313d2SEric Christopher  br i1 %Cond, label %T, label %F
100cee313d2SEric ChristopherT:
1013c514d31SNikita Popov  store i32 4, ptr %P
102cee313d2SEric Christopher  ret i32 42
103cee313d2SEric ChristopherF:
104cee313d2SEric Christopher  tail call void @llvm.assume(i1 %b)
1053c514d31SNikita Popov  %V2 = load i32, ptr %P
106cee313d2SEric Christopher  %Diff = sub i32 %V1, %V2
107cee313d2SEric Christopher  ret i32 %Diff
108cee313d2SEric Christopher}
109cee313d2SEric Christopher
110cee313d2SEric Christopher;; Cross block load value numbering stops when stores happen.
1113c514d31SNikita Popovdefine i32 @test4(ptr%P, i1 %Cond) {
11260147c60SNikita Popov; CHECK-LABEL: @test4(
1133c514d31SNikita Popov; CHECK-NEXT:    [[V1:%.*]] = load i32, ptr [[P:%.*]], align 4
11460147c60SNikita Popov; CHECK-NEXT:    br i1 [[COND:%.*]], label [[T:%.*]], label [[F:%.*]]
11560147c60SNikita Popov; CHECK:       T:
11660147c60SNikita Popov; CHECK-NEXT:    ret i32 42
11760147c60SNikita Popov; CHECK:       F:
1183c514d31SNikita Popov; CHECK-NEXT:    store i32 42, ptr [[P]], align 4
11960147c60SNikita Popov; CHECK-NEXT:    [[DIFF:%.*]] = sub i32 [[V1]], 42
12060147c60SNikita Popov; CHECK-NEXT:    ret i32 [[DIFF]]
12160147c60SNikita Popov;
1223c514d31SNikita Popov  %V1 = load i32, ptr %P
123cee313d2SEric Christopher  br i1 %Cond, label %T, label %F
124cee313d2SEric ChristopherT:
125cee313d2SEric Christopher  ret i32 42
126cee313d2SEric ChristopherF:
127cee313d2SEric Christopher  ; Clobbers V1
1283c514d31SNikita Popov  store i32 42, ptr %P
129cee313d2SEric Christopher
1303c514d31SNikita Popov  %V2 = load i32, ptr %P
131cee313d2SEric Christopher  %Diff = sub i32 %V1, %V2
132cee313d2SEric Christopher  ret i32 %Diff
133cee313d2SEric Christopher}
134cee313d2SEric Christopher
1353c514d31SNikita Popovdeclare i32 @func(ptr%P) readonly
136cee313d2SEric Christopher
137cee313d2SEric Christopher;; Simple call CSE'ing.
1383c514d31SNikita Popovdefine i32 @test5(ptr%P) {
13960147c60SNikita Popov; CHECK-LABEL: @test5(
140*297c10fdSMingming Liu; CHECK-NEXT:    [[V1:%.*]] = call i32 @func(ptr [[P:%.*]]), !prof !0
14160147c60SNikita Popov; CHECK-NEXT:    ret i32 0
14260147c60SNikita Popov;
143*297c10fdSMingming Liu  %V1 = call i32 @func(ptr %P), !prof !0
144*297c10fdSMingming Liu  %V2 = call i32 @func(ptr %P), !prof !1
145cee313d2SEric Christopher  %Diff = sub i32 %V1, %V2
146cee313d2SEric Christopher  ret i32 %Diff
147cee313d2SEric Christopher}
148cee313d2SEric Christopher
149*297c10fdSMingming Liu!0 = !{!"branch_weights", i32 95}
150*297c10fdSMingming Liu!1 = !{!"branch_weights", i32 95}
151*297c10fdSMingming Liu
152cee313d2SEric Christopher;; Trivial Store->load forwarding
1533c514d31SNikita Popovdefine i32 @test6(ptr%P) {
15460147c60SNikita Popov; CHECK-LABEL: @test6(
1553c514d31SNikita Popov; CHECK-NEXT:    store i32 42, ptr [[P:%.*]], align 4
15660147c60SNikita Popov; CHECK-NEXT:    ret i32 42
15760147c60SNikita Popov;
1583c514d31SNikita Popov  store i32 42, ptr %P
1593c514d31SNikita Popov  %V1 = load i32, ptr %P
160cee313d2SEric Christopher  ret i32 %V1
161cee313d2SEric Christopher}
162cee313d2SEric Christopher
1633c514d31SNikita Popovdefine i32 @test6a(ptr%P, i1 %b) {
16460147c60SNikita Popov; CHECK-LABEL: @test6a(
1653c514d31SNikita Popov; CHECK-NEXT:    store i32 42, ptr [[P:%.*]], align 4
16660147c60SNikita Popov; CHECK-NEXT:    tail call void @llvm.assume(i1 [[B:%.*]])
16760147c60SNikita Popov; CHECK-NEXT:    ret i32 42
16860147c60SNikita Popov;
1693c514d31SNikita Popov  store i32 42, ptr %P
170cee313d2SEric Christopher  tail call void @llvm.assume(i1 %b)
1713c514d31SNikita Popov  %V1 = load i32, ptr %P
172cee313d2SEric Christopher  ret i32 %V1
173cee313d2SEric Christopher}
174cee313d2SEric Christopher
175cee313d2SEric Christopher;; Trivial dead store elimination.
1763c514d31SNikita Popovdefine void @test7(ptr%P) {
17760147c60SNikita Popov; CHECK-LABEL: @test7(
1783c514d31SNikita Popov; CHECK-NEXT:    store i32 45, ptr [[P:%.*]], align 4
17960147c60SNikita Popov; CHECK-NEXT:    ret void
18060147c60SNikita Popov;
1813c514d31SNikita Popov  store i32 42, ptr %P
1823c514d31SNikita Popov  store i32 45, ptr %P
183cee313d2SEric Christopher  ret void
184cee313d2SEric Christopher}
185cee313d2SEric Christopher
186cee313d2SEric Christopher;; Readnone functions aren't invalidated by stores.
1873c514d31SNikita Popovdefine i32 @test8(ptr%P) {
18860147c60SNikita Popov; CHECK-LABEL: @test8(
1893c514d31SNikita Popov; CHECK-NEXT:    [[V1:%.*]] = call i32 @func(ptr [[P:%.*]]) #[[ATTR2:[0-9]+]]
1903c514d31SNikita Popov; CHECK-NEXT:    store i32 4, ptr [[P]], align 4
19160147c60SNikita Popov; CHECK-NEXT:    ret i32 0
19260147c60SNikita Popov;
1933c514d31SNikita Popov  %V1 = call i32 @func(ptr %P) readnone
1943c514d31SNikita Popov  store i32 4, ptr %P
1953c514d31SNikita Popov  %V2 = call i32 @func(ptr %P) readnone
196cee313d2SEric Christopher  %Diff = sub i32 %V1, %V2
197cee313d2SEric Christopher  ret i32 %Diff
198cee313d2SEric Christopher}
199cee313d2SEric Christopher
200cee313d2SEric Christopher;; Trivial DSE can't be performed across a readonly call.  The call
201cee313d2SEric Christopher;; can observe the earlier write.
2023c514d31SNikita Popovdefine i32 @test9(ptr%P) {
20360147c60SNikita Popov; CHECK-LABEL: @test9(
2043c514d31SNikita Popov; CHECK-NEXT:    store i32 4, ptr [[P:%.*]], align 4
2053c514d31SNikita Popov; CHECK-NEXT:    [[V1:%.*]] = call i32 @func(ptr [[P]]) #[[ATTR1:[0-9]+]]
2063c514d31SNikita Popov; CHECK-NEXT:    store i32 5, ptr [[P]], align 4
20760147c60SNikita Popov; CHECK-NEXT:    ret i32 [[V1]]
20860147c60SNikita Popov;
2093c514d31SNikita Popov  store i32 4, ptr %P
2103c514d31SNikita Popov  %V1 = call i32 @func(ptr %P) readonly
2113c514d31SNikita Popov  store i32 5, ptr %P
212cee313d2SEric Christopher  ret i32 %V1
213cee313d2SEric Christopher}
214cee313d2SEric Christopher
215cee313d2SEric Christopher;; Trivial DSE can be performed across a readnone call.
2163c514d31SNikita Popovdefine i32 @test10(ptr%P) {
21760147c60SNikita Popov; CHECK-LABEL: @test10(
2183c514d31SNikita Popov; CHECK-NEXT:    [[V1:%.*]] = call i32 @func(ptr [[P:%.*]]) #[[ATTR2]]
2193c514d31SNikita Popov; CHECK-NEXT:    store i32 5, ptr [[P]], align 4
22060147c60SNikita Popov; CHECK-NEXT:    ret i32 [[V1]]
22160147c60SNikita Popov;
2223c514d31SNikita Popov  store i32 4, ptr %P
2233c514d31SNikita Popov  %V1 = call i32 @func(ptr %P) readnone
2243c514d31SNikita Popov  store i32 5, ptr %P
225cee313d2SEric Christopher  ret i32 %V1
226cee313d2SEric Christopher}
227cee313d2SEric Christopher
228cee313d2SEric Christopher;; Trivial dead store elimination - should work for an entire series of dead stores too.
2293c514d31SNikita Popovdefine void @test11(ptr%P) {
23060147c60SNikita Popov; CHECK-LABEL: @test11(
2313c514d31SNikita Popov; CHECK-NEXT:    store i32 45, ptr [[P:%.*]], align 4
23260147c60SNikita Popov; CHECK-NEXT:    ret void
23360147c60SNikita Popov;
2343c514d31SNikita Popov  store i32 42, ptr %P
2353c514d31SNikita Popov  store i32 43, ptr %P
2363c514d31SNikita Popov  store i32 44, ptr %P
2373c514d31SNikita Popov  store i32 45, ptr %P
238cee313d2SEric Christopher  ret void
239cee313d2SEric Christopher}
240cee313d2SEric Christopher
2413c514d31SNikita Popovdefine i32 @test12(i1 %B, ptr %P1, ptr %P2) {
24260147c60SNikita Popov; CHECK-LABEL: @test12(
2433c514d31SNikita Popov; CHECK-NEXT:    [[LOAD0:%.*]] = load i32, ptr [[P1:%.*]], align 4
2443c514d31SNikita Popov; CHECK-NEXT:    [[TMP1:%.*]] = load atomic i32, ptr [[P2:%.*]] seq_cst, align 4
2453c514d31SNikita Popov; CHECK-NEXT:    [[LOAD1:%.*]] = load i32, ptr [[P1]], align 4
24660147c60SNikita Popov; CHECK-NEXT:    [[SEL:%.*]] = select i1 [[B:%.*]], i32 [[LOAD0]], i32 [[LOAD1]]
24760147c60SNikita Popov; CHECK-NEXT:    ret i32 [[SEL]]
24860147c60SNikita Popov;
2493c514d31SNikita Popov  %load0 = load i32, ptr %P1
2503c514d31SNikita Popov  %1 = load atomic i32, ptr %P2 seq_cst, align 4
2513c514d31SNikita Popov  %load1 = load i32, ptr %P1
252cee313d2SEric Christopher  %sel = select i1 %B, i32 %load0, i32 %load1
253cee313d2SEric Christopher  ret i32 %sel
254cee313d2SEric Christopher}
255cee313d2SEric Christopher
2563c514d31SNikita Popovdefine void @dse1(ptr%P) {
25760147c60SNikita Popov; CHECK-LABEL: @dse1(
2583c514d31SNikita Popov; CHECK-NEXT:    [[V:%.*]] = load i32, ptr [[P:%.*]], align 4
25960147c60SNikita Popov; CHECK-NEXT:    ret void
26060147c60SNikita Popov;
2613c514d31SNikita Popov  %v = load i32, ptr %P
2623c514d31SNikita Popov  store i32 %v, ptr %P
263cee313d2SEric Christopher  ret void
264cee313d2SEric Christopher}
265cee313d2SEric Christopher
2663c514d31SNikita Popovdefine void @dse2(ptr%P) {
26760147c60SNikita Popov; CHECK-LABEL: @dse2(
2683c514d31SNikita Popov; CHECK-NEXT:    [[V:%.*]] = load atomic i32, ptr [[P:%.*]] seq_cst, align 4
26960147c60SNikita Popov; CHECK-NEXT:    ret void
27060147c60SNikita Popov;
2713c514d31SNikita Popov  %v = load atomic i32, ptr %P seq_cst, align 4
2723c514d31SNikita Popov  store i32 %v, ptr %P
273cee313d2SEric Christopher  ret void
274cee313d2SEric Christopher}
275cee313d2SEric Christopher
2763c514d31SNikita Popovdefine void @dse3(ptr%P) {
27760147c60SNikita Popov; CHECK-LABEL: @dse3(
2783c514d31SNikita Popov; CHECK-NEXT:    [[V:%.*]] = load atomic i32, ptr [[P:%.*]] seq_cst, align 4
27960147c60SNikita Popov; CHECK-NEXT:    ret void
28060147c60SNikita Popov;
2813c514d31SNikita Popov  %v = load atomic i32, ptr %P seq_cst, align 4
2823c514d31SNikita Popov  store atomic i32 %v, ptr %P unordered, align 4
283cee313d2SEric Christopher  ret void
284cee313d2SEric Christopher}
285cee313d2SEric Christopher
2863c514d31SNikita Popovdefine i32 @dse4(ptr%P, ptr%Q) {
28760147c60SNikita Popov; CHECK-LABEL: @dse4(
2883c514d31SNikita Popov; CHECK-NEXT:    [[A:%.*]] = load i32, ptr [[Q:%.*]], align 4
2893c514d31SNikita Popov; CHECK-NEXT:    [[V:%.*]] = load atomic i32, ptr [[P:%.*]] unordered, align 4
29060147c60SNikita Popov; CHECK-NEXT:    ret i32 0
29160147c60SNikita Popov;
2923c514d31SNikita Popov  %a = load i32, ptr %Q
2933c514d31SNikita Popov  %v = load atomic i32, ptr %P unordered, align 4
2943c514d31SNikita Popov  store atomic i32 %v, ptr %P unordered, align 4
2953c514d31SNikita Popov  %b = load i32, ptr %Q
296cee313d2SEric Christopher  %res = sub i32 %a, %b
297cee313d2SEric Christopher  ret i32 %res
298cee313d2SEric Christopher}
299cee313d2SEric Christopher
300cee313d2SEric Christopher; Note that in this example, %P and %Q could in fact be the same
301cee313d2SEric Christopher; pointer.  %v could be different than the value observed for %a
302cee313d2SEric Christopher; and that's okay because we're using relaxed memory ordering.
303cee313d2SEric Christopher; The only guarantee we have to provide is that each of the loads
304cee313d2SEric Christopher; has to observe some value written to that location.  We  do
305cee313d2SEric Christopher; not have to respect the order in which those writes were done.
3063c514d31SNikita Popovdefine i32 @dse5(ptr%P, ptr%Q) {
30760147c60SNikita Popov; CHECK-LABEL: @dse5(
3083c514d31SNikita Popov; CHECK-NEXT:    [[V:%.*]] = load atomic i32, ptr [[P:%.*]] unordered, align 4
3093c514d31SNikita Popov; CHECK-NEXT:    [[A:%.*]] = load atomic i32, ptr [[Q:%.*]] unordered, align 4
31060147c60SNikita Popov; CHECK-NEXT:    ret i32 0
31160147c60SNikita Popov;
3123c514d31SNikita Popov  %v = load atomic i32, ptr %P unordered, align 4
3133c514d31SNikita Popov  %a = load atomic i32, ptr %Q unordered, align 4
3143c514d31SNikita Popov  store atomic i32 %v, ptr %P unordered, align 4
3153c514d31SNikita Popov  %b = load atomic i32, ptr %Q unordered, align 4
316cee313d2SEric Christopher  %res = sub i32 %a, %b
317cee313d2SEric Christopher  ret i32 %res
318cee313d2SEric Christopher}
319cee313d2SEric Christopher
320cee313d2SEric Christopher
3213c514d31SNikita Popovdefine void @dse_neg1(ptr%P) {
32260147c60SNikita Popov; CHECK-LABEL: @dse_neg1(
3233c514d31SNikita Popov; CHECK-NEXT:    store i32 5, ptr [[P:%.*]], align 4
32460147c60SNikita Popov; CHECK-NEXT:    ret void
32560147c60SNikita Popov;
3263c514d31SNikita Popov  %v = load i32, ptr %P
3273c514d31SNikita Popov  store i32 5, ptr %P
328cee313d2SEric Christopher  ret void
329cee313d2SEric Christopher}
330cee313d2SEric Christopher
331cee313d2SEric Christopher; Could remove the store, but only if ordering was somehow
332cee313d2SEric Christopher; encoded.
3333c514d31SNikita Popovdefine void @dse_neg2(ptr%P) {
33460147c60SNikita Popov; CHECK-LABEL: @dse_neg2(
3353c514d31SNikita Popov; CHECK-NEXT:    [[V:%.*]] = load i32, ptr [[P:%.*]], align 4
3363c514d31SNikita Popov; CHECK-NEXT:    store atomic i32 [[V]], ptr [[P]] seq_cst, align 4
33760147c60SNikita Popov; CHECK-NEXT:    ret void
33860147c60SNikita Popov;
3393c514d31SNikita Popov  %v = load i32, ptr %P
3403c514d31SNikita Popov  store atomic i32 %v, ptr %P seq_cst, align 4
341cee313d2SEric Christopher  ret void
342cee313d2SEric Christopher}
343cee313d2SEric Christopher
344cee313d2SEric Christopher@c = external global i32, align 4
345cee313d2SEric Christopherdeclare i32 @reads_c(i32 returned)
346cee313d2SEric Christopherdefine void @pr28763() {
347cee313d2SEric Christopher; CHECK-LABEL: @pr28763(
34860147c60SNikita Popov; CHECK-NEXT:  entry:
3493c514d31SNikita Popov; CHECK-NEXT:    store i32 0, ptr @c, align 4
35060147c60SNikita Popov; CHECK-NEXT:    [[CALL:%.*]] = call i32 @reads_c(i32 0)
3513c514d31SNikita Popov; CHECK-NEXT:    store i32 2, ptr @c, align 4
35260147c60SNikita Popov; CHECK-NEXT:    ret void
35360147c60SNikita Popov;
35460147c60SNikita Popoventry:
3553c514d31SNikita Popov  %load = load i32, ptr @c, align 4
3563c514d31SNikita Popov  store i32 0, ptr @c, align 4
357cee313d2SEric Christopher  %call = call i32 @reads_c(i32 0)
3583c514d31SNikita Popov  store i32 2, ptr @c, align 4
359cee313d2SEric Christopher  ret void
360cee313d2SEric Christopher}
361cc28a754SJuneyoung Lee
362cc28a754SJuneyoung Leedefine i1 @cse_freeze(i1 %a) {
363cc28a754SJuneyoung Lee; CHECK-LABEL: @cse_freeze(
36460147c60SNikita Popov; CHECK-NEXT:  entry:
36560147c60SNikita Popov; CHECK-NEXT:    [[B:%.*]] = freeze i1 [[A:%.*]]
36660147c60SNikita Popov; CHECK-NEXT:    ret i1 [[B]]
36760147c60SNikita Popov;
36860147c60SNikita Popoventry:
369cc28a754SJuneyoung Lee  %b = freeze i1 %a
370cc28a754SJuneyoung Lee  %c = freeze i1 %a
371cc28a754SJuneyoung Lee  %and = and i1 %b, %c
372cc28a754SJuneyoung Lee  ret i1 %and
373cc28a754SJuneyoung Lee}
374