1 ; Test removal of AND operations that don't affect last 6 bits of rotate amount
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 ; Test that AND is not removed when some lower 6 bits are not set.
7 define i32 @f1(i32 %val, i32 %amt) {
9 ; CHECK: nil{{[lf]}} %r3, 31
10 ; CHECK: rll %r2, %r2, 0(%r3)
11 %and = and i32 %amt, 31
13 %inv = sub i32 32, %and
14 %parta = shl i32 %val, %and
15 %partb = lshr i32 %val, %inv
17 %rotl = or i32 %parta, %partb
22 ; Test removal of AND mask with only bottom 6 bits set.
23 define i32 @f2(i32 %val, i32 %amt) {
25 ; CHECK-NOT: nil{{[lf]}} %r3, 63
26 ; CHECK: rll %r2, %r2, 0(%r3)
27 %and = and i32 %amt, 63
29 %inv = sub i32 32, %and
30 %parta = shl i32 %val, %and
31 %partb = lshr i32 %val, %inv
33 %rotl = or i32 %parta, %partb
38 ; Test removal of AND mask including but not limited to bottom 6 bits.
39 define i32 @f3(i32 %val, i32 %amt) {
41 ; CHECK-NOT: nil{{[lf]}} %r3, 255
42 ; CHECK: rll %r2, %r2, 0(%r3)
43 %and = and i32 %amt, 255
45 %inv = sub i32 32, %and
46 %parta = shl i32 %val, %and
47 %partb = lshr i32 %val, %inv
49 %rotl = or i32 %parta, %partb
54 ; Test removal of AND mask from RLLG.
55 define i64 @f4(i64 %val, i64 %amt) {
57 ; CHECK-NOT: nil{{[lf]}} %r3, 63
58 ; CHECK: rllg %r2, %r2, 0(%r3)
59 %and = and i64 %amt, 63
61 %inv = sub i64 64, %and
62 %parta = shl i64 %val, %and
63 %partb = lshr i64 %val, %inv
65 %rotl = or i64 %parta, %partb
70 ; Test that AND is not entirely removed if the result is reused.
71 define i32 @f5(i32 %val, i32 %amt) {
73 ; CHECK: rll %r2, %r2, 0(%r3)
74 ; CHECK: nil{{[lf]}} %r3, 63
76 %and = and i32 %amt, 63
78 %inv = sub i32 32, %and
79 %parta = shl i32 %val, %and
80 %partb = lshr i32 %val, %inv
82 %rotl = or i32 %parta, %partb
84 %reuse = add i32 %and, %rotl