124 lines · plain
1; Test sequences that can use RXSBG.2;3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s4 5; Test the simple case.6define i32 @f1(i32 %a, i32 %b) {7; CHECK-LABEL: f1:8; CHECK: rxsbg %r2, %r3, 59, 59, 09; CHECK: br %r1410 %andb = and i32 %b, 1611 %xor = xor i32 %a, %andb12 ret i32 %xor13}14 15; ...and again with i64.16define i64 @f2(i64 %a, i64 %b) {17; CHECK-LABEL: f2:18; CHECK: rxsbg %r2, %r3, 59, 59, 019; CHECK: br %r1420 %andb = and i64 %b, 1621 %xor = xor i64 %a, %andb22 ret i64 %xor23}24 25; Test a case where wraparound is needed.26define i32 @f3(i32 %a, i32 %b) {27; CHECK-LABEL: f3:28; CHECK: rxsbg %r2, %r3, 63, 60, 029; CHECK: br %r1430 %andb = and i32 %b, -731 %xor = xor i32 %a, %andb32 ret i32 %xor33}34 35; ...and again with i64.36define i64 @f4(i64 %a, i64 %b) {37; CHECK-LABEL: f4:38; CHECK: rxsbg %r2, %r3, 63, 60, 039; CHECK: br %r1440 %andb = and i64 %b, -741 %xor = xor i64 %a, %andb42 ret i64 %xor43}44 45; Test a case with just a shift.46define i32 @f6(i32 %a, i32 %b) {47; CHECK-LABEL: f6:48; CHECK: rxsbg %r2, %r3, 32, 51, 1249; CHECK: br %r1450 %shlb = shl i32 %b, 1251 %xor = xor i32 %a, %shlb52 ret i32 %xor53}54 55; ...and again with i64.56define i64 @f7(i64 %a, i64 %b) {57; CHECK-LABEL: f7:58; CHECK: rxsbg %r2, %r3, 0, 51, 1259; CHECK: br %r1460 %shlb = shl i64 %b, 1261 %xor = xor i64 %a, %shlb62 ret i64 %xor63}64 65; Test a case with just a rotate (using XOR for the rotate combination too,66; to test that this kind of rotate does get recognised by the target-67; independent code). This can't use RXSBG.68define i32 @f8(i32 %a, i32 %b) {69; CHECK-LABEL: f8:70; CHECK: rll {{%r[0-5]}}71; CHECK: xr {{%r[0-5]}}72; CHECK: br %r1473 %shlb = shl i32 %b, 3074 %shrb = lshr i32 %b, 275 %rotlb = xor i32 %shlb, %shrb76 %xor = xor i32 %a, %rotlb77 ret i32 %xor78}79 80; ...and again with i64, which can use RXSBG for the rotate.81define i64 @f9(i64 %a, i64 %b) {82; CHECK-LABEL: f9:83; CHECK: rxsbg %r2, %r3, 0, 63, 4784; CHECK: br %r1485 %shlb = shl i64 %b, 4786 %shrb = lshr i64 %b, 1787 %rotlb = xor i64 %shlb, %shrb88 %xor = xor i64 %a, %rotlb89 ret i64 %xor90}91 92; Test a case with a shift and AND.93define i32 @f10(i32 %a, i32 %b) {94; CHECK-LABEL: f10:95; CHECK: rxsbg %r2, %r3, 56, 59, 496; CHECK: br %r1497 %shlb = shl i32 %b, 498 %andb = and i32 %shlb, 24099 %xor = xor i32 %a, %andb100 ret i32 %xor101}102 103; ...and again with i64.104define i64 @f11(i64 %a, i64 %b) {105; CHECK-LABEL: f11:106; CHECK: rxsbg %r2, %r3, 56, 59, 4107; CHECK: br %r14108 %shlb = shl i64 %b, 4109 %andb = and i64 %shlb, 240110 %xor = xor i64 %a, %andb111 ret i64 %xor112}113 114; Check the handling of zext and XOR, which can use ROSBG.115define i64 @f12(i64 %a, i32 %b) {116; CHECK-LABEL: f12:117; CHECK: rxsbg %r2, %r3, 32, 63, 0118; CHECK: br %r14119 %add = add i32 %b, 1120 %ext = zext i32 %add to i64121 %xor = xor i64 %a, %ext122 ret i64 %xor123}124