1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; This test makes sure that these instructions are properly eliminated.
4 ; RUN: opt < %s -instcombine -S | FileCheck %s
6 define i32 @shl_C1_add_A_C2_i32(i16 %A) {
7 ; CHECK-LABEL: @shl_C1_add_A_C2_i32(
8 ; CHECK-NEXT: [[B:%.*]] = zext i16 %A to i32
9 ; CHECK-NEXT: [[D:%.*]] = shl i32 192, [[B]]
10 ; CHECK-NEXT: ret i32 [[D]]
12 %B = zext i16 %A to i32
18 define i32 @ashr_C1_add_A_C2_i32(i32 %A) {
19 ; CHECK-LABEL: @ashr_C1_add_A_C2_i32(
20 ; CHECK-NEXT: ret i32 0
22 %B = and i32 %A, 65535
28 define i32 @lshr_C1_add_A_C2_i32(i32 %A) {
29 ; CHECK-LABEL: @lshr_C1_add_A_C2_i32(
30 ; CHECK-NEXT: [[B:%.*]] = and i32 %A, 65535
31 ; CHECK-NEXT: [[D:%.*]] = shl i32 192, [[B]]
32 ; CHECK-NEXT: ret i32 [[D]]
34 %B = and i32 %A, 65535
40 define <4 x i32> @shl_C1_add_A_C2_v4i32(<4 x i16> %A) {
41 ; CHECK-LABEL: @shl_C1_add_A_C2_v4i32(
42 ; CHECK-NEXT: [[B:%.*]] = zext <4 x i16> %A to <4 x i32>
43 ; CHECK-NEXT: [[D:%.*]] = shl <4 x i32> <i32 6, i32 4, i32 undef, i32 -458752>, [[B]]
44 ; CHECK-NEXT: ret <4 x i32> [[D]]
46 %B = zext <4 x i16> %A to <4 x i32>
47 %C = add <4 x i32> %B, <i32 0, i32 1, i32 50, i32 16>
48 %D = shl <4 x i32> <i32 6, i32 2, i32 1, i32 -7>, %C
52 define <4 x i32> @ashr_C1_add_A_C2_v4i32(<4 x i32> %A) {
53 ; CHECK-LABEL: @ashr_C1_add_A_C2_v4i32(
54 ; CHECK-NEXT: [[B:%.*]] = and <4 x i32> %A, <i32 0, i32 15, i32 255, i32 65535>
55 ; CHECK-NEXT: [[D:%.*]] = ashr <4 x i32> <i32 6, i32 1, i32 undef, i32 -1>, [[B]]
56 ; CHECK-NEXT: ret <4 x i32> [[D]]
58 %B = and <4 x i32> %A, <i32 0, i32 15, i32 255, i32 65535>
59 %C = add <4 x i32> %B, <i32 0, i32 1, i32 50, i32 16>
60 %D = ashr <4 x i32> <i32 6, i32 2, i32 1, i32 -7>, %C
64 define <4 x i32> @lshr_C1_add_A_C2_v4i32(<4 x i32> %A) {
65 ; CHECK-LABEL: @lshr_C1_add_A_C2_v4i32(
66 ; CHECK-NEXT: [[B:%.*]] = and <4 x i32> %A, <i32 0, i32 15, i32 255, i32 65535>
67 ; CHECK-NEXT: [[D:%.*]] = lshr <4 x i32> <i32 6, i32 1, i32 undef, i32 65535>, [[B]]
68 ; CHECK-NEXT: ret <4 x i32> [[D]]
70 %B = and <4 x i32> %A, <i32 0, i32 15, i32 255, i32 65535>
71 %C = add <4 x i32> %B, <i32 0, i32 1, i32 50, i32 16>
72 %D = lshr <4 x i32> <i32 6, i32 2, i32 1, i32 -7>, %C