Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -mtriple=i386-apple-macosx   | FileCheck %s --check-prefix=X32
      2 ; RUN: llc < %s -mtriple=x86_64-apple-macosx | FileCheck %s --check-prefix=X64
      3 
      4 define i32 @t1(i32 %t, i32 %val) nounwind {
      5 ; X32-LABEL: t1:
      6 ; X32-NOT: andl
      7 ; X32: shll
      8 
      9 ; X64-LABEL: t1:
     10 ; X64-NOT: andl
     11 ; X64: shll
     12        %shamt = and i32 %t, 31
     13        %res = shl i32 %val, %shamt
     14        ret i32 %res
     15 }
     16 
     17 define i32 @t2(i32 %t, i32 %val) nounwind {
     18 ; X32-LABEL: t2:
     19 ; X32-NOT: andl
     20 ; X32: shll
     21 
     22 ; X64-LABEL: t2:
     23 ; X64-NOT: andl
     24 ; X64: shll
     25        %shamt = and i32 %t, 63
     26        %res = shl i32 %val, %shamt
     27        ret i32 %res
     28 }
     29 
     30 @X = internal global i16 0
     31 
     32 define void @t3(i16 %t) nounwind {
     33 ; X32-LABEL: t3:
     34 ; X32-NOT: andl
     35 ; X32: sarw
     36 
     37 ; X64-LABEL: t3:
     38 ; X64-NOT: andl
     39 ; X64: sarw
     40        %shamt = and i16 %t, 31
     41        %tmp = load i16, i16* @X
     42        %tmp1 = ashr i16 %tmp, %shamt
     43        store i16 %tmp1, i16* @X
     44        ret void
     45 }
     46 
     47 define i64 @t4(i64 %t, i64 %val) nounwind {
     48 ; X64-LABEL: t4:
     49 ; X64-NOT: and
     50 ; X64: shrq
     51        %shamt = and i64 %t, 63
     52        %res = lshr i64 %val, %shamt
     53        ret i64 %res
     54 }
     55 
     56 define i64 @t5(i64 %t, i64 %val) nounwind {
     57 ; X64-LABEL: t5:
     58 ; X64-NOT: and
     59 ; X64: shrq
     60        %shamt = and i64 %t, 191
     61        %res = lshr i64 %val, %shamt
     62        ret i64 %res
     63 }
     64 
     65 
     66 ; rdar://11866926
     67 define i64 @t6(i64 %key, i64* nocapture %val) nounwind {
     68 entry:
     69 ; X64-LABEL: t6:
     70 ; X64-NOT: movabsq
     71 ; X64: decq
     72 ; X64: andq
     73   %shr = lshr i64 %key, 3
     74   %0 = load i64, i64* %val, align 8
     75   %sub = add i64 %0, 2305843009213693951
     76   %and = and i64 %sub, %shr
     77   ret i64 %and
     78 }
     79