<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Analysis/InstructionSimplify.cpp, branch users/chapuni/cov/single/condop</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>[InstSimplify] Use multi-op replacement when simplify `select` (#121708)</title>
<updated>2025-01-07T17:42:01+00:00</updated>
<author>
<name>goldsteinn</name>
<email>35538541+goldsteinn@users.noreply.github.com</email>
</author>
<published>2025-01-07T17:42:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6192fafe9c8d287daa9d40e3adcd24220a7872af'/>
<id>6192fafe9c8d287daa9d40e3adcd24220a7872af</id>
<content type='text'>
- **[InstSimplify] Refactor `simplifyWithOpsReplaced` to allow multiple
replacements; NFC**
- **[InstSimplify] Use multi-op replacement when simplify `select`**

In the case of `select X | Y == 0 :...` or `select X &amp; Y == -1 : ...`
we can do more simplifications by trying to replace both `X` and `Y`
with the respective constant at once.

Handles some cases for https://github.com/llvm/llvm-project/pull/121672
more generically.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- **[InstSimplify] Refactor `simplifyWithOpsReplaced` to allow multiple
replacements; NFC**
- **[InstSimplify] Use multi-op replacement when simplify `select`**

In the case of `select X | Y == 0 :...` or `select X &amp; Y == -1 : ...`
we can do more simplifications by trying to replace both `X` and `Y`
with the respective constant at once.

Handles some cases for https://github.com/llvm/llvm-project/pull/121672
more generically.</pre>
</div>
</content>
</entry>
<entry>
<title>[InstSimplify] Simplify both operands of select before comparing (#121753)</title>
<updated>2025-01-06T13:43:28+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2025-01-06T13:43:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c630e13676009757400d5c2c22ba3e1f842cf925'/>
<id>c630e13676009757400d5c2c22ba3e1f842cf925</id>
<content type='text'>
In the simplifySelectWithEquivalence fold, simplify both operands before
comparing them, instead of comparing one simplified operand with a
non-simplified operand. This is slightly more powerful.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In the simplifySelectWithEquivalence fold, simplify both operands before
comparing them, instead of comparing one simplified operand with a
non-simplified operand. This is slightly more powerful.</pre>
</div>
</content>
</entry>
<entry>
<title>[InstCombine] Fold `A == MIN_INT ? B != MIN_INT : A &lt; B` to `A &lt; B` (#120177)</title>
<updated>2024-12-19T14:52:55+00:00</updated>
<author>
<name>Veera</name>
<email>32646674+veera-sivarajan@users.noreply.github.com</email>
</author>
<published>2024-12-19T14:52:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=6f8afafd308d37d9abc4af0801dd5a4451c13718'/>
<id>6f8afafd308d37d9abc4af0801dd5a4451c13718</id>
<content type='text'>
This PR folds:
 `A == MIN_INT ? B != MIN_INT : A &lt; B` to `A &lt; B`
 `A == MAX_INT ? B != MAX_INT : A &gt; B` to `A &gt; B`

Proof: https://alive2.llvm.org/ce/z/bR6E2s

This helps in optimizing comparison of optional unsigned non-zero types
in https://github.com/rust-lang/rust/issues/49892.

Rust compiler's current output: https://rust.godbolt.org/z/9fxfq3Gn8</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This PR folds:
 `A == MIN_INT ? B != MIN_INT : A &lt; B` to `A &lt; B`
 `A == MAX_INT ? B != MAX_INT : A &gt; B` to `A &gt; B`

Proof: https://alive2.llvm.org/ce/z/bR6E2s

This helps in optimizing comparison of optional unsigned non-zero types
in https://github.com/rust-lang/rust/issues/49892.

Rust compiler's current output: https://rust.godbolt.org/z/9fxfq3Gn8</pre>
</div>
</content>
</entry>
<entry>
<title>[InstSimplify] Treat float binop with identity as refining (#120098)</title>
<updated>2024-12-17T09:58:52+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2024-12-17T09:58:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=7c135e17fbb7178466eafce9826c896518907637'/>
<id>7c135e17fbb7178466eafce9826c896518907637</id>
<content type='text'>
If x is NaN, then fmul (x, 1) may produce a different NaN value.

Our float semantics explicitly permit folding fmul (x, 1) to x, but we
can't do this when we're replacing a select input, as selects are
supposed to preserve the exact bitwise value.

Fixes
https://github.com/llvm/llvm-project/pull/115152#issuecomment-2545773114.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If x is NaN, then fmul (x, 1) may produce a different NaN value.

Our float semantics explicitly permit folding fmul (x, 1) to x, but we
can't do this when we're replacing a select input, as selects are
supposed to preserve the exact bitwise value.

Fixes
https://github.com/llvm/llvm-project/pull/115152#issuecomment-2545773114.</pre>
</div>
</content>
</entry>
<entry>
<title>PatternMatch: migrate to CmpPredicate (#118534)</title>
<updated>2024-12-13T14:18:33+00:00</updated>
<author>
<name>Ramkumar Ramachandra</name>
<email>ramkumar.ramachandra@codasip.com</email>
</author>
<published>2024-12-13T14:18:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=4a0d53a0b0a58a3c6980a7c551357ac71ba3db10'/>
<id>4a0d53a0b0a58a3c6980a7c551357ac71ba3db10</id>
<content type='text'>
With the introduction of CmpPredicate in 51a895a (IR: introduce struct
with CmpInst::Predicate and samesign), PatternMatch is one of the first
key pieces of infrastructure that must be updated to match a CmpInst
respecting samesign information. Implement this change to Cmp-matchers.

This is a preparatory step in migrating the codebase over to
CmpPredicate. Since we no functional changes are desired at this stage,
we have chosen not to migrate CmpPredicate::operator==(CmpPredicate)
calls to use CmpPredicate::getMatching(), as that would have visible
impact on tests that are not yet written: instead, we call
CmpPredicate::operator==(Predicate), preserving the old behavior, while
also inserting a few FIXME comments for follow-ups.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With the introduction of CmpPredicate in 51a895a (IR: introduce struct
with CmpInst::Predicate and samesign), PatternMatch is one of the first
key pieces of infrastructure that must be updated to match a CmpInst
respecting samesign information. Implement this change to Cmp-matchers.

This is a preparatory step in migrating the codebase over to
CmpPredicate. Since we no functional changes are desired at this stage,
we have chosen not to migrate CmpPredicate::operator==(CmpPredicate)
calls to use CmpPredicate::getMatching(), as that would have visible
impact on tests that are not yet written: instead, we call
CmpPredicate::operator==(Predicate), preserving the old behavior, while
also inserting a few FIXME comments for follow-ups.</pre>
</div>
</content>
</entry>
<entry>
<title>[InstSimplify] Remove foldSelectWithBinaryOp (#118913)</title>
<updated>2024-12-09T09:31:54+00:00</updated>
<author>
<name>Yihang Liu</name>
<email>2654791554@qq.com</email>
</author>
<published>2024-12-09T09:31:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=62a25a4c7c3b291f0805894926419f1a64cd83f8'/>
<id>62a25a4c7c3b291f0805894926419f1a64cd83f8</id>
<content type='text'>
As mentioned in https://github.com/llvm/llvm-project/issues/118815, the
purpose of this simplification is superseded by
https://github.com/llvm/llvm-project/pull/76621, so we should have it
deleted.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As mentioned in https://github.com/llvm/llvm-project/issues/118815, the
purpose of this simplification is superseded by
https://github.com/llvm/llvm-project/pull/76621, so we should have it
deleted.</pre>
</div>
</content>
</entry>
<entry>
<title>IR: introduce struct with CmpInst::Predicate and samesign (#116867)</title>
<updated>2024-12-03T13:31:04+00:00</updated>
<author>
<name>Ramkumar Ramachandra</name>
<email>ramkumar.ramachandra@codasip.com</email>
</author>
<published>2024-12-03T13:31:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=51a895aded890e90493be59f7af0fa5a3b9b85aa'/>
<id>51a895aded890e90493be59f7af0fa5a3b9b85aa</id>
<content type='text'>
Introduce llvm::CmpPredicate, an abstraction over a floating-point
predicate, and a pack of an integer predicate with samesign information,
in order to ease extending large portions of the codebase that take a
CmpInst::Predicate to respect the samesign flag.

We have chosen to demonstrate the utility of this new abstraction by
migrating parts of ValueTracking, InstructionSimplify, and InstCombine
from CmpInst::Predicate to llvm::CmpPredicate. There should be no
functional changes, as we don't perform any extra optimizations with
samesign in this patch, or use CmpPredicate::getMatching.

The design approach taken by this patch allows for unaudited callers of
APIs that take a llvm::CmpPredicate to silently drop the samesign
information; it does not pose a correctness issue, and allows us to
migrate the codebase piece-wise.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Introduce llvm::CmpPredicate, an abstraction over a floating-point
predicate, and a pack of an integer predicate with samesign information,
in order to ease extending large portions of the codebase that take a
CmpInst::Predicate to respect the samesign flag.

We have chosen to demonstrate the utility of this new abstraction by
migrating parts of ValueTracking, InstructionSimplify, and InstCombine
from CmpInst::Predicate to llvm::CmpPredicate. There should be no
functional changes, as we don't perform any extra optimizations with
samesign in this patch, or use CmpPredicate::getMatching.

The design approach taken by this patch allows for unaudited callers of
APIs that take a llvm::CmpPredicate to silently drop the samesign
information; it does not pose a correctness issue, and allows us to
migrate the codebase piece-wise.</pre>
</div>
</content>
</entry>
<entry>
<title>[InstSimplify] Generalize simplification of icmps with monotonic operands (#69471)</title>
<updated>2024-12-02T08:53:10+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2024-12-02T08:53:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8201926ec0a61ea182e3b25c23e3dbaae6036dbf'/>
<id>8201926ec0a61ea182e3b25c23e3dbaae6036dbf</id>
<content type='text'>
InstSimplify currently folds patterns like `(x | y) uge x` and `(x &amp; y)
ule x` to true. However, it cannot handle combinations of such
situations, such as `(x | y) uge (x &amp; z)` etc.

To support this, recursively collect operands of monotonic instructions
(that preserve either a greater-or-equal or less-or-equal relationship)
and then check whether any of them match.

Fixes https://github.com/llvm/llvm-project/issues/69333.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
InstSimplify currently folds patterns like `(x | y) uge x` and `(x &amp; y)
ule x` to true. However, it cannot handle combinations of such
situations, such as `(x | y) uge (x &amp; z)` etc.

To support this, recursively collect operands of monotonic instructions
(that preserve either a greater-or-equal or less-or-equal relationship)
and then check whether any of them match.

Fixes https://github.com/llvm/llvm-project/issues/69333.</pre>
</div>
</content>
</entry>
<entry>
<title>[InstSimplify] Generalize `simplifyAndOrOfFCmps` to handle fabs (#116590)</title>
<updated>2024-11-19T12:10:40+00:00</updated>
<author>
<name>Yingwei Zheng</name>
<email>dtcxzyw2333@gmail.com</email>
</author>
<published>2024-11-19T12:10:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=42ed7757835122a63477b5783215e1100cd0b709'/>
<id>42ed7757835122a63477b5783215e1100cd0b709</id>
<content type='text'>
This patch generalizes https://github.com/llvm/llvm-project/issues/81027
to handle pattern `and/or (fcmp ord/uno X, 0), (fcmp pred fabs(X), Y)`.
Alive2: https://alive2.llvm.org/ce/z/tsgUrz
The correctness is straightforward because `fcmp ord/uno X, 0.0` is
equivalent to `fcmp ord/uno fabs(X), 0.0`. We may generalize it to
handle fneg as well.

Address comment
https://github.com/llvm/llvm-project/pull/116065#pullrequestreview-2434796846</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch generalizes https://github.com/llvm/llvm-project/issues/81027
to handle pattern `and/or (fcmp ord/uno X, 0), (fcmp pred fabs(X), Y)`.
Alive2: https://alive2.llvm.org/ce/z/tsgUrz
The correctness is straightforward because `fcmp ord/uno X, 0.0` is
equivalent to `fcmp ord/uno fabs(X), 0.0`. We may generalize it to
handle fneg as well.

Address comment
https://github.com/llvm/llvm-project/pull/116065#pullrequestreview-2434796846</pre>
</div>
</content>
</entry>
<entry>
<title>InstSimplify: support floating-point equivalences (#115152)</title>
<updated>2024-11-15T20:06:11+00:00</updated>
<author>
<name>Ramkumar Ramachandra</name>
<email>ramkumar.ramachandra@codasip.com</email>
</author>
<published>2024-11-15T20:06:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=94eebf721a2f8630412730f51d5071816a686ea0'/>
<id>94eebf721a2f8630412730f51d5071816a686ea0</id>
<content type='text'>
Since cd16b07 (IR: introduce CmpInst::isEquivalence), there is now an
isEquivalence routine in CmpInst that we can use to determine
equivalence in simplifySelectWithICmpEq. Implement this, extending the
code from integer-equalities to integer and floating-point equivalences.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since cd16b07 (IR: introduce CmpInst::isEquivalence), there is now an
isEquivalence routine in CmpInst that we can use to determine
equivalence in simplifySelectWithICmpEq. Implement this, extending the
code from integer-equalities to integer and floating-point equivalences.</pre>
</div>
</content>
</entry>
</feed>
