<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/test/Transforms/LoopUnrollAndJam, branch users/nico/python-2</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[UnrollAndJam] Do not preserve loop nests if a loop was fully unrolled. (#133510)</title>
<updated>2025-03-29T19:21:34+00:00</updated>
<author>
<name>David Green</name>
<email>david.green@arm.com</email>
</author>
<published>2025-03-29T19:21:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3ef33066bb32a9d9b76d72c6de6a7ae9ff72ddcc'/>
<id>3ef33066bb32a9d9b76d72c6de6a7ae9ff72ddcc</id>
<content type='text'>
If UnJ completely unrolls a loop and removes it entirely, the loop
remains in the current loop nest. If the loop nest gets reused the loops
will no longer be valid. As there is no way to remove a loop from a
LoopNest, this patch removes the preserve of the LoopNestAnalysis so
that it will be regenerated.

Fixes #124518</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If UnJ completely unrolls a loop and removes it entirely, the loop
remains in the current loop nest. If the loop nest gets reused the loops
will no longer be valid. As there is no way to remove a loop from a
LoopNest, this patch removes the preserve of the LoopNestAnalysis so
that it will be regenerated.

Fixes #124518</pre>
</div>
</content>
</entry>
<entry>
<title>[LoopUnroll] Use poison instead of undef for preheader value</title>
<updated>2024-06-25T10:09:58+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2024-06-25T10:02:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=eeb0884e6696ec618feb2181a432d10f66d4e840'/>
<id>eeb0884e6696ec618feb2181a432d10f66d4e840</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[LoopUnroll] Fold add chains during unrolling</title>
<updated>2023-07-05T07:54:28+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2023-06-14T08:34:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b9808e5660f5fe9e7414c0c0b93acd899235471c'/>
<id>b9808e5660f5fe9e7414c0c0b93acd899235471c</id>
<content type='text'>
Loop unrolling tends to produce chains of
`%x1 = add %x0, 1; %x2 = add %x1, 1; ...` with one add per unrolled
iteration. This patch simplifies these adds to `%xN = add %x0, N`
directly during unrolling, rather than waiting for InstCombine to do so.

The motivation for this is that having a single add (rather than
an add chain) on the induction variable makes it a simple recurrence,
which we specially recognize in a number of places. This allows
InstCombine to directly perform folds with that knowledge, instead
of first folding the add chains, and then doing other folds in another
InstCombine iteration.

Due to the reduced number of InstCombine iterations, this also
results in a small compile-time improvement.

Differential Revision: https://reviews.llvm.org/D153540
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Loop unrolling tends to produce chains of
`%x1 = add %x0, 1; %x2 = add %x1, 1; ...` with one add per unrolled
iteration. This patch simplifies these adds to `%xN = add %x0, N`
directly during unrolling, rather than waiting for InstCombine to do so.

The motivation for this is that having a single add (rather than
an add chain) on the induction variable makes it a simple recurrence,
which we specially recognize in a number of places. This allows
InstCombine to directly perform folds with that knowledge, instead
of first folding the add chains, and then doing other folds in another
InstCombine iteration.

Due to the reduced number of InstCombine iterations, this also
results in a small compile-time improvement.

Differential Revision: https://reviews.llvm.org/D153540
</pre>
</div>
</content>
</entry>
<entry>
<title>[Transforms] Convert some tests to opaque pointers (NFC)</title>
<updated>2023-01-05T11:43:45+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2023-01-05T11:35:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=055fb7795aa219a3d274d280ec9129784f169f56'/>
<id>055fb7795aa219a3d274d280ec9129784f169f56</id>
<content type='text'>
These are all tests where conversion worked automatically, and
required no manual fixup.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These are all tests where conversion worked automatically, and
required no manual fixup.
</pre>
</div>
</content>
</entry>
<entry>
<title>[LoopUnrollAndJam] Visit phi operand dependencies in post-order</title>
<updated>2023-01-05T08:05:49+00:00</updated>
<author>
<name>Joshua Cao</name>
<email>cao.joshua@yahoo.com</email>
</author>
<published>2022-12-16T09:00:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=629d880dc527cd7a8d692cd24af196db4ea8646b'/>
<id>629d880dc527cd7a8d692cd24af196db4ea8646b</id>
<content type='text'>
Fixes https://github.com/llvm/llvm-project/issues/58565

The previous implementation visits operands in pre-order, but this does
not guarantee an instruction is visited before its uses. This can cause
instructions to be copied in the incorrect order. For example:

```
a = ...
b = add a, 1
c = add a, b
d = add b, a
```

Pre-order visits does not guarantee the order in which `a` and `b` are
visited. LoopUnrollAndJam may incorrectly insert `b` before `a`.

This patch implements post-order visits. By visiting dependencies first,
we guarantee that an instruction's dependencies are visited first.

Differential Revision: https://reviews.llvm.org/D140255
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes https://github.com/llvm/llvm-project/issues/58565

The previous implementation visits operands in pre-order, but this does
not guarantee an instruction is visited before its uses. This can cause
instructions to be copied in the incorrect order. For example:

```
a = ...
b = add a, 1
c = add a, b
d = add b, a
```

Pre-order visits does not guarantee the order in which `a` and `b` are
visited. LoopUnrollAndJam may incorrectly insert `b` before `a`.

This patch implements post-order visits. By visiting dependencies first,
we guarantee that an instruction's dependencies are visited first.

Differential Revision: https://reviews.llvm.org/D140255
</pre>
</div>
</content>
</entry>
<entry>
<title>[LoopUnrollAndJam] Forget scalar evolution dispositions. Do no explicitly forget subloop.</title>
<updated>2023-01-05T03:35:50+00:00</updated>
<author>
<name>Joshua Cao</name>
<email>cao.joshua@yahoo.com</email>
</author>
<published>2023-01-04T06:37:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=50be2859443a7dea7c160cfb1e145832327b9ed8'/>
<id>50be2859443a7dea7c160cfb1e145832327b9ed8</id>
<content type='text'>
Fixes https://github.com/llvm/llvm-project/issues/58454

Scalar evolution dispositions need to be forgotten to pass verification.

We do not need to forget the subloop since it is automatically forgotten
when forgetting the parent loop.

Differential Revision: https://reviews.llvm.org/D140953
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes https://github.com/llvm/llvm-project/issues/58454

Scalar evolution dispositions need to be forgotten to pass verification.

We do not need to forget the subloop since it is automatically forgotten
when forgetting the parent loop.

Differential Revision: https://reviews.llvm.org/D140953
</pre>
</div>
</content>
</entry>
<entry>
<title>[NFC] Port all LoopUnrollAndJam tests to `-passes=` syntax</title>
<updated>2022-12-07T23:38:47+00:00</updated>
<author>
<name>Roman Lebedev</name>
<email>lebedev.ri@gmail.com</email>
</author>
<published>2022-12-07T23:27:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=865d88d47f29103c61cd1f7048707d5d02a0a985'/>
<id>865d88d47f29103c61cd1f7048707d5d02a0a985</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[opt] Don't translate legacy -analysis flag to require&lt;analysis&gt;</title>
<updated>2022-10-07T21:54:34+00:00</updated>
<author>
<name>Arthur Eubanks</name>
<email>aeubanks@google.com</email>
</author>
<published>2022-10-07T20:12:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f3a928e2334a4e8e3f09406f2ce7e1cbac520f95'/>
<id>f3a928e2334a4e8e3f09406f2ce7e1cbac520f95</id>
<content type='text'>
Tests relying on this should explicitly use -passes='require&lt;analysis&gt;,foo'.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Tests relying on this should explicitly use -passes='require&lt;analysis&gt;,foo'.
</pre>
</div>
</content>
</entry>
<entry>
<title>[LoopUnroll] Disable loop unroll when user explicitly asks for unroll-and-jam</title>
<updated>2021-12-15T15:58:05+00:00</updated>
<author>
<name>Zaara Syeda</name>
<email>syzaara@ca.ibm.com</email>
</author>
<published>2021-12-15T15:31:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=e0669931afdb3f11f1f1e359482372ae5f3c8cd5'/>
<id>e0669931afdb3f11f1f1e359482372ae5f3c8cd5</id>
<content type='text'>
If a loop isn't forced to be unrolled, we want to avoid unrolling it when there
is an explicit unroll-and-jam pragma. This is to prevent automatic unrolling
from interfering with the user requested transformation.
Missed adding the testcase in earlier commit.

Differential Revision: https://reviews.llvm.org/D114886
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If a loop isn't forced to be unrolled, we want to avoid unrolling it when there
is an explicit unroll-and-jam pragma. This is to prevent automatic unrolling
from interfering with the user requested transformation.
Missed adding the testcase in earlier commit.

Differential Revision: https://reviews.llvm.org/D114886
</pre>
</div>
</content>
</entry>
<entry>
<title>[runtime-unroll] Use incrementing IVs instead of decrementing ones</title>
<updated>2021-11-12T23:44:58+00:00</updated>
<author>
<name>Philip Reames</name>
<email>listmail@philipreames.com</email>
</author>
<published>2021-11-12T23:00:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=37ead201e6148f2b079179a71ccbad5af223ce03'/>
<id>37ead201e6148f2b079179a71ccbad5af223ce03</id>
<content type='text'>
This is one of those wonderful "in theory X doesn't matter, but in practice is does" changes. In this particular case, we shift the IVs inserted by the runtime unroller to clamp iteration count of the loops* from decrementing to incrementing.

Why does this matter?  A couple of reasons:
* SCEV doesn't have a native subtract node.  Instead, all subtracts (A - B) are represented as A + -1 * B and drops any flags invalidated by such.  As a result, SCEV is slightly less good at reasoning about edge cases involving decrementing addrecs than incrementing ones.  (You can see this in the inferred flags in some of the test cases.)
* Other parts of the optimizer produce incrementing IVs, and they're common in idiomatic source language.  We do have support for reversing IVs, but in general if we produce one of each, the pair will persist surprisingly far through the optimizer before being coalesced.  (You can see this looking at nearby phis in the test cases.)

Note that if the hardware prefers decrementing (i.e. zero tested) loops, LSR should convert back immediately before codegen.

* Mostly irrelevant detail: The main loop of the prolog case is handled independently and will simple use the original IV with a changed start value.  We could in theory use this scheme for all iteration clamping, but that's a larger and more invasive change.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is one of those wonderful "in theory X doesn't matter, but in practice is does" changes. In this particular case, we shift the IVs inserted by the runtime unroller to clamp iteration count of the loops* from decrementing to incrementing.

Why does this matter?  A couple of reasons:
* SCEV doesn't have a native subtract node.  Instead, all subtracts (A - B) are represented as A + -1 * B and drops any flags invalidated by such.  As a result, SCEV is slightly less good at reasoning about edge cases involving decrementing addrecs than incrementing ones.  (You can see this in the inferred flags in some of the test cases.)
* Other parts of the optimizer produce incrementing IVs, and they're common in idiomatic source language.  We do have support for reversing IVs, but in general if we produce one of each, the pair will persist surprisingly far through the optimizer before being coalesced.  (You can see this looking at nearby phis in the test cases.)

Note that if the hardware prefers decrementing (i.e. zero tested) loops, LSR should convert back immediately before codegen.

* Mostly irrelevant detail: The main loop of the prolog case is handled independently and will simple use the original IV with a changed start value.  We could in theory use this scheme for all iteration clamping, but that's a larger and more invasive change.
</pre>
</div>
</content>
</entry>
</feed>
