1; RUN: opt -passes=loop-vectorize -hexagon-autohvx=1 -force-vector-width=64 -prefer-predicate-over-epilogue=predicate-dont-vectorize -S %s | FileCheck %s
2
3target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
4target triple = "hexagon"
5
6; Test for PR45572.
7
8; Check that interleave groups and decisions based on them are correctly
9; invalidated with tail-folding on platforms where masked interleaved accesses
10; are disabled.
11
12; Make sure a vector body has been created, 64 element vectors are used and a block predicate has been computed.
13; Also make sure the loads are not widened.
14
15; CHECK-LABEL: @test1
16; CHECK: vector.body:
17; CHECK: icmp ule <64 x i32> %vec.ind
18; CHECK-NOT: load <{{.*}} x i32>
19
20
21define void @test1(ptr %arg, i32 %N) #0 {
22entry:
23  %tmp = alloca i32
24  br label %loop
25
26loop:                                              ; preds = %bb2, %bb
27  %iv = phi i32 [ %iv.next, %loop], [ 0, %entry ]
28  %idx.mul = mul nuw nsw i32 %iv, 7
29  %idx.start = add nuw nsw i32 %idx.mul, 1
30  %tmp6 = getelementptr inbounds i32, ptr %arg, i32 %idx.start
31  %tmp7 = load i32, ptr %tmp6, align 4
32  %tmp8 = add nuw nsw i32 %idx.start, 1
33  %tmp9 = getelementptr inbounds i32, ptr %arg, i32 %tmp8
34  %tmp10 = load i32, ptr %tmp9, align 4
35  %tmp11 = add nuw nsw i32 %idx.start, 2
36  %tmp12 = getelementptr inbounds i32, ptr %arg, i32 %tmp11
37  %tmp13 = load i32, ptr %tmp12, align 4
38  %tmp14 = add nuw nsw i32 %idx.start, 3
39  %tmp15 = getelementptr inbounds i32, ptr %arg, i32 %tmp14
40  %tmp16 = load i32, ptr %tmp15, align 4
41  %tmp18 = add nuw nsw i32 %idx.start, 4
42  %tmp19 = getelementptr inbounds i32, ptr %arg, i32 %tmp18
43  %tmp20 = load i32, ptr %tmp19, align 4
44  %tmp21 = add nuw nsw i32 %idx.start, 5
45  %tmp22 = getelementptr inbounds i32, ptr %arg, i32 %tmp21
46  %tmp23 = load i32, ptr %tmp22, align 4
47  %tmp25 = add nuw nsw i32 %idx.start, 6
48  %tmp26 = getelementptr inbounds i32, ptr %arg, i32 %tmp25
49  %tmp27 = load i32, ptr %tmp26, align 4
50  %add = add i32 %tmp7, %tmp27
51  store i32 %add, ptr %tmp, align 1
52  %iv.next= add nuw nsw i32 %iv, 1
53  %exit.cond = icmp eq i32 %iv.next, %N
54  br i1 %exit.cond, label %exit, label %loop
55
56exit:                                             ; preds = %loop
57  ret void
58}
59
60; The loop below only requires tail folding due to interleave groups with gaps.
61; Make sure the loads are not widened.
62
63; CHECK-LABEL: @test2
64; CHECK: vector.body:
65; CHECK-NOT: load <{{.*}} x i32>
66define void @test2(ptr %arg) #1 {
67entry:
68  %tmp = alloca i32
69  br label %loop
70
71loop:                                              ; preds = %bb2, %bb
72  %iv = phi i32 [ %iv.next, %loop], [ 0, %entry ]
73  %idx.start = mul nuw nsw i32 %iv, 5
74  %tmp6 = getelementptr inbounds i32, ptr %arg, i32 %idx.start
75  %tmp7 = load i32, ptr %tmp6, align 4
76  %tmp8 = add nuw nsw i32 %idx.start, 1
77  %tmp9 = getelementptr inbounds i32, ptr %arg, i32 %tmp8
78  %tmp10 = load i32, ptr %tmp9, align 4
79  %tmp11 = add nuw nsw i32 %idx.start, 2
80  %tmp12 = getelementptr inbounds i32, ptr %arg, i32 %tmp11
81  %tmp13 = load i32, ptr %tmp12, align 4
82  %tmp14 = add nuw nsw i32 %idx.start, 3
83  %tmp15 = getelementptr inbounds i32, ptr %arg, i32 %tmp14
84  %tmp16 = load i32, ptr %tmp15, align 4
85  %add = add i32 %tmp7, %tmp16
86  store i32 %add, ptr %tmp, align 1
87  %iv.next= add nuw nsw i32 %iv, 1
88  %exit.cond = icmp eq i32 %iv.next, 128
89  br i1 %exit.cond, label %exit, label %loop
90
91exit:                                             ; preds = %loop
92  ret void
93}
94
95
96attributes #0 = { "target-features"="+hvx,+hvx-length128b" }
97attributes #1 = { optsize "target-features"="+hvx,+hvx-length128b" }
98