1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=aggressive-instcombine -S | FileCheck %s
4 target datalayout = "e-m:m-p1:64:64:64-p:32:32:32-n8:16:32"
6 define dso_local i16 @select_i16(i16 %a, i16 %b, i1 %cond) {
7 ; CHECK-LABEL: @select_i16(
9 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i16 [[A:%.*]], i16 [[B:%.*]]
10 ; CHECK-NEXT: ret i16 [[SEL]]
13 %conv0 = sext i16 %a to i32
14 %conv1 = sext i16 %b to i32
15 %sel = select i1 %cond, i32 %conv0, i32 %conv1
16 %conv4 = trunc i32 %sel to i16
20 define dso_local i8 @select_i8(i8 %a, i8 %b, i1 %cond) {
21 ; CHECK-LABEL: @select_i8(
23 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i8 [[A:%.*]], i8 [[B:%.*]]
24 ; CHECK-NEXT: ret i8 [[SEL]]
27 %conv0 = sext i8 %a to i32
28 %conv1 = sext i8 %b to i32
29 %sel = select i1 %cond, i32 %conv0, i32 %conv1
30 %conv4 = trunc i32 %sel to i8
34 define dso_local i16 @select_i8Ops_trunc_i16(i8 %a, i8 %b, i1 %cond) {
35 ; CHECK-LABEL: @select_i8Ops_trunc_i16(
37 ; CHECK-NEXT: [[CONV0:%.*]] = sext i8 [[A:%.*]] to i16
38 ; CHECK-NEXT: [[CONV1:%.*]] = sext i8 [[B:%.*]] to i16
39 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i16 [[CONV0]], i16 [[CONV1]]
40 ; CHECK-NEXT: ret i16 [[SEL]]
43 %conv0 = sext i8 %a to i32
44 %conv1 = sext i8 %b to i32
45 %sel = select i1 %cond, i32 %conv0, i32 %conv1
46 %conv4 = trunc i32 %sel to i16
51 define dso_local i16 @select_i16_const(i16 %a, i1 %cond) {
52 ; CHECK-LABEL: @select_i16_const(
54 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i16 109, i16 [[A:%.*]]
55 ; CHECK-NEXT: ret i16 [[SEL]]
58 %conv = sext i16 %a to i32
59 %sel = select i1 %cond, i32 109, i32 %conv
60 %conv4 = trunc i32 %sel to i16
65 define dso_local i16 @select_i16_bigConst(i16 %a, i1 %cond) {
66 ; CHECK-LABEL: @select_i16_bigConst(
68 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i16 4, i16 [[A:%.*]]
69 ; CHECK-NEXT: ret i16 [[SEL]]
72 %conv = sext i16 %a to i32
73 %sel = select i1 %cond, i32 3080196, i32 %conv
74 %conv4 = trunc i32 %sel to i16
78 define dso_local i8 @select_i8_const(i8 %a, i1 %cond) {
79 ; CHECK-LABEL: @select_i8_const(
81 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i8 109, i8 [[A:%.*]]
82 ; CHECK-NEXT: ret i8 [[SEL]]
85 %conv = sext i8 %a to i32
86 %sel = select i1 %cond, i32 109, i32 %conv
87 %conv4 = trunc i32 %sel to i8
92 define dso_local i8 @select_i8_bigConst(i8 %a, i1 %cond) {
93 ; CHECK-LABEL: @select_i8_bigConst(
95 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i8 4, i8 [[A:%.*]]
96 ; CHECK-NEXT: ret i8 [[SEL]]
99 %conv = sext i8 %a to i32
100 %sel = select i1 %cond, i32 20228, i32 %conv
101 %conv4 = trunc i32 %sel to i8
105 define dso_local i16 @select_sext(i8 %a, i1 %cond) {
106 ; CHECK-LABEL: @select_sext(
108 ; CHECK-NEXT: [[CONV:%.*]] = sext i8 [[A:%.*]] to i16
109 ; CHECK-NEXT: [[SUB:%.*]] = sub i16 0, [[CONV]]
110 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i16 [[SUB]], i16 [[CONV]]
111 ; CHECK-NEXT: ret i16 [[SEL]]
114 %conv = sext i8 %a to i32
115 %sub = sub nsw i32 0, %conv
116 %sel = select i1 %cond, i32 %sub, i32 %conv
117 %conv4 = trunc i32 %sel to i16
121 define dso_local i16 @select_zext(i8 %a, i1 %cond) {
122 ; CHECK-LABEL: @select_zext(
124 ; CHECK-NEXT: [[CONV:%.*]] = zext i8 [[A:%.*]] to i16
125 ; CHECK-NEXT: [[SUB:%.*]] = sub i16 0, [[CONV]]
126 ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i16 [[SUB]], i16 [[CONV]]
127 ; CHECK-NEXT: ret i16 [[SEL]]
130 %conv = zext i8 %a to i32
131 %sub = sub nsw i32 0, %conv
132 %sel = select i1 %cond, i32 %sub, i32 %conv
133 %conv4 = trunc i32 %sel to i16