Home | History | Annotate | Download | only in SystemZ
      1 ; Test shortening of NILL to NILF when the result is used as a shift amount.
      2 ;
      3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
      4 
      5 ; Test logical shift right.
      6 define i32 @f1(i32 %a, i32 %sh) {
      7 ; CHECK-LABEL: f1:
      8 ; CHECK: nill %r3, 31
      9 ; CHECK: srl %r2, 0(%r3)
     10   %and = and i32 %sh, 31
     11   %shift = lshr i32 %a, %and
     12   ret i32 %shift
     13 }
     14 
     15 ; Test arithmetic shift right.
     16 define i32 @f2(i32 %a, i32 %sh) {
     17 ; CHECK-LABEL: f2:
     18 ; CHECK: nill %r3, 31
     19 ; CHECK: sra %r2, 0(%r3)
     20   %and = and i32 %sh, 31
     21   %shift = ashr i32 %a, %and
     22   ret i32 %shift
     23 }
     24 
     25 ; Test shift left.
     26 define i32 @f3(i32 %a, i32 %sh) {
     27 ; CHECK-LABEL: f3:
     28 ; CHECK: nill %r3, 31
     29 ; CHECK: sll %r2, 0(%r3)
     30   %and = and i32 %sh, 31
     31   %shift = shl i32 %a, %and
     32   ret i32 %shift
     33 }
     34 
     35 ; Test 64-bit logical shift right.
     36 define i64 @f4(i64 %a, i64 %sh) {
     37 ; CHECK-LABEL: f4:
     38 ; CHECK: nill %r3, 31
     39 ; CHECK: srlg %r2, %r2, 0(%r3)
     40   %and = and i64 %sh, 31
     41   %shift = lshr i64 %a, %and
     42   ret i64 %shift
     43 }
     44 
     45 ; Test 64-bit arithmetic shift right.
     46 define i64 @f5(i64 %a, i64 %sh) {
     47 ; CHECK-LABEL: f5:
     48 ; CHECK: nill %r3, 31
     49 ; CHECK: srag %r2, %r2, 0(%r3)
     50   %and = and i64 %sh, 31
     51   %shift = ashr i64 %a, %and
     52   ret i64 %shift
     53 }
     54 
     55 ; Test 64-bit shift left.
     56 define i64 @f6(i64 %a, i64 %sh) {
     57 ; CHECK-LABEL: f6:
     58 ; CHECK: nill %r3, 31
     59 ; CHECK: sllg %r2, %r2, 0(%r3)
     60   %and = and i64 %sh, 31
     61   %shift = shl i64 %a, %and
     62   ret i64 %shift
     63 }
     64