blob: 0a55923ec526b2492477025aa9528ff9d1672787 [file] [log] [blame]
Ehsan Amiria538b0f2016-08-03 18:17:35 +00001; RUN: llc -verify-machineinstrs -mcpu=pwr7 < %s | FileCheck %s
Hal Finkelcf599212015-02-25 21:36:59 +00002target datalayout = "E-m:e-i64:64-n32:64"
3target triple = "powerpc64-unknown-linux-gnu"
4
5@phasor = external constant [4096 x i32]
6
7; Function Attrs: nounwind
8define void @test(i32* nocapture %out, i32 zeroext %step_size) #0 {
9entry:
10 %shl = shl i32 %step_size, 2
11 %idxprom = zext i32 %shl to i64
12 br label %for.body
13
14; Make sure that the TOC load has been hoisted out of the loop.
15; CHECK-LABEL: @test
16; CHECK: ld {{[0-9]+}}, .LC{{[0-9]+}}@toc@l
17; CHECK: %for.body
18; CHECK: blr
19
20for.body: ; preds = %entry, %for.body
21 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
22 %0 = trunc i64 %indvars.iv to i32
23 %shl1 = shl i32 %0, %step_size
24 %idxprom2 = sext i32 %shl1 to i64
25 %arrayidx.sum = add nsw i64 %idxprom2, %idxprom
David Blaikie79e6c742015-02-27 19:29:02 +000026 %arrayidx3 = getelementptr inbounds [4096 x i32], [4096 x i32]* @phasor, i64 0, i64 %arrayidx.sum
David Blaikiea79ac142015-02-27 21:17:42 +000027 %1 = load i32, i32* %arrayidx3, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000028 %arrayidx5 = getelementptr inbounds i32, i32* %out, i64 %indvars.iv
Hal Finkelcf599212015-02-25 21:36:59 +000029 store i32 %1, i32* %arrayidx5, align 4
30 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 4
31 %cmp = icmp slt i64 %indvars.iv.next, 1020
32 br i1 %cmp, label %for.body, label %for.end
33
34for.end: ; preds = %for.body
35 ret void
36}
37
38attributes #0 = { nounwind }
39