<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Analysis/ValueTracking.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>[ValueTracking] Only check up to CtxIter in willNotFreeBetween.</title>
<updated>2025-11-15T13:58:16+00:00</updated>
<author>
<name>Florian Hahn</name>
<email>flo@fhahn.com</email>
</author>
<published>2025-11-15T13:58:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=20db716418bd102c35c29b2e05c0f20b7458e559'/>
<id>20db716418bd102c35c29b2e05c0f20b7458e559</id>
<content type='text'>
Only check up to CtxI (CtxIter) when checking for calls that may free
in CtxI's block.

Missed update in https://github.com/llvm/llvm-project/pull/167965.

This should be NFC, as all current callers pass a terminator that is
guaranteed to not free as CtxI
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Only check up to CtxI (CtxIter) when checking for calls that may free
in CtxI's block.

Missed update in https://github.com/llvm/llvm-project/pull/167965.

This should be NFC, as all current callers pass a terminator that is
guaranteed to not free as CtxI
</pre>
</div>
</content>
</entry>
<entry>
<title>[ValueTracking] Bail out on non-immediate constant expressions (#168084)</title>
<updated>2025-11-15T13:14:29+00:00</updated>
<author>
<name>Yingwei Zheng</name>
<email>dtcxzyw2333@gmail.com</email>
</author>
<published>2025-11-15T13:14:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=76c69ca29c1b0ffa86cddb5e199f53915215be8c'/>
<id>76c69ca29c1b0ffa86cddb5e199f53915215be8c</id>
<content type='text'>
In https://github.com/llvm/llvm-project/pull/165748 constant expressions
were allowed in `collectPossibleValues` because we are still using
insertelement + shufflevector idioms to represent a scalable vector
splat. However, it also accepts some unresolved constants like ptrtoint
of globals or pointer difference between two globals. Absolutely we can
ask the user to check this case with the constant folding API. However,
since we don't observe the real-world usefulness of handling constant
expressions, I decide to be more conservative and only handle immediate
constants in the helper function. With this patch, we don't need to
touch the SimplifyCFG part, as the values can only be either ConstantInt
or undef/poison values (NB: switch on undef condition is UB).

Fix the miscompilation reported by
https://github.com/llvm/llvm-project/pull/165748#issuecomment-3532245218</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In https://github.com/llvm/llvm-project/pull/165748 constant expressions
were allowed in `collectPossibleValues` because we are still using
insertelement + shufflevector idioms to represent a scalable vector
splat. However, it also accepts some unresolved constants like ptrtoint
of globals or pointer difference between two globals. Absolutely we can
ask the user to check this case with the constant folding API. However,
since we don't observe the real-world usefulness of handling constant
expressions, I decide to be more conservative and only handle immediate
constants in the helper function. With this patch, we don't need to
touch the SimplifyCFG part, as the values can only be either ConstantInt
or undef/poison values (NB: switch on undef condition is UB).

Fix the miscompilation reported by
https://github.com/llvm/llvm-project/pull/165748#issuecomment-3532245218</pre>
</div>
</content>
</entry>
<entry>
<title>[ValueTracking] Check across single predecessors in willNotFreeBetween. (#167965)</title>
<updated>2025-11-15T12:11:52+00:00</updated>
<author>
<name>Florian Hahn</name>
<email>flo@fhahn.com</email>
</author>
<published>2025-11-15T12:11:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=eb98b65e82125ebadef48cf668689ec34a4f811f'/>
<id>eb98b65e82125ebadef48cf668689ec34a4f811f</id>
<content type='text'>
Extend willNotFreeBetween to perform simple checking across blocks to
support the case where CtxI is in a successor of the block that contains
the assume, but the assume's parent is the single predecessor of CtxI's
block.

This enables using _builtin_assume_dereferenceable to vectorize
std::find_if and co in practice.

End-to-end reproducer: https://godbolt.org/z/6jbsd4EjT

PR: https://github.com/llvm/llvm-project/pull/167965</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Extend willNotFreeBetween to perform simple checking across blocks to
support the case where CtxI is in a successor of the block that contains
the assume, but the assume's parent is the single predecessor of CtxI's
block.

This enables using _builtin_assume_dereferenceable to vectorize
std::find_if and co in practice.

End-to-end reproducer: https://godbolt.org/z/6jbsd4EjT

PR: https://github.com/llvm/llvm-project/pull/167965</pre>
</div>
</content>
</entry>
<entry>
<title>[ValueTracking] Refine known bits for linear interpolation patterns (#166378)</title>
<updated>2025-11-07T09:03:55+00:00</updated>
<author>
<name>Valeriy Savchenko</name>
<email>vsavchenko@apple.com</email>
</author>
<published>2025-11-07T09:03:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3e90ecaa2fe252e6c9c045ad8ad1ce7dfefd526d'/>
<id>3e90ecaa2fe252e6c9c045ad8ad1ce7dfefd526d</id>
<content type='text'>
In this patch, we try to detect the lerp pattern: a * (b - c) + c * d
where a &gt;= 0, b &gt;= 0, c &gt;= 0, d &gt;= 0, and b &gt;= c.

In that particular case, we can use the following chain of reasoning:

a * (b - c) + c * d &lt;= a' * (b - c) + a' * c = a' * b where a' = max(a,
d)

Since that is true for arbitrary a, b, c and d within our constraints,
we can
conclude that:

  max(a * (b - c) + c * d) &lt;= max(max(a), max(d)) * max(b) = U

Considering that any result of the lerp would be less or equal to U, it
would
have at least the number of leading 0s as in U.

While being quite a specific situation, it is fairly common in computer
graphics in the shape of alpha blending.

In conjunction with #165877, increases vectorization factor for lerp
loops.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In this patch, we try to detect the lerp pattern: a * (b - c) + c * d
where a &gt;= 0, b &gt;= 0, c &gt;= 0, d &gt;= 0, and b &gt;= c.

In that particular case, we can use the following chain of reasoning:

a * (b - c) + c * d &lt;= a' * (b - c) + a' * c = a' * b where a' = max(a,
d)

Since that is true for arbitrary a, b, c and d within our constraints,
we can
conclude that:

  max(a * (b - c) + c * d) &lt;= max(max(a), max(d)) * max(b) = U

Considering that any result of the lerp would be less or equal to U, it
would
have at least the number of leading 0s as in U.

While being quite a specific situation, it is fairly common in computer
graphics in the shape of alpha blending.

In conjunction with #165877, increases vectorization factor for lerp
loops.</pre>
</div>
</content>
</entry>
<entry>
<title>[SimplifyCFG] Eliminate dead edges of switches according to the domain of conditions (#165748)</title>
<updated>2025-11-04T12:55:33+00:00</updated>
<author>
<name>Yingwei Zheng</name>
<email>dtcxzyw2333@gmail.com</email>
</author>
<published>2025-11-04T12:55:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8a84b285f67cb778493e225dc9699d902921e7b0'/>
<id>8a84b285f67cb778493e225dc9699d902921e7b0</id>
<content type='text'>
In simplifycfg/cvp/sccp, we eliminate dead edges of switches according
to the knownbits/range info of conditions. However, these approximations
may not meet the real-world needs when the domain of condition values is
sparse. For example, if the condition can only be either -3 or 3, we
cannot prove that the condition never evaluates to 1 (knownbits:
???????1, range: [-3, 4)).
This patch adds a helper function `collectPossibleValues` to enumerate
all the possible values of V. To fix the motivating issue,
`eliminateDeadSwitchCases` will use the result to remove dead edges.

Note: In
https://discourse.llvm.org/t/missed-optimization-due-to-overflow-check/88700
I proposed a new value lattice kind to represent such values. But I find
it hard to apply because the transition becomes much complicated.

Compile-time impact looks neutral:
https://llvm-compile-time-tracker.com/compare.php?from=32d6b2139a6c8f79e074e8c6cfe0cc9e79c4c0c8&amp;to=e47c26e3f1bf9eb062684dda4fafce58438e994b&amp;stat=instructions:u
This patch removes many dead error-handling codes:
https://github.com/dtcxzyw/llvm-opt-benchmark/pull/3012
Closes https://github.com/llvm/llvm-project/issues/165179.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In simplifycfg/cvp/sccp, we eliminate dead edges of switches according
to the knownbits/range info of conditions. However, these approximations
may not meet the real-world needs when the domain of condition values is
sparse. For example, if the condition can only be either -3 or 3, we
cannot prove that the condition never evaluates to 1 (knownbits:
???????1, range: [-3, 4)).
This patch adds a helper function `collectPossibleValues` to enumerate
all the possible values of V. To fix the motivating issue,
`eliminateDeadSwitchCases` will use the result to remove dead edges.

Note: In
https://discourse.llvm.org/t/missed-optimization-due-to-overflow-check/88700
I proposed a new value lattice kind to represent such values. But I find
it hard to apply because the transition becomes much complicated.

Compile-time impact looks neutral:
https://llvm-compile-time-tracker.com/compare.php?from=32d6b2139a6c8f79e074e8c6cfe0cc9e79c4c0c8&amp;to=e47c26e3f1bf9eb062684dda4fafce58438e994b&amp;stat=instructions:u
This patch removes many dead error-handling codes:
https://github.com/dtcxzyw/llvm-opt-benchmark/pull/3012
Closes https://github.com/llvm/llvm-project/issues/165179.</pre>
</div>
</content>
</entry>
<entry>
<title>[IR] Add new function attribute nocreateundeforpoison (#164809)</title>
<updated>2025-11-04T12:00:44+00:00</updated>
<author>
<name>Jay Foad</name>
<email>jay.foad@amd.com</email>
</author>
<published>2025-11-04T12:00:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f037f413506af9e32898e102f391175a3a2852ef'/>
<id>f037f413506af9e32898e102f391175a3a2852ef</id>
<content type='text'>
Also add a corresponding intrinsic property that can be used to mark
intrinsics that do not introduce poison, for example simple arithmetic
intrinsics that propagate poison just like a simple arithmetic
instruction.

As a smoke test this patch adds the new property to
llvm.amdgcn.fmul.legacy.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Also add a corresponding intrinsic property that can be used to mark
intrinsics that do not introduce poison, for example simple arithmetic
intrinsics that propagate poison just like a simple arithmetic
instruction.

As a smoke test this patch adds the new property to
llvm.amdgcn.fmul.legacy.</pre>
</div>
</content>
</entry>
<entry>
<title>[ValueTracking] Teach isGuaranteedNotToBeUndefOrPoison about splats (#163570)</title>
<updated>2025-10-20T10:20:09+00:00</updated>
<author>
<name>Cullen Rhodes</name>
<email>cullen.rhodes@arm.com</email>
</author>
<published>2025-10-20T10:20:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=5b5eacc5790365b90878a79893325bfae00ed693'/>
<id>5b5eacc5790365b90878a79893325bfae00ed693</id>
<content type='text'>
Splats include two poison values, but only the poison-ness of the
splatted value actually matters.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Splats include two poison values, but only the poison-ness of the
splatted value actually matters.</pre>
</div>
</content>
</entry>
<entry>
<title>[InstSimplify] Optimize maximumnum and minimumnum (#139581)</title>
<updated>2025-10-07T13:23:32+00:00</updated>
<author>
<name>Lewis Crawford</name>
<email>lcrawford@nvidia.com</email>
</author>
<published>2025-10-07T13:23:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=17efa572c3827fe12e37d0f1f28d20a8e44890c7'/>
<id>17efa572c3827fe12e37d0f1f28d20a8e44890c7</id>
<content type='text'>
Add support for the new maximumnum and minimumnum intrinsics in various
optimizations in InstSimplify.

Also, change the behavior of optimizing maxnum(sNaN, x) to simplify to
qNaN instead of x to better match the LLVM IR spec, and add more tests
for sNaN behavior for all 3 max/min intrinsic types.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add support for the new maximumnum and minimumnum intrinsics in various
optimizations in InstSimplify.

Also, change the behavior of optimizing maxnum(sNaN, x) to simplify to
qNaN instead of x to better match the LLVM IR spec, and add more tests
for sNaN behavior for all 3 max/min intrinsic types.</pre>
</div>
</content>
</entry>
<entry>
<title>[InstSimplify] Simplify fcmp implied by dominating fcmp (#161090)</title>
<updated>2025-10-05T08:15:51+00:00</updated>
<author>
<name>Yingwei Zheng</name>
<email>dtcxzyw2333@gmail.com</email>
</author>
<published>2025-10-05T08:15:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ca5ece89394f64ab814032d9562b2e4770160523'/>
<id>ca5ece89394f64ab814032d9562b2e4770160523</id>
<content type='text'>
This patch simplifies an fcmp into true/false if it is implied by a
dominating fcmp.
As an initial support, it only handles two cases:
+ `fcmp pred1, X, Y -&gt; fcmp pred2, X, Y`: use set operations.
+ `fcmp pred1, X, C1 -&gt; fcmp pred2, X, C2`: use `ConstantFPRange` and
set operations.

Note: It doesn't fix https://github.com/llvm/llvm-project/issues/70985,
as the second fcmp in the motivating case is not dominated by the edge.
We may need to adjust JumpThreading to handle this case.

Comptime impact (~+0.1%):
https://llvm-compile-time-tracker.com/compare.php?from=a728f213c863e4dd19f8969a417148d2951323c0&amp;to=8ca70404fb0d66a824f39d83050ac38e2f1b25b9&amp;stat=instructions:u
IR diff: https://github.com/dtcxzyw/llvm-opt-benchmark/pull/2848</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch simplifies an fcmp into true/false if it is implied by a
dominating fcmp.
As an initial support, it only handles two cases:
+ `fcmp pred1, X, Y -&gt; fcmp pred2, X, Y`: use set operations.
+ `fcmp pred1, X, C1 -&gt; fcmp pred2, X, C2`: use `ConstantFPRange` and
set operations.

Note: It doesn't fix https://github.com/llvm/llvm-project/issues/70985,
as the second fcmp in the motivating case is not dominated by the edge.
We may need to adjust JumpThreading to handle this case.

Comptime impact (~+0.1%):
https://llvm-compile-time-tracker.com/compare.php?from=a728f213c863e4dd19f8969a417148d2951323c0&amp;to=8ca70404fb0d66a824f39d83050ac38e2f1b25b9&amp;stat=instructions:u
IR diff: https://github.com/dtcxzyw/llvm-opt-benchmark/pull/2848</pre>
</div>
</content>
</entry>
<entry>
<title>[LAA] Check if Ptr can be freed between Assume and CtxI. (#161725)</title>
<updated>2025-10-03T13:44:58+00:00</updated>
<author>
<name>Florian Hahn</name>
<email>flo@fhahn.com</email>
</author>
<published>2025-10-03T13:44:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=7ceef762c8c914270cfa49ad5794227b270c8223'/>
<id>7ceef762c8c914270cfa49ad5794227b270c8223</id>
<content type='text'>
When using information from dereferenceable assumptions, we need to make
sure that the memory is not freed between the assume and the specified
context instruction. Instead of just checking canBeFreed, check if there
any calls that may free between the assume and the context instruction.

This patch introduces a willNotFreeBetween to check for calls that may
free between an assume and a context instructions, to also be used in
https://github.com/llvm/llvm-project/pull/161255.

PR: https://github.com/llvm/llvm-project/pull/161725</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When using information from dereferenceable assumptions, we need to make
sure that the memory is not freed between the assume and the specified
context instruction. Instead of just checking canBeFreed, check if there
any calls that may free between the assume and the context instruction.

This patch introduces a willNotFreeBetween to check for calls that may
free between an assume and a context instructions, to also be used in
https://github.com/llvm/llvm-project/pull/161255.

PR: https://github.com/llvm/llvm-project/pull/161725</pre>
</div>
</content>
</entry>
</feed>
