1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --filter "LV: Found an estimated cost of [0-9]+ for VF [0-9]+ For instruction:\s*store i16 %[0,2], ptr %[a-zA-Z0-7]+, align 2"
2 ; RUN: opt -passes=loop-vectorize -enable-interleaved-mem-accesses -prefer-predicate-over-epilogue=predicate-dont-vectorize -S -mcpu=skx --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefix=DISABLED_MASKED_STRIDED
3 ; RUN: opt -passes=loop-vectorize -enable-interleaved-mem-accesses -enable-masked-interleaved-mem-accesses -prefer-predicate-over-epilogue=predicate-dont-vectorize -S -mcpu=skx --debug-only=loop-vectorize < %s 2>&1 | FileCheck %s --check-prefix=ENABLED_MASKED_STRIDED
6 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-unknown-linux-gnu"
9 ; (1) Interleave-group with factor 4, storing only 2 members out of the 4.
10 ; Check that when we allow masked-memops to support interleave-group with gaps,
11 ; the store is vectorized using a wide masked store, with a 1,1,0,0,1,1,0,0,... mask.
12 ; Check that when we don't allow masked-memops to support interleave-group with gaps,
13 ; the store is scalarized.
14 ; The input IR was generated from this source:
15 ; for(i=0;i<1024;i++){
17 ; points[i*4 + 1] = y[i];
19 ; (relates to the testcase in PR50566)
21 define void @test1(ptr noalias nocapture %points, ptr noalias nocapture readonly %x, ptr noalias nocapture readonly %y) {
22 ; DISABLED_MASKED_STRIDED-LABEL: 'test1'
23 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx2, align 2
24 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %2, ptr %arrayidx7, align 2
25 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx2, align 2
26 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %2, ptr %arrayidx7, align 2
27 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 6 for VF 2 For instruction: store i16 %0, ptr %arrayidx2, align 2
28 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 6 for VF 2 For instruction: store i16 %2, ptr %arrayidx7, align 2
29 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 13 for VF 4 For instruction: store i16 %0, ptr %arrayidx2, align 2
30 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 13 for VF 4 For instruction: store i16 %2, ptr %arrayidx7, align 2
31 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 27 for VF 8 For instruction: store i16 %0, ptr %arrayidx2, align 2
32 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 27 for VF 8 For instruction: store i16 %2, ptr %arrayidx7, align 2
33 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 55 for VF 16 For instruction: store i16 %0, ptr %arrayidx2, align 2
34 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 55 for VF 16 For instruction: store i16 %2, ptr %arrayidx7, align 2
36 ; ENABLED_MASKED_STRIDED-LABEL: 'test1'
37 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx2, align 2
38 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %2, ptr %arrayidx7, align 2
39 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx2, align 2
40 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %2, ptr %arrayidx7, align 2
41 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 6 for VF 2 For instruction: store i16 %0, ptr %arrayidx2, align 2
42 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 6 for VF 2 For instruction: store i16 %2, ptr %arrayidx7, align 2
43 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 0 for VF 4 For instruction: store i16 %0, ptr %arrayidx2, align 2
44 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 14 for VF 4 For instruction: store i16 %2, ptr %arrayidx7, align 2
45 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 0 for VF 8 For instruction: store i16 %0, ptr %arrayidx2, align 2
46 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 14 for VF 8 For instruction: store i16 %2, ptr %arrayidx7, align 2
47 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 0 for VF 16 For instruction: store i16 %0, ptr %arrayidx2, align 2
48 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 27 for VF 16 For instruction: store i16 %2, ptr %arrayidx7, align 2
54 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
55 %arrayidx = getelementptr inbounds i16, ptr %x, i64 %indvars.iv
56 %0 = load i16, ptr %arrayidx, align 2
57 %1 = shl nuw nsw i64 %indvars.iv, 2
58 %arrayidx2 = getelementptr inbounds i16, ptr %points, i64 %1
59 store i16 %0, ptr %arrayidx2, align 2
60 %arrayidx4 = getelementptr inbounds i16, ptr %y, i64 %indvars.iv
61 %2 = load i16, ptr %arrayidx4, align 2
62 %3 = or disjoint i64 %1, 1
63 %arrayidx7 = getelementptr inbounds i16, ptr %points, i64 %3
64 store i16 %2, ptr %arrayidx7, align 2
65 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
66 %exitcond.not = icmp eq i64 %indvars.iv.next, 1024
67 br i1 %exitcond.not, label %for.end, label %for.body
73 ; (2) Same as above, but this time the gaps mask of the store is also And-ed with the
74 ; fold-tail mask. If using masked memops to vectorize interleaved-group with gaps is
75 ; not allowed, the store is scalarized and predicated.
76 ; The input IR was generated from this source:
77 ; for(i=0;i<numPoints;i++){
79 ; points[i*4 + 1] = y[i];
82 define void @test2(ptr noalias nocapture %points, i32 %numPoints, ptr noalias nocapture readonly %x, ptr noalias nocapture readonly %y) {
83 ; DISABLED_MASKED_STRIDED-LABEL: 'test2'
84 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx2, align 2
85 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %2, ptr %arrayidx7, align 2
86 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx2, align 2
87 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %2, ptr %arrayidx7, align 2
88 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 5 for VF 2 For instruction: store i16 %0, ptr %arrayidx2, align 2
89 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 3000000 for VF 2 For instruction: store i16 %2, ptr %arrayidx7, align 2
90 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 10 for VF 4 For instruction: store i16 %0, ptr %arrayidx2, align 2
91 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 3000000 for VF 4 For instruction: store i16 %2, ptr %arrayidx7, align 2
92 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 21 for VF 8 For instruction: store i16 %0, ptr %arrayidx2, align 2
93 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 3000000 for VF 8 For instruction: store i16 %2, ptr %arrayidx7, align 2
94 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 43 for VF 16 For instruction: store i16 %0, ptr %arrayidx2, align 2
95 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 3000000 for VF 16 For instruction: store i16 %2, ptr %arrayidx7, align 2
97 ; ENABLED_MASKED_STRIDED-LABEL: 'test2'
98 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx2, align 2
99 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %2, ptr %arrayidx7, align 2
100 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx2, align 2
101 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %2, ptr %arrayidx7, align 2
102 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 5 for VF 2 For instruction: store i16 %0, ptr %arrayidx2, align 2
103 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 5 for VF 2 For instruction: store i16 %2, ptr %arrayidx7, align 2
104 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 0 for VF 4 For instruction: store i16 %0, ptr %arrayidx2, align 2
105 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 14 for VF 4 For instruction: store i16 %2, ptr %arrayidx7, align 2
106 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 0 for VF 8 For instruction: store i16 %0, ptr %arrayidx2, align 2
107 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 14 for VF 8 For instruction: store i16 %2, ptr %arrayidx7, align 2
108 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 0 for VF 16 For instruction: store i16 %0, ptr %arrayidx2, align 2
109 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 27 for VF 16 For instruction: store i16 %2, ptr %arrayidx7, align 2
112 %cmp15 = icmp sgt i32 %numPoints, 0
113 br i1 %cmp15, label %for.body.preheader, label %for.end
116 %wide.trip.count = zext i32 %numPoints to i64
120 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
121 %arrayidx = getelementptr inbounds i16, ptr %x, i64 %indvars.iv
122 %0 = load i16, ptr %arrayidx, align 2
123 %1 = shl nsw i64 %indvars.iv, 2
124 %arrayidx2 = getelementptr inbounds i16, ptr %points, i64 %1
125 store i16 %0, ptr %arrayidx2, align 2
126 %arrayidx4 = getelementptr inbounds i16, ptr %y, i64 %indvars.iv
127 %2 = load i16, ptr %arrayidx4, align 2
128 %3 = or disjoint i64 %1, 1
129 %arrayidx7 = getelementptr inbounds i16, ptr %points, i64 %3
130 store i16 %2, ptr %arrayidx7, align 2
131 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
132 %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
133 br i1 %exitcond.not, label %for.end.loopexit, label %for.body
142 ; (3) Testing a scenario of a conditional store. The gaps mask of the store is also
143 ; And-ed with the condition mask (x[i] > 0).
144 ; If using masked memops to vectorize interleaved-group with gaps is
145 ; not allowed, the store is scalarized and predicated.
146 ; Here the Interleave-group is with factor 3, storing only 1 member out of the 3.
147 ; The input IR was generated from this source:
148 ; for(i=0;i<1024;i++){
150 ; points[i*3] = x[i];
153 define void @test(ptr noalias nocapture %points, ptr noalias nocapture readonly %x, ptr noalias nocapture readnone %y) {
154 ; DISABLED_MASKED_STRIDED-LABEL: 'test'
155 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx6, align 2
156 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx6, align 2
157 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 2 for VF 2 For instruction: store i16 %0, ptr %arrayidx6, align 2
158 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 4 for VF 4 For instruction: store i16 %0, ptr %arrayidx6, align 2
159 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 8 for VF 8 For instruction: store i16 %0, ptr %arrayidx6, align 2
160 ; DISABLED_MASKED_STRIDED: LV: Found an estimated cost of 16 for VF 16 For instruction: store i16 %0, ptr %arrayidx6, align 2
162 ; ENABLED_MASKED_STRIDED-LABEL: 'test'
163 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx6, align 2
164 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 1 for VF 1 For instruction: store i16 %0, ptr %arrayidx6, align 2
165 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 2 for VF 2 For instruction: store i16 %0, ptr %arrayidx6, align 2
166 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 4 for VF 4 For instruction: store i16 %0, ptr %arrayidx6, align 2
167 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 8 for VF 8 For instruction: store i16 %0, ptr %arrayidx6, align 2
168 ; ENABLED_MASKED_STRIDED: LV: Found an estimated cost of 16 for VF 16 For instruction: store i16 %0, ptr %arrayidx6, align 2
174 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.inc ]
175 %arrayidx = getelementptr inbounds i16, ptr %x, i64 %indvars.iv
176 %0 = load i16, ptr %arrayidx, align 2
177 %cmp1 = icmp sgt i16 %0, 0
178 br i1 %cmp1, label %if.then, label %for.inc
181 %1 = mul nuw nsw i64 %indvars.iv, 3
182 %arrayidx6 = getelementptr inbounds i16, ptr %points, i64 %1
183 store i16 %0, ptr %arrayidx6, align 2
187 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
188 %exitcond.not = icmp eq i64 %indvars.iv.next, 1024
189 br i1 %exitcond.not, label %for.end, label %for.body