1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=aggressive-instcombine -S | FileCheck %s
4 define i16 @trunc_shl(i16 %x, i16 %y) {
5 ; CHECK-LABEL: @trunc_shl(
6 ; CHECK-NEXT: [[CMP0:%.*]] = icmp ult i16 [[Y:%.*]], 16
7 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP0]])
8 ; CHECK-NEXT: [[I0:%.*]] = shl i16 [[X:%.*]], [[Y]]
9 ; CHECK-NEXT: ret i16 [[I0]]
11 %cmp0 = icmp ult i16 %y, 16
12 call void @llvm.assume(i1 %cmp0)
14 %zextx = zext i16 %x to i32
15 %zexty = zext i16 %y to i32
17 %i0 = shl i32 %zextx, %zexty
18 %r = trunc i32 %i0 to i16
22 define i16 @trunc_lshr(i16 %x, i16 %y) {
23 ; CHECK-LABEL: @trunc_lshr(
24 ; CHECK-NEXT: [[CMP0:%.*]] = icmp ult i16 [[X:%.*]], 0
25 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i16 [[Y:%.*]], 16
26 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP0]])
27 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP1]])
28 ; CHECK-NEXT: [[I0:%.*]] = lshr i16 [[X]], [[Y]]
29 ; CHECK-NEXT: ret i16 [[I0]]
31 %cmp0 = icmp ult i16 %x, 65536
32 %cmp1 = icmp ult i16 %y, 16
33 call void @llvm.assume(i1 %cmp0)
34 call void @llvm.assume(i1 %cmp1)
36 %zextx = zext i16 %x to i32
37 %zexty = zext i16 %y to i32
39 %i0 = lshr i32 %zextx, %zexty
40 %r = trunc i32 %i0 to i16
44 define i16 @trunc_ashr(i16 %x, i16 %y) {
45 ; CHECK-LABEL: @trunc_ashr(
46 ; CHECK-NEXT: [[CMP0:%.*]] = icmp slt i16 [[X:%.*]], 32767
47 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i16 [[X]], -32768
48 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i16 [[Y:%.*]], 16
49 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP0]])
50 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP1]])
51 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP2]])
52 ; CHECK-NEXT: [[I0:%.*]] = ashr i16 [[X]], [[Y]]
53 ; CHECK-NEXT: ret i16 [[I0]]
55 %cmp0 = icmp slt i16 %x, 32767
56 %cmp1 = icmp sge i16 %x, -32768
57 %cmp2 = icmp ult i16 %y, 16
58 call void @llvm.assume(i1 %cmp0)
59 call void @llvm.assume(i1 %cmp1)
60 call void @llvm.assume(i1 %cmp2)
62 %zextx = sext i16 %x to i32
63 %zexty = sext i16 %y to i32
65 %i0 = ashr i32 %zextx, %zexty
66 %r = trunc i32 %i0 to i16
70 declare void @llvm.assume(i1)