diff --git a/llvm/test/CodeGen/X86/switch-bt.ll b/llvm/test/CodeGen/X86/switch-bt.ll --- a/llvm/test/CodeGen/X86/switch-bt.ll +++ b/llvm/test/CodeGen/X86/switch-bt.ll @@ -1,4 +1,5 @@ -; RUN: llc -mtriple=x86_64-- -asm-verbose=false < %s -jump-table-density=40 -switch-peel-threshold=101 | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=x86_64-- < %s -jump-table-density=40 -switch-peel-threshold=101 | FileCheck %s ; This switch should use bit tests, and the third bit test case is just ; testing for one possible value, so it doesn't need a bt. @@ -13,6 +14,40 @@ ; CHECK-NEXT: j define void @test(ptr %l) nounwind { +; CHECK-LABEL: test: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: pushq %rax +; CHECK-NEXT: movq %rdi, (%rsp) +; CHECK-NEXT: movsbl (%rdi), %eax +; CHECK-NEXT: addl $-33, %eax +; CHECK-NEXT: cmpl $61, %eax +; CHECK-NEXT: ja .LBB0_7 +; CHECK-NEXT: # %bb.1: # %entry +; CHECK-NEXT: movabsq $2305843009482129440, %rcx # imm = 0x2000000010000020 +; CHECK-NEXT: btq %rax, %rcx +; CHECK-NEXT: jb .LBB0_6 +; CHECK-NEXT: # %bb.2: # %entry +; CHECK-NEXT: movl $671088640, %ecx # imm = 0x28000000 +; CHECK-NEXT: btq %rax, %rcx +; CHECK-NEXT: jae .LBB0_3 +; CHECK-NEXT: # %bb.5: # %sw.bb +; CHECK-NEXT: xorl %edi, %edi +; CHECK-NEXT: jmp .LBB0_8 +; CHECK-NEXT: .LBB0_6: # %sw.bb2 +; CHECK-NEXT: movl $1, %edi +; CHECK-NEXT: jmp .LBB0_8 +; CHECK-NEXT: .LBB0_3: # %entry +; CHECK-NEXT: testq %rax, %rax +; CHECK-NEXT: jne .LBB0_7 +; CHECK-NEXT: # %bb.4: # %sw.bb4 +; CHECK-NEXT: movl $3, %edi +; CHECK-NEXT: jmp .LBB0_8 +; CHECK-NEXT: .LBB0_7: # %sw.default +; CHECK-NEXT: movl $97, %edi +; CHECK-NEXT: .LBB0_8: # %sw.epilog +; CHECK-NEXT: callq foo@PLT +; CHECK-NEXT: popq %rax +; CHECK-NEXT: retq entry: %l.addr = alloca ptr, align 8 ; [#uses=2] store ptr %l, ptr %l.addr @@ -54,13 +89,18 @@ ; rdar://8781238 define void @test2(i32 %x) nounwind ssp { ; CHECK-LABEL: test2: -; CHECK: cmpl $6 -; CHECK: ja +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: cmpl $6, %edi +; CHECK-NEXT: ja .LBB1_2 +; CHECK-NEXT: # %bb.1: # %entry +; CHECK-NEXT: movl $91, %eax +; CHECK-NEXT: btl %edi, %eax +; CHECK-NEXT: jae .LBB1_2 +; CHECK-NEXT: # %bb.3: # %if.then +; CHECK-NEXT: jmp bar@PLT # TAILCALL +; CHECK-NEXT: .LBB1_2: # %if.end +; CHECK-NEXT: retq -; CHECK-NEXT: movl $91 -; CHECK-NOT: movl -; CHECK-NEXT: btl -; CHECK-NEXT: jae entry: switch i32 %x, label %if.end [ i32 6, label %if.then @@ -82,10 +122,16 @@ define void @test3(i32 %x) nounwind { ; CHECK-LABEL: test3: -; CHECK: cmpl $5 -; CHECK: ja -; CHECK: cmpl $4 -; CHECK: je +; CHECK: # %bb.0: +; CHECK-NEXT: cmpl $5, %edi +; CHECK-NEXT: ja .LBB2_2 +; CHECK-NEXT: # %bb.1: +; CHECK-NEXT: cmpl $4, %edi +; CHECK-NEXT: je .LBB2_2 +; CHECK-NEXT: # %bb.3: # %if.then +; CHECK-NEXT: jmp bar@PLT # TAILCALL +; CHECK-NEXT: .LBB2_2: # %if.end +; CHECK-NEXT: retq switch i32 %x, label %if.end [ i32 0, label %if.then i32 1, label %if.then @@ -104,6 +150,48 @@ ; created binary tree search. See PR22262. define void @test4(i32 %x, ptr %y) { ; CHECK-LABEL: test4: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: cmpl $39, %edi +; CHECK-NEXT: jg .LBB3_5 +; CHECK-NEXT: # %bb.1: # %entry +; CHECK-NEXT: cmpl $10, %edi +; CHECK-NEXT: je .LBB3_9 +; CHECK-NEXT: # %bb.2: # %entry +; CHECK-NEXT: cmpl $20, %edi +; CHECK-NEXT: je .LBB3_10 +; CHECK-NEXT: # %bb.3: # %entry +; CHECK-NEXT: cmpl $30, %edi +; CHECK-NEXT: jne .LBB3_13 +; CHECK-NEXT: # %bb.4: # %sw.bb2 +; CHECK-NEXT: movl $3, (%rsi) +; CHECK-NEXT: retq +; CHECK-NEXT: .LBB3_5: # %entry +; CHECK-NEXT: cmpl $40, %edi +; CHECK-NEXT: je .LBB3_11 +; CHECK-NEXT: # %bb.6: # %entry +; CHECK-NEXT: cmpl $50, %edi +; CHECK-NEXT: je .LBB3_12 +; CHECK-NEXT: # %bb.7: # %entry +; CHECK-NEXT: cmpl $60, %edi +; CHECK-NEXT: jne .LBB3_13 +; CHECK-NEXT: # %bb.8: # %sw.bb5 +; CHECK-NEXT: movl $6, (%rsi) +; CHECK-NEXT: retq +; CHECK-NEXT: .LBB3_9: # %sw.bb +; CHECK-NEXT: movl $1, (%rsi) +; CHECK-NEXT: retq +; CHECK-NEXT: .LBB3_10: # %sw.bb1 +; CHECK-NEXT: movl $2, (%rsi) +; CHECK-NEXT: retq +; CHECK-NEXT: .LBB3_11: # %sw.bb3 +; CHECK-NEXT: movl $4, (%rsi) +; CHECK-NEXT: retq +; CHECK-NEXT: .LBB3_12: # %sw.bb4 +; CHECK-NEXT: movl $5, (%rsi) +; CHECK-NEXT: retq +; CHECK-NEXT: .LBB3_13: # %sw.default +; CHECK-NEXT: movl $7, (%rsi) +; CHECK-NEXT: retq entry: switch i32 %x, label %sw.default [ @@ -140,39 +228,36 @@ ; The balanced binary switch here would start with a comparison against 39, but ; it is currently starting with 29 because of the density-sum heuristic. -; CHECK: cmpl $39 -; CHECK: jg -; CHECK: cmpl $10 -; CHECK: je -; CHECK: cmpl $20 -; CHECK: je -; CHECK: cmpl $30 -; CHECK: jne -; CHECK: cmpl $40 -; CHECK: je -; CHECK: cmpl $50 -; CHECK: je -; CHECK: cmpl $60 -; CHECK: jne } ; Omit the range check when the default case is unreachable, see PR43129. declare void @g(i32) define void @test5(i32 %x) { - -; CHECK-LABEL: test5 -; CHECK-NOT: cmp +; CHECK-LABEL: test5: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: pushq %rax +; CHECK-NEXT: .cfi_def_cfa_offset 16 +; CHECK-NEXT: movl $73, %eax +; CHECK-NEXT: btl %edi, %eax +; CHECK-NEXT: jb .LBB4_3 +; CHECK-NEXT: # %bb.1: # %entry +; CHECK-NEXT: movl $146, %eax +; CHECK-NEXT: btl %edi, %eax +; CHECK-NEXT: jae .LBB4_2 +; CHECK-NEXT: # %bb.4: # %bb1 +; CHECK-NEXT: movl $1, %edi +; CHECK-NEXT: callq g@PLT +; CHECK-NEXT: .LBB4_3: # %bb0 +; CHECK-NEXT: xorl %edi, %edi +; CHECK-NEXT: callq g@PLT +; CHECK-NEXT: .LBB4_2: # %bb2 +; CHECK-NEXT: movl $2, %edi +; CHECK-NEXT: callq g@PLT ; 73 = 2^0 + 2^3 + 2^6 -; CHECK: movl $73 -; CHECK-NEXT: btl -; CHECK-NEXT: jb ; 146 = 2^1 + 2^4 + 2^7 -; CHECK-NEXT: movl $146 -; CHECK-NEXT: btl -; CHECK-NEXT: jae entry: