1 ; This test makes sure that these instructions are properly eliminated.
3 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep sh
9 %B = shl int %A, ubyte 0
13 int %test2(ubyte %A) {
14 %B = shl int 0, ubyte %A
19 %B = shr int %A, ubyte 0
23 int %test4(ubyte %A) {
24 %B = shr int 0, ubyte %A
28 uint %test5(uint %A) {
29 %B = shr uint %A, ubyte 32 ;; shift all bits out
33 uint %test5a(uint %A) {
34 %B = shl uint %A, ubyte 32 ;; shift all bits out
38 uint %test6(uint %A) {
39 %B = shl uint %A, ubyte 1 ;; convert to an mul instruction
44 int %test7(ubyte %A) {
45 %B = shr int -1, ubyte %A ;; Always equal to -1
49 ubyte %test8(ubyte %A) { ;; (A << 5) << 3 === A << 8 == 0
50 %B = shl ubyte %A, ubyte 5
51 %C = shl ubyte %B, ubyte 3
55 ubyte %test9(ubyte %A) { ;; (A << 7) >> 7 === A & 1
56 %B = shl ubyte %A, ubyte 7
57 %C = shr ubyte %B, ubyte 7
61 ubyte %test10(ubyte %A) { ;; (A >> 7) << 7 === A & 128
62 %B = shr ubyte %A, ubyte 7
63 %C = shl ubyte %B, ubyte 7
67 ubyte %test11(ubyte %A) { ;; (A >> 3) << 4 === (A & 0x1F) << 1
69 %B = shr ubyte %a, ubyte 3
70 %C = shl ubyte %B, ubyte 4
75 %B = shr int %A, ubyte 8 ;; (A >> 8) << 8 === A & -256
76 %C = shl int %B, ubyte 8
80 sbyte %test13(sbyte %A) { ;; (A >> 3) << 4 === (A & -8) * 2
82 %B = shr sbyte %a, ubyte 3
83 %C = shl sbyte %B, ubyte 4
87 uint %test14(uint %A) {
88 %B = shr uint %A, ubyte 4
90 %D = shl uint %C, ubyte 4 ;; D = ((B | 1234) << 4) === ((B << 4)|(1234 << 4)
93 uint %test14a(uint %A) {
94 %B = shl uint %A, ubyte 4
95 %C = and uint %B, 1234
96 %D = shr uint %C, ubyte 4 ;; D = ((B | 1234) << 4) === ((B << 4)|(1234 << 4)
100 int %test15(bool %C) {
101 %A = select bool %C, int 3, int 1
102 %V = shl int %A, ubyte 2
106 int %test15a(bool %C) {
107 %A = select bool %C, ubyte 3, ubyte 1
108 %V = shl int 64, ubyte %A
112 bool %test16(int %X) {
113 %tmp.3 = shr int %X, ubyte 4
114 %tmp.6 = and int %tmp.3, 1
115 %tmp.7 = setne int %tmp.6, 0 ;; X & 16 != 0
119 bool %test17(uint %A) {
120 %B = shr uint %A, ubyte 3
121 %C = seteq uint %B, 1234
125 bool %test18(ubyte %A) {
126 %B = shr ubyte %A, ubyte 7
127 %C = seteq ubyte %B, 123 ;; false
131 bool %test19(int %A) {
132 %B = shr int %A, ubyte 2
133 %C = seteq int %B, 0 ;; (X & -4) == 0
137 bool %test19a(int %A) {
138 %B = shr int %A, ubyte 2
139 %C = seteq int %B, -1 ;; (X & -4) == -4
143 bool %test20(sbyte %A) {
144 %B = shr sbyte %A, ubyte 7
145 %C = seteq sbyte %B, 123 ;; false
149 bool %test21(ubyte %A) {
150 %B = shl ubyte %A, ubyte 4
151 %C = seteq ubyte %B, 128
155 bool %test22(ubyte %A) {
156 %B = shl ubyte %A, ubyte 4
157 %C = seteq ubyte %B, 0
161 sbyte %test23(int %A) {
162 %B = shl int %A, ubyte 24 ;; casts not needed
163 %C = shr int %B, ubyte 24
164 %D = cast int %C to sbyte
168 sbyte %test24(sbyte %X) {
169 %Y = and sbyte %X, -5 ; ~4
170 %Z = shl sbyte %Y, ubyte 5
171 %Q = shr sbyte %Z, ubyte 5
175 uint %test25(uint %tmp.2, uint %AA) {
176 %x = shr uint %AA, ubyte 17
177 %tmp.3 = shr uint %tmp.2, ubyte 17 ; <uint> [#uses=1]
178 %tmp.5 = add uint %tmp.3, %x ; <uint> [#uses=1]
179 %tmp.6 = shl uint %tmp.5, ubyte 17 ; <uint> [#uses=1]
183 int %test26(uint %A) { ;; handle casts between shifts.
184 %B = shr uint %A, ubyte 1
185 %C = cast uint %B to int
186 %D = shl int %C, ubyte 1