1; Test removal of AND operations that don't affect last 6 bits of rotate amount 2; operand. 3; 4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 5 6; Test that AND is not removed when some lower 6 bits are not set. 7define i32 @f1(i32 %val, i32 %amt) { 8; CHECK-LABEL: f1: 9; CHECK: nil{{[lf]}} %r3, 31 10; CHECK: rll %r2, %r2, 0(%r3) 11 %and = and i32 %amt, 31 12 13 %inv = sub i32 32, %and 14 %parta = shl i32 %val, %and 15 %partb = lshr i32 %val, %inv 16 17 %rotl = or i32 %parta, %partb 18 19 ret i32 %rotl 20} 21 22; Test removal of AND mask with only bottom 6 bits set. 23define i32 @f2(i32 %val, i32 %amt) { 24; CHECK-LABEL: f2: 25; CHECK-NOT: nil{{[lf]}} %r3, 63 26; CHECK: rll %r2, %r2, 0(%r3) 27 %and = and i32 %amt, 63 28 29 %inv = sub i32 32, %and 30 %parta = shl i32 %val, %and 31 %partb = lshr i32 %val, %inv 32 33 %rotl = or i32 %parta, %partb 34 35 ret i32 %rotl 36} 37 38; Test removal of AND mask including but not limited to bottom 6 bits. 39define i32 @f3(i32 %val, i32 %amt) { 40; CHECK-LABEL: f3: 41; CHECK-NOT: nil{{[lf]}} %r3, 255 42; CHECK: rll %r2, %r2, 0(%r3) 43 %and = and i32 %amt, 255 44 45 %inv = sub i32 32, %and 46 %parta = shl i32 %val, %and 47 %partb = lshr i32 %val, %inv 48 49 %rotl = or i32 %parta, %partb 50 51 ret i32 %rotl 52} 53 54; Test removal of AND mask from RLLG. 55define i64 @f4(i64 %val, i64 %amt) { 56; CHECK-LABEL: f4: 57; CHECK-NOT: nil{{[lf]}} %r3, 63 58; CHECK: rllg %r2, %r2, 0(%r3) 59 %and = and i64 %amt, 63 60 61 %inv = sub i64 64, %and 62 %parta = shl i64 %val, %and 63 %partb = lshr i64 %val, %inv 64 65 %rotl = or i64 %parta, %partb 66 67 ret i64 %rotl 68} 69 70; Test that AND is not entirely removed if the result is reused. 71define i32 @f5(i32 %val, i32 %amt) { 72; CHECK-LABEL: f5: 73; CHECK: rll %r2, %r2, 0(%r3) 74; CHECK: nil{{[lf]}} %r3, 63 75; CHECK: ar %r2, %r3 76 %and = and i32 %amt, 63 77 78 %inv = sub i32 32, %and 79 %parta = shl i32 %val, %and 80 %partb = lshr i32 %val, %inv 81 82 %rotl = or i32 %parta, %partb 83 84 %reuse = add i32 %and, %rotl 85 ret i32 %reuse 86} 87