• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -march=x86 < %s | FileCheck %s
2
3@array = weak global [4 x i32] zeroinitializer
4
5define i32 @test_lshr_and(i32 %x) {
6; CHECK-LABEL: test_lshr_and:
7; CHECK-NOT: shrl
8; CHECK: andl $12,
9; CHECK: movl {{.*}}array{{.*}},
10; CHECK: ret
11
12entry:
13  %tmp2 = lshr i32 %x, 2
14  %tmp3 = and i32 %tmp2, 3
15  %tmp4 = getelementptr [4 x i32], [4 x i32]* @array, i32 0, i32 %tmp3
16  %tmp5 = load i32, i32* %tmp4, align 4
17  ret i32 %tmp5
18}
19
20define i32* @test_exact1(i32 %a, i32 %b, i32* %x)  {
21; CHECK-LABEL: test_exact1:
22; CHECK: sarl %
23
24  %sub = sub i32 %b, %a
25  %shr = ashr exact i32 %sub, 3
26  %gep = getelementptr inbounds i32, i32* %x, i32 %shr
27  ret i32* %gep
28}
29
30define i32* @test_exact2(i32 %a, i32 %b, i32* %x)  {
31; CHECK-LABEL: test_exact2:
32; CHECK: sarl %
33
34  %sub = sub i32 %b, %a
35  %shr = ashr exact i32 %sub, 3
36  %gep = getelementptr inbounds i32, i32* %x, i32 %shr
37  ret i32* %gep
38}
39
40define i32* @test_exact3(i32 %a, i32 %b, i32* %x)  {
41; CHECK-LABEL: test_exact3:
42; CHECK-NOT: sarl
43
44  %sub = sub i32 %b, %a
45  %shr = ashr exact i32 %sub, 2
46  %gep = getelementptr inbounds i32, i32* %x, i32 %shr
47  ret i32* %gep
48}
49
50define i32* @test_exact4(i32 %a, i32 %b, i32* %x)  {
51; CHECK-LABEL: test_exact4:
52; CHECK: shrl %
53
54  %sub = sub i32 %b, %a
55  %shr = lshr exact i32 %sub, 3
56  %gep = getelementptr inbounds i32, i32* %x, i32 %shr
57  ret i32* %gep
58}
59
60define i32* @test_exact5(i32 %a, i32 %b, i32* %x)  {
61; CHECK-LABEL: test_exact5:
62; CHECK: shrl %
63
64  %sub = sub i32 %b, %a
65  %shr = lshr exact i32 %sub, 3
66  %gep = getelementptr inbounds i32, i32* %x, i32 %shr
67  ret i32* %gep
68}
69
70define i32* @test_exact6(i32 %a, i32 %b, i32* %x)  {
71; CHECK-LABEL: test_exact6:
72; CHECK-NOT: shrl
73
74  %sub = sub i32 %b, %a
75  %shr = lshr exact i32 %sub, 2
76  %gep = getelementptr inbounds i32, i32* %x, i32 %shr
77  ret i32* %gep
78}
79