1 ; RUN: opt < %s -loop-vectorize -mtriple=thumbv7-apple-ios3.0.0 -S | FileCheck %s
2 ; RUN: opt < %s -loop-vectorize -mtriple=thumbv7-apple-ios3.0.0 -mcpu=swift -S | FileCheck %s --check-prefix=SWIFT
3 ; RUN: opt < %s -loop-vectorize -force-vector-width=1 -mtriple=thumbv7-apple-ios3.0.0 -mcpu=swift -S | FileCheck %s --check-prefix=SWIFTUNROLL
5 target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
6 target triple = "thumbv7-apple-ios3.0.0"
10 ;CHECK-NOT: load <4 x i32>
13 ;SWIFT: load <4 x i32>
14 ;SWIFT: load <4 x i32>
16 define i32 @foo(i32* nocapture %A, i32 %n) nounwind readonly ssp {
17 %1 = icmp sgt i32 %n, 0
18 br i1 %1, label %.lr.ph, label %._crit_edge
20 .lr.ph: ; preds = %0, %.lr.ph
21 %i.02 = phi i32 [ %5, %.lr.ph ], [ 0, %0 ]
22 %sum.01 = phi i32 [ %4, %.lr.ph ], [ 0, %0 ]
23 %2 = getelementptr inbounds i32* %A, i32 %i.02
24 %3 = load i32* %2, align 4
25 %4 = add nsw i32 %3, %sum.01
26 %5 = add nsw i32 %i.02, 1
27 %exitcond = icmp eq i32 %5, %n
28 br i1 %exitcond, label %._crit_edge, label %.lr.ph
30 ._crit_edge: ; preds = %.lr.ph, %0
31 %sum.0.lcssa = phi i32 [ 0, %0 ], [ %4, %.lr.ph ]
35 ; Verify the register limit. On arm we don't have 16 allocatable registers.
36 ;SWIFTUNROLL-LABEL: @register_limit(
37 ;SWIFTUNROLL: load i32
38 ;SWIFTUNROLL-NOT: load i32
39 define i32 @register_limit(i32* nocapture %A, i32 %n) {
40 %1 = icmp sgt i32 %n, 0
41 br i1 %1, label %.lr.ph, label %._crit_edge
44 %i.02 = phi i32 [ %5, %.lr.ph ], [ 0, %0 ]
45 %sum.01 = phi i32 [ %4, %.lr.ph ], [ 0, %0 ]
46 %sum.02 = phi i32 [ %6, %.lr.ph ], [ 0, %0 ]
47 %sum.03 = phi i32 [ %7, %.lr.ph ], [ 0, %0 ]
48 %sum.04 = phi i32 [ %8, %.lr.ph ], [ 0, %0 ]
49 %sum.05 = phi i32 [ %9, %.lr.ph ], [ 0, %0 ]
50 %2 = getelementptr inbounds i32* %A, i32 %i.02
51 %3 = load i32* %2, align 4
52 %4 = add nsw i32 %3, %sum.01
53 %5 = add nsw i32 %i.02, 1
54 %6 = add nsw i32 %3, %sum.02
55 %7 = add nsw i32 %3, %sum.03
56 %8 = add nsw i32 %3, %sum.04
57 %9 = add nsw i32 %3, %sum.05
58 %exitcond = icmp eq i32 %5, %n
59 br i1 %exitcond, label %._crit_edge, label %.lr.ph
61 ._crit_edge: ; preds = %.lr.ph, %0
62 %sum.0.lcssa = phi i32 [ 0, %0 ], [ %4, %.lr.ph ]
63 %sum.1.lcssa = phi i32 [ 0, %0 ], [ %6, %.lr.ph ]
64 %sum.2.lcssa = phi i32 [ 0, %0 ], [ %7, %.lr.ph ]
65 %sum.4.lcssa = phi i32 [ 0, %0 ], [ %8, %.lr.ph ]
66 %sum.5.lcssa = phi i32 [ 0, %0 ], [ %9, %.lr.ph ]