• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -loop-reduce -S < %s | FileCheck %s
2;
3; Test LSR's intelligence regarding phi reuse.
4; Verify that scaled GEPs are not reused. rdar://5064068
5
6target triple = "x86-apple-darwin"
7
8; Provide legal integer types.
9target datalayout = "n8:16:32:64"
10
11
12; CHECK-LABEL: @test(
13; multiplies are hoisted out of the loop
14; CHECK: while.body.lr.ph:
15; CHECK: shl i64
16; CHECK: shl i64
17; GEPs are ugly
18; CHECK: while.body:
19; CHECK: phi
20; CHECK: phi
21; CHECK: phi
22; CHECK: phi
23; CHECK-NOT: phi
24; CHECK: bitcast float* {{.*}} to i1*
25; CHECK: bitcast float* {{.*}} to i1*
26; CHECK: getelementptr i1, i1*
27; CHECK: getelementptr i1, i1*
28
29define float @test(float* nocapture %A, float* nocapture %B, i32 %N, i32 %IA, i32 %IB) nounwind uwtable readonly ssp {
30entry:
31  %cmp1 = icmp sgt i32 %N, 0
32  br i1 %cmp1, label %while.body.lr.ph, label %while.end
33
34while.body.lr.ph:                                 ; preds = %entry
35  %idx.ext = sext i32 %IA to i64
36  %idx.ext2 = sext i32 %IB to i64
37  br label %while.body
38
39while.body:                                       ; preds = %while.body.lr.ph, %while.body
40  %A.addr.05 = phi float* [ %A, %while.body.lr.ph ], [ %add.ptr, %while.body ]
41  %B.addr.04 = phi float* [ %B, %while.body.lr.ph ], [ %add.ptr3, %while.body ]
42  %N.addr.03 = phi i32 [ %N, %while.body.lr.ph ], [ %sub, %while.body ]
43  %Sum0.02 = phi float [ 0.000000e+00, %while.body.lr.ph ], [ %add, %while.body ]
44  %0 = load float, float* %A.addr.05, align 4
45  %1 = load float, float* %B.addr.04, align 4
46  %mul = fmul float %0, %1
47  %add = fadd float %Sum0.02, %mul
48  %add.ptr = getelementptr inbounds float, float* %A.addr.05, i64 %idx.ext
49  %add.ptr3 = getelementptr inbounds float, float* %B.addr.04, i64 %idx.ext2
50  %sub = add nsw i32 %N.addr.03, -1
51  %cmp = icmp sgt i32 %sub, 0
52  br i1 %cmp, label %while.body, label %while.end
53
54while.end:                                        ; preds = %while.body, %entry
55  %Sum0.0.lcssa = phi float [ 0.000000e+00, %entry ], [ %add, %while.body ]
56  ret float %Sum0.0.lcssa
57}
58