diff options
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r-- | llvm/test/CodeGen/AArch64/switch-unreachable-default.ll | 16 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/switch.ll | 27 |
2 files changed, 34 insertions, 9 deletions
diff --git a/llvm/test/CodeGen/AArch64/switch-unreachable-default.ll b/llvm/test/CodeGen/AArch64/switch-unreachable-default.ll index 9db3cee14e5..9acc5a150b6 100644 --- a/llvm/test/CodeGen/AArch64/switch-unreachable-default.ll +++ b/llvm/test/CodeGen/AArch64/switch-unreachable-default.ll @@ -74,17 +74,15 @@ entry: i32 64, label %bb5 ] -; The switch is lowered with a jump table for cases 1--32 and case 64 checked -; separately. Even though the default of switch is unreachable, the fall-through -; for the jump table *is* reachable so the range check must be emitted. +; The switch is lowered with a jump table for cases 1--32 and case 64 handled +; separately. Even though the default of the switch is unreachable, the +; fall-through for the jump table *is* reachable so the range check must be +; emitted. ; ; CHECK-LABEL: reachable_fallthrough -; CHECK: sub -; CHECK: cmp +; CHECK: sub [[REG:w[0-9]+]], w0, #1 +; CHECK: cmp [[REG]], #31 ; CHECK: b.hi -; -; TODO: Drop the cmp for the 64 case since its fallthrough is unreachable. - def: unreachable bb1: br label %return @@ -94,6 +92,6 @@ bb4: br label %return bb5: br label %return return: - %p = phi i32 [ 3, %bb1 ], [ 2, %bb2 ], [ 1, %bb3 ], [ 0, %bb4 ], [ 0, %bb5 ] + %p = phi i32 [ 3, %bb1 ], [ 2, %bb2 ], [ 1, %bb3 ], [ 0, %bb4 ], [ 42, %bb5 ] ret i32 %p } diff --git a/llvm/test/CodeGen/X86/switch.ll b/llvm/test/CodeGen/X86/switch.ll index a0ebc4eeba2..639b9c0eb8f 100644 --- a/llvm/test/CodeGen/X86/switch.ll +++ b/llvm/test/CodeGen/X86/switch.ll @@ -778,3 +778,30 @@ end: ; CHECK: btl ; CHECK-NOT: btl } + + +define void @range_with_unreachable_fallthrough(i32 %i) { +entry: + switch i32 %i, label %default [ + i32 1, label %bb1 + i32 2, label %bb1 + i32 3, label %bb1 + i32 4, label %bb2 + i32 5, label %bb2 + i32 6, label %bb2 + ] +bb1: tail call void @g(i32 0) br label %return +bb2: tail call void @g(i32 1) br label %return +default: unreachable + +return: + ret void + +; CHECK-LABEL: range_with_unreachable_fallthrough: +; Since the default is unreachable, either the 1--3 or the 4--6 cluster will be +; reached. Only one comparison should be emitted. +; CHECK: cmpl +; CHECK-NOT: cmpl +; CHECK: jmp g +; CHECK: jmp g +} |