1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=ipsccp -S %s | FileCheck %s
4 declare noalias ptr @malloc(i64)
6 ; Make sure we can eliminate `%tmp17 = icmp ult i32 %tmp10, 3`.
10 define internal ptr @spam(ptr %arg) {
13 ; CHECK-NEXT: [[TMP:%.*]] = call ptr @malloc(i64 10368)
14 ; CHECK-NEXT: [[TMP5:%.*]] = load i32, ptr [[ARG:%.*]], align 8
15 ; CHECK-NEXT: [[TMP6:%.*]] = add i32 [[TMP5]], 1
16 ; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds i32, ptr [[ARG]], i32 1
17 ; CHECK-NEXT: [[TMP10:%.*]] = icmp ne ptr [[TMP7]], null
18 ; CHECK-NEXT: br i1 [[TMP10]], label [[BB17:%.*]], label [[BB13:%.*]]
20 ; CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds i32, ptr [[ARG]], i32 2
21 ; CHECK-NEXT: [[TMP15:%.*]] = load i32, ptr [[TMP14]], align 8
22 ; CHECK-NEXT: [[TMP16:%.*]] = add i32 [[TMP15]], 1
23 ; CHECK-NEXT: br label [[BB30:%.*]]
25 ; CHECK-NEXT: [[TMP18:%.*]] = icmp eq i32 [[TMP6]], [[TMP5]]
26 ; CHECK-NEXT: [[TMP19:%.*]] = getelementptr inbounds i32, ptr [[ARG]], i32 3
27 ; CHECK-NEXT: [[TMP20:%.*]] = load i32, ptr [[TMP19]], align 8
28 ; CHECK-NEXT: br i1 [[TMP18]], label [[BB30]], label [[BB13]]
30 ; CHECK-NEXT: ret ptr [[TMP]]
33 %tmp = call ptr @malloc(i64 10368)
34 %tmp5 = load i32, ptr %arg, align 8
35 %tmp6 = add i32 %tmp5, 1
36 %tmp7 = getelementptr inbounds i32, ptr %arg, i32 1
37 %tmp10 = icmp ne ptr %tmp7, null
38 br i1 %tmp10, label %bb17, label %bb13
41 %tmp14 = getelementptr inbounds i32, ptr %arg, i32 2
42 %tmp15 = load i32, ptr %tmp14, align 8
43 %tmp16 = add i32 %tmp15, 1
47 %tmp18 = icmp eq i32 %tmp6, %tmp5
48 %tmp19 = getelementptr inbounds i32, ptr %arg, i32 3
49 %tmp20 = load i32, ptr %tmp19, align 8
50 br i1 %tmp18, label %bb30, label %bb13
56 define void @spam.1(ptr %arg) {
58 %tmp = alloca ptr, align 8
59 %tmp4 = call ptr @spam(ptr %arg)
63 %tmp7 = getelementptr inbounds i32, ptr %tmp4, i32 1
64 %tmp10 = load i32, ptr %tmp7, align 8
65 %tmp11 = icmp ne i32 %tmp10, 0
66 br i1 %tmp11, label %bb6, label %bb15
69 %tmp17 = icmp ult i32 %tmp10, 3
70 call void @use(i1 %tmp17)
71 br i1 %tmp17, label %bb6, label %bb24