Florian Hahn | 6615a71 | 2018-11-25 16:32:02 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -ipsccp -S | FileCheck %s |
| 2 | ; RUN: opt < %s -passes=ipsccp -S | FileCheck %s |
| 3 | |
| 4 | ; Test for PR39772 |
| 5 | ; CHECK-LABEL: cleanup: |
| 6 | ; CHECK-NEXT: %retval.0 = phi i32 [ 0, %if.then ], [ %add, %if.then7 ], [ %add8, %if.else ] |
| 7 | |
| 8 | |
| 9 | %struct.Node = type { %struct.Node*, %struct.Node*, i32 } |
| 10 | |
| 11 | define i32 @check(%struct.Node* %node) { |
| 12 | entry: |
| 13 | %cmp = icmp eq %struct.Node* %node, null |
| 14 | br i1 %cmp, label %if.then, label %if.end |
| 15 | |
| 16 | if.then: ; preds = %entry |
| 17 | br label %cleanup |
| 18 | |
| 19 | if.end: ; preds = %entry |
| 20 | %left = getelementptr inbounds %struct.Node, %struct.Node* %node, i32 0, i32 0 |
| 21 | %0 = load %struct.Node*, %struct.Node** %left |
| 22 | %call = call i32 @check(%struct.Node* %0) |
| 23 | %right = getelementptr inbounds %struct.Node, %struct.Node* %node, i32 0, i32 1 |
| 24 | %1 = load %struct.Node*, %struct.Node** %right |
| 25 | %call1 = call i32 @check(%struct.Node* %1) |
| 26 | %2 = load %struct.Node*, %struct.Node** %right |
| 27 | %height = getelementptr inbounds %struct.Node, %struct.Node* %2, i32 0, i32 2 |
| 28 | %3 = load i32, i32* %height |
| 29 | %cmp3 = icmp ne i32 %3, %call1 |
| 30 | br i1 %cmp3, label %if.then4, label %if.end5 |
| 31 | |
| 32 | if.then4: ; preds = %if.end |
| 33 | unreachable |
| 34 | |
| 35 | if.end5: ; preds = %if.end |
| 36 | %cmp6 = icmp sgt i32 %call, %call1 |
| 37 | br i1 %cmp6, label %if.then7, label %if.else |
| 38 | |
| 39 | if.then7: ; preds = %if.end5 |
| 40 | %add = add nsw i32 %call, 1 |
| 41 | br label %cleanup |
| 42 | |
| 43 | if.else: ; preds = %if.end5 |
| 44 | %add8 = add nsw i32 %call1, 1 |
| 45 | br label %cleanup |
| 46 | |
| 47 | cleanup: ; preds = %if.else, %if.then7, %if.then |
| 48 | %retval.0 = phi i32 [ 0, %if.then ], [ %add, %if.then7 ], [ %add8, %if.else ] |
| 49 | ret i32 %retval.0 |
| 50 | } |