llvm.org GIT mirror llvm / 861a410
Unit test for LSR phi reuse in r141442. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141472 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew Trick 8 years ago
1 changed file(s) with 53 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: opt -loop-reduce -S < %s | FileCheck %s
1 ;
2 ; Test LSR's intelligence regarding phi reuse.
3 ; Verify that scaled GEPs are not reused. rdar://5064068
4
5 target triple = "x86-apple-darwin"
6
7 ; CHECK: @test
8 ; multiplies are hoisted out of the loop
9 ; CHECK: while.body.lr.ph:
10 ; CHECK: mul i64
11 ; CHECK: mul i64
12 ; GEPs are ugly
13 ; CHECK: while.body:
14 ; CHECK: phi
15 ; CHECK: phi
16 ; CHECK: phi
17 ; CHECK: phi
18 ; CHECK-NOT: phi
19 ; CHECK: bitcast float* {{.*}} to i8*
20 ; CHECK: bitcast float* {{.*}} to i8*
21 ; CHECK: getelementptr i8*
22 ; CHECK: getelementptr i8*
23
24 define float @test(float* nocapture %A, float* nocapture %B, i32 %N, i32 %IA, i32 %IB) nounwind uwtable readonly ssp {
25 entry:
26 %cmp1 = icmp sgt i32 %N, 0
27 br i1 %cmp1, label %while.body.lr.ph, label %while.end
28
29 while.body.lr.ph: ; preds = %entry
30 %idx.ext = sext i32 %IA to i64
31 %idx.ext2 = sext i32 %IB to i64
32 br label %while.body
33
34 while.body: ; preds = %while.body.lr.ph, %while.body
35 %A.addr.05 = phi float* [ %A, %while.body.lr.ph ], [ %add.ptr, %while.body ]
36 %B.addr.04 = phi float* [ %B, %while.body.lr.ph ], [ %add.ptr3, %while.body ]
37 %N.addr.03 = phi i32 [ %N, %while.body.lr.ph ], [ %sub, %while.body ]
38 %Sum0.02 = phi float [ 0.000000e+00, %while.body.lr.ph ], [ %add, %while.body ]
39 %0 = load float* %A.addr.05, align 4
40 %1 = load float* %B.addr.04, align 4
41 %mul = fmul float %0, %1
42 %add = fadd float %Sum0.02, %mul
43 %add.ptr = getelementptr inbounds float* %A.addr.05, i64 %idx.ext
44 %add.ptr3 = getelementptr inbounds float* %B.addr.04, i64 %idx.ext2
45 %sub = add nsw i32 %N.addr.03, -1
46 %cmp = icmp sgt i32 %sub, 0
47 br i1 %cmp, label %while.body, label %while.end
48
49 while.end: ; preds = %while.body, %entry
50 %Sum0.0.lcssa = phi float [ 0.000000e+00, %entry ], [ %add, %while.body ]
51 ret float %Sum0.0.lcssa
52 }