1 ;; AArch64 is arbitralily chosen as a 32/64-bit RISC representative to show the transform in all tests.
3 ; RUN: opt < %s -codegenprepare -S -mtriple=aarch64-unknown-unknown | FileCheck %s --check-prefix=ARM64
5 ; AArch64 widens to 32-bit.
7 define i32 @widen_switch_i16(i32 %a) {
9 %trunc = trunc i32 %a to i16
10 switch i16 %trunc, label %sw.default [
25 %retval = phi i32 [ -1, %sw.default ], [ 0, %sw.bb0 ], [ 1, %sw.bb1 ]
28 ; ARM64-LABEL: @widen_switch_i16(
29 ; ARM64: %0 = zext i16 %trunc to i32
30 ; ARM64-NEXT: switch i32 %0, label %sw.default [
31 ; ARM64-NEXT: i32 1, label %sw.bb0
32 ; ARM64-NEXT: i32 65535, label %sw.bb1
35 ; Widen to 32-bit from a smaller, non-native type.
37 define i32 @widen_switch_i17(i32 %a) {
39 %trunc = trunc i32 %a to i17
40 switch i17 %trunc, label %sw.default [
55 %retval = phi i32 [ -1, %sw.default ], [ 0, %sw.bb0 ], [ 1, %sw.bb1 ]
58 ; ARM64-LABEL: @widen_switch_i17(
59 ; ARM64: %0 = zext i17 %trunc to i32
60 ; ARM64-NEXT: switch i32 %0, label %sw.default [
61 ; ARM64-NEXT: i32 10, label %sw.bb0
62 ; ARM64-NEXT: i32 131071, label %sw.bb1
65 ; If the switch condition is a sign-extended function argument, then the
66 ; condition and cases should be sign-extended rather than zero-extended
67 ; because the sign-extension can be optimized away.
69 define i32 @widen_switch_i16_sext(i2 signext %a) {
71 switch i2 %a, label %sw.default [
86 %retval = phi i32 [ -1, %sw.default ], [ 0, %sw.bb0 ], [ 1, %sw.bb1 ]
89 ; ARM64-LABEL: @widen_switch_i16_sext(
90 ; ARM64: %0 = sext i2 %a to i32
91 ; ARM64-NEXT: switch i32 %0, label %sw.default [
92 ; ARM64-NEXT: i32 1, label %sw.bb0
93 ; ARM64-NEXT: i32 -1, label %sw.bb1