1 ; Test compound shifts.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Test a shift right followed by a sign extension. This can use two shifts.
6 define i64 @f1(i32 %a) {
8 ; CHECK: risbg %r0, %r2, 63, 191, 63
12 %trunc = trunc i32 %shr to i1
13 %ext = sext i1 %trunc to i64
17 ; ...and again with the highest shift count that doesn't reduce to an
19 define i64 @f2(i32 %a) {
21 ; CHECK: risbg %r0, %r2, 63, 191, 34
22 ; CHECK: lcgr %r2, %r0
24 %shr = lshr i32 %a, 30
25 %trunc = trunc i32 %shr to i1
26 %ext = sext i1 %trunc to i64
30 ; Test a left shift that of an extended right shift in a case where folding
32 define i64 @f3(i32 %a) {
34 ; CHECK: risbg %r2, %r2, 27, 181, 9
37 %ext = zext i32 %shr to i64
38 %shl = shl i64 %ext, 10
39 %and = and i64 %shl, 137438952960
43 ; ...and again with a larger right shift.
44 define i64 @f4(i32 %a) {
46 ; CHECK: risbg %r2, %r2, 30, 158, 3
48 %shr = lshr i32 %a, 30
49 %ext = sext i32 %shr to i64
50 %shl = shl i64 %ext, 33
51 %and = and i64 %shl, 8589934592
55 ; Repeat the previous test in a case where all bits outside the
57 define i64 @f5(i32 %a) {
59 ; CHECK: risbg %r2, %r2, 29, 158, 3
62 %shr = lshr i32 %a, 30
63 %ext = sext i32 %shr to i64
64 %shl = shl i64 %ext, 33
69 ; Test that SRA gets replaced with SRL if the sign bit is the only one
71 define i64 @f6(i64 %a) {
73 ; CHECK: risbg %r2, %r2, 55, 183, 19
76 %shr = ashr i64 %shl, 60
77 %and = and i64 %shr, 256
81 ; Test another form of f1.
82 define i64 @f7(i32 %a) {
84 ; CHECK: sllg [[REG:%r[0-5]]], %r2, 62
85 ; CHECK: srag %r2, [[REG]], 63
88 %sext = ashr i32 %1, 31
89 %ext = sext i32 %sext to i64