blob: c518cdd3aa4ea2037ab49acee357171c0e7ea617 [file] [log] [blame]
Jakob Stoklund Olesen8e869292012-05-20 06:38:32 +00001; RUN: llc < %s -march=x86 -verify-coalescing | FileCheck %s
Chris Lattnerbd8b13d2005-05-09 17:09:31 +00002
Chandler Carruth1e141a82012-01-05 11:05:47 +00003define i32* @test1(i32* %P, i32 %X) {
4; CHECK: test1:
5; CHECK-NOT: shrl
6; CHECK-NOT: shll
7; CHECK: ret
8
9entry:
10 %Y = lshr i32 %X, 2
11 %gep.upgrd.1 = zext i32 %Y to i64
12 %P2 = getelementptr i32* %P, i64 %gep.upgrd.1
13 ret i32* %P2
Chris Lattnerbd8b13d2005-05-09 17:09:31 +000014}
15
Chandler Carruth1e141a82012-01-05 11:05:47 +000016define i32* @test2(i32* %P, i32 %X) {
17; CHECK: test2:
18; CHECK: shll $4
19; CHECK-NOT: shll
20; CHECK: ret
21
22entry:
23 %Y = shl i32 %X, 2
24 %gep.upgrd.2 = zext i32 %Y to i64
25 %P2 = getelementptr i32* %P, i64 %gep.upgrd.2
26 ret i32* %P2
Chris Lattnerbd8b13d2005-05-09 17:09:31 +000027}
28
Chandler Carruth1e141a82012-01-05 11:05:47 +000029define i32* @test3(i32* %P, i32 %X) {
30; CHECK: test3:
31; CHECK-NOT: shrl
32; CHECK-NOT: shll
33; CHECK: ret
34
35entry:
36 %Y = ashr i32 %X, 2
37 %P2 = getelementptr i32* %P, i32 %Y
38 ret i32* %P2
Chris Lattnerbd8b13d2005-05-09 17:09:31 +000039}
Tanya Lattner33eefff2008-02-21 07:42:26 +000040
Chandler Carruth1e141a82012-01-05 11:05:47 +000041define fastcc i32 @test4(i32* %d) {
42; CHECK: test4:
43; CHECK-NOT: shrl
44; CHECK: ret
45
46entry:
Dan Gohman4e39e9d2010-06-24 14:30:44 +000047 %tmp4 = load i32* %d
48 %tmp512 = lshr i32 %tmp4, 24
49 ret i32 %tmp512
50}
Chandler Carruth62dfc512012-01-05 11:05:55 +000051
52define i64 @test5(i16 %i, i32* %arr) {
53; Ensure that we don't fold away shifts which have multiple uses, as they are
54; just re-introduced for the second use.
55; CHECK: test5:
56; CHECK-NOT: shrl
57; CHECK: shrl $11
58; CHECK-NOT: shrl
59; CHECK: ret
60
61entry:
62 %i.zext = zext i16 %i to i32
63 %index = lshr i32 %i.zext, 11
64 %index.zext = zext i32 %index to i64
65 %val.ptr = getelementptr inbounds i32* %arr, i64 %index.zext
66 %val = load i32* %val.ptr
67 %val.zext = zext i32 %val to i64
68 %sum = add i64 %val.zext, %index.zext
69 ret i64 %sum
70}