<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Analysis/ConstantFolding.cpp, 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> [ConstantFold] Special case atan +/-0.0 (#143962)</title>
<updated>2025-06-25T20:03:18+00:00</updated>
<author>
<name>Lei Huang</name>
<email>lei@ca.ibm.com</email>
</author>
<published>2025-06-25T20:03:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=4a31f7f8ea776383d72350cb5ce74ce13ee15431'/>
<id>4a31f7f8ea776383d72350cb5ce74ce13ee15431</id>
<content type='text'>
C's Annex F specifies that atan +/-0.0 returns the input value;
however, this behavior is optional and host C libraries may behave
differently. This change applies the Annex F behavior to constant
folding by LLVM.

Ref:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/atan.html</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
C's Annex F specifies that atan +/-0.0 returns the input value;
however, this behavior is optional and host C libraries may behave
differently. This change applies the Annex F behavior to constant
folding by LLVM.

Ref:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/atan.html</pre>
</div>
</content>
</entry>
<entry>
<title>[ConstantFolding] Handle reading from type padding (#144330)</title>
<updated>2025-06-17T07:30:28+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2025-06-17T07:30:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=80b79ce432bbe12701fd9fe495ff9feeb5e4b9ca'/>
<id>80b79ce432bbe12701fd9fe495ff9feeb5e4b9ca</id>
<content type='text'>
ReadDataFromGlobal() did not handle reads from the padding of types (in
the sense of type store size != type alloc size, rather than struct
padding).

Return zero in that case.

Fixes https://github.com/llvm/llvm-project/issues/144279.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ReadDataFromGlobal() did not handle reads from the padding of types (in
the sense of type store size != type alloc size, rather than struct
padding).

Return zero in that case.

Fixes https://github.com/llvm/llvm-project/issues/144279.</pre>
</div>
</content>
</entry>
<entry>
<title>[ConstantFolding] Fold deinterleave2 of any splat vector not just zeroinitializer (#144144)</title>
<updated>2025-06-14T00:11:52+00:00</updated>
<author>
<name>Craig Topper</name>
<email>craig.topper@sifive.com</email>
</author>
<published>2025-06-14T00:11:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=417ab37d85ad1bb3e5623dff487ef108404e37f5'/>
<id>417ab37d85ad1bb3e5623dff487ef108404e37f5</id>
<content type='text'>
While there remove an unnecessary dyn_cast from Constant to Constant.
Reverse a branch condition into an early out to reduce nesting.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
While there remove an unnecessary dyn_cast from Constant to Constant.
Reverse a branch condition into an early out to reduce nesting.</pre>
</div>
</content>
</entry>
<entry>
<title>[llvm] Compare std::optional&lt;T&gt; to values directly (NFC) (#143913)</title>
<updated>2025-06-13T15:11:20+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2025-06-13T15:11:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=bcfbba12e6754e0a2a5a1c8e3aac3a24316bba2d'/>
<id>bcfbba12e6754e0a2a5a1c8e3aac3a24316bba2d</id>
<content type='text'>
This patch transforms:

  X &amp;&amp; *X == Y

to:

  X == Y

where X is of std::optional&lt;T&gt;, and Y is of T or similar.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch transforms:

  X &amp;&amp; *X == Y

to:

  X == Y

where X is of std::optional&lt;T&gt;, and Y is of T or similar.</pre>
</div>
</content>
</entry>
<entry>
<title>[ConstantFolding] Add folding for [de]interleave2, insert and extract (#141301)</title>
<updated>2025-06-11T23:00:29+00:00</updated>
<author>
<name>Nikolay Panchenko</name>
<email>nicholas.panchenko@gmail.com</email>
</author>
<published>2025-06-11T23:00:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ee35e342945d6825c9b2b004fd135cf16c84ea0e'/>
<id>ee35e342945d6825c9b2b004fd135cf16c84ea0e</id>
<content type='text'>
The change adds folding for 4 vector intrinsics: `interleave2`,
`deinterleave2`, `vector_extract` and `vector_insert`. For the last 2
intrinsics the change does not use `ShuffleVector` fold mechanism as
it's much simpler to construct result vector explicitly.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The change adds folding for 4 vector intrinsics: `interleave2`,
`deinterleave2`, `vector_extract` and `vector_insert`. For the last 2
intrinsics the change does not use `ShuffleVector` fold mechanism as
it's much simpler to construct result vector explicitly.</pre>
</div>
</content>
</entry>
<entry>
<title>[ConstantFolding] Fold sqrt poison -&gt; poison (#141821)</title>
<updated>2025-06-11T11:27:14+00:00</updated>
<author>
<name>Luke Lau</name>
<email>luke@igalia.com</email>
</author>
<published>2025-06-11T11:27:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=19b0e1227ca6653405e4a34627d04a14f2287f26'/>
<id>19b0e1227ca6653405e4a34627d04a14f2287f26</id>
<content type='text'>
I noticed this when a sqrt produced by VectorCombine with a poison
operand wasn't getting folded away to poison.

Most intrinsics in general could probably be folded to poison if one of
their arguments are poison too. Are there any exceptions to this we need
to be aware of?</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I noticed this when a sqrt produced by VectorCombine with a poison
operand wasn't getting folded away to poison.

Most intrinsics in general could probably be folded to poison if one of
their arguments are poison too. Are there any exceptions to this we need
to be aware of?</pre>
</div>
</content>
</entry>
<entry>
<title>[ConstantFolding] Add support for llvm.atan in constant folding. (#143416)</title>
<updated>2025-06-09T19:38:08+00:00</updated>
<author>
<name>Craig Topper</name>
<email>craig.topper@sifive.com</email>
</author>
<published>2025-06-09T19:38:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=112490f06abca669eb3fe158739bf751e6024f46'/>
<id>112490f06abca669eb3fe158739bf751e6024f46</id>
<content type='text'>
Fixes #143360</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes #143360</pre>
</div>
</content>
</entry>
<entry>
<title>[ConstantFolding] Add flag to disable call folding (#140270)</title>
<updated>2025-05-30T10:27:18+00:00</updated>
<author>
<name>Lewis Crawford</name>
<email>lcrawford@nvidia.com</email>
</author>
<published>2025-05-30T10:27:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=1f7885cf9c6801d11491c8c194c999f7223dd141'/>
<id>1f7885cf9c6801d11491c8c194c999f7223dd141</id>
<content type='text'>
Add an optional flag to disable constant-folding for function calls.
This applies to both intrinsics and libcalls.

This is not necessary in most cases, so is disabled by default, but in
cases that require bit-exact precision between the result from
constant-folding and run-time execution, having this flag can be useful,
and may help with debugging. Cases where mismatches can occur include
GPU execution vs host-side folding, cross-compilation scenarios, or
compilation vs execution environments with different math library
versions.

This applies only to calls, rather than all FP arithmetic. Methods such
as fast-math-flags can be used to limit reassociation, fma-fusion etc,
and basic arithmetic operations are precisely defined in IEEE 754.
However, other math operations such as sqrt, sin, pow etc. represented
by either libcalls or intrinsics are less well defined, and may vary
more between different architectures/library implementations.

As this option is not intended for most common use-cases, this patch
takes the more conservative approach of disabling constant-folding even
for operations like fmax, copysign, fabs etc. in order to keep the
implementation simple, rather than sprinkling checks for this flag
throughout.

The use-cases for this option are similar to StrictFP, but it is only
limited to FP call folding, rather than all FP operations, as it is
about precise arithmetic results, rather than FP environment behaviours.
It also can be used to when linking .bc files compiled with different
StrictFP settings with llvm-link.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add an optional flag to disable constant-folding for function calls.
This applies to both intrinsics and libcalls.

This is not necessary in most cases, so is disabled by default, but in
cases that require bit-exact precision between the result from
constant-folding and run-time execution, having this flag can be useful,
and may help with debugging. Cases where mismatches can occur include
GPU execution vs host-side folding, cross-compilation scenarios, or
compilation vs execution environments with different math library
versions.

This applies only to calls, rather than all FP arithmetic. Methods such
as fast-math-flags can be used to limit reassociation, fma-fusion etc,
and basic arithmetic operations are precisely defined in IEEE 754.
However, other math operations such as sqrt, sin, pow etc. represented
by either libcalls or intrinsics are less well defined, and may vary
more between different architectures/library implementations.

As this option is not intended for most common use-cases, this patch
takes the more conservative approach of disabling constant-folding even
for operations like fmax, copysign, fabs etc. in order to keep the
implementation simple, rather than sprinkling checks for this flag
throughout.

The use-cases for this option are similar to StrictFP, but it is only
limited to FP call folding, rather than all FP operations, as it is
about precise arithmetic results, rather than FP environment behaviours.
It also can be used to when linking .bc files compiled with different
StrictFP settings with llvm-link.</pre>
</div>
</content>
</entry>
<entry>
<title>[Constant] Make Constant::getSplatValue return poison on poison (#141870)</title>
<updated>2025-05-29T14:01:28+00:00</updated>
<author>
<name>Luke Lau</name>
<email>luke@igalia.com</email>
</author>
<published>2025-05-29T14:01:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=64106581b9d4f68eb4911c402b12b154d77a9eb0'/>
<id>64106581b9d4f68eb4911c402b12b154d77a9eb0</id>
<content type='text'>
This is a follow up from #141845. 

TargetTransformInfo::getOperandInfo needs to be updated to check for
undef values as otherwise a splat is considered a constant, and some
RISC-V cost model tests will start adding a cost to materialize the
constant.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a follow up from #141845. 

TargetTransformInfo::getOperandInfo needs to be updated to check for
undef values as otherwise a splat is considered a constant, and some
RISC-V cost model tests will start adding a cost to materialize the
constant.</pre>
</div>
</content>
</entry>
<entry>
<title>[ConstantFolding] Fold intrinsics of scalable vectors with splatted operands (#141845)</title>
<updated>2025-05-28T22:29:41+00:00</updated>
<author>
<name>Luke Lau</name>
<email>luke@igalia.com</email>
</author>
<published>2025-05-28T22:29:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=79ae407c95715f0be5a78260c3b135090f679637'/>
<id>79ae407c95715f0be5a78260c3b135090f679637</id>
<content type='text'>
As noted in
https://github.com/llvm/llvm-project/pull/141821#issuecomment-2917328924,
whilst we currently constant fold intrinsics of fixed-length vectors via
their scalar counterpart, we don't do the same for scalable vectors.

This handles the scalable vector case when the operands are splats.

One weird snag in ConstantVector::getSplat was that it produced a undef
if passed in poison, so this also contains a fix by checking for
PoisonValue before UndefValue.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As noted in
https://github.com/llvm/llvm-project/pull/141821#issuecomment-2917328924,
whilst we currently constant fold intrinsics of fixed-length vectors via
their scalar counterpart, we don't do the same for scalable vectors.

This handles the scalable vector case when the operands are splats.

One weird snag in ConstantVector::getSplat was that it produced a undef
if passed in poison, so this also contains a fix by checking for
PoisonValue before UndefValue.</pre>
</div>
</content>
</entry>
</feed>
