1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -ipsccp -S | FileCheck %s
3 ; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
7 %struct.Node = type { %struct.Node*, %struct.Node*, i32 }
9 define i32 @check(%struct.Node* %node) {
10 ; CHECK-LABEL: define i32 @check(
12 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq %struct.Node* [[NODE:%.*]], null
13 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
15 ; CHECK-NEXT: br label [[CLEANUP:%.*]]
17 ; CHECK-NEXT: [[LEFT:%.*]] = getelementptr inbounds [[STRUCT_NODE:%.*]], %struct.Node* [[NODE]], i32 0, i32 0
18 ; CHECK-NEXT: [[TMP0:%.*]] = load %struct.Node*, %struct.Node** [[LEFT]]
19 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @check(%struct.Node* [[TMP0]])
20 ; CHECK-NEXT: [[RIGHT:%.*]] = getelementptr inbounds [[STRUCT_NODE]], %struct.Node* [[NODE]], i32 0, i32 1
21 ; CHECK-NEXT: [[TMP1:%.*]] = load %struct.Node*, %struct.Node** [[RIGHT]]
22 ; CHECK-NEXT: [[CALL1:%.*]] = call i32 @check(%struct.Node* [[TMP1]])
23 ; CHECK-NEXT: [[TMP2:%.*]] = load %struct.Node*, %struct.Node** [[RIGHT]]
24 ; CHECK-NEXT: [[HEIGHT:%.*]] = getelementptr inbounds [[STRUCT_NODE]], %struct.Node* [[TMP2]], i32 0, i32 2
25 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* [[HEIGHT]]
26 ; CHECK-NEXT: [[CMP3:%.*]] = icmp ne i32 [[TMP3]], [[CALL1]]
27 ; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN4:%.*]], label [[IF_END5:%.*]]
29 ; CHECK-NEXT: unreachable
31 ; CHECK-NEXT: [[CMP6:%.*]] = icmp sgt i32 [[CALL]], [[CALL1]]
32 ; CHECK-NEXT: br i1 [[CMP6]], label [[IF_THEN7:%.*]], label [[IF_ELSE:%.*]]
34 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL]], 1
35 ; CHECK-NEXT: br label [[CLEANUP]]
37 ; CHECK-NEXT: [[ADD8:%.*]] = add nsw i32 [[CALL1]], 1
38 ; CHECK-NEXT: br label [[CLEANUP]]
40 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ 0, [[IF_THEN]] ], [ [[ADD]], [[IF_THEN7]] ], [ [[ADD8]], [[IF_ELSE]] ]
41 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
44 %cmp = icmp eq %struct.Node* %node, null
45 br i1 %cmp, label %if.then, label %if.end
47 if.then: ; preds = %entry
50 if.end: ; preds = %entry
51 %left = getelementptr inbounds %struct.Node, %struct.Node* %node, i32 0, i32 0
52 %0 = load %struct.Node*, %struct.Node** %left
53 %call = call i32 @check(%struct.Node* %0)
54 %right = getelementptr inbounds %struct.Node, %struct.Node* %node, i32 0, i32 1
55 %1 = load %struct.Node*, %struct.Node** %right
56 %call1 = call i32 @check(%struct.Node* %1)
57 %2 = load %struct.Node*, %struct.Node** %right
58 %height = getelementptr inbounds %struct.Node, %struct.Node* %2, i32 0, i32 2
59 %3 = load i32, i32* %height
60 %cmp3 = icmp ne i32 %3, %call1
61 br i1 %cmp3, label %if.then4, label %if.end5
63 if.then4: ; preds = %if.end
66 if.end5: ; preds = %if.end
67 %cmp6 = icmp sgt i32 %call, %call1
68 br i1 %cmp6, label %if.then7, label %if.else
70 if.then7: ; preds = %if.end5
71 %add = add nsw i32 %call, 1
74 if.else: ; preds = %if.end5
75 %add8 = add nsw i32 %call1, 1
78 cleanup: ; preds = %if.else, %if.then7, %if.then
79 %retval.0 = phi i32 [ 0, %if.then ], [ %add, %if.then7 ], [ %add8, %if.else ]
83 declare i8* @test2_callee(i32, i32)
85 define void @test2() {
86 ; CHECK-LABEL: @test2(
88 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
90 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
92 ; CHECK-NEXT: br label [[IF_ELSE33:%.*]]
94 ; CHECK-NEXT: br label [[IF_THEN38:%.*]]
96 ; CHECK-NEXT: [[CALL42:%.*]] = call i8* @test2_callee(i32 0, i32 0)
97 ; CHECK-NEXT: unreachable
102 for.cond: ; preds = %for.inc46, %entry
103 %op.0 = phi i32 [ 0, %entry ], [ 0, %for.inc46 ]
106 for.body: ; preds = %for.cond
107 %cmp24 = icmp eq i32 %op.0, 38
108 br i1 %cmp24, label %if.then26, label %if.else33
110 if.then26: ; preds = %for.body
113 if.else33: ; preds = %for.body
114 %cmp34 = icmp ne i32 %op.0, 80
115 %cmp36 = icmp ne i32 %op.0, 81
116 %or.cond = and i1 %cmp34, %cmp36
117 br i1 %or.cond, label %if.then38, label %for.inc46
119 if.then38: ; preds = %if.else33
120 %call42 = call i8* @test2_callee(i32 %op.0, i32 0)
123 for.inc46: ; preds = %if.else33