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
6 ; RUN: llc < %s -mtriple=s390x-linux-gnu -early-live-intervals | FileCheck %s
8 ; Test that AND is not removed when some lower 5 bits are not set.
9 define i32 @f1(i32 %val, i32 %amt) {
12 ; CHECK-NEXT: nill %r3, 15
13 ; CHECK-NEXT: rll %r2, %r2, 0(%r3)
15 %and = and i32 %amt, 15
17 %inv = sub i32 32, %and
18 %parta = shl i32 %val, %and
19 %partb = lshr i32 %val, %inv
21 %rotl = or i32 %parta, %partb
26 ; Test removal of AND mask with only bottom 6 bits set.
27 define i32 @f2(i32 %val, i32 %amt) {
30 ; CHECK-NEXT: rll %r2, %r2, 0(%r3)
32 %and = and i32 %amt, 63
34 %inv = sub i32 32, %and
35 %parta = shl i32 %val, %and
36 %partb = lshr i32 %val, %inv
38 %rotl = or i32 %parta, %partb
43 ; Test removal of AND mask including but not limited to bottom 6 bits.
44 define i32 @f3(i32 %val, i32 %amt) {
47 ; CHECK-NEXT: rll %r2, %r2, 0(%r3)
49 %and = and i32 %amt, 255
51 %inv = sub i32 32, %and
52 %parta = shl i32 %val, %and
53 %partb = lshr i32 %val, %inv
55 %rotl = or i32 %parta, %partb
60 ; Test removal of AND mask from RLLG.
61 define i64 @f4(i64 %val, i64 %amt) {
64 ; CHECK-NEXT: rllg %r2, %r2, 0(%r3)
66 %and = and i64 %amt, 63
68 %inv = sub i64 64, %and
69 %parta = shl i64 %val, %and
70 %partb = lshr i64 %val, %inv
72 %rotl = or i64 %parta, %partb
77 ; Test that AND is not entirely removed if the result is reused.
78 define i32 @f5(i32 %val, i32 %amt) {
81 ; CHECK-NEXT: rll %r2, %r2, 0(%r3)
82 ; CHECK-NEXT: nilf %r3, 63
83 ; CHECK-NEXT: ar %r2, %r3
85 %and = and i32 %amt, 63
87 %inv = sub i32 32, %and
88 %parta = shl i32 %val, %and
89 %partb = lshr i32 %val, %inv
91 %rotl = or i32 %parta, %partb
93 %reuse = add i32 %and, %rotl