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