<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Analysis/LoopCacheAnalysis.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>[LoopCacheAnalysis] Replace delinearization for fixed size array (#164798)</title>
<updated>2025-11-21T14:06:45+00:00</updated>
<author>
<name>Ryotaro Kasuga</name>
<email>kasuga.ryotaro@fujitsu.com</email>
</author>
<published>2025-11-21T14:06:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=31a552def53964025ccc507c6c90002a5d8d7e25'/>
<id>31a552def53964025ccc507c6c90002a5d8d7e25</id>
<content type='text'>
This patch replaces the delinearization function used in
LoopCacheAnalysis, switching from one that depends on type information
in GEPs to one that does not. Once this patch and
https://github.com/llvm/llvm-project/pull/161822 are landed, we can
delete `tryDelinearizeFixedSize` from Delienarization, which is an
optimization heuristic guided by GEP type information. After Polly
eliminates its use of `getIndexExpressionsFromGEP`, we will be able to
completely delete GEP-driven heuristics from Delinearization.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch replaces the delinearization function used in
LoopCacheAnalysis, switching from one that depends on type information
in GEPs to one that does not. Once this patch and
https://github.com/llvm/llvm-project/pull/161822 are landed, we can
delete `tryDelinearizeFixedSize` from Delienarization, which is an
optimization heuristic guided by GEP type information. After Polly
eliminates its use of `getIndexExpressionsFromGEP`, we will be able to
completely delete GEP-driven heuristics from Delinearization.</pre>
</div>
</content>
</entry>
<entry>
<title>[LoopCacheAnalysis] Drop incorrect nowrap flags from addrec (#164796)</title>
<updated>2025-10-23T15:32:34+00:00</updated>
<author>
<name>Ryotaro Kasuga</name>
<email>kasuga.ryotaro@fujitsu.com</email>
</author>
<published>2025-10-23T15:32:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c6073d72ee23d8cd6aa49c08edde846359e41bde'/>
<id>c6073d72ee23d8cd6aa49c08edde846359e41bde</id>
<content type='text'>
This patch stops propagating nowrap flags unconditionally. In the
modified part, when we have an addrec `{%a,+,%b}` where `%b` is known to
be negative, we create a new addrec `{%a,+,(-1 * %b)}`. When creating
it, the nowrap flags are transferred from the original addrec to the new
one without any checks, which is generally incorrect. Since the nowrap
property is not essential for this analysis, it would be better to drop
it to avoid potential bugs.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch stops propagating nowrap flags unconditionally. In the
modified part, when we have an addrec `{%a,+,%b}` where `%b` is known to
be negative, we create a new addrec `{%a,+,(-1 * %b)}`. When creating
it, the nowrap flags are transferred from the original addrec to the new
one without any checks, which is generally incorrect. Since the nowrap
property is not essential for this analysis, it would be better to drop
it to avoid potential bugs.</pre>
</div>
</content>
</entry>
<entry>
<title>[DependenceAnalysis][NFC] Removing PossiblyLoopIndependent parameter (#124615)</title>
<updated>2025-02-11T21:23:28+00:00</updated>
<author>
<name>Alireza Torabian</name>
<email>torabian.alireza@gmail.com</email>
</author>
<published>2025-02-11T21:23:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3c74430320619495d4d547b05427654c9a7c8586'/>
<id>3c74430320619495d4d547b05427654c9a7c8586</id>
<content type='text'>
Parameter PossiblyLoopIndependent has lost its intended purpose. This
flag is always set to true in all cases when depends() is called, hence
we want to reconsider the utility of this variable and remove it from
the function signature entirely. This is an NFC patch.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Parameter PossiblyLoopIndependent has lost its intended purpose. This
flag is always set to true in all cases when depends() is called, hence
we want to reconsider the utility of this variable and remove it from
the function signature entirely. This is an NFC patch.</pre>
</div>
</content>
</entry>
<entry>
<title>[LoopInterchange] Fix overflow in cost calculation (#111807)</title>
<updated>2024-11-14T08:40:45+00:00</updated>
<author>
<name>Sjoerd Meijer</name>
<email>smeijer@nvidia.com</email>
</author>
<published>2024-11-14T08:40:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=2e6deb1dd3a4422807633ba08773e8d786e43d4c'/>
<id>2e6deb1dd3a4422807633ba08773e8d786e43d4c</id>
<content type='text'>
If the iteration count is really large, e.g. UINT_MAX, then the cost
calculation can overflows and trigger an assert. So saturate the cost to
INT_MAX if this is the case by using InstructionCost as a type which
already supports this kind of overflow handling.

This fixes #104761</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If the iteration count is really large, e.g. UINT_MAX, then the cost
calculation can overflows and trigger an assert. So saturate the cost to
INT_MAX if this is the case by using InstructionCost as a type which
already supports this kind of overflow handling.

This fixes #104761</pre>
</div>
</content>
</entry>
<entry>
<title>[LoopCacheAnalysis] Fix loop cache cost to always round the cost up to the nearest integer number (#88915)</title>
<updated>2024-05-27T13:54:39+00:00</updated>
<author>
<name>Rouzbeh</name>
<email>rouzbeh.paktinat1@huawei.com</email>
</author>
<published>2024-05-27T13:54:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=670259466b238176ac302c8dedf806d2b2be7e0c'/>
<id>670259466b238176ac302c8dedf806d2b2be7e0c</id>
<content type='text'>
Currently loop cache analysis uses following formula to evaluate cost of
an RefGroup for a consecutive memory access:

`RefCost=(TripCount*Stride)/CLS`

This cost evaluates to zero when `TripCount*Stride` is smaller than
cache-line-size. This results in wrong cost value for a loop and
misleads loopInterchange decisions as shown in [this
case](https://llvm.godbolt.org/z/jTz1vn4hn).

This patch fixes the problem by rounding the cost to 1 once this problem
happens.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently loop cache analysis uses following formula to evaluate cost of
an RefGroup for a consecutive memory access:

`RefCost=(TripCount*Stride)/CLS`

This cost evaluates to zero when `TripCount*Stride` is smaller than
cache-line-size. This results in wrong cost value for a loop and
misleads loopInterchange decisions as shown in [this
case](https://llvm.godbolt.org/z/jTz1vn4hn).

This patch fixes the problem by rounding the cost to 1 once this problem
happens.</pre>
</div>
</content>
</entry>
<entry>
<title>Fix typos (#88565)</title>
<updated>2024-04-12T21:33:35+00:00</updated>
<author>
<name>Victor Toni</name>
<email>ViToni@users.noreply.github.com</email>
</author>
<published>2024-04-12T21:33:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=900be9013fdc3bab9fce906f8a71e59ecd8873b4'/>
<id>900be9013fdc3bab9fce906f8a71e59ecd8873b4</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[SCEV] When computing trip count, only zext if necessary</title>
<updated>2023-04-11T02:40:52+00:00</updated>
<author>
<name>Joshua Cao</name>
<email>cao.joshua@yahoo.com</email>
</author>
<published>2023-03-29T03:49:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=585742cbfccd734b19c75dff9709b20367506668'/>
<id>585742cbfccd734b19c75dff9709b20367506668</id>
<content type='text'>
This patch improves on https://reviews.llvm.org/D110587. To summarize
the patch, given backedge-taken count BC, trip count TC is `BC + 1`.
However, we don't know if BC we might overflow. So the patch modifies TC
computation to `1 + zext(BC)`.

This patch only adds the zext if necessary by looking at the constant
range. If we can determine that BC cannot be the max value for its
bitwidth, then we know adding 1 will not overflow, and the zext is not
needed. We apply loop guards before computing TC to get more data.

The primary motivation is to support my work on more precise trip
multiples in https://reviews.llvm.org/D141823. For example:

```
void test(unsigned n)
  __builtin_assume(n % 6 == 0);
  for (unsigned i = 0; i &lt; n; ++i)
    foo();
```

Prior to this patch, we had `TC = 1 + zext(-1 + 6 * ((6 umax %n) /u
6))&lt;nuw&gt;`. SCEV range computation is able to determine that the BC
cannot be the max value, so the zext is not needed. The result is `TC
-&gt; (6 * ((6 umax %n) /u 6))&lt;nuw&gt;`. From here, we would be able to
determine that %n is a multiple of 6.

There was one change in LoopCacheAnalysis/LoopInterchange required.
Before this patch, if a loop has BC = false, it would compute `TC -&gt; 1 +
zext(false) -&gt; 1`, which was fine. After this patch, it computes `TC -&gt; 1
+ false = true`. CacheAnalysis would then sign extend the `true`, which
was not the intended the behavior. I modified CacheAnalysis such that
it would only zero extend trip counts.

This patch is not NFC, but also does not change any SCEV outputs. I
would like to get this patch out first to make work with trip multiples
easier.

Differential Revision: https://reviews.llvm.org/D147117
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch improves on https://reviews.llvm.org/D110587. To summarize
the patch, given backedge-taken count BC, trip count TC is `BC + 1`.
However, we don't know if BC we might overflow. So the patch modifies TC
computation to `1 + zext(BC)`.

This patch only adds the zext if necessary by looking at the constant
range. If we can determine that BC cannot be the max value for its
bitwidth, then we know adding 1 will not overflow, and the zext is not
needed. We apply loop guards before computing TC to get more data.

The primary motivation is to support my work on more precise trip
multiples in https://reviews.llvm.org/D141823. For example:

```
void test(unsigned n)
  __builtin_assume(n % 6 == 0);
  for (unsigned i = 0; i &lt; n; ++i)
    foo();
```

Prior to this patch, we had `TC = 1 + zext(-1 + 6 * ((6 umax %n) /u
6))&lt;nuw&gt;`. SCEV range computation is able to determine that the BC
cannot be the max value, so the zext is not needed. The result is `TC
-&gt; (6 * ((6 umax %n) /u 6))&lt;nuw&gt;`. From here, we would be able to
determine that %n is a multiple of 6.

There was one change in LoopCacheAnalysis/LoopInterchange required.
Before this patch, if a loop has BC = false, it would compute `TC -&gt; 1 +
zext(false) -&gt; 1`, which was fine. After this patch, it computes `TC -&gt; 1
+ false = true`. CacheAnalysis would then sign extend the `true`, which
was not the intended the behavior. I modified CacheAnalysis such that
it would only zero extend trip counts.

This patch is not NFC, but also does not change any SCEV outputs. I
would like to get this patch out first to make work with trip multiples
easier.

Differential Revision: https://reviews.llvm.org/D147117
</pre>
</div>
</content>
</entry>
<entry>
<title>[Analysis] llvm::Optional =&gt; std::optional</title>
<updated>2022-12-14T07:32:24+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2022-12-14T07:32:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d4b6fcb32e29d0cd834a3c89205fef48fbfc1d2d'/>
<id>d4b6fcb32e29d0cd834a3c89205fef48fbfc1d2d</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[Analysis] Use std::nullopt instead of None (NFC)</title>
<updated>2022-12-03T03:43:04+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2022-12-03T03:43:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=19aff0f37dd68ee51e78b764c0ce629ae73d1eef'/>
<id>19aff0f37dd68ee51e78b764c0ce629ae73d1eef</id>
<content type='text'>
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
</pre>
</div>
</content>
</entry>
<entry>
<title>[Analysis] Use llvm::Optional::value_or (NFC)</title>
<updated>2022-11-20T05:11:10+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2022-11-20T05:11:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=7b91798a5d3a8432b296778da4efe169012fb7b4'/>
<id>7b91798a5d3a8432b296778da4efe169012fb7b4</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
