Lines Matching refs:loop

34 Attributes can be attached to loops as described in :ref:`llvm.loop`.
35 Attributes can describe properties of the loop, disable transformations,
40 metadata), in order to add or remove a loop attributes, a new ``MDNode``
41 must be created and assigned as the new ``llvm.loop`` metadata. Any
42 connection between the old ``MDNode`` and the loop is lost. The
43 ``llvm.loop`` node is also used as LoopID (``Loop::getLoopID()``), i.e.
44 the loop effectively gets a new identifier. For instance,
47 loop attributes, any ``llvm.mem.parallel_loop_access`` reference must be
54 loop distribution, etc.). They can either be a hint to the optimizer
57 ``#pragma clang loop`` or ``#pragma omp simd``).
69 different loop or the loop not existing anymore. To avoid having to
71 ``llvm.loop.disable_nonforced`` disables all optional, high-level,
74 The following example avoids the loop being altered before being
79 br i1 %exitcond, label %for.exit, label %for.header, !llvm.loop !0
82 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
83 !2 = !{!"llvm.loop.disable_nonforced"}
86 transformed and/or new loop(s). This allows additional attributes
90 ``llvm.loop.vectorize.enable`` and ``llvm.loop.unroll.enable`` are
94 As an example, the following instructs a loop to be vectorized and only
100 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
101 !2 = !{!"llvm.loop.disable_nonforced"}
102 !3 = !{!"llvm.loop.vectorize.followup_vectorized", !{"llvm.loop.unroll.enable"}}
105 For instance, the vectorizer adds a ``llvm.loop.isvectorized`` attribute and
106 all attributes from the original loop excluding its loop vectorizer
111 !3 = !{!"llvm.loop.vectorize.followup_vectorized"}
114 never be added to a loop and are therefore effectively ignored. This means
125 following, we present the model for each LLVM loop optimization pass and
133 ``!{"llvm.loop.vectorize.enable", i1 true}`` is set.
135 Assuming the pre-vectorization loop is
139 for (int i = 0; i < n; i+=1) // original loop
149 for (; i + 3 < n; i+=4) // vectorized/interleaved loop
152 for (; i < n; i+=1) // epilogue loop
157 ``llvm.loop.vectorize.followup_vectorized`` will set the attributes for
158 the vectorized loop. If not specified, ``llvm.loop.isvectorized`` is
159 combined with the original loop's attributes to avoid it being
162 ``llvm.loop.vectorize.followup_epilogue`` will set the attributes for
163 the remainder loop. If not specified, it will have the original loop's
164 attributes combined with ``llvm.loop.isvectorized`` and
165 ``llvm.loop.unroll.runtime.disable`` (unless the original loop already
168 The attributes specified by ``llvm.loop.vectorize.followup_all`` are
172 attributes for the generated loop in question. Therefore it is
173 recommended to add ``llvm.loop.isvectorized`` to
174 ``llvm.loop.vectorize.followup_all`` which avoids that the loop
180 Unrolling is interpreted as forced any ``!{!"llvm.loop.unroll.enable"}``
181 metadata or option (``llvm.loop.unroll.count``, ``llvm.loop.unroll.full``)
182 is present. Unrolling can be full unrolling, partial unrolling of a loop
183 with constant trip count or runtime unrolling of a loop with a trip
186 If the loop has been unrolled fully, there is no followup-loop. For
187 partial/runtime unrolling, the original loop of
191 for (int i = 0; i < n; i+=1) // original loop
199 for (; i + 3 < n; i+=4) { // unrolled loop
205 for (; i < n; i+=1) // remainder loop
208 ``llvm.loop.unroll.followup_unrolled`` will set the loop attributes of
209 the unrolled loop. If not specified, the attributes of the original loop
210 without the ``llvm.loop.unroll.*`` attributes are copied and
211 ``llvm.loop.unroll.disable`` added to it.
213 ``llvm.loop.unroll.followup_remainder`` defines the attributes of the
214 remainder loop. If not specified the remainder loop will have no
215 attributes. The remainder loop might not be present due to being fully
218 Attributes defined in ``llvm.loop.unroll.followup_all`` are added to the
221 To avoid that the partially unrolled loop is unrolled again, it is
222 recommended to add ``llvm.loop.unroll.disable`` to
223 ``llvm.loop.unroll.followup_all``. If no follow-up attribute specified
224 for a generated loop, it is added automatically.
235 for (int i = 0; i < n; i+=1) { // original outer loop
237 for (int j = 0; j < m; j+=1) // original inner loop
245 for (; i + 1 < n; i+=2) { // unrolled outer loop
248 for (int j = 0; j < m; j+=1) { // unrolled inner loop
255 for (; i < n; i+=1) { // remainder outer loop
257 for (int j = 0; j < m; j+=1) // remainder inner loop
262 ``llvm.loop.unroll_and_jam.followup_outer`` will set the loop attributes
263 of the unrolled outer loop. If not specified, the attributes of the
264 original outer loop without the ``llvm.loop.unroll.*`` attributes are
265 copied and ``llvm.loop.unroll.disable`` added to it.
267 ``llvm.loop.unroll_and_jam.followup_inner`` will set the loop attributes
268 of the unrolled inner loop. If not specified, the attributes of the
269 original inner loop are used unchanged.
271 ``llvm.loop.unroll_and_jam.followup_remainder_outer`` sets the loop
272 attributes of the outer remainder loop. If not specified it will not
273 have any attributes. The remainder loop might not be present due to
276 ``llvm.loop.unroll_and_jam.followup_remainder_inner`` sets the loop
277 attributes of the inner remainder loop. If not specified it will have
278 the attributes of the original inner loop. It the outer remainder loop
279 is unrolled, the inner remainder loop might be present multiple times.
281 Attributes defined in ``llvm.loop.unroll_and_jam.followup_all`` are
284 To avoid that the unrolled loop is unrolled again, it is
285 recommended to add ``llvm.loop.unroll.disable`` to
286 ``llvm.loop.unroll_and_jam.followup_all``. It suppresses unroll-and-jam
287 as well as an additional inner loop unrolling. If no follow-up
288 attribute specified for a generated loop, it is added automatically.
293 The LoopDistribution pass tries to separate vectorizable parts of a loop
295 loop non-vectorizable). Conceptually, it transforms a loop such as
299 for (int i = 1; i < n; i+=1) { // original loop
310 for (int i = 1; i < n; i+=1) // coincident loop
312 for (int i = 1; i < n; i+=1) // coincident loop
314 for (int i = 1; i < n; i+=1) // sequential loop
317 for (int i = 1; i < n; i+=1) { // fallback loop
326 ``llvm.loop.distribute.followup_coincident`` sets the loop attributes of
327 all loops without loop-carried dependencies (i.e. vectorizable loops).
329 inherit the original loop's attributes.
331 ``llvm.loop.distribute.followup_sequential`` sets the loop attributes of the
332 loop with potentially unsafe dependencies. There should be at most one
333 such loop. If not defined, the loop will inherit the original loop's
336 ``llvm.loop.distribute.followup_fallback`` defines the loop attributes
337 for the fallback loop, which is a copy of the original loop for when
338 loop versioning is required. If undefined, the fallback loop inherits
339 all attributes from the original loop.
341 Attributes defined in ``llvm.loop.distribute.followup_all`` are added to
344 It is recommended to add ``llvm.loop.disable_nonforced`` to
345 ``llvm.loop.distribute.followup_fallback``. This avoids that the
352 The pass hoists code out of loops that are only loop-invariant when
353 dynamic conditions apply. For instance, it transforms the loop
357 for (int i = 0; i < n; i+=1) // original loop
366 for (int i = 0; i < n; i+=1) // versioned loop
369 for (int i = 0; i < n; i+=1) // unversioned loop
433 that is executed later and thus leftover. For instance, a loop nest
435 pipeline. The loop distribution will execute, but there is no loop
436 interchange pass following such that any loop interchange metadata will