1 ; This test makes sure that these instructions are properly eliminated.
4 ; RUN: llvm-as < %s | opt -instcombine -disable-output &&
5 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep sh
10 %B = shl int %A, ubyte 0
14 int %test2(ubyte %A) {
15 %B = shl int 0, ubyte %A
20 %B = shr int %A, ubyte 0
24 int %test4(ubyte %A) {
25 %B = shr int 0, ubyte %A
29 uint %test5(uint %A) {
30 %B = shr uint %A, ubyte 32 ;; shift all bits out
34 uint %test5a(uint %A) {
35 %B = shl uint %A, ubyte 32 ;; shift all bits out
39 uint %test6(uint %A) {
40 %B = shl uint %A, ubyte 1 ;; convert to an mul instruction
45 int %test7(ubyte %A) {
46 %B = shr int -1, ubyte %A ;; Always equal to -1
50 ubyte %test8(ubyte %A) { ;; (A << 5) << 3 === A << 8 == 0
51 %B = shl ubyte %A, ubyte 5
52 %C = shl ubyte %B, ubyte 3
56 ubyte %test9(ubyte %A) { ;; (A << 7) >> 7 === A & 1
57 %B = shl ubyte %A, ubyte 7
58 %C = shr ubyte %B, ubyte 7
62 ubyte %test10(ubyte %A) { ;; (A >> 7) << 7 === A & 128
63 %B = shr ubyte %A, ubyte 7
64 %C = shl ubyte %B, ubyte 7
68 ubyte %test11(ubyte %A) { ;; (A >> 3) << 4 === (A & 0x1F) << 1
70 %B = shr ubyte %a, ubyte 3
71 %C = shl ubyte %B, ubyte 4
76 %B = shr int %A, ubyte 8 ;; (A >> 8) << 8 === A & -256
77 %C = shl int %B, ubyte 8
81 sbyte %test13(sbyte %A) { ;; (A >> 3) << 4 === (A & -8) * 2
83 %B = shr sbyte %a, ubyte 3
84 %C = shl sbyte %B, ubyte 4
88 uint %test14(uint %A) {
89 %B = shr uint %A, ubyte 4
91 %D = shl uint %C, ubyte 4 ;; D = ((B | 1234) << 4) === ((B << 4)|(1234 << 4)
94 uint %test14a(uint %A) {
95 %B = shl uint %A, ubyte 4
96 %C = and uint %B, 1234
97 %D = shr uint %C, ubyte 4 ;; D = ((B | 1234) << 4) === ((B << 4)|(1234 << 4)
101 int %test15(bool %C) {
102 %A = select bool %C, int 3, int 1
103 %V = shl int %A, ubyte 2
107 int %test15a(bool %C) {
108 %A = select bool %C, ubyte 3, ubyte 1
109 %V = shl int 64, ubyte %A
113 bool %test16(int %X) {
114 %tmp.3 = shr int %X, ubyte 4
115 %tmp.6 = and int %tmp.3, 1
116 %tmp.7 = setne int %tmp.6, 0 ;; X & 16 != 0
120 bool %test17(uint %A) {
121 %B = shr uint %A, ubyte 3
122 %C = seteq uint %B, 1234
126 bool %test18(ubyte %A) {
127 %B = shr ubyte %A, ubyte 7
128 %C = seteq ubyte %B, 123 ;; false
132 bool %test19(int %A) {
133 %B = shr int %A, ubyte 2
134 %C = seteq int %B, 0 ;; (X & -4) == 0
138 bool %test19a(int %A) {
139 %B = shr int %A, ubyte 2
140 %C = seteq int %B, -1 ;; (X & -4) == -4
144 bool %test20(sbyte %A) {
145 %B = shr sbyte %A, ubyte 7
146 %C = seteq sbyte %B, 123 ;; false
150 bool %test21(ubyte %A) {
151 %B = shl ubyte %A, ubyte 4
152 %C = seteq ubyte %B, 128
156 bool %test22(ubyte %A) {
157 %B = shl ubyte %A, ubyte 4
158 %C = seteq ubyte %B, 0
162 sbyte %test23(int %A) {
163 %B = shl int %A, ubyte 24 ;; casts not needed
164 %C = shr int %B, ubyte 24
165 %D = cast int %C to sbyte
169 sbyte %test24(sbyte %X) {
170 %Y = and sbyte %X, -5 ; ~4
171 %Z = shl sbyte %Y, ubyte 5
172 %Q = shr sbyte %Z, ubyte 5
176 uint %test25(uint %tmp.2, uint %AA) {
177 %x = shr uint %AA, ubyte 17
178 %tmp.3 = shr uint %tmp.2, ubyte 17 ; <uint> [#uses=1]
179 %tmp.5 = add uint %tmp.3, %x ; <uint> [#uses=1]
180 %tmp.6 = shl uint %tmp.5, ubyte 17 ; <uint> [#uses=1]
184 int %test26(uint %A) { ;; handle casts between shifts.
185 %B = shr uint %A, ubyte 1
186 %C = cast uint %B to int
187 %D = shl int %C, ubyte 1