IRTranslator lowers switches to [G_SUB] + G_ICMP + G_BRCOND + G_BR sequences. Since values and destination MBBs are included in the spv_switch intrinsics, the sequences are not needed for ISel. Before this commit, the information decoded by these sequences were added to spv_switch intrinsics in SPIRVPreLegalizer and the sequences were kept until SPIRVModuleAnalysis where they were marked skipped for emission. After this commit, the [G_SUB] + G_ICMP + G_BRCOND + G_BR sequences and MBBs containing only these MIs are erased in SPIRVPreLegalizer. Differential Revision: https://reviews.llvm.org/D146923
21 lines
539 B
LLVM
21 lines
539 B
LLVM
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
|
|
|
|
define void @test_switch_with_unreachable_block(i1 %a) {
|
|
%value = zext i1 %a to i32
|
|
; CHECK-SPIRV: OpSwitch %[[#]] %[[#REACHABLE:]]
|
|
switch i32 %value, label %unreachable [
|
|
i32 0, label %reachable
|
|
i32 1, label %reachable
|
|
]
|
|
|
|
; CHECK-SPIRV-NEXT: %[[#REACHABLE]] = OpLabel
|
|
reachable:
|
|
; CHECK-SPIRV-NEXT: OpReturn
|
|
ret void
|
|
|
|
; CHECK-SPIRV: %[[#]] = OpLabel
|
|
; CHECK-SPIRV-NEXT: OpUnreachable
|
|
unreachable:
|
|
unreachable
|
|
}
|