1; RUN: llc -march=x86-64 -asm-verbose=false < %s | FileCheck %s 2 3; This switch should use bit tests, and the third bit test case is just 4; testing for one possible value, so it doesn't need a bt. 5 6; CHECK: movabsq $2305843009482129440, %r 7; CHECK-NEXT: btq %rax, %r 8; CHECK-NEXT: jae 9; CHECK: movl $671088640, %e 10; CHECK-NEXT: btq %rax, %r 11; CHECK-NEXT: jae 12; CHECK: testq %rax, %r 13; CHECK-NEXT: j 14 15define void @test(i8* %l) nounwind { 16entry: 17 %l.addr = alloca i8*, align 8 ; <i8**> [#uses=2] 18 store i8* %l, i8** %l.addr 19 %tmp = load i8** %l.addr ; <i8*> [#uses=1] 20 %tmp1 = load i8* %tmp ; <i8> [#uses=1] 21 %conv = sext i8 %tmp1 to i32 ; <i32> [#uses=1] 22 switch i32 %conv, label %sw.default [ 23 i32 62, label %sw.bb 24 i32 60, label %sw.bb 25 i32 38, label %sw.bb2 26 i32 94, label %sw.bb2 27 i32 61, label %sw.bb2 28 i32 33, label %sw.bb4 29 ] 30 31sw.bb: ; preds = %entry, %entry 32 call void @foo(i32 0) 33 br label %sw.epilog 34 35sw.bb2: ; preds = %entry, %entry, %entry 36 call void @foo(i32 1) 37 br label %sw.epilog 38 39sw.bb4: ; preds = %entry 40 call void @foo(i32 3) 41 br label %sw.epilog 42 43sw.default: ; preds = %entry 44 call void @foo(i32 97) 45 br label %sw.epilog 46 47sw.epilog: ; preds = %sw.default, %sw.bb4, %sw.bb2, %sw.bb 48 ret void 49} 50 51declare void @foo(i32) 52 53; Don't zero extend the test operands to pointer type if it can be avoided. 54; rdar://8781238 55define void @test2(i32 %x) nounwind ssp { 56; CHECK-LABEL: test2: 57; CHECK: cmpl $6 58; CHECK: ja 59 60; CHECK-NEXT: movl $91 61; CHECK-NOT: movl 62; CHECK-NEXT: btl 63; CHECK-NEXT: jae 64entry: 65 switch i32 %x, label %if.end [ 66 i32 6, label %if.then 67 i32 4, label %if.then 68 i32 3, label %if.then 69 i32 1, label %if.then 70 i32 0, label %if.then 71 ] 72 73if.then: ; preds = %entry, %entry, %entry, %entry, %entry 74 tail call void @bar() nounwind 75 ret void 76 77if.end: ; preds = %entry 78 ret void 79} 80 81declare void @bar() 82 83define void @test3(i32 %x) nounwind { 84; CHECK-LABEL: test3: 85; CHECK: cmpl $5 86; CHECK: ja 87; CHECK: cmpl $4 88; CHECK: je 89 switch i32 %x, label %if.end [ 90 i32 0, label %if.then 91 i32 1, label %if.then 92 i32 2, label %if.then 93 i32 3, label %if.then 94 i32 5, label %if.then 95 ] 96if.then: 97 tail call void @bar() nounwind 98 ret void 99if.end: 100 ret void 101} 102