1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Test removal of AND operations that don't affect last 6 bits of rotate amount
5 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
7 ; Test that AND is not removed when some lower 5 bits are not set.
8 define i32 @f1(i32 %val, i32 %amt) {
11 ; CHECK-NEXT: nill %r3, 15
12 ; CHECK-NEXT: rll %r2, %r2, 0(%r3)
14 %and = and i32 %amt, 15
16 %inv = sub i32 32, %and
17 %parta = shl i32 %val, %and
18 %partb = lshr i32 %val, %inv
20 %rotl = or i32 %parta, %partb
25 ; Test removal of AND mask with only bottom 6 bits set.
26 define i32 @f2(i32 %val, i32 %amt) {
29 ; CHECK-NEXT: rll %r2, %r2, 0(%r3)
31 %and = and i32 %amt, 63
33 %inv = sub i32 32, %and
34 %parta = shl i32 %val, %and
35 %partb = lshr i32 %val, %inv
37 %rotl = or i32 %parta, %partb
42 ; Test removal of AND mask including but not limited to bottom 6 bits.
43 define i32 @f3(i32 %val, i32 %amt) {
46 ; CHECK-NEXT: rll %r2, %r2, 0(%r3)
48 %and = and i32 %amt, 255
50 %inv = sub i32 32, %and
51 %parta = shl i32 %val, %and
52 %partb = lshr i32 %val, %inv
54 %rotl = or i32 %parta, %partb
59 ; Test removal of AND mask from RLLG.
60 define i64 @f4(i64 %val, i64 %amt) {
63 ; CHECK-NEXT: rllg %r2, %r2, 0(%r3)
65 %and = and i64 %amt, 63
67 %inv = sub i64 64, %and
68 %parta = shl i64 %val, %and
69 %partb = lshr i64 %val, %inv
71 %rotl = or i64 %parta, %partb
76 ; Test that AND is not entirely removed if the result is reused.
77 define i32 @f5(i32 %val, i32 %amt) {
80 ; CHECK-NEXT: rll %r2, %r2, 0(%r3)
81 ; CHECK-NEXT: nilf %r3, 63
82 ; CHECK-NEXT: ar %r2, %r3
84 %and = and i32 %amt, 63
86 %inv = sub i32 32, %and
87 %parta = shl i32 %val, %and
88 %partb = lshr i32 %val, %inv
90 %rotl = or i32 %parta, %partb
92 %reuse = add i32 %and, %rotl