1 ; Test sequences that can use ROSBG.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Test the simple case.
6 define i32 @f1(i32 %a, i32 %b) {
8 ; CHECK: rosbg %r2, %r3, 59, 59, 0
10 %andb = and i32 %b, 16
11 %or = or i32 %a, %andb
15 ; ...and again with i64.
16 define i64 @f2(i64 %a, i64 %b) {
18 ; CHECK: rosbg %r2, %r3, 59, 59, 0
20 %andb = and i64 %b, 16
21 %or = or i64 %a, %andb
25 ; Test a case where wraparound is needed.
26 define i32 @f3(i32 %a, i32 %b) {
28 ; CHECK: rosbg %r2, %r3, 63, 60, 0
30 %andb = and i32 %b, -7
31 %or = or i32 %a, %andb
35 ; ...and again with i64.
36 define i64 @f4(i64 %a, i64 %b) {
38 ; CHECK: rosbg %r2, %r3, 63, 60, 0
40 %andb = and i64 %b, -7
41 %or = or i64 %a, %andb
45 ; Test a case with just a shift.
46 define i32 @f6(i32 %a, i32 %b) {
48 ; CHECK: rosbg %r2, %r3, 32, 51, 12
50 %shrb = shl i32 %b, 12
51 %or = or i32 %a, %shrb
55 ; ...and again with i64.
56 define i64 @f7(i64 %a, i64 %b) {
58 ; CHECK: rosbg %r2, %r3, 0, 51, 12
60 %shrb = shl i64 %b, 12
61 %or = or i64 %a, %shrb
65 ; Test a case with just a rotate. This can't use ROSBG.
66 define i32 @f8(i32 %a, i32 %b) {
68 ; CHECK: rll {{%r[0-5]}}
69 ; CHECK: or {{%r[0-5]}}
71 %shlb = shl i32 %b, 30
72 %shrb = lshr i32 %b, 2
73 %rotlb = or i32 %shlb, %shrb
74 %or = or i32 %a, %rotlb
78 ; ...and again with i64, which can.
79 define i64 @f9(i64 %a, i64 %b) {
81 ; CHECK: rosbg %r2, %r3, 0, 63, 47
83 %shlb = shl i64 %b, 47
84 %shrb = lshr i64 %b, 17
85 %rotlb = or i64 %shlb, %shrb
86 %or = or i64 %a, %rotlb
90 ; Test a case with a shift and AND.
91 define i32 @f10(i32 %a, i32 %b) {
93 ; CHECK: rosbg %r2, %r3, 56, 59, 4
96 %andb = and i32 %shrb, 240
97 %or = or i32 %a, %andb
101 ; ...and again with i64.
102 define i64 @f11(i64 %a, i64 %b) {
104 ; CHECK: rosbg %r2, %r3, 56, 59, 4
106 %shrb = shl i64 %b, 4
107 %andb = and i64 %shrb, 240
108 %or = or i64 %a, %andb
112 ; Check the handling of zext and OR, which can use ROSBG.
113 define i64 @f12(i64 %a, i32 %b) {
115 ; CHECK: rosbg %r2, %r3, 32, 63, 0
118 %ext = zext i32 %add to i64
119 %or = or i64 %a, %ext