xref: /aosp_15_r20/external/llvm/test/Transforms/StructurizeCFG/switch.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -S -structurizecfg %s -o - | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; The structurizecfg pass cannot handle switch instructions, so we need to
4*9880d681SAndroid Build Coastguard Worker; make sure the lower switch pass is always run before structurizecfg.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @switch
7*9880d681SAndroid Build Coastguard Workerdefine void @switch(i32 addrspace(1)* %out, i32 %cond) nounwind {
8*9880d681SAndroid Build Coastguard Workerentry:
9*9880d681SAndroid Build Coastguard Worker; CHECK: icmp
10*9880d681SAndroid Build Coastguard Worker  switch i32 %cond, label %done [ i32 0, label %zero]
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker; CHECK: zero:
13*9880d681SAndroid Build Coastguard Workerzero:
14*9880d681SAndroid Build Coastguard Worker; CHECK: store i32 7, i32 addrspace(1)* %out
15*9880d681SAndroid Build Coastguard Worker  store i32 7, i32 addrspace(1)* %out
16*9880d681SAndroid Build Coastguard Worker; CHECK: br label %done
17*9880d681SAndroid Build Coastguard Worker  br label %done
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; CHECK: done:
20*9880d681SAndroid Build Coastguard Workerdone:
21*9880d681SAndroid Build Coastguard Worker; CHECK: ret void
22*9880d681SAndroid Build Coastguard Worker  ret void
23*9880d681SAndroid Build Coastguard Worker}
24