Files
clang-p2996/llvm/test/CodeGen/SPIRV/branching/OpSwitchEmpty.ll
Michal Paszkowski 8bfb2b6d77 [SPIR-V] Remove switch G_ICMP+G_BRCOND+G_BR before ISel
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
2023-04-04 23:50:07 +02:00

25 lines
613 B
LLVM

;; Source:
;; void kk(int x){
;; switch(x) {
;; default: return;
;; }
;; }
;; Command:
;; clang -cc1 -triple spir -emit-llvm -o test/SPIRV/OpSwitchEmpty.ll OpSwitchEmpty.cl -disable-llvm-passes
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
; CHECK-SPIRV: %[[#X:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV: OpSwitch %[[#X]] %[[#DEFAULT:]]{{$}}
; CHECK-SPIRV: %[[#DEFAULT]] = OpLabel
define spir_func void @kk(i32 %x) {
entry:
switch i32 %x, label %sw.default [
]
sw.default: ; preds = %entry
ret void
}