1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
6 %struct.Node = type { %struct.Node*, %struct.Node*, i32 }
8 define i32 @check(%struct.Node* %node) {
9 ; CHECK-LABEL: define i32 @check(
11 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq %struct.Node* [[NODE:%.*]], null
12 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
14 ; CHECK-NEXT: br label [[CLEANUP:%.*]]
16 ; CHECK-NEXT: [[LEFT:%.*]] = getelementptr inbounds [[STRUCT_NODE:%.*]], %struct.Node* [[NODE]], i32 0, i32 0
17 ; CHECK-NEXT: [[TMP0:%.*]] = load %struct.Node*, %struct.Node** [[LEFT]]
18 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @check(%struct.Node* [[TMP0]])
19 ; CHECK-NEXT: [[RIGHT:%.*]] = getelementptr inbounds [[STRUCT_NODE]], %struct.Node* [[NODE]], i32 0, i32 1
20 ; CHECK-NEXT: [[TMP1:%.*]] = load %struct.Node*, %struct.Node** [[RIGHT]]
21 ; CHECK-NEXT: [[CALL1:%.*]] = call i32 @check(%struct.Node* [[TMP1]])
22 ; CHECK-NEXT: [[TMP2:%.*]] = load %struct.Node*, %struct.Node** [[RIGHT]]
23 ; CHECK-NEXT: [[HEIGHT:%.*]] = getelementptr inbounds [[STRUCT_NODE]], %struct.Node* [[TMP2]], i32 0, i32 2
24 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* [[HEIGHT]]
25 ; CHECK-NEXT: [[CMP3:%.*]] = icmp ne i32 [[TMP3]], [[CALL1]]
26 ; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN4:%.*]], label [[IF_END5:%.*]]
28 ; CHECK-NEXT: unreachable
30 ; CHECK-NEXT: [[CMP6:%.*]] = icmp sgt i32 [[CALL]], [[CALL1]]
31 ; CHECK-NEXT: br i1 [[CMP6]], label [[IF_THEN7:%.*]], label [[IF_ELSE:%.*]]
33 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL]], 1
34 ; CHECK-NEXT: br label [[CLEANUP]]
36 ; CHECK-NEXT: [[ADD8:%.*]] = add nsw i32 [[CALL1]], 1
37 ; CHECK-NEXT: br label [[CLEANUP]]
39 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ 0, [[IF_THEN]] ], [ [[ADD]], [[IF_THEN7]] ], [ [[ADD8]], [[IF_ELSE]] ]
40 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
43 %cmp = icmp eq %struct.Node* %node, null
44 br i1 %cmp, label %if.then, label %if.end
46 if.then: ; preds = %entry
49 if.end: ; preds = %entry
50 %left = getelementptr inbounds %struct.Node, %struct.Node* %node, i32 0, i32 0
51 %0 = load %struct.Node*, %struct.Node** %left
52 %call = call i32 @check(%struct.Node* %0)
53 %right = getelementptr inbounds %struct.Node, %struct.Node* %node, i32 0, i32 1
54 %1 = load %struct.Node*, %struct.Node** %right
55 %call1 = call i32 @check(%struct.Node* %1)
56 %2 = load %struct.Node*, %struct.Node** %right
57 %height = getelementptr inbounds %struct.Node, %struct.Node* %2, i32 0, i32 2
58 %3 = load i32, i32* %height
59 %cmp3 = icmp ne i32 %3, %call1
60 br i1 %cmp3, label %if.then4, label %if.end5
62 if.then4: ; preds = %if.end
65 if.end5: ; preds = %if.end
66 %cmp6 = icmp sgt i32 %call, %call1
67 br i1 %cmp6, label %if.then7, label %if.else
69 if.then7: ; preds = %if.end5
70 %add = add nsw i32 %call, 1
73 if.else: ; preds = %if.end5
74 %add8 = add nsw i32 %call1, 1
77 cleanup: ; preds = %if.else, %if.then7, %if.then
78 %retval.0 = phi i32 [ 0, %if.then ], [ %add, %if.then7 ], [ %add8, %if.else ]
82 declare i8* @test2_callee(i32, i32)
84 define void @test2() {
85 ; CHECK-LABEL: @test2(
87 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
89 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
91 ; CHECK-NEXT: br label [[IF_ELSE33:%.*]]
93 ; CHECK-NEXT: br label [[IF_THEN38:%.*]]
95 ; CHECK-NEXT: [[CALL42:%.*]] = call i8* @test2_callee(i32 0, i32 0)
96 ; CHECK-NEXT: unreachable
101 for.cond: ; preds = %for.inc46, %entry
102 %op.0 = phi i32 [ 0, %entry ], [ 0, %for.inc46 ]
105 for.body: ; preds = %for.cond
106 %cmp24 = icmp eq i32 %op.0, 38
107 br i1 %cmp24, label %if.then26, label %if.else33
109 if.then26: ; preds = %for.body
112 if.else33: ; preds = %for.body
113 %cmp34 = icmp ne i32 %op.0, 80
114 %cmp36 = icmp ne i32 %op.0, 81
115 %or.cond = and i1 %cmp34, %cmp36
116 br i1 %or.cond, label %if.then38, label %for.inc46
118 if.then38: ; preds = %if.else33
119 %call42 = call i8* @test2_callee(i32 %op.0, i32 0)
122 for.inc46: ; preds = %if.else33