1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=newgvn -S | FileCheck %s
4 @g_20 = external global i32, align 4
9 ; CHECK-NEXT: br label [[BB1:%.*]]
11 ; CHECK-NEXT: [[STOREMERGE:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[ADD1:%.*]], [[CRITEDGE:%.*]] ]
12 ; CHECK-NEXT: store i32 [[STOREMERGE]], ptr @g_20, align 4
13 ; CHECK-NEXT: [[CMP0:%.*]] = icmp eq i32 [[STOREMERGE]], 0
14 ; CHECK-NEXT: br i1 [[CMP0]], label [[LR_PH:%.*]], label [[CRITEDGE]]
16 ; CHECK-NEXT: [[LV:%.*]] = load i64, ptr inttoptr (i64 16 to ptr), align 16
17 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i64 [[LV]], 0
18 ; CHECK-NEXT: br i1 [[CMP1]], label [[PREHEADER_SPLIT:%.*]], label [[CRITEDGE]]
19 ; CHECK: preheader.split:
20 ; CHECK-NEXT: br label [[PREHEADER_SPLIT]]
22 ; CHECK-NEXT: [[PHIOFOPS1:%.*]] = phi i1 [ false, [[BB1]] ], [ true, [[LR_PH]] ]
23 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i1 [ [[CMP0]], [[BB1]] ], [ true, [[LR_PH]] ]
24 ; CHECK-NEXT: [[DOT05_LCSSA:%.*]] = phi i32 [ 0, [[BB1]] ], [ -1, [[LR_PH]] ]
25 ; CHECK-NEXT: [[ADD1]] = add nsw i32 [[STOREMERGE]], -1
26 ; CHECK-NEXT: br i1 [[PHIOFOPS]], label [[BB1]], label [[END:%.*]]
28 ; CHECK-NEXT: ret void
33 bb1: ; preds = %critedge, %entry
34 %storemerge = phi i32 [ 0, %entry ], [ %add1, %critedge ]
35 store i32 %storemerge, ptr @g_20, align 4
36 %cmp0 = icmp eq i32 %storemerge, 0
37 br i1 %cmp0, label %lr.ph, label %critedge
40 %lv = load i64, ptr inttoptr (i64 16 to ptr), align 16
41 %cmp1 = icmp eq i64 %lv, 0
42 br i1 %cmp1, label %preheader.split, label %critedge
44 preheader.split: ; preds = %lr.ph, %preheader.split
45 br label %preheader.split
47 critedge: ; preds = %lr.ph, %bb1
48 %.05.lcssa = phi i32 [ 0, %bb1 ], [ -1, %lr.ph ]
49 %cmp2 = icmp ne i32 %.05.lcssa, 0
50 %brmerge = or i1 %cmp0, %cmp2
51 %add1 = add nsw i32 %storemerge, -1
52 br i1 %brmerge, label %bb1, label %end
58 ; In this test case a temporary PhiOfOps node gets moved to BB with more
59 ; predecessors, so a new one needs to be created.
60 define void @test2() {
61 ; CHECK-LABEL: @test2(
62 ; CHECK-NEXT: br label [[BB1:%.*]]
64 ; CHECK-NEXT: [[STOREMERGE:%.*]] = phi i32 [ 0, [[TMP0:%.*]] ], [ [[ADD:%.*]], [[CRITEDGE:%.*]] ]
65 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[STOREMERGE]], 0
66 ; CHECK-NEXT: br i1 [[CMP1]], label [[LR_PH:%.*]], label [[CRITEDGE]]
68 ; CHECK-NEXT: br i1 undef, label [[SPLIT1:%.*]], label [[SPLIT2:%.*]]
70 ; CHECK-NEXT: br label [[CRITEDGE]]
72 ; CHECK-NEXT: br label [[CRITEDGE]]
74 ; CHECK-NEXT: [[PHIOFOPS1:%.*]] = phi i1 [ false, [[BB1]] ], [ true, [[SPLIT2]] ], [ true, [[SPLIT1]] ]
75 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i1 [ [[CMP1]], [[BB1]] ], [ true, [[SPLIT2]] ], [ true, [[SPLIT1]] ]
76 ; CHECK-NEXT: [[LCSSA:%.*]] = phi i32 [ 0, [[BB1]] ], [ -1, [[SPLIT1]] ], [ -1, [[SPLIT2]] ]
77 ; CHECK-NEXT: [[ADD]] = add nsw i32 [[STOREMERGE]], -1
78 ; CHECK-NEXT: br i1 [[PHIOFOPS]], label [[BB1]], label [[EXIT:%.*]]
80 ; CHECK-NEXT: ret void
84 bb1: ; preds = %critedge, %0
85 %storemerge = phi i32 [ 0, %0 ], [ %add, %critedge ]
86 %cmp1 = icmp eq i32 %storemerge, 0
87 br i1 %cmp1, label %lr.ph, label %critedge
90 br i1 undef, label %split1, label %split2
92 split1: ; preds = %lr.ph
95 split2: ; preds = %lr.ph
98 critedge: ; preds = %split1, %split2, %bb1
99 %lcssa = phi i32 [ 0, %bb1 ], [ -1, %split1 ], [ -1, %split2 ]
100 %cmp2 = icmp ne i32 %lcssa, 0
101 %brmerge = or i1 %cmp1, %cmp2
102 %add = add nsw i32 %storemerge, -1
103 br i1 %brmerge, label %bb1, label %exit
105 exit: ; preds = %critedge