1; RUN: opt -loop-unswitch -enable-new-pm=0 %s -S | FileCheck %s 2 3; We want to check that the loop does not get split (so only 2 callbr's not 4). 4; It's ok to modify this test in the future should we allow the loop containing 5; callbr to be unswitched and are able to do so correctly. 6 7; CHECK: callbr void asm sideeffect "# ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@foo, %10)) 8; CHECK: to label %7 [label %10] 9; CHECK: callbr void asm sideeffect "# ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@foo, %10)) 10; CHECK: to label %9 [label %10] 11 12; CHECK-NOT: callbr void asm sideeffect "# ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@foo, %10)) 13; CHECK-NOT: to label %7 [label %10] 14; CHECK-NOT: callbr void asm sideeffect "# ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@foo, %10)) 15; CHECK-NOT: to label %9 [label %10] 16; CHECK-NOT: callbr void asm sideeffect "# ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@foo, %19)) 17; CHECK-NOT: to label %16 [label %19] 18; CHECK-NOT: callbr void asm sideeffect "# ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@foo, %19)) 19; CHECK-NOT: to label %18 [label %19] 20 21; This test is essentially: 22; void foo(int n) { 23; for (int i = 0; i < 1000; ++i) 24; if (n) { 25; asm goto("# %l0"::::bar); 26; bar:; 27; } else { 28; asm goto("# %l0"::::baz); 29; baz:; 30; } 31;} 32 33define dso_local void @foo(i32) #0 { 34 br label %2 35 362: ; preds = %10, %1 37 %.0 = phi i32 [ 0, %1 ], [ %11, %10 ] 38 %3 = icmp ult i32 %.0, 1000 39 br i1 %3, label %4, label %12 40 414: ; preds = %2 42 %5 = icmp eq i32 %0, 0 43 br i1 %5, label %8, label %6 44 456: ; preds = %4 46 callbr void asm sideeffect "# ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@foo, %10)) #0 47 to label %7 [label %10] 48 497: ; preds = %6 50 br label %10 51 528: ; preds = %4 53 callbr void asm sideeffect "# ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@foo, %10)) #0 54 to label %9 [label %10] 55 569: ; preds = %8 57 br label %10 58 5910: ; preds = %7, %6, %9, %8 60 %11 = add nuw nsw i32 %.0, 1 61 br label %2 62 6312: ; preds = %2 64 ret void 65} 66 67