• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X86
3; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s  --check-prefix=X64
4
5; Shift i64 integers on 32-bit target
6
7define i64 @test1(i64 %X, i8 %C) nounwind {
8; X86-LABEL: test1:
9; X86:       # %bb.0:
10; X86-NEXT:    pushl %esi
11; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
12; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
13; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
14; X86-NEXT:    movl %esi, %eax
15; X86-NEXT:    shll %cl, %eax
16; X86-NEXT:    shldl %cl, %esi, %edx
17; X86-NEXT:    testb $32, %cl
18; X86-NEXT:    je .LBB0_2
19; X86-NEXT:  # %bb.1:
20; X86-NEXT:    movl %eax, %edx
21; X86-NEXT:    xorl %eax, %eax
22; X86-NEXT:  .LBB0_2:
23; X86-NEXT:    popl %esi
24; X86-NEXT:    retl
25;
26; X64-LABEL: test1:
27; X64:       # %bb.0:
28; X64-NEXT:    movl %esi, %ecx
29; X64-NEXT:    movq %rdi, %rax
30; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
31; X64-NEXT:    shlq %cl, %rax
32; X64-NEXT:    retq
33        %shift.upgrd.1 = zext i8 %C to i64              ; <i64> [#uses=1]
34        %Y = shl i64 %X, %shift.upgrd.1         ; <i64> [#uses=1]
35        ret i64 %Y
36}
37
38define i64 @test2(i64 %X, i8 %C) nounwind {
39; X86-LABEL: test2:
40; X86:       # %bb.0:
41; X86-NEXT:    pushl %esi
42; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
43; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
44; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
45; X86-NEXT:    movl %esi, %edx
46; X86-NEXT:    sarl %cl, %edx
47; X86-NEXT:    shrdl %cl, %esi, %eax
48; X86-NEXT:    testb $32, %cl
49; X86-NEXT:    je .LBB1_2
50; X86-NEXT:  # %bb.1:
51; X86-NEXT:    sarl $31, %esi
52; X86-NEXT:    movl %edx, %eax
53; X86-NEXT:    movl %esi, %edx
54; X86-NEXT:  .LBB1_2:
55; X86-NEXT:    popl %esi
56; X86-NEXT:    retl
57;
58; X64-LABEL: test2:
59; X64:       # %bb.0:
60; X64-NEXT:    movl %esi, %ecx
61; X64-NEXT:    movq %rdi, %rax
62; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
63; X64-NEXT:    sarq %cl, %rax
64; X64-NEXT:    retq
65        %shift.upgrd.2 = zext i8 %C to i64              ; <i64> [#uses=1]
66        %Y = ashr i64 %X, %shift.upgrd.2                ; <i64> [#uses=1]
67        ret i64 %Y
68}
69
70define i64 @test3(i64 %X, i8 %C) nounwind {
71; X86-LABEL: test3:
72; X86:       # %bb.0:
73; X86-NEXT:    pushl %esi
74; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
75; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
76; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
77; X86-NEXT:    movl %esi, %edx
78; X86-NEXT:    shrl %cl, %edx
79; X86-NEXT:    shrdl %cl, %esi, %eax
80; X86-NEXT:    testb $32, %cl
81; X86-NEXT:    je .LBB2_2
82; X86-NEXT:  # %bb.1:
83; X86-NEXT:    movl %edx, %eax
84; X86-NEXT:    xorl %edx, %edx
85; X86-NEXT:  .LBB2_2:
86; X86-NEXT:    popl %esi
87; X86-NEXT:    retl
88;
89; X64-LABEL: test3:
90; X64:       # %bb.0:
91; X64-NEXT:    movl %esi, %ecx
92; X64-NEXT:    movq %rdi, %rax
93; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
94; X64-NEXT:    shrq %cl, %rax
95; X64-NEXT:    retq
96        %shift.upgrd.3 = zext i8 %C to i64              ; <i64> [#uses=1]
97        %Y = lshr i64 %X, %shift.upgrd.3                ; <i64> [#uses=1]
98        ret i64 %Y
99}
100
101; Combine 2xi32/2xi16 shifts into SHLD
102
103define i32 @test4(i32 %A, i32 %B, i8 %C) nounwind {
104; X86-LABEL: test4:
105; X86:       # %bb.0:
106; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
107; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
108; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
109; X86-NEXT:    shldl %cl, %edx, %eax
110; X86-NEXT:    retl
111;
112; X64-LABEL: test4:
113; X64:       # %bb.0:
114; X64-NEXT:    movl %edx, %ecx
115; X64-NEXT:    movl %edi, %eax
116; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
117; X64-NEXT:    shldl %cl, %esi, %eax
118; X64-NEXT:    retq
119        %shift.upgrd.4 = zext i8 %C to i32              ; <i32> [#uses=1]
120        %X = shl i32 %A, %shift.upgrd.4         ; <i32> [#uses=1]
121        %Cv = sub i8 32, %C             ; <i8> [#uses=1]
122        %shift.upgrd.5 = zext i8 %Cv to i32             ; <i32> [#uses=1]
123        %Y = lshr i32 %B, %shift.upgrd.5                ; <i32> [#uses=1]
124        %Z = or i32 %Y, %X              ; <i32> [#uses=1]
125        ret i32 %Z
126}
127
128define i16 @test5(i16 %A, i16 %B, i8 %C) nounwind {
129; X86-LABEL: test5:
130; X86:       # %bb.0:
131; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %edx
132; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
133; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
134; X86-NEXT:    andb $15, %cl
135; X86-NEXT:    shldw %cl, %dx, %ax
136; X86-NEXT:    retl
137;
138; X64-LABEL: test5:
139; X64:       # %bb.0:
140; X64-NEXT:    movl %edx, %ecx
141; X64-NEXT:    movl %edi, %eax
142; X64-NEXT:    andb $15, %cl
143; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
144; X64-NEXT:    shldw %cl, %si, %ax
145; X64-NEXT:    # kill: def $ax killed $ax killed $eax
146; X64-NEXT:    retq
147        %shift.upgrd.6 = zext i8 %C to i16              ; <i16> [#uses=1]
148        %X = shl i16 %A, %shift.upgrd.6         ; <i16> [#uses=1]
149        %Cv = sub i8 16, %C             ; <i8> [#uses=1]
150        %shift.upgrd.7 = zext i8 %Cv to i16             ; <i16> [#uses=1]
151        %Y = lshr i16 %B, %shift.upgrd.7                ; <i16> [#uses=1]
152        %Z = or i16 %Y, %X              ; <i16> [#uses=1]
153        ret i16 %Z
154}
155
156; Combine 2xi32/2xi16 shifts into SHRD
157
158define i32 @test6(i32 %A, i32 %B, i8 %C) nounwind {
159; X86-LABEL: test6:
160; X86:       # %bb.0:
161; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
162; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
163; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
164; X86-NEXT:    shrdl %cl, %edx, %eax
165; X86-NEXT:    retl
166;
167; X64-LABEL: test6:
168; X64:       # %bb.0:
169; X64-NEXT:    movl %edx, %ecx
170; X64-NEXT:    movl %edi, %eax
171; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
172; X64-NEXT:    shrdl %cl, %esi, %eax
173; X64-NEXT:    retq
174        %shift.upgrd.4 = zext i8 %C to i32              ; <i32> [#uses=1]
175        %X = lshr i32 %A, %shift.upgrd.4         ; <i32> [#uses=1]
176        %Cv = sub i8 32, %C             ; <i8> [#uses=1]
177        %shift.upgrd.5 = zext i8 %Cv to i32             ; <i32> [#uses=1]
178        %Y = shl i32 %B, %shift.upgrd.5                ; <i32> [#uses=1]
179        %Z = or i32 %Y, %X              ; <i32> [#uses=1]
180        ret i32 %Z
181}
182
183define i16 @test7(i16 %A, i16 %B, i8 %C) nounwind {
184; X86-LABEL: test7:
185; X86:       # %bb.0:
186; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %edx
187; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
188; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
189; X86-NEXT:    andb $15, %cl
190; X86-NEXT:    shrdw %cl, %dx, %ax
191; X86-NEXT:    retl
192;
193; X64-LABEL: test7:
194; X64:       # %bb.0:
195; X64-NEXT:    movl %edx, %ecx
196; X64-NEXT:    movl %edi, %eax
197; X64-NEXT:    andb $15, %cl
198; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
199; X64-NEXT:    shrdw %cl, %si, %ax
200; X64-NEXT:    # kill: def $ax killed $ax killed $eax
201; X64-NEXT:    retq
202        %shift.upgrd.6 = zext i8 %C to i16              ; <i16> [#uses=1]
203        %X = lshr i16 %A, %shift.upgrd.6         ; <i16> [#uses=1]
204        %Cv = sub i8 16, %C             ; <i8> [#uses=1]
205        %shift.upgrd.7 = zext i8 %Cv to i16             ; <i16> [#uses=1]
206        %Y = shl i16 %B, %shift.upgrd.7                ; <i16> [#uses=1]
207        %Z = or i16 %Y, %X              ; <i16> [#uses=1]
208        ret i16 %Z
209}
210
211; Shift i64 integers on 32-bit target by shift value less then 32 (PR14593)
212
213define i64 @test8(i64 %val, i32 %bits) nounwind {
214; X86-LABEL: test8:
215; X86:       # %bb.0:
216; X86-NEXT:    pushl %esi
217; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
218; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
219; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
220; X86-NEXT:    movl %esi, %eax
221; X86-NEXT:    shll %cl, %eax
222; X86-NEXT:    shldl %cl, %esi, %edx
223; X86-NEXT:    popl %esi
224; X86-NEXT:    retl
225;
226; X64-LABEL: test8:
227; X64:       # %bb.0:
228; X64-NEXT:    movl %esi, %ecx
229; X64-NEXT:    movq %rdi, %rax
230; X64-NEXT:    andb $31, %cl
231; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
232; X64-NEXT:    shlq %cl, %rax
233; X64-NEXT:    retq
234  %and = and i32 %bits, 31
235  %sh_prom = zext i32 %and to i64
236  %shl = shl i64 %val, %sh_prom
237  ret i64 %shl
238}
239
240define i64 @test9(i64 %val, i32 %bits) nounwind {
241; X86-LABEL: test9:
242; X86:       # %bb.0:
243; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
244; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
245; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
246; X86-NEXT:    shrdl %cl, %edx, %eax
247; X86-NEXT:    sarl %cl, %edx
248; X86-NEXT:    retl
249;
250; X64-LABEL: test9:
251; X64:       # %bb.0:
252; X64-NEXT:    movl %esi, %ecx
253; X64-NEXT:    movq %rdi, %rax
254; X64-NEXT:    andb $31, %cl
255; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
256; X64-NEXT:    sarq %cl, %rax
257; X64-NEXT:    retq
258  %and = and i32 %bits, 31
259  %sh_prom = zext i32 %and to i64
260  %ashr = ashr i64 %val, %sh_prom
261  ret i64 %ashr
262}
263
264define i64 @test10(i64 %val, i32 %bits) nounwind {
265; X86-LABEL: test10:
266; X86:       # %bb.0:
267; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
268; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
269; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
270; X86-NEXT:    shrdl %cl, %edx, %eax
271; X86-NEXT:    shrl %cl, %edx
272; X86-NEXT:    retl
273;
274; X64-LABEL: test10:
275; X64:       # %bb.0:
276; X64-NEXT:    movl %esi, %ecx
277; X64-NEXT:    movq %rdi, %rax
278; X64-NEXT:    andb $31, %cl
279; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
280; X64-NEXT:    shrq %cl, %rax
281; X64-NEXT:    retq
282  %and = and i32 %bits, 31
283  %sh_prom = zext i32 %and to i64
284  %lshr = lshr i64 %val, %sh_prom
285  ret i64 %lshr
286}
287
288; SHLD/SHRD manual shifts
289
290define i32 @test11(i32 %hi, i32 %lo, i32 %bits) nounwind {
291; X86-LABEL: test11:
292; X86:       # %bb.0:
293; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
294; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
295; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
296; X86-NEXT:    shldl %cl, %edx, %eax
297; X86-NEXT:    retl
298;
299; X64-LABEL: test11:
300; X64:       # %bb.0:
301; X64-NEXT:    movl %edx, %ecx
302; X64-NEXT:    movl %edi, %eax
303; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
304; X64-NEXT:    shldl %cl, %esi, %eax
305; X64-NEXT:    retq
306  %and = and i32 %bits, 31
307  %and32 = sub i32 32, %and
308  %sh_lo = lshr i32 %lo, %and32
309  %sh_hi = shl i32 %hi, %and
310  %sh = or i32 %sh_lo, %sh_hi
311  ret i32 %sh
312}
313
314define i32 @test12(i32 %hi, i32 %lo, i32 %bits) nounwind {
315; X86-LABEL: test12:
316; X86:       # %bb.0:
317; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
318; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
319; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
320; X86-NEXT:    shrdl %cl, %edx, %eax
321; X86-NEXT:    retl
322;
323; X64-LABEL: test12:
324; X64:       # %bb.0:
325; X64-NEXT:    movl %edx, %ecx
326; X64-NEXT:    movl %esi, %eax
327; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
328; X64-NEXT:    shrdl %cl, %edi, %eax
329; X64-NEXT:    retq
330  %and = and i32 %bits, 31
331  %and32 = sub i32 32, %and
332  %sh_lo = shl i32 %hi, %and32
333  %sh_hi = lshr i32 %lo, %and
334  %sh = or i32 %sh_lo, %sh_hi
335  ret i32 %sh
336}
337
338define i32 @test13(i32 %hi, i32 %lo, i32 %bits) nounwind {
339; X86-LABEL: test13:
340; X86:       # %bb.0:
341; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
342; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
343; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
344; X86-NEXT:    shldl %cl, %edx, %eax
345; X86-NEXT:    retl
346;
347; X64-LABEL: test13:
348; X64:       # %bb.0:
349; X64-NEXT:    movl %edx, %ecx
350; X64-NEXT:    movl %edi, %eax
351; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
352; X64-NEXT:    shldl %cl, %esi, %eax
353; X64-NEXT:    retq
354  %bits32 = sub i32 32, %bits
355  %sh_lo = lshr i32 %lo, %bits32
356  %sh_hi = shl i32 %hi, %bits
357  %sh = or i32 %sh_lo, %sh_hi
358  ret i32 %sh
359}
360
361define i32 @test14(i32 %hi, i32 %lo, i32 %bits) nounwind {
362; X86-LABEL: test14:
363; X86:       # %bb.0:
364; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
365; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
366; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
367; X86-NEXT:    shrdl %cl, %edx, %eax
368; X86-NEXT:    retl
369;
370; X64-LABEL: test14:
371; X64:       # %bb.0:
372; X64-NEXT:    movl %edx, %ecx
373; X64-NEXT:    movl %esi, %eax
374; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
375; X64-NEXT:    shrdl %cl, %edi, %eax
376; X64-NEXT:    retq
377  %bits32 = sub i32 32, %bits
378  %sh_lo = shl i32 %hi, %bits32
379  %sh_hi = lshr i32 %lo, %bits
380  %sh = or i32 %sh_lo, %sh_hi
381  ret i32 %sh
382}
383
384define i32 @test15(i32 %hi, i32 %lo, i32 %bits) nounwind {
385; X86-LABEL: test15:
386; X86:       # %bb.0:
387; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
388; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
389; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
390; X86-NEXT:    shldl %cl, %edx, %eax
391; X86-NEXT:    retl
392;
393; X64-LABEL: test15:
394; X64:       # %bb.0:
395; X64-NEXT:    movl %edx, %ecx
396; X64-NEXT:    movl %edi, %eax
397; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
398; X64-NEXT:    shldl %cl, %esi, %eax
399; X64-NEXT:    retq
400  %bits32 = xor i32 %bits, 31
401  %lo2 = lshr i32 %lo, 1
402  %sh_lo = lshr i32 %lo2, %bits32
403  %sh_hi = shl i32 %hi, %bits
404  %sh = or i32 %sh_lo, %sh_hi
405  ret i32 %sh
406}
407
408define i32 @test16(i32 %hi, i32 %lo, i32 %bits) nounwind {
409; X86-LABEL: test16:
410; X86:       # %bb.0:
411; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
412; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
413; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
414; X86-NEXT:    shrdl %cl, %edx, %eax
415; X86-NEXT:    retl
416;
417; X64-LABEL: test16:
418; X64:       # %bb.0:
419; X64-NEXT:    movl %edx, %ecx
420; X64-NEXT:    movl %edi, %eax
421; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
422; X64-NEXT:    shrdl %cl, %esi, %eax
423; X64-NEXT:    retq
424  %bits32 = xor i32 %bits, 31
425  %lo2 = shl i32 %lo, 1
426  %sh_lo = shl i32 %lo2, %bits32
427  %sh_hi = lshr i32 %hi, %bits
428  %sh = or i32 %sh_lo, %sh_hi
429  ret i32 %sh
430}
431
432define i32 @test17(i32 %hi, i32 %lo, i32 %bits) nounwind {
433; X86-LABEL: test17:
434; X86:       # %bb.0:
435; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
436; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
437; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
438; X86-NEXT:    shrdl %cl, %edx, %eax
439; X86-NEXT:    retl
440;
441; X64-LABEL: test17:
442; X64:       # %bb.0:
443; X64-NEXT:    movl %edx, %ecx
444; X64-NEXT:    movl %edi, %eax
445; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
446; X64-NEXT:    shrdl %cl, %esi, %eax
447; X64-NEXT:    retq
448  %bits32 = xor i32 %bits, 31
449  %lo2 = add i32 %lo, %lo
450  %sh_lo = shl i32 %lo2, %bits32
451  %sh_hi = lshr i32 %hi, %bits
452  %sh = or i32 %sh_lo, %sh_hi
453  ret i32 %sh
454}
455
456define i32 @test18(i32 %hi, i32 %lo, i32 %bits) nounwind {
457; X86-LABEL: test18:
458; X86:       # %bb.0:
459; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
460; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
461; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
462; X86-NEXT:    shldl %cl, %edx, %eax
463; X86-NEXT:    retl
464;
465; X64-LABEL: test18:
466; X64:       # %bb.0:
467; X64-NEXT:    movl %edx, %ecx
468; X64-NEXT:    movl %edi, %eax
469; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
470; X64-NEXT:    shldl %cl, %esi, %eax
471; X64-NEXT:    retq
472  %tbits = trunc i32 %bits to i8
473  %tand = and i8 %tbits, 31
474  %tand64 = sub i8 32, %tand
475  %and = zext i8 %tand to i32
476  %and64 = zext i8 %tand64 to i32
477  %sh_lo = lshr i32 %lo, %and64
478  %sh_hi = shl i32 %hi, %and
479  %sh = or i32 %sh_lo, %sh_hi
480  ret i32 %sh
481}
482
483; PR34641 - Masked Shift Counts
484
485define i32 @shld_safe_i32(i32, i32, i32) {
486; X86-LABEL: shld_safe_i32:
487; X86:       # %bb.0:
488; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
489; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
490; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
491; X86-NEXT:    shldl %cl, %edx, %eax
492; X86-NEXT:    retl
493;
494; X64-LABEL: shld_safe_i32:
495; X64:       # %bb.0:
496; X64-NEXT:    movl %edx, %ecx
497; X64-NEXT:    movl %edi, %eax
498; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
499; X64-NEXT:    shldl %cl, %esi, %eax
500; X64-NEXT:    retq
501  %4 = and i32 %2, 31
502  %5 = shl i32 %0, %4
503  %6 = sub i32 0, %2
504  %7 = and i32 %6, 31
505  %8 = lshr i32 %1, %7
506  %9 = or i32 %5, %8
507  ret i32 %9
508}
509
510define i32 @shrd_safe_i32(i32, i32, i32) {
511; X86-LABEL: shrd_safe_i32:
512; X86:       # %bb.0:
513; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
514; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
515; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
516; X86-NEXT:    shrdl %cl, %edx, %eax
517; X86-NEXT:    retl
518;
519; X64-LABEL: shrd_safe_i32:
520; X64:       # %bb.0:
521; X64-NEXT:    movl %edx, %ecx
522; X64-NEXT:    movl %edi, %eax
523; X64-NEXT:    # kill: def $cl killed $cl killed $ecx
524; X64-NEXT:    shrdl %cl, %esi, %eax
525; X64-NEXT:    retq
526  %4 = and i32 %2, 31
527  %5 = lshr i32 %0, %4
528  %6 = sub i32 0, %2
529  %7 = and i32 %6, 31
530  %8 = shl i32 %1, %7
531  %9 = or i32 %5, %8
532  ret i32 %9
533}
534