1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
declare void @use(i8)
define i1 @ult_2(i32 %x) {
; CHECK-LABEL: @ult_2(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 254
; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[TMP1]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp ult i8 %t, 2
ret i1 %r
}
define <2 x i1> @ult_16_splat(<2 x i16> %x) {
; CHECK-LABEL: @ult_16_splat(
; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i16> [[X:%.*]], <i16 2032, i16 2032>
; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i16> [[TMP1]], zeroinitializer
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%t = trunc <2 x i16> %x to <2 x i11>
%r = icmp ult <2 x i11> %t, <i11 16, i11 16>
ret <2 x i1> %r
}
; negative test - need power-of-2 constant
define i1 @ult_3(i32 %x) {
; CHECK-LABEL: @ult_3(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: [[R:%.*]] = icmp ult i8 [[T]], 3
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp ult i8 %t, 3
ret i1 %r
}
; negative test - no extra use allowed
define i1 @ult_2_use(i32 %x) {
; CHECK-LABEL: @ult_2_use(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: call void @use(i8 [[T]])
; CHECK-NEXT: [[R:%.*]] = icmp ult i8 [[T]], 2
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
call void @use(i8 %t)
%r = icmp ult i8 %t, 2
ret i1 %r
}
@a = internal unnamed_addr constant [3 x i32] [i32 0, i32 0, i32 1], align 4
define i1 @PR52260(i32 %x) {
; CHECK-LABEL: @PR52260(
; CHECK-NEXT: ret i1 true
;
%idxprom = sext i32 %x to i64
%idx = getelementptr inbounds [3 x i32], [3 x i32]* @a, i64 0, i64 %idxprom
%t1 = load i32, i32* %idx, align 4
%conv1 = lshr i32 %t1, 1
%t2 = trunc i32 %conv1 to i8
%conv2 = and i8 %t2, 127
%tobool = icmp eq i8 %conv2, 0
ret i1 %tobool
}
define i1 @ult_192(i32 %x) {
; CHECK-LABEL: @ult_192(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 192
; CHECK-NEXT: [[R:%.*]] = icmp ne i32 [[TMP1]], 192
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp ult i8 %t, 192 ; 0b1100_0000
ret i1 %r
}
define <2 x i1> @ult_2044_splat(<2 x i16> %x) {
; CHECK-LABEL: @ult_2044_splat(
; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i16> [[X:%.*]], <i16 2044, i16 2044>
; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i16> [[TMP1]], <i16 2044, i16 2044>
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%t = trunc <2 x i16> %x to <2 x i11>
%r = icmp ult <2 x i11> %t, <i11 2044, i11 2044> ; 0b111_1111_1100
ret <2 x i1> %r
}
; negative test - need high-bit-mask constant
define i1 @ult_96(i32 %x) {
; CHECK-LABEL: @ult_96(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: [[R:%.*]] = icmp ult i8 [[T]], 96
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp ult i8 %t, 96 ; 0b0110_0000
ret i1 %r
}
; negative test - no extra use allowed
define i1 @ult_192_use(i32 %x) {
; CHECK-LABEL: @ult_192_use(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: call void @use(i8 [[T]])
; CHECK-NEXT: [[R:%.*]] = icmp ult i8 [[T]], -64
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
call void @use(i8 %t)
%r = icmp ult i8 %t, 192
ret i1 %r
}
define i1 @ugt_3(i32 %x) {
; CHECK-LABEL: @ugt_3(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 252
; CHECK-NEXT: [[R:%.*]] = icmp ne i32 [[TMP1]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp ugt i8 %t, 3
ret i1 %r
}
define <2 x i1> @ugt_7_splat(<2 x i16> %x) {
; CHECK-LABEL: @ugt_7_splat(
; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i16> [[X:%.*]], <i16 2040, i16 2040>
; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i16> [[TMP1]], zeroinitializer
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%t = trunc <2 x i16> %x to <2 x i11>
%r = icmp ugt <2 x i11> %t, <i11 7, i11 7>
ret <2 x i1> %r
}
; negative test - need low-bit-mask constant
define i1 @ugt_4(i32 %x) {
; CHECK-LABEL: @ugt_4(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[T]], 4
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp ugt i8 %t, 4
ret i1 %r
}
; negative test - no extra use allowed
define i1 @ugt_3_use(i32 %x) {
; CHECK-LABEL: @ugt_3_use(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: call void @use(i8 [[T]])
; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[T]], 3
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
call void @use(i8 %t)
%r = icmp ugt i8 %t, 3
ret i1 %r
}
define i1 @ugt_253(i32 %x) {
; CHECK-LABEL: @ugt_253(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 254
; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[TMP1]], 254
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp ugt i8 %t, 253
ret i1 %r
}
define <2 x i1> @ugt_2043_splat(<2 x i16> %x) {
; CHECK-LABEL: @ugt_2043_splat(
; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i16> [[X:%.*]], <i16 2044, i16 2044>
; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i16> [[TMP1]], <i16 2044, i16 2044>
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%t = trunc <2 x i16> %x to <2 x i11>
%r = icmp ugt <2 x i11> %t, <i11 2043, i11 2043> ; 0b111_1111_101
ret <2 x i1> %r
}
; negative test - need not-of-power-of-2 constant
define i1 @ugt_252(i32 %x) {
; CHECK-LABEL: @ugt_252(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[T]], -4
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp ugt i8 %t, 252
ret i1 %r
}
; negative test - no extra use allowed
define i1 @ugt_253_use(i32 %x) {
; CHECK-LABEL: @ugt_253_use(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: call void @use(i8 [[T]])
; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[T]], -3
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
call void @use(i8 %t)
%r = icmp ugt i8 %t, 253
ret i1 %r
}
define i1 @slt_0(i32 %x) {
; CHECK-LABEL: @slt_0(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 128
; CHECK-NEXT: [[R:%.*]] = icmp ne i32 [[TMP1]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp slt i8 %t, 0
ret i1 %r
}
define <2 x i1> @slt_0_splat(<2 x i16> %x) {
; CHECK-LABEL: @slt_0_splat(
; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i16> [[X:%.*]], <i16 1024, i16 1024>
; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i16> [[TMP1]], zeroinitializer
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%t = trunc <2 x i16> %x to <2 x i11>
%r = icmp slt <2 x i11> %t, zeroinitializer
ret <2 x i1> %r
}
define i1 @slt_1(i32 %x) {
; CHECK-LABEL: @slt_1(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[T]], 1
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp slt i8 %t, 1
ret i1 %r
}
define i1 @slt_0_use(i32 %x) {
; CHECK-LABEL: @slt_0_use(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: call void @use(i8 [[T]])
; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[T]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
call void @use(i8 %t)
%r = icmp slt i8 %t, 0
ret i1 %r
}
define i1 @sgt_n1(i32 %x) {
; CHECK-LABEL: @sgt_n1(
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X:%.*]], 128
; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[TMP1]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp sgt i8 %t, -1
ret i1 %r
}
define <2 x i1> @sgt_n1_splat(<2 x i16> %x) {
; CHECK-LABEL: @sgt_n1_splat(
; CHECK-NEXT: [[TMP1:%.*]] = and <2 x i16> [[X:%.*]], <i16 1024, i16 1024>
; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i16> [[TMP1]], zeroinitializer
; CHECK-NEXT: ret <2 x i1> [[R]]
;
%t = trunc <2 x i16> %x to <2 x i11>
%r = icmp sgt <2 x i11> %t, <i11 -1, i11 -1>
ret <2 x i1> %r
}
define i1 @sgt_0(i32 %x) {
; CHECK-LABEL: @sgt_0(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[T]], 0
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
%r = icmp sgt i8 %t, 0
ret i1 %r
}
define i1 @sgt_n1_use(i32 %x) {
; CHECK-LABEL: @sgt_n1_use(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: call void @use(i8 [[T]])
; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[T]], -1
; CHECK-NEXT: ret i1 [[R]]
;
%t = trunc i32 %x to i8
call void @use(i8 %t)
%r = icmp sgt i8 %t, -1
ret i1 %r
}
|