1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -basic-aa -newgvn -enable-store-refinement -S | FileCheck %s 3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4 5;; Both of these tests are tests of phi nodes that end up all equivalent to each other 6;; Without proper leader ordering, we will end up cycling the leader between all of them and never converge. 7 8define void @foo() { 9; CHECK-LABEL: @foo( 10; CHECK-NEXT: bb: 11; CHECK-NEXT: br label [[BB1:%.*]] 12; CHECK: bb1: 13; CHECK-NEXT: [[TMP:%.*]] = phi i32 [ 0, [[BB:%.*]] ], [ 1, [[BB18:%.*]] ] 14; CHECK-NEXT: br label [[BB2:%.*]] 15; CHECK: bb2: 16; CHECK-NEXT: br label [[BB4:%.*]] 17; CHECK: bb4: 18; CHECK-NEXT: br i1 undef, label [[BB18]], label [[BB7:%.*]] 19; CHECK: bb7: 20; CHECK-NEXT: br label [[BB9:%.*]] 21; CHECK: bb9: 22; CHECK-NEXT: br i1 undef, label [[BB2]], label [[BB11:%.*]] 23; CHECK: bb11: 24; CHECK-NEXT: br i1 undef, label [[BB16:%.*]], label [[BB14:%.*]] 25; CHECK: bb14: 26; CHECK-NEXT: br label [[BB4]] 27; CHECK: bb16: 28; CHECK-NEXT: br label [[BB7]] 29; CHECK: bb18: 30; CHECK-NEXT: br label [[BB1]] 31; 32bb: 33 br label %bb1 34 35bb1: ; preds = %bb18, %bb 36 %tmp = phi i32 [ 0, %bb ], [ 1, %bb18 ] 37 br label %bb2 38 39bb2: ; preds = %bb9, %bb1 40 %tmp3 = phi i32 [ %tmp, %bb1 ], [ %tmp8, %bb9 ] 41 br label %bb4 42 43bb4: ; preds = %bb14, %bb2 44 %tmp5 = phi i32 [ %tmp3, %bb2 ], [ %tmp15, %bb14 ] 45 br i1 undef, label %bb18, label %bb7 46 47bb7: ; preds = %bb16, %bb4 48 %tmp8 = phi i32 [ %tmp17, %bb16 ], [ %tmp5, %bb4 ] 49 br label %bb9 50 51bb9: ; preds = %bb7 52 br i1 undef, label %bb2, label %bb11 53 54bb11: ; preds = %bb9 55 br i1 undef, label %bb16, label %bb14 56 57bb14: ; preds = %bb11 58 %tmp15 = phi i32 [ %tmp8, %bb11 ] 59 br label %bb4 60 61bb16: ; preds = %bb11 62 %tmp17 = phi i32 [ %tmp8, %bb11 ] 63 br label %bb7 64 65bb18: ; preds = %bb4 66 br label %bb1 67} 68 69%struct.a = type {} 70%struct.b = type {} 71 72declare void @c.d.p(i64, i8*) 73 74define void @e(i32 %a0, i32 %a1, %struct.a** %p2) { 75; CHECK-LABEL: @e( 76; CHECK-NEXT: [[F:%.*]] = alloca i32 77; CHECK-NEXT: store i32 [[A0:%.*]], i32* [[F]], align 4, !g !0 78; CHECK-NEXT: br label [[H:%.*]] 79; CHECK: h: 80; CHECK-NEXT: call void @c.d.p(i64 8, i8* undef) 81; CHECK-NEXT: [[I:%.*]] = load i32, i32* [[F]], align 4 82; CHECK-NEXT: [[J:%.*]] = load i32, i32* null, align 4 83; CHECK-NEXT: [[K:%.*]] = icmp eq i32 [[I]], [[J]] 84; CHECK-NEXT: br i1 [[K]], label [[L:%.*]], label [[Q:%.*]] 85; CHECK: l: 86; CHECK-NEXT: br label [[R:%.*]] 87; CHECK: q: 88; CHECK-NEXT: [[M:%.*]] = load %struct.a*, %struct.a** null, align 8 89; CHECK-NEXT: br label [[R]] 90; CHECK: r: 91; CHECK-NEXT: switch i32 undef, label [[N:%.*]] [ 92; CHECK-NEXT: i32 0, label [[S:%.*]] 93; CHECK-NEXT: ] 94; CHECK: s: 95; CHECK-NEXT: store i32 [[A1:%.*]], i32* [[F]], align 4, !g !0 96; CHECK-NEXT: br label [[H]] 97; CHECK: n: 98; CHECK-NEXT: [[O:%.*]] = load %struct.a*, %struct.a** [[P2:%.*]], align 8 99; CHECK-NEXT: ret void 100; 101 %f = alloca i32 102 store i32 %a0, i32* %f, !g !0 103 br label %h 104 105h: ; preds = %s, %0 106 call void @c.d.p(i64 8, i8* undef) 107 %i = load i32, i32* %f 108 %j = load i32, i32* null 109 %k = icmp eq i32 %i, %j 110 br i1 %k, label %l, label %q 111 112l: ; preds = %h 113 br label %r 114 115q: ; preds = %h 116 %m = load %struct.a*, %struct.a** null 117 %1 = bitcast %struct.a* %m to %struct.b* 118 br label %r 119 120r: ; preds = %q, %l 121 switch i32 undef, label %n [ 122 i32 0, label %s 123 ] 124 125s: ; preds = %r 126 store i32 %a1, i32* %f, !g !0 127 br label %h 128 129n: ; preds = %r 130 %o = load %struct.a*, %struct.a** %p2 131 %2 = bitcast %struct.a* %o to %struct.b* 132 ret void 133} 134 135!0 = !{} 136