<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Transforms/InstCombine/InstCombineAddSub.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>[InstCombine] Pull vector reverse through fneg (#146349)</title>
<updated>2025-06-30T15:15:04+00:00</updated>
<author>
<name>Luke Lau</name>
<email>luke@igalia.com</email>
</author>
<published>2025-06-30T15:15:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6f7370ced630ec1994456a979ca10ac26e3dc0a7'/>
<id>6f7370ced630ec1994456a979ca10ac26e3dc0a7</id>
<content type='text'>
This follows on from
https://github.com/llvm/llvm-project/pull/144933#issuecomment-2992372627,
and allows us to remove the reverse (fneg (reverse x)) combine.

A separate patch will handle the case for fabs. I haven't checked if we
perform this canonicalization for either unops or binops for vp.reverse</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This follows on from
https://github.com/llvm/llvm-project/pull/144933#issuecomment-2992372627,
and allows us to remove the reverse (fneg (reverse x)) combine.

A separate patch will handle the case for fabs. I haven't checked if we
perform this canonicalization for either unops or binops for vp.reverse</pre>
</div>
</content>
</entry>
<entry>
<title>[InstCombine] Pull unary shuffles through fneg/fabs (#144933)</title>
<updated>2025-06-30T09:40:12+00:00</updated>
<author>
<name>Luke Lau</name>
<email>luke@igalia.com</email>
</author>
<published>2025-06-30T09:40:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d0c1ea928c5c4a99689ff3dcbf1ca578d56b80a3'/>
<id>d0c1ea928c5c4a99689ff3dcbf1ca578d56b80a3</id>
<content type='text'>
This canonicalizes fneg/fabs (shuffle X, poison, mask) -&gt; shuffle
(fneg/fabs X), posion, mask

This undoes part of b331a7ebc1e02f9939d1a4a1509e7eb6cdda3d38 and
a8f13dbdeb31be37ee15b5febb7cc2137bbece67, but keeps the binary shuffle
case i.e. shuffle fneg, fneg, mask.

By pulling out the shuffle we bring it inline with the same
canonicalisation we perform on binary ops and intrinsics, which the
original commit acknowledges it goes in the opposite direction.

However nowadays VectorCombine is more powerful and can do more
optimisations when the shuffle is pulled out, so I think we should
revisit this. In particular we get more shuffles folded and can perform
scalarization.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This canonicalizes fneg/fabs (shuffle X, poison, mask) -&gt; shuffle
(fneg/fabs X), posion, mask

This undoes part of b331a7ebc1e02f9939d1a4a1509e7eb6cdda3d38 and
a8f13dbdeb31be37ee15b5febb7cc2137bbece67, but keeps the binary shuffle
case i.e. shuffle fneg, fneg, mask.

By pulling out the shuffle we bring it inline with the same
canonicalisation we perform on binary ops and intrinsics, which the
original commit acknowledges it goes in the opposite direction.

However nowadays VectorCombine is more powerful and can do more
optimisations when the shuffle is pulled out, so I think we should
revisit this. In particular we get more shuffles folded and can perform
scalarization.
</pre>
</div>
</content>
</entry>
<entry>
<title>[InstCombine] Optimize sub(sext(add(x,y)),sext(add(x,z))). (#144174)</title>
<updated>2025-06-19T17:13:58+00:00</updated>
<author>
<name>Slava Zakharin</name>
<email>szakharin@nvidia.com</email>
</author>
<published>2025-06-19T17:13:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c0c71463f6bca05eb4540b68cdcbd17c916562c9'/>
<id>c0c71463f6bca05eb4540b68cdcbd17c916562c9</id>
<content type='text'>
This pattern can be often met in Flang generated LLVM IR,
for example, for the counts of the loops generated for array
expressions like: `a(x:x+y)` or `a(x+z:x+z)` or their variations.

In order to compute the loop count, Flang needs to subtract
the lower bound of the array slice from the upper bound
of the array slice. To avoid the sign wraps, it sign extends
the original values (that may be of any user data type)
to `i64`.

This peephole is really helpful in CPU2017/548.exchange2,
where we have multiple following statements like this:
```
block(row+1:row+2, 7:9, i7) = block(row+1:row+2, 7:9, i7) - 10
```

While this is just a 2x3 iterations loop nest, LLVM cannot
figure it out, ending up vectorizing the inner loop really
hard (with a vector epilog and scalar remainder). This, in turn,
causes problems for LSR that ends up creating too many loop-carried
values in the loop containing the above statement, which are then
causing too many spills/reloads.

Alive2: https://alive2.llvm.org/ce/z/gLgfYX

Related to #143219.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This pattern can be often met in Flang generated LLVM IR,
for example, for the counts of the loops generated for array
expressions like: `a(x:x+y)` or `a(x+z:x+z)` or their variations.

In order to compute the loop count, Flang needs to subtract
the lower bound of the array slice from the upper bound
of the array slice. To avoid the sign wraps, it sign extends
the original values (that may be of any user data type)
to `i64`.

This peephole is really helpful in CPU2017/548.exchange2,
where we have multiple following statements like this:
```
block(row+1:row+2, 7:9, i7) = block(row+1:row+2, 7:9, i7) - 10
```

While this is just a 2x3 iterations loop nest, LLVM cannot
figure it out, ending up vectorizing the inner loop really
hard (with a vector epilog and scalar remainder). This, in turn,
causes problems for LSR that ends up creating too many loop-carried
values in the loop containing the above statement, which are then
causing too many spills/reloads.

Alive2: https://alive2.llvm.org/ce/z/gLgfYX

Related to #143219.</pre>
</div>
</content>
</entry>
<entry>
<title>InstCombine: improve optimizations for ceiling division with no overflow (#142869)</title>
<updated>2025-06-17T07:52:18+00:00</updated>
<author>
<name>gaynor-anthropic</name>
<email>gaynor@anthropic.com</email>
</author>
<published>2025-06-17T07:52:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=632151fbeea972f4aa3c14921eca1e45c07646f3'/>
<id>632151fbeea972f4aa3c14921eca1e45c07646f3</id>
<content type='text'>
Fixes #142497.

Alive2: https://alive2.llvm.org/ce/z/CeaHaH

The contents of this pull request were substantially written using
claude-code. I've reviewed to the best of my ability (it's been years
since I did any compilers work).

---------

Co-authored-by: Yingwei Zheng &lt;dtcxzyw@qq.com&gt;
Co-authored-by: Nikita Popov &lt;github@npopov.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes #142497.

Alive2: https://alive2.llvm.org/ce/z/CeaHaH

The contents of this pull request were substantially written using
claude-code. I've reviewed to the best of my ability (it's been years
since I did any compilers work).

---------

Co-authored-by: Yingwei Zheng &lt;dtcxzyw@qq.com&gt;
Co-authored-by: Nikita Popov &lt;github@npopov.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[InstCombine] Extract EmitGEPOffsets() helper (NFC)</title>
<updated>2025-06-13T10:34:18+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2025-06-13T10:34:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=2019553a0b8811a23d7546cbace52a8e241a3b37'/>
<id>2019553a0b8811a23d7546cbace52a8e241a3b37</id>
<content type='text'>
Extract a reusable helper for emitting a sum of multiple GEP
offsets.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Extract a reusable helper for emitting a sum of multiple GEP
offsets.
</pre>
</div>
</content>
</entry>
<entry>
<title>[InstCombine] Restore splat gep support in OptimizePointerDifference() (#143906)</title>
<updated>2025-06-13T10:29:50+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2025-06-13T10:29:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6fc8ec720ea590bbdb94e19acefaf5bafdfcf817'/>
<id>6fc8ec720ea590bbdb94e19acefaf5bafdfcf817</id>
<content type='text'>
When looking for the common base pointer, support the case where the
type changes because the GEP goes from pointer to vector of pointers.
This was supported prior to #142958.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When looking for the common base pointer, support the case where the
type changes because the GEP goes from pointer to vector of pointers.
This was supported prior to #142958.</pre>
</div>
</content>
</entry>
<entry>
<title>[InstCombine] Export logic for common base pointer (NFC)</title>
<updated>2025-06-12T13:33:45+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2025-06-12T13:27:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b8e3e0749fb62a9845f8790f858e11f2558f94a2'/>
<id>b8e3e0749fb62a9845f8790f858e11f2558f94a2</id>
<content type='text'>
Make this available to other parts of InstCombine, to be used for
pointer comparison optimization.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Make this available to other parts of InstCombine, to be used for
pointer comparison optimization.
</pre>
</div>
</content>
</entry>
<entry>
<title>[InstCombine] Ensure Safe Handling of Flags in foldFNegIntoConstant (#94148)</title>
<updated>2025-06-12T10:31:43+00:00</updated>
<author>
<name>SahilPatidar</name>
<email>patidarsahil2001@gmail.com</email>
</author>
<published>2025-06-12T10:31:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=971c49fbf361c22ccf20913f61a58c28b26c4e27'/>
<id>971c49fbf361c22ccf20913f61a58c28b26c4e27</id>
<content type='text'>
Fix #93769 

alive2: https://alive2.llvm.org/ce/z/MHShQY</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix #93769 

alive2: https://alive2.llvm.org/ce/z/MHShQY</pre>
</div>
</content>
</entry>
<entry>
<title>[InstCombine] Preserve flags for difference of gep chains (#143488)</title>
<updated>2025-06-10T14:19:45+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2025-06-10T14:19:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b27ab06a3d3f7f37496c5fa4dc367a3be0a8498d'/>
<id>b27ab06a3d3f7f37496c5fa4dc367a3be0a8498d</id>
<content type='text'>
When expanding the offset of a GEP chain via a series of adds, try to
preserve the nsw/nuw flags based on inbounds/nuw. This is a followup to
https://github.com/llvm/llvm-project/pull/142958.

Proof: https://alive2.llvm.org/ce/z/8HiFYY (note that preserving nsw in
the nusw case is not valid)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When expanding the offset of a GEP chain via a series of adds, try to
preserve the nsw/nuw flags based on inbounds/nuw. This is a followup to
https://github.com/llvm/llvm-project/pull/142958.

Proof: https://alive2.llvm.org/ce/z/8HiFYY (note that preserving nsw in
the nusw case is not valid)</pre>
</div>
</content>
</entry>
<entry>
<title>[InstCombine] Support nested GEPs in OptimizePointerDifference (#142958)</title>
<updated>2025-06-10T07:28:15+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2025-06-10T07:28:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=20e8de9c8f4cf54c6c57535428c987d921861034'/>
<id>20e8de9c8f4cf54c6c57535428c987d921861034</id>
<content type='text'>
Currently OptimizePointerDifference() only handles single GEPs with a
common base, not GEP chains. This patch generalizes the support to
nested GEPs with a common base.

Finding the common base is a bit annoying because we want to stop as
soon as possible and not recurse into common GEP prefixes.

This helps avoids regressions from
https://github.com/llvm/llvm-project/pull/137297.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently OptimizePointerDifference() only handles single GEPs with a
common base, not GEP chains. This patch generalizes the support to
nested GEPs with a common base.

Finding the common base is a bit annoying because we want to stop as
soon as possible and not recurse into common GEP prefixes.

This helps avoids regressions from
https://github.com/llvm/llvm-project/pull/137297.</pre>
</div>
</content>
</entry>
</feed>
