1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt %s -passes=instcombine -S | FileCheck %s
4 define i1 @test_switch_with_zext(i16 %a, i1 %b, i1 %c) {
5 ; CHECK-LABEL: define i1 @test_switch_with_zext(
6 ; CHECK-SAME: i16 [[A:%.*]], i1 [[B:%.*]], i1 [[C:%.*]]) {
8 ; CHECK-NEXT: switch i16 [[A]], label [[SW_DEFAULT:%.*]] [
9 ; CHECK-NEXT: i16 37, label [[SW_BB:%.*]]
10 ; CHECK-NEXT: i16 38, label [[SW_BB]]
11 ; CHECK-NEXT: i16 39, label [[SW_BB]]
14 ; CHECK-NEXT: ret i1 [[B]]
16 ; CHECK-NEXT: ret i1 [[C]]
19 %a.ext = zext i16 %a to i32
20 switch i32 %a.ext, label %sw.default [
32 define i1 @test_switch_with_sext(i16 %a, i1 %b, i1 %c) {
33 ; CHECK-LABEL: define i1 @test_switch_with_sext(
34 ; CHECK-SAME: i16 [[A:%.*]], i1 [[B:%.*]], i1 [[C:%.*]]) {
36 ; CHECK-NEXT: switch i16 [[A]], label [[SW_DEFAULT:%.*]] [
37 ; CHECK-NEXT: i16 37, label [[SW_BB:%.*]]
38 ; CHECK-NEXT: i16 38, label [[SW_BB]]
39 ; CHECK-NEXT: i16 39, label [[SW_BB]]
42 ; CHECK-NEXT: ret i1 [[B]]
44 ; CHECK-NEXT: ret i1 [[C]]
47 %a.ext = sext i16 %a to i32
48 switch i32 %a.ext, label %sw.default [
62 define i1 @test_switch_with_zext_unreachable_case(i16 %a, i1 %b, i1 %c) {
63 ; CHECK-LABEL: define i1 @test_switch_with_zext_unreachable_case(
64 ; CHECK-SAME: i16 [[A:%.*]], i1 [[B:%.*]], i1 [[C:%.*]]) {
66 ; CHECK-NEXT: [[A_EXT:%.*]] = zext i16 [[A]] to i32
67 ; CHECK-NEXT: switch i32 [[A_EXT]], label [[SW_DEFAULT:%.*]] [
68 ; CHECK-NEXT: i32 37, label [[SW_BB:%.*]]
69 ; CHECK-NEXT: i32 38, label [[SW_BB]]
70 ; CHECK-NEXT: i32 39, label [[SW_BB]]
71 ; CHECK-NEXT: i32 65537, label [[SW_BB]]
74 ; CHECK-NEXT: ret i1 [[B]]
76 ; CHECK-NEXT: ret i1 [[C]]
79 %a.ext = zext i16 %a to i32
80 switch i32 %a.ext, label %sw.default [
84 i32 65537, label %sw.bb
93 define i1 @test_switch_with_sext_unreachable_case(i16 %a, i1 %b, i1 %c) {
94 ; CHECK-LABEL: define i1 @test_switch_with_sext_unreachable_case(
95 ; CHECK-SAME: i16 [[A:%.*]], i1 [[B:%.*]], i1 [[C:%.*]]) {
97 ; CHECK-NEXT: [[A_EXT:%.*]] = sext i16 [[A]] to i32
98 ; CHECK-NEXT: switch i32 [[A_EXT]], label [[SW_DEFAULT:%.*]] [
99 ; CHECK-NEXT: i32 37, label [[SW_BB:%.*]]
100 ; CHECK-NEXT: i32 38, label [[SW_BB]]
101 ; CHECK-NEXT: i32 39, label [[SW_BB]]
102 ; CHECK-NEXT: i32 -65537, label [[SW_BB]]
105 ; CHECK-NEXT: ret i1 [[B]]
107 ; CHECK-NEXT: ret i1 [[C]]
110 %a.ext = sext i16 %a to i32
111 switch i32 %a.ext, label %sw.default [
115 i32 -65537, label %sw.bb