<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Transforms/Utils/LoopUtils.cpp, branch main</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>[LoopUnroll] Fix assert fail on zeroed branch weights (#165938)</title>
<updated>2025-11-03T15:19:12+00:00</updated>
<author>
<name>Joel E. Denny</name>
<email>jdenny.ornl@gmail.com</email>
</author>
<published>2025-11-03T15:19:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=bb9bd5f263226840194b28457ddf9861986db51f'/>
<id>bb9bd5f263226840194b28457ddf9861986db51f</id>
<content type='text'>
BranchProbability fails an assert when its denominator is zero.

Reported at
&lt;https://github.com/llvm/llvm-project/pull/159163#pullrequestreview-3406318423&gt;.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
BranchProbability fails an assert when its denominator is zero.

Reported at
&lt;https://github.com/llvm/llvm-project/pull/159163#pullrequestreview-3406318423&gt;.</pre>
</div>
</content>
</entry>
<entry>
<title>[LoopUnroll] Fix block frequencies for epilogue (#159163)</title>
<updated>2025-10-31T15:01:42+00:00</updated>
<author>
<name>Joel E. Denny</name>
<email>jdenny.ornl@gmail.com</email>
</author>
<published>2025-10-31T15:01:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=cc8ff73fbab875e33071b23ff6e4b512d5adf64e'/>
<id>cc8ff73fbab875e33071b23ff6e4b512d5adf64e</id>
<content type='text'>
As another step in issue #135812, this patch fixes block frequencies for
partial loop unrolling with an epilogue remainder loop. It does not
fully handle the case when the epilogue loop itself is unrolled. That
will be handled in the next patch.

For the guard and latch of each of the unrolled loop and epilogue loop,
this patch sets branch weights derived directly from the original loop
latch branch weights. The total frequency of the original loop body,
summed across all its occurrences in the unrolled loop and epilogue
loop, is the same as in the original loop. This patch also sets
`llvm.loop.estimated_trip_count` for the epilogue loop instead of
relying on the epilogue's latch branch weights to imply it.

This patch fixes branch weights in tests that PR #157754 adversely
affected.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As another step in issue #135812, this patch fixes block frequencies for
partial loop unrolling with an epilogue remainder loop. It does not
fully handle the case when the epilogue loop itself is unrolled. That
will be handled in the next patch.

For the guard and latch of each of the unrolled loop and epilogue loop,
this patch sets branch weights derived directly from the original loop
latch branch weights. The total frequency of the original loop body,
summed across all its occurrences in the unrolled loop and epilogue
loop, is the same as in the original loop. This patch also sets
`llvm.loop.estimated_trip_count` for the epilogue loop instead of
relying on the epilogue's latch branch weights to imply it.

This patch fixes branch weights in tests that PR #157754 adversely
affected.</pre>
</div>
</content>
</entry>
<entry>
<title>[VPlan] Simplify Plan's entry in removeBranchOnConst. (#154510)</title>
<updated>2025-09-18T18:25:05+00:00</updated>
<author>
<name>Florian Hahn</name>
<email>flo@fhahn.com</email>
</author>
<published>2025-09-18T18:25:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=50b9ca4ddaea08fc72b7dcba1390c1689eed9a17'/>
<id>50b9ca4ddaea08fc72b7dcba1390c1689eed9a17</id>
<content type='text'>
After https://github.com/llvm/llvm-project/pull/153643, there may be a
BranchOnCond with constant condition in the entry block.

Simplify those in removeBranchOnConst. This removes a number of
redundant conditional branch from entry blocks.

In some cases, it may also make the original scalar loop unreachable,
because we know it will never execute. In that case, we need to remove
the loop from LoopInfo, because all unreachable blocks may dominate each
other, making LoopInfo invalid. In those cases, we can also completely
remove the loop, for which I'll share a follow-up patch.

Depends on https://github.com/llvm/llvm-project/pull/153643.

PR: https://github.com/llvm/llvm-project/pull/154510</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
After https://github.com/llvm/llvm-project/pull/153643, there may be a
BranchOnCond with constant condition in the entry block.

Simplify those in removeBranchOnConst. This removes a number of
redundant conditional branch from entry blocks.

In some cases, it may also make the original scalar loop unreachable,
because we know it will never execute. In that case, we need to remove
the loop from LoopInfo, because all unreachable blocks may dominate each
other, making LoopInfo invalid. In those cases, we can also completely
remove the loop, for which I'll share a follow-up patch.

Depends on https://github.com/llvm/llvm-project/pull/153643.

PR: https://github.com/llvm/llvm-project/pull/154510</pre>
</div>
</content>
</entry>
<entry>
<title>[PGO] Add llvm.loop.estimated_trip_count metadata (#152775)</title>
<updated>2025-09-11T19:55:18+00:00</updated>
<author>
<name>Joel E. Denny</name>
<email>jdenny.ornl@gmail.com</email>
</author>
<published>2025-09-11T19:55:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0e3c5566c0c62a56629a927d7de5e2594d2dbe7c'/>
<id>0e3c5566c0c62a56629a927d7de5e2594d2dbe7c</id>
<content type='text'>
This patch implements the `llvm.loop.estimated_trip_count` metadata
discussed in [[RFC] Fix Loop Transformations to Preserve Block
Frequencies](https://discourse.llvm.org/t/rfc-fix-loop-transformations-to-preserve-block-frequencies/85785).
As the RFC explains, that metadata enables future patches, such as PR
#128785, to fix block frequency issues without losing estimated trip
counts.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch implements the `llvm.loop.estimated_trip_count` metadata
discussed in [[RFC] Fix Loop Transformations to Preserve Block
Frequencies](https://discourse.llvm.org/t/rfc-fix-loop-transformations-to-preserve-block-frequencies/85785).
As the RFC explains, that metadata enables future patches, such as PR
#128785, to fix block frequency issues without losing estimated trip
counts.</pre>
</div>
</content>
</entry>
<entry>
<title>[LoopUtils] Simplify expanded RT-checks (#157518)</title>
<updated>2025-09-09T11:38:54+00:00</updated>
<author>
<name>Ramkumar Ramachandra</name>
<email>ramkumar.ramachandra@codasip.com</email>
</author>
<published>2025-09-09T11:38:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=5544afd25368413fd663362cd4eb58811bf558d2'/>
<id>5544afd25368413fd663362cd4eb58811bf558d2</id>
<content type='text'>
Follow up on 528b13d ([SCEVExp] Add helper to clean up dead instructions
after expansion.) to hoist the SCEVExapnder::eraseDeadInstructions call
from LoopVectorize into the LoopUtils APIs add[Diff]RuntimeChecks, so
that other callers (LoopDistribute and LoopVersioning) can benefit from
the patch.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Follow up on 528b13d ([SCEVExp] Add helper to clean up dead instructions
after expansion.) to hoist the SCEVExapnder::eraseDeadInstructions call
from LoopVectorize into the LoopUtils APIs add[Diff]RuntimeChecks, so
that other callers (LoopDistribute and LoopVersioning) can benefit from
the patch.</pre>
</div>
</content>
</entry>
<entry>
<title>[VectorCombine] New folding pattern for extract/binop/shuffle chains (#145232)</title>
<updated>2025-08-24T08:51:48+00:00</updated>
<author>
<name>Rajveer Singh Bharadwaj</name>
<email>rajveer.developer@icloud.com</email>
</author>
<published>2025-08-24T08:51:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=93c96849c89507579a77980ff03adbeabb413573'/>
<id>93c96849c89507579a77980ff03adbeabb413573</id>
<content type='text'>
Resolves #144654
Part of #143088

This adds a new `foldShuffleChainsToReduce` for horizontal reduction of
patterns like:

```llvm
define i16 @test_reduce_v8i16(&lt;8 x i16&gt; %a0) local_unnamed_addr #0 {
  %1 = shufflevector &lt;8 x i16&gt; %a0, &lt;8 x i16&gt; poison, &lt;8 x i32&gt; &lt;i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison&gt;
  %2 = tail call &lt;8 x i16&gt; @llvm.umin.v8i16(&lt;8 x i16&gt; %a0, &lt;8 x i16&gt; %1)
  %3 = shufflevector &lt;8 x i16&gt; %2, &lt;8 x i16&gt; poison, &lt;8 x i32&gt; &lt;i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison&gt;
  %4 = tail call &lt;8 x i16&gt; @llvm.umin.v8i16(&lt;8 x i16&gt; %2, &lt;8 x i16&gt; %3)
  %5 = shufflevector &lt;8 x i16&gt; %4, &lt;8 x i16&gt; poison, &lt;8 x i32&gt; &lt;i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison&gt;
  %6 = tail call &lt;8 x i16&gt; @llvm.umin.v8i16(&lt;8 x i16&gt; %4, &lt;8 x i16&gt; %5)
  %7 = extractelement &lt;8 x i16&gt; %6, i64 0
  ret i16 %7
}
```
...which can be reduced to a llvm.vector.reduce.umin.v8i16(%a0)
intrinsic call.

Similar transformation for other ops when costs permit to do so.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Resolves #144654
Part of #143088

This adds a new `foldShuffleChainsToReduce` for horizontal reduction of
patterns like:

```llvm
define i16 @test_reduce_v8i16(&lt;8 x i16&gt; %a0) local_unnamed_addr #0 {
  %1 = shufflevector &lt;8 x i16&gt; %a0, &lt;8 x i16&gt; poison, &lt;8 x i32&gt; &lt;i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison&gt;
  %2 = tail call &lt;8 x i16&gt; @llvm.umin.v8i16(&lt;8 x i16&gt; %a0, &lt;8 x i16&gt; %1)
  %3 = shufflevector &lt;8 x i16&gt; %2, &lt;8 x i16&gt; poison, &lt;8 x i32&gt; &lt;i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison&gt;
  %4 = tail call &lt;8 x i16&gt; @llvm.umin.v8i16(&lt;8 x i16&gt; %2, &lt;8 x i16&gt; %3)
  %5 = shufflevector &lt;8 x i16&gt; %4, &lt;8 x i16&gt; poison, &lt;8 x i32&gt; &lt;i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison&gt;
  %6 = tail call &lt;8 x i16&gt; @llvm.umin.v8i16(&lt;8 x i16&gt; %4, &lt;8 x i16&gt; %5)
  %7 = extractelement &lt;8 x i16&gt; %6, i64 0
  ret i16 %7
}
```
...which can be reduced to a llvm.vector.reduce.umin.v8i16(%a0)
intrinsic call.

Similar transformation for other ops when costs permit to do so.</pre>
</div>
</content>
</entry>
<entry>
<title>[LV] Create in-loop sub reductions (#147026)</title>
<updated>2025-08-12T09:22:41+00:00</updated>
<author>
<name>Sam Tebbs</name>
<email>samuel.tebbs@arm.com</email>
</author>
<published>2025-08-12T09:22:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0bfa1718af7663f39d5089f29907b8446e919789'/>
<id>0bfa1718af7663f39d5089f29907b8446e919789</id>
<content type='text'>
This PR allows the loop vectorizer to handle in-loop sub reductions by
forming a normal in-loop add reduction with a negated input.

Stacked PRs:
1. -&gt; https://github.com/llvm/llvm-project/pull/147026
2. https://github.com/llvm/llvm-project/pull/147255
3. https://github.com/llvm/llvm-project/pull/147302
4. https://github.com/llvm/llvm-project/pull/147513</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR allows the loop vectorizer to handle in-loop sub reductions by
forming a normal in-loop add reduction with a negated input.

Stacked PRs:
1. -&gt; https://github.com/llvm/llvm-project/pull/147026
2. https://github.com/llvm/llvm-project/pull/147255
3. https://github.com/llvm/llvm-project/pull/147302
4. https://github.com/llvm/llvm-project/pull/147513</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[PGO] Add `llvm.loop.estimated_trip_count` metadata" (#151585)</title>
<updated>2025-07-31T19:56:31+00:00</updated>
<author>
<name>Joel E. Denny</name>
<email>jdenny.ornl@gmail.com</email>
</author>
<published>2025-07-31T19:56:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=37e03b56b8172d73ebd755a210fcfa031133220a'/>
<id>37e03b56b8172d73ebd755a210fcfa031133220a</id>
<content type='text'>
Reverts llvm/llvm-project#148758

[As
requested.](https://github.com/llvm/llvm-project/pull/148758#pullrequestreview-3076627201)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reverts llvm/llvm-project#148758

[As
requested.](https://github.com/llvm/llvm-project/pull/148758#pullrequestreview-3076627201)</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[Utils] Fix a warning"</title>
<updated>2025-07-31T19:54:01+00:00</updated>
<author>
<name>Joel E. Denny</name>
<email>jdenny.ornl@gmail.com</email>
</author>
<published>2025-07-31T19:51:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a85c725952f7eec54552c195353ff0cb6275a2e0'/>
<id>a85c725952f7eec54552c195353ff0cb6275a2e0</id>
<content type='text'>
This reverts commit 3a18fe33f0763cd9276c99c276448412100f6270.

So that we can revert PR #148758.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 3a18fe33f0763cd9276c99c276448412100f6270.

So that we can revert PR #148758.
</pre>
</div>
</content>
</entry>
<entry>
<title>[Utils] Fix a warning</title>
<updated>2025-07-31T18:24:33+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2025-07-31T18:24:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3a18fe33f0763cd9276c99c276448412100f6270'/>
<id>3a18fe33f0763cd9276c99c276448412100f6270</id>
<content type='text'>
This patch fixes:

  llvm/lib/Transforms/Utils/LoopUtils.cpp:818:28: error: unused
  function 'operator&lt;&lt;' [-Werror,-Wunused-function]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch fixes:

  llvm/lib/Transforms/Utils/LoopUtils.cpp:818:28: error: unused
  function 'operator&lt;&lt;' [-Werror,-Wunused-function]
</pre>
</div>
</content>
</entry>
</feed>
