• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s  -loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7 -debug-only=loop-vectorize -S 2>&1 | FileCheck %s
2; REQUIRES: asserts
3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
6; CHECK-LABEL: test
7; CHECK-DAG: LV: Found uniform instruction:   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
8; CHECK-DAG: LV: Found uniform instruction:   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
9; CHECK-DAG: LV: Found uniform instruction:   %exitcond = icmp eq i64 %indvars.iv, 1599
10
11define void @test(float* noalias nocapture %a, float* noalias nocapture readonly %b) #0 {
12entry:
13  br label %for.body
14
15for.body:                                         ; preds = %for.body, %entry
16  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
17  %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
18  %tmp0 = load float, float* %arrayidx, align 4
19  %add = fadd float %tmp0, 1.000000e+00
20  %arrayidx5 = getelementptr inbounds float, float* %a, i64 %indvars.iv
21  store float %add, float* %arrayidx5, align 4
22  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
23  %exitcond = icmp eq i64 %indvars.iv, 1599
24  br i1 %exitcond, label %for.end, label %for.body
25
26for.end:                                          ; preds = %for.body
27  ret void
28}
29
30; CHECK-LABEL: foo
31; CHECK-DAG: LV: Found uniform instruction:   %cond = icmp eq i64 %i.next, %n
32; CHECK-DAG: LV: Found uniform instruction:   %tmp1 = getelementptr inbounds i32, i32* %a, i32 %tmp0
33; CHECK-NOT: LV: Found uniform instruction:   %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ]
34
35define void @foo(i32* %a, i64 %n) {
36entry:
37  br label %for.body
38
39for.body:
40  %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ]
41  %tmp0 = trunc i64 %i to i32
42  %tmp1 = getelementptr inbounds i32, i32* %a, i32 %tmp0
43  store i32 %tmp0, i32* %tmp1, align 4
44  %i.next = add nuw nsw i64 %i, 1
45  %cond = icmp eq i64 %i.next, %n
46  br i1 %cond, label %for.end, label %for.body
47
48for.end:
49  ret void
50}
51
52; CHECK-LABEL: goo
53; Check %indvars.iv and %indvars.iv.next are uniform instructions even if they are used outside of loop.
54; CHECK-DAG: LV: Found uniform instruction:   %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
55; CHECK-DAG: LV: Found uniform instruction:   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
56; CHECK-DAG: LV: Found uniform instruction:   %exitcond = icmp eq i64 %indvars.iv, 1599
57
58define i64 @goo(float* noalias nocapture %a, float* noalias nocapture readonly %b) #0 {
59entry:
60  br label %for.body
61
62for.body:                                         ; preds = %for.body, %entry
63  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
64  %arrayidx = getelementptr inbounds float, float* %b, i64 %indvars.iv
65  %tmp0 = load float, float* %arrayidx, align 4
66  %add = fadd float %tmp0, 1.000000e+00
67  %arrayidx5 = getelementptr inbounds float, float* %a, i64 %indvars.iv
68  store float %add, float* %arrayidx5, align 4
69  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
70  %exitcond = icmp eq i64 %indvars.iv, 1599
71  br i1 %exitcond, label %for.end, label %for.body
72
73for.end:                                          ; preds = %for.body
74  %retval = add i64 %indvars.iv, %indvars.iv.next
75  ret i64 %retval
76}
77
78; CHECK-LABEL: PR38786
79; Check that first order recurrence phis (%phi32 and %phi64) are not uniform.
80; CHECK-NOT: LV: Found uniform instruction:   %phi
81define void @PR38786(double* %y, double* %x, i64 %n) {
82entry:
83  br label %for.body
84
85for.body:
86  %phi32 = phi i32 [ 0, %entry ], [ %i32next, %for.body ]
87  %phi64 = phi i64 [ 0, %entry ], [ %i64next, %for.body ]
88  %i32next = add i32 %phi32, 1
89  %i64next = zext i32 %i32next to i64
90  %xip = getelementptr inbounds double, double* %x, i64 %i64next
91  %yip = getelementptr inbounds double, double* %y, i64 %phi64
92  %xi = load double, double* %xip, align 8
93  store double %xi, double* %yip, align 8
94  %cmp = icmp slt i64 %i64next, %n
95  br i1 %cmp, label %for.body, label %for.end
96
97for.end:
98  ret void
99}
100