1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Test compound shifts.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 ; Test a shift right followed by a sign extension. This can use two shifts.
7 define i64 @f1(i32 %a) {
10 ; CHECK-NEXT: # kill: def $r2l killed $r2l def $r2d
11 ; CHECK-NEXT: risbg %r0, %r2, 63, 191, 63
12 ; CHECK-NEXT: lcgr %r2, %r0
15 %trunc = trunc i32 %shr to i1
16 %ext = sext i1 %trunc to i64
20 ; ...and again with the highest shift count that doesn't reduce to an
22 define i64 @f2(i32 %a) {
25 ; CHECK-NEXT: # kill: def $r2l killed $r2l def $r2d
26 ; CHECK-NEXT: risbg %r0, %r2, 63, 191, 34
27 ; CHECK-NEXT: lcgr %r2, %r0
29 %shr = lshr i32 %a, 30
30 %trunc = trunc i32 %shr to i1
31 %ext = sext i1 %trunc to i64
35 ; Test a left shift that of an extended right shift in a case where folding
37 define i64 @f3(i32 %a) {
40 ; CHECK-NEXT: # kill: def $r2l killed $r2l def $r2d
41 ; CHECK-NEXT: risbg %r2, %r2, 27, 181, 9
44 %ext = zext i32 %shr to i64
45 %shl = shl i64 %ext, 10
46 %and = and i64 %shl, 137438952960
50 ; ...and again with a larger right shift.
51 define i64 @f4(i32 %a) {
54 ; CHECK-NEXT: # kill: def $r2l killed $r2l def $r2d
55 ; CHECK-NEXT: risbg %r2, %r2, 30, 158, 3
57 %shr = lshr i32 %a, 30
58 %ext = sext i32 %shr to i64
59 %shl = shl i64 %ext, 33
60 %and = and i64 %shl, 8589934592
64 ; Repeat the previous test in a case where all bits outside the
66 define i64 @f5(i32 %a) {
69 ; CHECK-NEXT: # kill: def $r2l killed $r2l def $r2d
70 ; CHECK-NEXT: risbg %r2, %r2, 29, 158, 3
71 ; CHECK-NEXT: lhi %r2, 7
73 %shr = lshr i32 %a, 30
74 %ext = sext i32 %shr to i64
75 %shl = shl i64 %ext, 33
80 ; Test that SRA gets replaced with SRL if the sign bit is the only one
82 define i64 @f6(i64 %a) {
85 ; CHECK-NEXT: risbg %r2, %r2, 55, 183, 19
88 %shr = ashr i64 %shl, 60
89 %and = and i64 %shr, 256
93 ; Test another form of f1.
94 define i64 @f7(i32 %a) {
97 ; CHECK-NEXT: # kill: def $r2l killed $r2l def $r2d
98 ; CHECK-NEXT: sllg %r0, %r2, 62
99 ; CHECK-NEXT: srag %r2, %r0, 63
100 ; CHECK-NEXT: br %r14
102 %sext = ashr i32 %1, 31
103 %ext = sext i32 %sext to i64