brintos

brintos / llvm-project-archived public Read only

0
0
Text · 28.0 KiB · 775ab3f Raw
989 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 52; RUN: llc -O3 -mtriple=arm64-apple-macosx -o - %s | FileCheck %s3; RUN: llc -O3 -mtriple=arm64-apple-macosx -global-isel -o - %s | FileCheck --check-prefix=GISEL %s4 5define i32 @switch_with_matching_dests_0_and_pow2_3_cases(i8 %v) {6; CHECK-LABEL: switch_with_matching_dests_0_and_pow2_3_cases:7; CHECK:       ; %bb.0: ; %entry8; CHECK-NEXT:    mov w9, #100 ; =0x649; CHECK-NEXT:    mov w8, #20 ; =0x1410; CHECK-NEXT:  LBB0_1: ; %loop.header11; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=112; CHECK-NEXT:    ands w10, w0, #0xff13; CHECK-NEXT:    b.eq LBB0_614; CHECK-NEXT:  ; %bb.2: ; %loop.header15; CHECK-NEXT:    ; in Loop: Header=BB0_1 Depth=116; CHECK-NEXT:    cmp w10, #3217; CHECK-NEXT:    b.eq LBB0_618; CHECK-NEXT:  ; %bb.3: ; %loop.header19; CHECK-NEXT:    ; in Loop: Header=BB0_1 Depth=120; CHECK-NEXT:    cmp w10, #12421; CHECK-NEXT:    b.eq LBB0_722; CHECK-NEXT:  ; %bb.4: ; %loop.latch23; CHECK-NEXT:    ; in Loop: Header=BB0_1 Depth=124; CHECK-NEXT:    subs w9, w9, #125; CHECK-NEXT:    b.ne LBB0_126; CHECK-NEXT:  ; %bb.5:27; CHECK-NEXT:    mov w8, #20 ; =0x1428; CHECK-NEXT:  LBB0_6: ; %common.ret29; CHECK-NEXT:    mov w0, w830; CHECK-NEXT:    ret31; CHECK-NEXT:  LBB0_7: ; %e232; CHECK-NEXT:    mov w0, #30 ; =0x1e33; CHECK-NEXT:    ret34;35; GISEL-LABEL: switch_with_matching_dests_0_and_pow2_3_cases:36; GISEL:       ; %bb.0: ; %entry37; GISEL-NEXT:    mov w8, w038; GISEL-NEXT:    mov w0, #20 ; =0x1439; GISEL-NEXT:    mov w9, #100 ; =0x6440; GISEL-NEXT:  LBB0_1: ; %loop.header41; GISEL-NEXT:    ; =>This Inner Loop Header: Depth=142; GISEL-NEXT:    ands w10, w8, #0xff43; GISEL-NEXT:    b.eq LBB0_544; GISEL-NEXT:  ; %bb.2: ; %loop.header45; GISEL-NEXT:    ; in Loop: Header=BB0_1 Depth=146; GISEL-NEXT:    cmp w10, #3247; GISEL-NEXT:    b.eq LBB0_548; GISEL-NEXT:  ; %bb.3: ; %loop.header49; GISEL-NEXT:    ; in Loop: Header=BB0_1 Depth=150; GISEL-NEXT:    cmp w10, #12451; GISEL-NEXT:    b.eq LBB0_652; GISEL-NEXT:  ; %bb.4: ; %loop.latch53; GISEL-NEXT:    ; in Loop: Header=BB0_1 Depth=154; GISEL-NEXT:    subs w9, w9, #155; GISEL-NEXT:    b.ne LBB0_156; GISEL-NEXT:  LBB0_5: ; %common.ret57; GISEL-NEXT:    ret58; GISEL-NEXT:  LBB0_6: ; %e259; GISEL-NEXT:    mov w0, #30 ; =0x1e60; GISEL-NEXT:    ret61entry:62  br label %loop.header63 64loop.header:65  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]66  switch i8 %v, label %loop.latch [67  i8 32, label %e168  i8 0, label %e169  i8 124, label %e270  ]71 72loop.latch:73  %iv.next = add i32 %iv, 174  %c = icmp eq i32 %iv.next, 10075  br i1 %c, label %e1, label %loop.header76 77e1:78  ret i32 2079 80e2:81  ret i32 3082}83 84define i32 @switch_with_matching_dests_0_and_pow2_3_cases_swapped(i8 %v) {85; CHECK-LABEL: switch_with_matching_dests_0_and_pow2_3_cases_swapped:86; CHECK:       ; %bb.0: ; %entry87; CHECK-NEXT:    mov w9, #100 ; =0x6488; CHECK-NEXT:    mov w8, #20 ; =0x1489; CHECK-NEXT:  LBB1_1: ; %loop.header90; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=191; CHECK-NEXT:    ands w10, w0, #0xff92; CHECK-NEXT:    b.eq LBB1_693; CHECK-NEXT:  ; %bb.2: ; %loop.header94; CHECK-NEXT:    ; in Loop: Header=BB1_1 Depth=195; CHECK-NEXT:    cmp w10, #3296; CHECK-NEXT:    b.eq LBB1_697; CHECK-NEXT:  ; %bb.3: ; %loop.header98; CHECK-NEXT:    ; in Loop: Header=BB1_1 Depth=199; CHECK-NEXT:    cmp w10, #124100; CHECK-NEXT:    b.eq LBB1_7101; CHECK-NEXT:  ; %bb.4: ; %loop.latch102; CHECK-NEXT:    ; in Loop: Header=BB1_1 Depth=1103; CHECK-NEXT:    subs w9, w9, #1104; CHECK-NEXT:    b.ne LBB1_1105; CHECK-NEXT:  ; %bb.5:106; CHECK-NEXT:    mov w8, #10 ; =0xa107; CHECK-NEXT:  LBB1_6: ; %common.ret108; CHECK-NEXT:    mov w0, w8109; CHECK-NEXT:    ret110; CHECK-NEXT:  LBB1_7: ; %e2111; CHECK-NEXT:    mov w0, #30 ; =0x1e112; CHECK-NEXT:    ret113;114; GISEL-LABEL: switch_with_matching_dests_0_and_pow2_3_cases_swapped:115; GISEL:       ; %bb.0: ; %entry116; GISEL-NEXT:    mov w9, #100 ; =0x64117; GISEL-NEXT:    mov w8, #20 ; =0x14118; GISEL-NEXT:  LBB1_1: ; %loop.header119; GISEL-NEXT:    ; =>This Inner Loop Header: Depth=1120; GISEL-NEXT:    ands w10, w0, #0xff121; GISEL-NEXT:    b.eq LBB1_6122; GISEL-NEXT:  ; %bb.2: ; %loop.header123; GISEL-NEXT:    ; in Loop: Header=BB1_1 Depth=1124; GISEL-NEXT:    cmp w10, #32125; GISEL-NEXT:    b.eq LBB1_6126; GISEL-NEXT:  ; %bb.3: ; %loop.header127; GISEL-NEXT:    ; in Loop: Header=BB1_1 Depth=1128; GISEL-NEXT:    cmp w10, #124129; GISEL-NEXT:    b.eq LBB1_7130; GISEL-NEXT:  ; %bb.4: ; %loop.latch131; GISEL-NEXT:    ; in Loop: Header=BB1_1 Depth=1132; GISEL-NEXT:    subs w9, w9, #1133; GISEL-NEXT:    b.ne LBB1_1134; GISEL-NEXT:  ; %bb.5:135; GISEL-NEXT:    mov w8, #10 ; =0xa136; GISEL-NEXT:  LBB1_6: ; %common.ret137; GISEL-NEXT:    mov w0, w8138; GISEL-NEXT:    ret139; GISEL-NEXT:  LBB1_7: ; %e2140; GISEL-NEXT:    mov w0, #30 ; =0x1e141; GISEL-NEXT:    ret142entry:143  br label %loop.header144 145loop.header:146  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]147  switch i8 %v, label %loop.latch [148  i8 0, label %e1149  i8 32, label %e1150  i8 124, label %e2151  ]152 153loop.latch:154  %iv.next = add i32 %iv, 1155  %c = icmp eq i32 %iv.next, 100156  br i1 %c, label %e0, label %loop.header157 158e0:159  ret i32 10160 161e1:162  ret i32 20163 164e2:165  ret i32 30166}167 168define i32 @switch_with_matching_dests_0_and_pow2_3_cases_with_phi(i8 %v, i1 %c) {169; CHECK-LABEL: switch_with_matching_dests_0_and_pow2_3_cases_with_phi:170; CHECK:       ; %bb.0: ; %entry171; CHECK-NEXT:    tbz w1, #0, LBB2_8172; CHECK-NEXT:  ; %bb.1: ; %loop.header.preheader173; CHECK-NEXT:    mov w9, #100 ; =0x64174; CHECK-NEXT:    mov w8, #20 ; =0x14175; CHECK-NEXT:  LBB2_2: ; %loop.header176; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=1177; CHECK-NEXT:    ands w10, w0, #0xff178; CHECK-NEXT:    b.eq LBB2_7179; CHECK-NEXT:  ; %bb.3: ; %loop.header180; CHECK-NEXT:    ; in Loop: Header=BB2_2 Depth=1181; CHECK-NEXT:    cmp w10, #32182; CHECK-NEXT:    b.eq LBB2_7183; CHECK-NEXT:  ; %bb.4: ; %loop.header184; CHECK-NEXT:    ; in Loop: Header=BB2_2 Depth=1185; CHECK-NEXT:    cmp w10, #124186; CHECK-NEXT:    b.eq LBB2_9187; CHECK-NEXT:  ; %bb.5: ; %loop.latch188; CHECK-NEXT:    ; in Loop: Header=BB2_2 Depth=1189; CHECK-NEXT:    subs w9, w9, #1190; CHECK-NEXT:    b.ne LBB2_2191; CHECK-NEXT:  ; %bb.6:192; CHECK-NEXT:    mov w8, #10 ; =0xa193; CHECK-NEXT:  LBB2_7: ; %common.ret194; CHECK-NEXT:    mov w0, w8195; CHECK-NEXT:    ret196; CHECK-NEXT:  LBB2_8:197; CHECK-NEXT:    mov w0, wzr198; CHECK-NEXT:    ret199; CHECK-NEXT:  LBB2_9: ; %e2200; CHECK-NEXT:    mov w0, #30 ; =0x1e201; CHECK-NEXT:    ret202;203; GISEL-LABEL: switch_with_matching_dests_0_and_pow2_3_cases_with_phi:204; GISEL:       ; %bb.0: ; %entry205; GISEL-NEXT:    mov w8, wzr206; GISEL-NEXT:    tbz w1, #0, LBB2_7207; GISEL-NEXT:  ; %bb.1: ; %loop.header.preheader208; GISEL-NEXT:    mov w9, #100 ; =0x64209; GISEL-NEXT:    mov w8, #20 ; =0x14210; GISEL-NEXT:  LBB2_2: ; %loop.header211; GISEL-NEXT:    ; =>This Inner Loop Header: Depth=1212; GISEL-NEXT:    ands w10, w0, #0xff213; GISEL-NEXT:    b.eq LBB2_7214; GISEL-NEXT:  ; %bb.3: ; %loop.header215; GISEL-NEXT:    ; in Loop: Header=BB2_2 Depth=1216; GISEL-NEXT:    cmp w10, #32217; GISEL-NEXT:    b.eq LBB2_7218; GISEL-NEXT:  ; %bb.4: ; %loop.header219; GISEL-NEXT:    ; in Loop: Header=BB2_2 Depth=1220; GISEL-NEXT:    cmp w10, #124221; GISEL-NEXT:    b.eq LBB2_8222; GISEL-NEXT:  ; %bb.5: ; %loop.latch223; GISEL-NEXT:    ; in Loop: Header=BB2_2 Depth=1224; GISEL-NEXT:    subs w9, w9, #1225; GISEL-NEXT:    b.ne LBB2_2226; GISEL-NEXT:  ; %bb.6:227; GISEL-NEXT:    mov w8, #10 ; =0xa228; GISEL-NEXT:  LBB2_7: ; %common.ret229; GISEL-NEXT:    mov w0, w8230; GISEL-NEXT:    ret231; GISEL-NEXT:  LBB2_8: ; %e2232; GISEL-NEXT:    mov w0, #30 ; =0x1e233; GISEL-NEXT:    ret234entry:235  br i1 %c, label %then, label %e1236 237then:238  br label %loop.header239 240loop.header:241  %iv = phi i32 [ 0, %then], [ %iv.next, %loop.latch ]242  switch i8 %v, label %loop.latch [243  i8 32, label %e1244  i8 0, label %e1245  i8 124, label %e2246  ]247 248loop.latch:249  %iv.next = add i32 %iv, 1250  %ec = icmp eq i32 %iv.next, 100251  br i1 %ec, label %e0, label %loop.header252 253e0:254  ret i32 10255 256e1:257  %p = phi i32 [ 0, %entry ], [ 20, %loop.header ], [ 20, %loop.header ]258  ret i32 %p259 260e2:261  ret i32 30262}263 264define i32 @switch_with_matching_dests_0_and_pow2_3_cases_all_different_succs(i8 %v) {265; CHECK-LABEL: switch_with_matching_dests_0_and_pow2_3_cases_all_different_succs:266; CHECK:       ; %bb.0: ; %entry267; CHECK-NEXT:    mov w8, #100 ; =0x64268; CHECK-NEXT:  LBB3_1: ; %loop.header269; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=1270; CHECK-NEXT:    ands w9, w0, #0xff271; CHECK-NEXT:    b.eq LBB3_6272; CHECK-NEXT:  ; %bb.2: ; %loop.header273; CHECK-NEXT:    ; in Loop: Header=BB3_1 Depth=1274; CHECK-NEXT:    cmp w9, #32275; CHECK-NEXT:    b.eq LBB3_8276; CHECK-NEXT:  ; %bb.3: ; %loop.header277; CHECK-NEXT:    ; in Loop: Header=BB3_1 Depth=1278; CHECK-NEXT:    cmp w9, #124279; CHECK-NEXT:    b.eq LBB3_7280; CHECK-NEXT:  ; %bb.4: ; %loop.latch281; CHECK-NEXT:    ; in Loop: Header=BB3_1 Depth=1282; CHECK-NEXT:    subs w8, w8, #1283; CHECK-NEXT:    b.ne LBB3_1284; CHECK-NEXT:  ; %bb.5:285; CHECK-NEXT:    mov w0, #10 ; =0xa286; CHECK-NEXT:    ret287; CHECK-NEXT:  LBB3_6: ; %e2288; CHECK-NEXT:    mov w0, #30 ; =0x1e289; CHECK-NEXT:    ret290; CHECK-NEXT:  LBB3_7: ; %e3291; CHECK-NEXT:    mov w0, #40 ; =0x28292; CHECK-NEXT:    ret293; CHECK-NEXT:  LBB3_8:294; CHECK-NEXT:    mov w0, #20 ; =0x14295; CHECK-NEXT:    ret296;297; GISEL-LABEL: switch_with_matching_dests_0_and_pow2_3_cases_all_different_succs:298; GISEL:       ; %bb.0: ; %entry299; GISEL-NEXT:    mov w8, #100 ; =0x64300; GISEL-NEXT:  LBB3_1: ; %loop.header301; GISEL-NEXT:    ; =>This Inner Loop Header: Depth=1302; GISEL-NEXT:    ands w9, w0, #0xff303; GISEL-NEXT:    b.eq LBB3_6304; GISEL-NEXT:  ; %bb.2: ; %loop.header305; GISEL-NEXT:    ; in Loop: Header=BB3_1 Depth=1306; GISEL-NEXT:    cmp w9, #32307; GISEL-NEXT:    b.eq LBB3_8308; GISEL-NEXT:  ; %bb.3: ; %loop.header309; GISEL-NEXT:    ; in Loop: Header=BB3_1 Depth=1310; GISEL-NEXT:    cmp w9, #124311; GISEL-NEXT:    b.eq LBB3_7312; GISEL-NEXT:  ; %bb.4: ; %loop.latch313; GISEL-NEXT:    ; in Loop: Header=BB3_1 Depth=1314; GISEL-NEXT:    subs w8, w8, #1315; GISEL-NEXT:    b.ne LBB3_1316; GISEL-NEXT:  ; %bb.5:317; GISEL-NEXT:    mov w0, #10 ; =0xa318; GISEL-NEXT:    ret319; GISEL-NEXT:  LBB3_6: ; %e2320; GISEL-NEXT:    mov w0, #30 ; =0x1e321; GISEL-NEXT:    ret322; GISEL-NEXT:  LBB3_7: ; %e3323; GISEL-NEXT:    mov w0, #40 ; =0x28324; GISEL-NEXT:    ret325; GISEL-NEXT:  LBB3_8:326; GISEL-NEXT:    mov w0, #20 ; =0x14327; GISEL-NEXT:    ret328entry:329  br label %loop.header330 331loop.header:332  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]333  switch i8 %v, label %loop.latch [334  i8 32, label %e1335  i8 0, label %e2336  i8 124, label %e3337  ]338 339loop.latch:340  %iv.next = add i32 %iv, 1341  %ec = icmp eq i32 %iv.next, 100342  br i1 %ec, label %e0, label %loop.header343 344e0:345  ret i32 10346 347e1:348  ret i32 20349 350e2:351  ret i32 30352 353e3:354  ret i32 40355}356 357define i32 @switch_in_loop_with_matching_dests_0_and_pow2_3_cases(ptr %start) {358; CHECK-LABEL: switch_in_loop_with_matching_dests_0_and_pow2_3_cases:359; CHECK:       ; %bb.0: ; %entry360; CHECK-NEXT:    add x8, x0, #1361; CHECK-NEXT:  LBB4_1: ; %loop362; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=1363; CHECK-NEXT:    ldrb w9, [x8], #1364; CHECK-NEXT:    cbz w9, LBB4_4365; CHECK-NEXT:  ; %bb.2: ; %loop366; CHECK-NEXT:    ; in Loop: Header=BB4_1 Depth=1367; CHECK-NEXT:    cmp w9, #124368; CHECK-NEXT:    b.eq LBB4_5369; CHECK-NEXT:  ; %bb.3: ; %loop370; CHECK-NEXT:    ; in Loop: Header=BB4_1 Depth=1371; CHECK-NEXT:    cmp w9, #32372; CHECK-NEXT:    b.ne LBB4_1373; CHECK-NEXT:  LBB4_4: ; %e1374; CHECK-NEXT:    mov w0, #-1 ; =0xffffffff375; CHECK-NEXT:    ret376; CHECK-NEXT:  LBB4_5: ; %e2.loopexit377; CHECK-NEXT:    mov w0, wzr378; CHECK-NEXT:    ret379;380; GISEL-LABEL: switch_in_loop_with_matching_dests_0_and_pow2_3_cases:381; GISEL:       ; %bb.0: ; %entry382; GISEL-NEXT:    add x8, x0, #1383; GISEL-NEXT:  LBB4_1: ; %loop384; GISEL-NEXT:    ; =>This Inner Loop Header: Depth=1385; GISEL-NEXT:    ldrb w9, [x8], #1386; GISEL-NEXT:    cbz w9, LBB4_4387; GISEL-NEXT:  ; %bb.2: ; %loop388; GISEL-NEXT:    ; in Loop: Header=BB4_1 Depth=1389; GISEL-NEXT:    cmp w9, #124390; GISEL-NEXT:    b.eq LBB4_5391; GISEL-NEXT:  ; %bb.3: ; %loop392; GISEL-NEXT:    ; in Loop: Header=BB4_1 Depth=1393; GISEL-NEXT:    cmp w9, #32394; GISEL-NEXT:    b.ne LBB4_1395; GISEL-NEXT:  LBB4_4: ; %e1396; GISEL-NEXT:    mov w0, #-1 ; =0xffffffff397; GISEL-NEXT:    ret398; GISEL-NEXT:  LBB4_5: ; %e2.loopexit399; GISEL-NEXT:    mov w0, wzr400; GISEL-NEXT:    ret401entry:402  br label %loop403 404loop:405  %p = phi ptr [ %start, %entry ], [ %4, %loop ]406  %4 = getelementptr inbounds nuw i8, ptr %p, i64 1407  %l = load i8, ptr %4, align 1408  switch i8 %l, label %loop [409  i8 32, label %e1410  i8 0, label %e1411  i8 124, label %e2412  ]413 414e1:415  br label %e2416 417e2:418  %8 = phi i32 [ -1, %e1 ], [ 0, %loop ]419  ret i32 %8420}421 422define i32 @switch_in_loop_with_matching_dests_0_and_pow2_4_cases(ptr %start) {423; CHECK-LABEL: switch_in_loop_with_matching_dests_0_and_pow2_4_cases:424; CHECK:       ; %bb.0: ; %entry425; CHECK-NEXT:    mov x10, #32769 ; =0x8001426; CHECK-NEXT:    mov w8, #1 ; =0x1427; CHECK-NEXT:    add x9, x0, #1428; CHECK-NEXT:    movk x10, #1, lsl #32429; CHECK-NEXT:    b LBB5_2430; CHECK-NEXT:  LBB5_1: ; %loop431; CHECK-NEXT:    ; in Loop: Header=BB5_2 Depth=1432; CHECK-NEXT:    cmp w11, #124433; CHECK-NEXT:    b.eq LBB5_5434; CHECK-NEXT:  LBB5_2: ; %loop435; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=1436; CHECK-NEXT:    ldrb w11, [x9], #1437; CHECK-NEXT:    cmp w11, #32438; CHECK-NEXT:    b.hi LBB5_1439; CHECK-NEXT:  ; %bb.3: ; %loop440; CHECK-NEXT:    ; in Loop: Header=BB5_2 Depth=1441; CHECK-NEXT:    lsl x12, x8, x11442; CHECK-NEXT:    tst x12, x10443; CHECK-NEXT:    b.eq LBB5_1444; CHECK-NEXT:  ; %bb.4: ; %e1445; CHECK-NEXT:    mov w0, #-1 ; =0xffffffff446; CHECK-NEXT:    ret447; CHECK-NEXT:  LBB5_5: ; %e2.loopexit448; CHECK-NEXT:    mov w0, wzr449; CHECK-NEXT:    ret450;451; GISEL-LABEL: switch_in_loop_with_matching_dests_0_and_pow2_4_cases:452; GISEL:       ; %bb.0: ; %entry453; GISEL-NEXT:    mov x10, #32769 ; =0x8001454; GISEL-NEXT:    mov w8, #1 ; =0x1455; GISEL-NEXT:    add x9, x0, #1456; GISEL-NEXT:    movk x10, #1, lsl #32457; GISEL-NEXT:    b LBB5_2458; GISEL-NEXT:  LBB5_1: ; %loop459; GISEL-NEXT:    ; in Loop: Header=BB5_2 Depth=1460; GISEL-NEXT:    cmp w11, #124461; GISEL-NEXT:    b.eq LBB5_5462; GISEL-NEXT:  LBB5_2: ; %loop463; GISEL-NEXT:    ; =>This Inner Loop Header: Depth=1464; GISEL-NEXT:    ldrb w11, [x9], #1465; GISEL-NEXT:    cmp w11, #32466; GISEL-NEXT:    b.hi LBB5_1467; GISEL-NEXT:  ; %bb.3: ; %loop468; GISEL-NEXT:    ; in Loop: Header=BB5_2 Depth=1469; GISEL-NEXT:    lsl x12, x8, x11470; GISEL-NEXT:    tst x12, x10471; GISEL-NEXT:    b.eq LBB5_1472; GISEL-NEXT:  ; %bb.4: ; %e1473; GISEL-NEXT:    mov w0, #-1 ; =0xffffffff474; GISEL-NEXT:    ret475; GISEL-NEXT:  LBB5_5: ; %e2.loopexit476; GISEL-NEXT:    mov w0, wzr477; GISEL-NEXT:    ret478entry:479  br label %loop480 481loop:482  %p = phi ptr [ %start, %entry ], [ %4, %loop ]483  %4 = getelementptr inbounds nuw i8, ptr %p, i64 1484  %l = load i8, ptr %4, align 1485  switch i8 %l, label %loop [486  i8 0, label %e1487  i8 15, label %e1488  i8 32, label %e1489  i8 124, label %e2490  ]491 492e1:493  br label %e2494 495e2:496  %8 = phi i32 [ -1, %e1 ], [ 0, %loop ]497  ret i32 %8498}499 500define i32 @switch_in_loop_with_matching_dests_0_and_non_pow2(ptr %start) {501; CHECK-LABEL: switch_in_loop_with_matching_dests_0_and_non_pow2:502; CHECK:       ; %bb.0: ; %entry503; CHECK-NEXT:    add x8, x0, #1504; CHECK-NEXT:  LBB6_1: ; %loop505; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=1506; CHECK-NEXT:    ldrb w9, [x8], #1507; CHECK-NEXT:    cmp w9, #35508; CHECK-NEXT:    b.eq LBB6_4509; CHECK-NEXT:  ; %bb.2: ; %loop510; CHECK-NEXT:    ; in Loop: Header=BB6_1 Depth=1511; CHECK-NEXT:    cmp w9, #33512; CHECK-NEXT:    b.eq LBB6_5513; CHECK-NEXT:  ; %bb.3: ; %loop514; CHECK-NEXT:    ; in Loop: Header=BB6_1 Depth=1515; CHECK-NEXT:    cbnz w9, LBB6_1516; CHECK-NEXT:  LBB6_4: ; %common.ret.loopexit517; CHECK-NEXT:    mov w0, #-1 ; =0xffffffff518; CHECK-NEXT:    ret519; CHECK-NEXT:  LBB6_5: ; %e2520; CHECK-NEXT:    mov w0, #10 ; =0xa521; CHECK-NEXT:    ret522;523; GISEL-LABEL: switch_in_loop_with_matching_dests_0_and_non_pow2:524; GISEL:       ; %bb.0: ; %entry525; GISEL-NEXT:    add x8, x0, #1526; GISEL-NEXT:  LBB6_1: ; %loop527; GISEL-NEXT:    ; =>This Inner Loop Header: Depth=1528; GISEL-NEXT:    ldrb w9, [x8], #1529; GISEL-NEXT:    cmp w9, #35530; GISEL-NEXT:    b.eq LBB6_4531; GISEL-NEXT:  ; %bb.2: ; %loop532; GISEL-NEXT:    ; in Loop: Header=BB6_1 Depth=1533; GISEL-NEXT:    cmp w9, #33534; GISEL-NEXT:    b.eq LBB6_5535; GISEL-NEXT:  ; %bb.3: ; %loop536; GISEL-NEXT:    ; in Loop: Header=BB6_1 Depth=1537; GISEL-NEXT:    cbnz w9, LBB6_1538; GISEL-NEXT:  LBB6_4: ; %common.ret.loopexit539; GISEL-NEXT:    mov w0, #-1 ; =0xffffffff540; GISEL-NEXT:    ret541; GISEL-NEXT:  LBB6_5: ; %e2542; GISEL-NEXT:    mov w0, #10 ; =0xa543; GISEL-NEXT:    ret544entry:545  br label %loop546 547loop:548  %p = phi ptr [ %start, %entry ], [ %4, %loop ]549  %4 = getelementptr inbounds nuw i8, ptr %p, i64 1550  %l = load i8, ptr %4, align 1551  switch i8 %l, label %loop [552  i8 0, label %e1553  i8 35, label %e1554  i8 33, label %e2555  ]556 557e1:558  ret i32 -1559 560e2:561  ret i32 10562}563 564define void @test_successor_with_loop_phi(ptr %A, ptr %B) {565; CHECK-LABEL: test_successor_with_loop_phi:566; CHECK:       ; %bb.0: ; %entry567; CHECK-NEXT:  LBB7_1: ; %loop568; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=1569; CHECK-NEXT:    ldr w8, [x0]570; CHECK-NEXT:    str wzr, [x0]571; CHECK-NEXT:    mov x0, x1572; CHECK-NEXT:    tst w8, #0xfffffffb573; CHECK-NEXT:    b.eq LBB7_1574; CHECK-NEXT:  ; %bb.2: ; %exit575; CHECK-NEXT:    ret576;577; GISEL-LABEL: test_successor_with_loop_phi:578; GISEL:       ; %bb.0: ; %entry579; GISEL-NEXT:  LBB7_1: ; %loop580; GISEL-NEXT:    ; =>This Inner Loop Header: Depth=1581; GISEL-NEXT:    ldr w8, [x0]582; GISEL-NEXT:    str wzr, [x0]583; GISEL-NEXT:    mov x0, x1584; GISEL-NEXT:    cbz w8, LBB7_1585; GISEL-NEXT:  ; %bb.2: ; %loop586; GISEL-NEXT:    ; in Loop: Header=BB7_1 Depth=1587; GISEL-NEXT:    cmp w8, #4588; GISEL-NEXT:    mov x0, x1589; GISEL-NEXT:    b.eq LBB7_1590; GISEL-NEXT:  ; %bb.3: ; %exit591; GISEL-NEXT:    ret592entry:593  br label %loop594 595loop:596  %p = phi ptr [ %A, %entry ], [ %B , %loop ], [ %B, %loop ]597  %l = load i32, ptr %p598  store i32 0, ptr %p599  switch i32 %l, label %exit [600  i32 4, label %loop601  i32 0, label %loop602  ]603 604exit:605  ret void606}607 608define i64 @consecutive_match_both(ptr %p, i32 %param) {609; CHECK-LABEL: consecutive_match_both:610; CHECK:       ; %bb.0: ; %entry611; CHECK-NEXT:    mov w8, #1 ; =0x1612; CHECK-NEXT:    mov w9, #100 ; =0x64613; CHECK-NEXT:    mov w10, #249 ; =0xf9614; CHECK-NEXT:    lsl w8, w8, w1615; CHECK-NEXT:    b LBB8_2616; CHECK-NEXT:  LBB8_1: ; %loop.latch617; CHECK-NEXT:    ; in Loop: Header=BB8_2 Depth=1618; CHECK-NEXT:    subs w9, w9, #1619; CHECK-NEXT:    b.eq LBB8_5620; CHECK-NEXT:  LBB8_2: ; %loop.header621; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=1622; CHECK-NEXT:    cmp w1, #7623; CHECK-NEXT:    b.hi LBB8_1624; CHECK-NEXT:  ; %bb.3: ; %loop.header625; CHECK-NEXT:    ; in Loop: Header=BB8_2 Depth=1626; CHECK-NEXT:    tst w8, w10627; CHECK-NEXT:    b.eq LBB8_1628; CHECK-NEXT:  ; %bb.4: ; %e0629; CHECK-NEXT:    mov x0, xzr630; CHECK-NEXT:    ret631; CHECK-NEXT:  LBB8_5:632; CHECK-NEXT:    mov x0, #-42 ; =0xffffffffffffffd6633; CHECK-NEXT:    ret634;635; GISEL-LABEL: consecutive_match_both:636; GISEL:       ; %bb.0: ; %entry637; GISEL-NEXT:    mov w8, #1 ; =0x1638; GISEL-NEXT:    mov w9, #100 ; =0x64639; GISEL-NEXT:    mov w10, #249 ; =0xf9640; GISEL-NEXT:    lsl w8, w8, w1641; GISEL-NEXT:    b LBB8_2642; GISEL-NEXT:  LBB8_1: ; %loop.latch643; GISEL-NEXT:    ; in Loop: Header=BB8_2 Depth=1644; GISEL-NEXT:    subs w9, w9, #1645; GISEL-NEXT:    b.eq LBB8_5646; GISEL-NEXT:  LBB8_2: ; %loop.header647; GISEL-NEXT:    ; =>This Inner Loop Header: Depth=1648; GISEL-NEXT:    cmp w1, #7649; GISEL-NEXT:    b.hi LBB8_1650; GISEL-NEXT:  ; %bb.3: ; %loop.header651; GISEL-NEXT:    ; in Loop: Header=BB8_2 Depth=1652; GISEL-NEXT:    tst w8, w10653; GISEL-NEXT:    b.eq LBB8_1654; GISEL-NEXT:  ; %bb.4: ; %e0655; GISEL-NEXT:    mov x0, xzr656; GISEL-NEXT:    ret657; GISEL-NEXT:  LBB8_5:658; GISEL-NEXT:    mov x0, #-42 ; =0xffffffffffffffd6659; GISEL-NEXT:    ret660entry:661  br label %loop.header662 663loop.header:664  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]665  switch i32 %param, label %loop.latch [666  i32 7, label %e0667  i32 6, label %e0668  i32 5, label %e0669  i32 4, label %e0670  i32 3, label %e0671  i32 0, label %e0672  ]673 674loop.latch:675  %iv.next = add i32 %iv, 1676  %ec = icmp eq i32 %iv.next, 100677  br i1 %ec, label %e1, label %loop.header678 679e0:680  %m = getelementptr i8, ptr %p, i64 20681  br label %e1682 683e1:684  %res = phi i64 [ 0, %e0 ], [ -42, %loop.latch ]685  ret i64 %res686}687 688define i64 @consecutive_match_before(ptr %p, i32 %param) {689; CHECK-LABEL: consecutive_match_before:690; CHECK:       ; %bb.0: ; %entry691; CHECK-NEXT:    mov w8, #1 ; =0x1692; CHECK-NEXT:    mov w9, #100 ; =0x64693; CHECK-NEXT:    mov w10, #25 ; =0x19694; CHECK-NEXT:    lsl w8, w8, w1695; CHECK-NEXT:    b LBB9_2696; CHECK-NEXT:  LBB9_1: ; %loop.latch697; CHECK-NEXT:    ; in Loop: Header=BB9_2 Depth=1698; CHECK-NEXT:    subs w9, w9, #1699; CHECK-NEXT:    b.eq LBB9_5700; CHECK-NEXT:  LBB9_2: ; %loop.header701; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=1702; CHECK-NEXT:    cmp w1, #4703; CHECK-NEXT:    b.hi LBB9_1704; CHECK-NEXT:  ; %bb.3: ; %loop.header705; CHECK-NEXT:    ; in Loop: Header=BB9_2 Depth=1706; CHECK-NEXT:    tst w8, w10707; CHECK-NEXT:    b.eq LBB9_1708; CHECK-NEXT:  ; %bb.4: ; %e0709; CHECK-NEXT:    mov x0, xzr710; CHECK-NEXT:    ret711; CHECK-NEXT:  LBB9_5:712; CHECK-NEXT:    mov x0, #-42 ; =0xffffffffffffffd6713; CHECK-NEXT:    ret714;715; GISEL-LABEL: consecutive_match_before:716; GISEL:       ; %bb.0: ; %entry717; GISEL-NEXT:    mov w8, #1 ; =0x1718; GISEL-NEXT:    mov w9, #100 ; =0x64719; GISEL-NEXT:    mov w10, #25 ; =0x19720; GISEL-NEXT:    lsl w8, w8, w1721; GISEL-NEXT:    b LBB9_2722; GISEL-NEXT:  LBB9_1: ; %loop.latch723; GISEL-NEXT:    ; in Loop: Header=BB9_2 Depth=1724; GISEL-NEXT:    subs w9, w9, #1725; GISEL-NEXT:    b.eq LBB9_5726; GISEL-NEXT:  LBB9_2: ; %loop.header727; GISEL-NEXT:    ; =>This Inner Loop Header: Depth=1728; GISEL-NEXT:    cmp w1, #4729; GISEL-NEXT:    b.hi LBB9_1730; GISEL-NEXT:  ; %bb.3: ; %loop.header731; GISEL-NEXT:    ; in Loop: Header=BB9_2 Depth=1732; GISEL-NEXT:    tst w8, w10733; GISEL-NEXT:    b.eq LBB9_1734; GISEL-NEXT:  ; %bb.4: ; %e0735; GISEL-NEXT:    mov x0, xzr736; GISEL-NEXT:    ret737; GISEL-NEXT:  LBB9_5:738; GISEL-NEXT:    mov x0, #-42 ; =0xffffffffffffffd6739; GISEL-NEXT:    ret740entry:741  br label %loop.header742 743loop.header:744  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]745  switch i32 %param, label %loop.latch [746  i32 4, label %e0747  i32 3, label %e0748  i32 0, label %e0749  ]750 751loop.latch:752  %iv.next = add i32 %iv, 1753  %ec = icmp eq i32 %iv.next, 100754  br i1 %ec, label %e1, label %loop.header755 756e0:757  %m = getelementptr i8, ptr %p, i64 20758  br label %e1759 760e1:761  %res = phi i64 [ 0, %e0 ], [ -42, %loop.latch ]762  ret i64 %res763}764 765define i64 @consecutive_match_after(ptr %p, i32 %param) {766; CHECK-LABEL: consecutive_match_after:767; CHECK:       ; %bb.0: ; %entry768; CHECK-NEXT:    mov w8, #1 ; =0x1769; CHECK-NEXT:    mov w9, #100 ; =0x64770; CHECK-NEXT:    mov w10, #49 ; =0x31771; CHECK-NEXT:    lsl w8, w8, w1772; CHECK-NEXT:    b LBB10_2773; CHECK-NEXT:  LBB10_1: ; %loop.latch774; CHECK-NEXT:    ; in Loop: Header=BB10_2 Depth=1775; CHECK-NEXT:    subs w9, w9, #1776; CHECK-NEXT:    b.eq LBB10_5777; CHECK-NEXT:  LBB10_2: ; %loop.header778; CHECK-NEXT:    ; =>This Inner Loop Header: Depth=1779; CHECK-NEXT:    cmp w1, #5780; CHECK-NEXT:    b.hi LBB10_1781; CHECK-NEXT:  ; %bb.3: ; %loop.header782; CHECK-NEXT:    ; in Loop: Header=BB10_2 Depth=1783; CHECK-NEXT:    tst w8, w10784; CHECK-NEXT:    b.eq LBB10_1785; CHECK-NEXT:  ; %bb.4: ; %e0786; CHECK-NEXT:    mov x0, xzr787; CHECK-NEXT:    ret788; CHECK-NEXT:  LBB10_5:789; CHECK-NEXT:    mov x0, #-42 ; =0xffffffffffffffd6790; CHECK-NEXT:    ret791;792; GISEL-LABEL: consecutive_match_after:793; GISEL:       ; %bb.0: ; %entry794; GISEL-NEXT:    mov w8, #1 ; =0x1795; GISEL-NEXT:    mov w9, #100 ; =0x64796; GISEL-NEXT:    mov w10, #49 ; =0x31797; GISEL-NEXT:    lsl w8, w8, w1798; GISEL-NEXT:    b LBB10_2799; GISEL-NEXT:  LBB10_1: ; %loop.latch800; GISEL-NEXT:    ; in Loop: Header=BB10_2 Depth=1801; GISEL-NEXT:    subs w9, w9, #1802; GISEL-NEXT:    b.eq LBB10_5803; GISEL-NEXT:  LBB10_2: ; %loop.header804; GISEL-NEXT:    ; =>This Inner Loop Header: Depth=1805; GISEL-NEXT:    cmp w1, #5806; GISEL-NEXT:    b.hi LBB10_1807; GISEL-NEXT:  ; %bb.3: ; %loop.header808; GISEL-NEXT:    ; in Loop: Header=BB10_2 Depth=1809; GISEL-NEXT:    tst w8, w10810; GISEL-NEXT:    b.eq LBB10_1811; GISEL-NEXT:  ; %bb.4: ; %e0812; GISEL-NEXT:    mov x0, xzr813; GISEL-NEXT:    ret814; GISEL-NEXT:  LBB10_5:815; GISEL-NEXT:    mov x0, #-42 ; =0xffffffffffffffd6816; GISEL-NEXT:    ret817entry:818  br label %loop.header819 820loop.header:821  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]822  switch i32 %param, label %loop.latch [823  i32 5, label %e0824  i32 4, label %e0825  i32 0, label %e0826  ]827 828loop.latch:829  %iv.next = add i32 %iv, 1830  %ec = icmp eq i32 %iv.next, 100831  br i1 %ec, label %e1, label %loop.header832 833e0:834  %m = getelementptr i8, ptr %p, i64 20835  br label %e1836 837e1:838  %res = phi i64 [ 0, %e0 ], [ -42, %loop.latch ]839  ret i64 %res840}841 842define void @merge_with_stores(ptr %A, i16 %v) {843; CHECK-LABEL: merge_with_stores:844; CHECK:       ; %bb.0: ; %entry845; CHECK-NEXT:    and w8, w1, #0xffff846; CHECK-NEXT:    sub w9, w8, #10847; CHECK-NEXT:    cmp w9, #2848; CHECK-NEXT:    b.lo LBB11_4849; CHECK-NEXT:  ; %bb.1: ; %entry850; CHECK-NEXT:    cbz w8, LBB11_5851; CHECK-NEXT:  ; %bb.2: ; %entry852; CHECK-NEXT:    cmp w8, #2853; CHECK-NEXT:    b.eq LBB11_5854; CHECK-NEXT:  ; %bb.3: ; %default.dst855; CHECK-NEXT:    strh wzr, [x0]856; CHECK-NEXT:    ret857; CHECK-NEXT:  LBB11_4: ; %other.dst858; CHECK-NEXT:    mov w8, #1 ; =0x1859; CHECK-NEXT:    strh w8, [x0, #36]860; CHECK-NEXT:  LBB11_5: ; %pow2.dst861; CHECK-NEXT:    ret862;863; GISEL-LABEL: merge_with_stores:864; GISEL:       ; %bb.0: ; %entry865; GISEL-NEXT:    and w8, w1, #0xffff866; GISEL-NEXT:    sub w9, w8, #10867; GISEL-NEXT:    cmp w9, #1868; GISEL-NEXT:    b.ls LBB11_4869; GISEL-NEXT:  ; %bb.1: ; %entry870; GISEL-NEXT:    cbz w8, LBB11_5871; GISEL-NEXT:  ; %bb.2: ; %entry872; GISEL-NEXT:    cmp w8, #2873; GISEL-NEXT:    b.eq LBB11_5874; GISEL-NEXT:  ; %bb.3: ; %default.dst875; GISEL-NEXT:    strh wzr, [x0]876; GISEL-NEXT:    ret877; GISEL-NEXT:  LBB11_4: ; %other.dst878; GISEL-NEXT:    mov w8, #1 ; =0x1879; GISEL-NEXT:    strh w8, [x0, #36]880; GISEL-NEXT:  LBB11_5: ; %pow2.dst881; GISEL-NEXT:    ret882entry:883  switch i16 %v, label %default.dst [884    i16 10, label %other.dst885    i16 0, label %pow2.dst886    i16 2, label %pow2.dst887    i16 11, label %other.dst888  ]889 890default.dst:891  store i16 0, ptr %A, align 8892  br label %pow2.dst893 894other.dst:895  %gep = getelementptr i8, ptr %A, i64 36896  store i16 1, ptr %gep, align 8897  br label %pow2.dst898 899pow2.dst:900  ret void901}902 903define void @switch_large_enough_for_clustering(i32 %x, ptr %dst) {904; CHECK-LABEL: switch_large_enough_for_clustering:905; CHECK:       ; %bb.0: ; %entry906; CHECK-NEXT:    cmp w0, #1907; CHECK-NEXT:    b.le LBB12_5908; CHECK-NEXT:  ; %bb.1: ; %entry909; CHECK-NEXT:    cmp w0, #7910; CHECK-NEXT:    b.eq LBB12_9911; CHECK-NEXT:  ; %bb.2: ; %entry912; CHECK-NEXT:    cmp w0, #4913; CHECK-NEXT:    b.eq LBB12_7914; CHECK-NEXT:  ; %bb.3: ; %entry915; CHECK-NEXT:    cmp w0, #2916; CHECK-NEXT:    b.eq LBB12_8917; CHECK-NEXT:  LBB12_4: ; %exit918; CHECK-NEXT:    ret919; CHECK-NEXT:  LBB12_5: ; %entry920; CHECK-NEXT:    cbz w0, LBB12_8921; CHECK-NEXT:  ; %bb.6: ; %entry922; CHECK-NEXT:    cmp w0, #1923; CHECK-NEXT:    b.ne LBB12_4924; CHECK-NEXT:  LBB12_7: ; %succ.2925; CHECK-NEXT:    str wzr, [x1]926; CHECK-NEXT:    ret927; CHECK-NEXT:  LBB12_8: ; %succ.1928; CHECK-NEXT:    strb wzr, [x1]929; CHECK-NEXT:    ret930; CHECK-NEXT:  LBB12_9: ; %succ.3931; CHECK-NEXT:    strh wzr, [x1]932; CHECK-NEXT:    ret933;934; GISEL-LABEL: switch_large_enough_for_clustering:935; GISEL:       ; %bb.0: ; %entry936; GISEL-NEXT:    cmp w0, #2937; GISEL-NEXT:    b.lt LBB12_5938; GISEL-NEXT:  ; %bb.1: ; %entry939; GISEL-NEXT:    cmp w0, #7940; GISEL-NEXT:    b.eq LBB12_9941; GISEL-NEXT:  ; %bb.2: ; %entry942; GISEL-NEXT:    cmp w0, #4943; GISEL-NEXT:    b.eq LBB12_7944; GISEL-NEXT:  ; %bb.3: ; %entry945; GISEL-NEXT:    cmp w0, #2946; GISEL-NEXT:    b.eq LBB12_8947; GISEL-NEXT:  LBB12_4: ; %exit948; GISEL-NEXT:    ret949; GISEL-NEXT:  LBB12_5: ; %entry950; GISEL-NEXT:    cbz w0, LBB12_8951; GISEL-NEXT:  ; %bb.6: ; %entry952; GISEL-NEXT:    cmp w0, #1953; GISEL-NEXT:    b.ne LBB12_4954; GISEL-NEXT:  LBB12_7: ; %succ.2955; GISEL-NEXT:    str wzr, [x1]956; GISEL-NEXT:    ret957; GISEL-NEXT:  LBB12_8: ; %succ.1958; GISEL-NEXT:    strb wzr, [x1]959; GISEL-NEXT:    ret960; GISEL-NEXT:  LBB12_9: ; %succ.3961; GISEL-NEXT:    strh wzr, [x1]962; GISEL-NEXT:    ret963entry:964  switch i32 %x, label %exit [965    i32 0, label %succ.1966    i32 2, label %succ.1967    i32 1, label %succ.2968    i32 4, label %succ.2969    i32 7, label %succ.3970  ]971 972succ.1:973  store i8 0, ptr %dst974  br label %exit975 976succ.2:977  call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 4, i1 false)978  br label %exit979 980succ.3:981  call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 2, i1 false)982  br label %exit983 984exit:985  ret void986}987 988declare void @llvm.memset.p0.i64(ptr writeonly captures(none), i8, i64, i1 immarg)989