1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes='licm' < %s | FileCheck %s
4 define void @test_01(ptr addrspace(1) %arg, i32 %arg2) {
5 ; CHECK-LABEL: @test_01(
7 ; CHECK-NEXT: [[TMP103:%.*]] = load atomic ptr addrspace(1), ptr addrspace(1) [[ARG:%.*]] unordered, align 8, !dereferenceable_or_null !0, !align !1
8 ; CHECK-NEXT: [[TMP117:%.*]] = icmp eq ptr addrspace(1) [[TMP103]], null
9 ; CHECK-NEXT: [[TMP118:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[TMP103]], i64 8
10 ; CHECK-NEXT: br i1 [[TMP117]], label [[FAIL:%.*]], label [[PREHEADER:%.*]]
12 ; CHECK-NEXT: ret void
14 ; CHECK-NEXT: [[TMP157:%.*]] = load atomic i32, ptr addrspace(1) [[TMP118]] unordered, align 8
15 ; CHECK-NEXT: br label [[LOOP:%.*]]
17 ; CHECK-NEXT: [[TMP151:%.*]] = phi i32 [ 0, [[PREHEADER]] ], [ [[TMP163:%.*]], [[LOOP]] ]
18 ; CHECK-NEXT: [[TMP152:%.*]] = icmp ult i32 [[TMP151]], [[ARG2:%.*]]
19 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[TMP152]]) [ "deopt"() ]
20 ; CHECK-NEXT: [[TMP158:%.*]] = icmp ult i32 [[TMP151]], [[TMP157]]
21 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[TMP158]]) [ "deopt"() ]
22 ; CHECK-NEXT: [[TMP163]] = add i32 [[TMP151]], 1
23 ; CHECK-NEXT: br label [[LOOP]]
26 %tmp103 = load atomic ptr addrspace(1), ptr addrspace(1) %arg unordered, align 8, !dereferenceable_or_null !0, !align !1
27 %tmp117 = icmp eq ptr addrspace(1) %tmp103, null
28 %tmp118 = getelementptr inbounds i8, ptr addrspace(1) %tmp103, i64 8
29 br i1 %tmp117, label %fail, label %preheader
31 fail: ; preds = %entry
34 preheader: ; preds = %entry
37 loop: ; preds = %loop, %preheader
38 %tmp151 = phi i32 [ 0, %preheader ], [ %tmp163, %loop ]
39 %tmp152 = icmp ult i32 %tmp151, %arg2
40 call void (i1, ...) @llvm.experimental.guard(i1 %tmp152) [ "deopt"() ]
41 %tmp157 = load atomic i32, ptr addrspace(1) %tmp118 unordered, align 8
42 %tmp158 = icmp ult i32 %tmp151, %tmp157
43 call void (i1, ...) @llvm.experimental.guard(i1 %tmp158) [ "deopt"() ]
44 %tmp163 = add i32 %tmp151, 1
48 ; FIXME: should be able to hoist load just as test_01
49 define void @test_02(ptr addrspace(1) %arg, i32 %arg2) {
50 ; CHECK-LABEL: @test_02(
52 ; CHECK-NEXT: [[TMP103:%.*]] = load atomic ptr addrspace(1), ptr addrspace(1) [[ARG:%.*]] unordered, align 8, !dereferenceable_or_null !0, !align !1
53 ; CHECK-NEXT: [[TMP117:%.*]] = icmp eq ptr addrspace(1) [[TMP103]], null
54 ; CHECK-NEXT: [[TMP118:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[TMP103]], i64 8
55 ; CHECK-NEXT: [[FREEZE:%.*]] = freeze i1 [[TMP117]]
56 ; CHECK-NEXT: br i1 [[FREEZE]], label [[FAIL:%.*]], label [[PREHEADER:%.*]]
58 ; CHECK-NEXT: ret void
60 ; CHECK-NEXT: br label [[LOOP:%.*]]
62 ; CHECK-NEXT: [[TMP151:%.*]] = phi i32 [ 0, [[PREHEADER]] ], [ [[TMP163:%.*]], [[LOOP]] ]
63 ; CHECK-NEXT: [[TMP152:%.*]] = icmp ult i32 [[TMP151]], [[ARG2:%.*]]
64 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[TMP152]]) [ "deopt"() ]
65 ; CHECK-NEXT: [[TMP157:%.*]] = load atomic i32, ptr addrspace(1) [[TMP118]] unordered, align 8
66 ; CHECK-NEXT: [[TMP158:%.*]] = icmp ult i32 [[TMP151]], [[TMP157]]
67 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[TMP158]]) [ "deopt"() ]
68 ; CHECK-NEXT: [[TMP163]] = add i32 [[TMP151]], 1
69 ; CHECK-NEXT: br label [[LOOP]]
72 %tmp103 = load atomic ptr addrspace(1), ptr addrspace(1) %arg unordered, align 8, !dereferenceable_or_null !0, !align !1
73 %tmp117 = icmp eq ptr addrspace(1) %tmp103, null
74 %tmp118 = getelementptr inbounds i8, ptr addrspace(1) %tmp103, i64 8
75 %freeze = freeze i1 %tmp117
76 br i1 %freeze, label %fail, label %preheader
78 fail: ; preds = %entry
81 preheader: ; preds = %entry
84 loop: ; preds = %loop, %preheader
85 %tmp151 = phi i32 [ 0, %preheader ], [ %tmp163, %loop ]
86 %tmp152 = icmp ult i32 %tmp151, %arg2
87 call void (i1, ...) @llvm.experimental.guard(i1 %tmp152) [ "deopt"() ]
88 %tmp157 = load atomic i32, ptr addrspace(1) %tmp118 unordered, align 8
89 %tmp158 = icmp ult i32 %tmp151, %tmp157
90 call void (i1, ...) @llvm.experimental.guard(i1 %tmp158) [ "deopt"() ]
91 %tmp163 = add i32 %tmp151, 1
95 ; Function Attrs: nocallback nofree nosync willreturn
96 declare void @llvm.experimental.guard(i1, ...) #0
98 attributes #0 = { nocallback nofree nosync willreturn }