1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2;; Ensure we don't change after value numbering by accidentally deleting the wrong expression. 3; RUN: opt -newgvn -S %s | FileCheck %s 4define void @fn1() local_unnamed_addr #0 { 5; CHECK-LABEL: @fn1( 6; CHECK-NEXT: entry: 7; CHECK-NEXT: br label [[FOR_COND_PREHEADER:%.*]] 8; CHECK: while.cond: 9; CHECK-NEXT: br label [[FOR_COND_PREHEADER]] 10; CHECK: for.cond.preheader: 11; CHECK-NEXT: [[H_031:%.*]] = phi i32 [ 5, [[ENTRY:%.*]] ], [ [[H_127:%.*]], [[WHILE_COND:%.*]] ] 12; CHECK-NEXT: br label [[FOR_BODY:%.*]] 13; CHECK: for.body: 14; CHECK-NEXT: [[H_128:%.*]] = phi i32 [ [[H_031]], [[FOR_COND_PREHEADER]] ], [ [[H_2:%.*]], [[FOR_INC:%.*]] ] 15; CHECK-NEXT: br label [[IF_THEN:%.*]] 16; CHECK: if.then: 17; CHECK-NEXT: br i1 false, label [[L_LOOPEXIT:%.*]], label [[IF_END:%.*]] 18; CHECK: if.end: 19; CHECK-NEXT: br i1 undef, label [[FOR_INC]], label [[IF_END9:%.*]] 20; CHECK: if.end9: 21; CHECK-NEXT: br label [[FOR_INC]] 22; CHECK: for.inc: 23; CHECK-NEXT: [[H_2]] = phi i32 [ [[H_128]], [[IF_END]] ], [ 0, [[IF_END9]] ] 24; CHECK-NEXT: br i1 undef, label [[WHILE_COND10_LOOPEXIT:%.*]], label [[FOR_BODY]] 25; CHECK: while.cond10.loopexit: 26; CHECK-NEXT: br label [[WHILE_COND10:%.*]] 27; CHECK: while.cond10: 28; CHECK-NEXT: [[H_127]] = phi i32 [ [[H_126:%.*]], [[IF_END18:%.*]] ], [ [[H_125:%.*]], [[L:%.*]] ], [ [[H_2]], [[WHILE_COND10_LOOPEXIT]] ] 29; CHECK-NEXT: br i1 undef, label [[WHILE_COND]], label [[WHILE_BODY12:%.*]] 30; CHECK: while.body12: 31; CHECK-NEXT: br i1 undef, label [[IF_END18]], label [[L]] 32; CHECK: L.loopexit: 33; CHECK-NEXT: store i8 undef, i8* null 34; CHECK-NEXT: br label [[L]] 35; CHECK: L: 36; CHECK-NEXT: [[H_125]] = phi i32 [ [[H_127]], [[WHILE_BODY12]] ], [ undef, [[L_LOOPEXIT]] ] 37; CHECK-NEXT: br i1 undef, label [[WHILE_COND10]], label [[IF_END18]] 38; CHECK: if.end18: 39; CHECK-NEXT: [[H_126]] = phi i32 [ [[H_125]], [[L]] ], [ [[H_127]], [[WHILE_BODY12]] ] 40; CHECK-NEXT: br label [[WHILE_COND10]] 41; 42entry: 43 br label %for.cond.preheader 44 45while.cond: ; preds = %while.cond10 46 br label %for.cond.preheader 47 48for.cond.preheader: ; preds = %while.cond, %entry 49 %h.031 = phi i32 [ 5, %entry ], [ %h.127, %while.cond ] 50 br label %for.body 51 52for.body: ; preds = %for.inc, %for.cond.preheader 53 %h.128 = phi i32 [ %h.031, %for.cond.preheader ], [ %h.2, %for.inc ] 54 br label %if.then 55 56if.then: ; preds = %for.body 57 br i1 false, label %L.loopexit, label %if.end 58 59if.end: ; preds = %if.then 60 br i1 undef, label %for.inc, label %if.end9 61 62if.end9: ; preds = %if.end 63 br label %for.inc 64 65for.inc: ; preds = %if.end9, %if.end 66 %h.2 = phi i32 [ %h.128, %if.end ], [ 0, %if.end9 ] 67 br i1 undef, label %while.cond10.loopexit, label %for.body 68 69while.cond10.loopexit: ; preds = %for.inc 70 %h.2.lcssa = phi i32 [ %h.2, %for.inc ] 71 br label %while.cond10 72 73while.cond10: ; preds = %if.end18, %L, %while.cond10.loopexit 74 %h.127 = phi i32 [ %h.126, %if.end18 ], [ %h.125, %L ], [ %h.2.lcssa, %while.cond10.loopexit ] 75 br i1 undef, label %while.cond, label %while.body12 76 77while.body12: ; preds = %while.cond10 78 br i1 undef, label %if.end18, label %L 79 80L.loopexit: ; preds = %if.then 81 br label %L 82 83L: ; preds = %L.loopexit, %while.body12 84 %h.125 = phi i32 [ %h.127, %while.body12 ], [ undef, %L.loopexit ] 85 br i1 undef, label %while.cond10, label %if.end18 86 87if.end18: ; preds = %L, %while.body12 88 %h.126 = phi i32 [ %h.125, %L ], [ %h.127, %while.body12 ] 89 br label %while.cond10 90} 91 92 93define void @hoge() local_unnamed_addr #0 { 94; CHECK-LABEL: @hoge( 95; CHECK-NEXT: bb: 96; CHECK-NEXT: br label [[BB1:%.*]] 97; CHECK: bb1: 98; CHECK-NEXT: [[TMP:%.*]] = phi i64 [ 0, [[BB:%.*]] ], [ [[TMP2:%.*]], [[BB1]] ] 99; CHECK-NEXT: [[TMP2]] = add nuw nsw i64 [[TMP]], 1 100; CHECK-NEXT: br label [[BB1]] 101; 102bb: 103 br label %bb1 104 105bb1: ; preds = %bb1, %bb 106 %tmp = phi i64 [ 0, %bb ], [ %tmp2, %bb1 ] 107 %tmp2 = add nuw nsw i64 %tmp, 1 108 br label %bb1 109} 110 111attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 112 113 114source_filename = "pr33187-c.ll" 115 116define void @a() { 117; CHECK-LABEL: @a( 118; CHECK-NEXT: b: 119; CHECK-NEXT: store i8* null, i8** null 120; CHECK-NEXT: br label [[D:%.*]] 121; CHECK: d: 122; CHECK-NEXT: [[I:%.*]] = phi i8* [ null, [[B:%.*]] ], [ [[E:%.*]], [[F:%.*]] ] 123; CHECK-NEXT: br i1 undef, label [[F]], label [[G:%.*]] 124; CHECK: g: 125; CHECK-NEXT: store i8* [[I]], i8** null 126; CHECK-NEXT: unreachable 127; CHECK: f: 128; CHECK-NEXT: [[E]] = getelementptr i8, i8* [[I]], i64 1 129; CHECK-NEXT: br label [[D]] 130; 131b: 132 store i8* null, i8** null 133 br label %d 134 135d: ; preds = %f, %b 136 %i = phi i8* [ null, %b ], [ %e, %f ] 137 br i1 undef, label %f, label %g 138 139g: ; preds = %d 140 %h = phi i8* [ %i, %d ] 141 store i8* %h, i8** null 142 unreachable 143 144f: ; preds = %d 145 %e = getelementptr i8, i8* %i, i64 1 146 br label %d 147} 148 149