1 ; This test makes sure that shit instructions are properly eliminated
2 ; even with arbitrary precision integers.
3 ; RUN: opt < %s -instcombine -S | not grep sh
6 define i47 @test1(i47 %A) {
7 %B = shl i47 %A, 0 ; <i47> [#uses=1]
11 define i41 @test2(i7 %X) {
12 %A = zext i7 %X to i41 ; <i41> [#uses=1]
13 %B = shl i41 0, %A ; <i41> [#uses=1]
17 define i41 @test3(i41 %A) {
18 %B = ashr i41 %A, 0 ; <i41> [#uses=1]
22 define i39 @test4(i7 %X) {
23 %A = zext i7 %X to i39 ; <i39> [#uses=1]
24 %B = ashr i39 0, %A ; <i39> [#uses=1]
28 define i55 @test5(i55 %A) {
29 %B = lshr i55 %A, 55 ; <i55> [#uses=1]
33 define i32 @test5a(i32 %A) {
34 %B = shl i32 %A, 32 ; <i32> [#uses=1]
38 define i55 @test6(i55 %A) {
39 %B = shl i55 %A, 1 ; <i55> [#uses=1]
40 %C = mul i55 %B, 3 ; <i55> [#uses=1]
44 define i29 @test7(i8 %X) {
45 %A = zext i8 %X to i29 ; <i29> [#uses=1]
46 %B = ashr i29 -1, %A ; <i29> [#uses=1]
50 define i7 @test8(i7 %A) {
51 %B = shl i7 %A, 4 ; <i7> [#uses=1]
52 %C = shl i7 %B, 3 ; <i7> [#uses=1]
56 define i17 @test9(i17 %A) {
57 %B = shl i17 %A, 16 ; <i17> [#uses=1]
58 %C = lshr i17 %B, 16 ; <i17> [#uses=1]
62 define i19 @test10(i19 %A) {
63 %B = lshr i19 %A, 18 ; <i19> [#uses=1]
64 %C = shl i19 %B, 18 ; <i19> [#uses=1]
68 define i23 @test11(i23 %A) {
69 %a = mul i23 %A, 3 ; <i23> [#uses=1]
70 %B = lshr i23 %a, 11 ; <i23> [#uses=1]
71 %C = shl i23 %B, 12 ; <i23> [#uses=1]
75 define i47 @test12(i47 %A) {
76 %B = ashr i47 %A, 8 ; <i47> [#uses=1]
77 %C = shl i47 %B, 8 ; <i47> [#uses=1]
81 define i18 @test13(i18 %A) {
82 %a = mul i18 %A, 3 ; <i18> [#uses=1]
83 %B = ashr i18 %a, 8 ; <i18> [#uses=1]
84 %C = shl i18 %B, 9 ; <i18> [#uses=1]
88 define i35 @test14(i35 %A) {
89 %B = lshr i35 %A, 4 ; <i35> [#uses=1]
90 %C = or i35 %B, 1234 ; <i35> [#uses=1]
91 %D = shl i35 %C, 4 ; <i35> [#uses=1]
95 define i79 @test14a(i79 %A) {
96 %B = shl i79 %A, 4 ; <i79> [#uses=1]
97 %C = and i79 %B, 1234 ; <i79> [#uses=1]
98 %D = lshr i79 %C, 4 ; <i79> [#uses=1]
102 define i45 @test15(i1 %C) {
103 %A = select i1 %C, i45 3, i45 1 ; <i45> [#uses=1]
104 %V = shl i45 %A, 2 ; <i45> [#uses=1]
108 define i53 @test15a(i1 %X) {
109 %A = select i1 %X, i8 3, i8 1 ; <i8> [#uses=1]
110 %B = zext i8 %A to i53 ; <i53> [#uses=1]
111 %V = shl i53 64, %B ; <i53> [#uses=1]
115 define i1 @test16(i84 %X) {
116 %tmp.3 = ashr i84 %X, 4 ; <i84> [#uses=1]
117 %tmp.6 = and i84 %tmp.3, 1 ; <i84> [#uses=1]
118 %tmp.7 = icmp ne i84 %tmp.6, 0 ; <i1> [#uses=1]
122 define i1 @test17(i106 %A) {
123 %B = lshr i106 %A, 3 ; <i106> [#uses=1]
124 %C = icmp eq i106 %B, 1234 ; <i1> [#uses=1]
128 define i1 @test18(i11 %A) {
129 %B = lshr i11 %A, 10 ; <i11> [#uses=1]
130 %C = icmp eq i11 %B, 123 ; <i1> [#uses=1]
134 define i1 @test19(i37 %A) {
135 %B = ashr i37 %A, 2 ; <i37> [#uses=1]
136 %C = icmp eq i37 %B, 0 ; <i1> [#uses=1]
140 define i1 @test19a(i39 %A) {
141 %B = ashr i39 %A, 2 ; <i39> [#uses=1]
142 %C = icmp eq i39 %B, -1 ; <i1> [#uses=1]
146 define i1 @test20(i13 %A) {
147 %B = ashr i13 %A, 12 ; <i13> [#uses=1]
148 %C = icmp eq i13 %B, 123 ; <i1> [#uses=1]
152 define i1 @test21(i12 %A) {
153 %B = shl i12 %A, 6 ; <i12> [#uses=1]
154 %C = icmp eq i12 %B, -128 ; <i1> [#uses=1]
158 define i1 @test22(i14 %A) {
159 %B = shl i14 %A, 7 ; <i14> [#uses=1]
160 %C = icmp eq i14 %B, 0 ; <i1> [#uses=1]
164 define i11 @test23(i44 %A) {
165 %B = shl i44 %A, 33 ; <i44> [#uses=1]
166 %C = ashr i44 %B, 33 ; <i44> [#uses=1]
167 %D = trunc i44 %C to i11 ; <i8> [#uses=1]
171 define i17 @test24(i17 %X) {
172 %Y = and i17 %X, -5 ; <i17> [#uses=1]
173 %Z = shl i17 %Y, 9 ; <i17> [#uses=1]
174 %Q = ashr i17 %Z, 9 ; <i17> [#uses=1]
178 define i37 @test25(i37 %tmp.2, i37 %AA) {
179 %x = lshr i37 %AA, 17 ; <i37> [#uses=1]
180 %tmp.3 = lshr i37 %tmp.2, 17 ; <i37> [#uses=1]
181 %tmp.5 = add i37 %tmp.3, %x ; <i37> [#uses=1]
182 %tmp.6 = shl i37 %tmp.5, 17 ; <i37> [#uses=1]
186 define i40 @test26(i40 %A) {
187 %B = lshr i40 %A, 1 ; <i40> [#uses=1]
188 %C = bitcast i40 %B to i40 ; <i40> [#uses=1]
189 %D = shl i40 %C, 1 ; <i40> [#uses=1]