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_neg(i32 %a) {
5 ; CHECK-LABEL: define i1 @test_switch_with_neg(
6 ; CHECK-SAME: i32 [[A:%.*]]) {
8 ; CHECK-NEXT: switch i32 [[A]], label [[SW_DEFAULT:%.*]] [
9 ; CHECK-NEXT: i32 -37, label [[SW_BB:%.*]]
10 ; CHECK-NEXT: i32 -38, label [[SW_BB]]
11 ; CHECK-NEXT: i32 -39, label [[SW_BB]]
14 ; CHECK-NEXT: ret i1 true
16 ; CHECK-NEXT: ret i1 false
19 %a.neg = sub i32 0, %a
20 switch i32 %a.neg, label %sw.default [
32 define i1 @test_switch_with_sub(i32 %a) {
33 ; CHECK-LABEL: define i1 @test_switch_with_sub(
34 ; CHECK-SAME: i32 [[A:%.*]]) {
36 ; CHECK-NEXT: switch i32 [[A]], label [[SW_DEFAULT:%.*]] [
37 ; CHECK-NEXT: i32 0, label [[SW_BB:%.*]]
38 ; CHECK-NEXT: i32 -1, label [[SW_BB]]
39 ; CHECK-NEXT: i32 -2, label [[SW_BB]]
42 ; CHECK-NEXT: ret i1 true
44 ; CHECK-NEXT: ret i1 false
47 %a.neg = sub i32 37, %a
48 switch i32 %a.neg, label %sw.default [
62 define i1 @test_switch_with_sub_nonconst(i32 %a, i32 %b) {
63 ; CHECK-LABEL: define i1 @test_switch_with_sub_nonconst(
64 ; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]]) {
66 ; CHECK-NEXT: [[A_NEG:%.*]] = sub i32 [[B]], [[A]]
67 ; CHECK-NEXT: switch i32 [[A_NEG]], 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]]
73 ; CHECK-NEXT: ret i1 true
75 ; CHECK-NEXT: ret i1 false
78 %a.neg = sub i32 %b, %a
79 switch i32 %a.neg, label %sw.default [