History log of /llvm-project/llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp (Results 1 – 25 of 54)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4
# ff07df66 08-Nov-2024 Yingwei Zheng <dtcxzyw2333@gmail.com>

[InstCombine] Drop nsw in negation of select (#112893)

Closes https://github.com/llvm/llvm-project/issues/112666 and
https://github.com/llvm/llvm-project/issues/114181.


# e5bf14e9 03-Nov-2024 Kazu Hirata <kazu@google.com>

[InstCombine] Remove unused includes (NFC) (#114709)

Identified with misc-include-cleaner.


Revision tags: llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3
# 48ae6147 17-Aug-2024 Yingwei Zheng <dtcxzyw2333@gmail.com>

[InstCombine] Avoid infinite loop when negating phi nodes (#104581)

Closes https://github.com/llvm/llvm-project/issues/96012

---------

Co-authored-by: Nikita Popov <github@npopov.com>


# 1753008b 11-Aug-2024 Rahul Joshi <rjoshi@nvidia.com>

[NFC] Eliminate top-level "using namespace" from some headers. (#102751)

- Eliminate top-level "using namespace" from some headers.


Revision tags: llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init
# 8c664a9f 10-Jul-2024 Poseydon42 <vvmposeydon@gmail.com>

[InstCombine] Fold negation of calls to `ucmp/scmp` by swapping its operands (#98360)

Proofs: https://alive2.llvm.org/ce/z/cp_a36


# d314cf24 18-Jun-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Avoid use of ConstantExpr::getShl()

Use IRBuilder instead, as we don't care about the return type
here. Use ImmConstant to ensure that constant folding will
succeed.


Revision tags: llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5
# a1b1c4a6 24-Apr-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Fix miscompile in negation of select (#89698)

Swapping the operands of a select is not valid if one hand is more
poisonous that the other, because the negation zero contains poison
e

[InstCombine] Fix miscompile in negation of select (#89698)

Swapping the operands of a select is not valid if one hand is more
poisonous that the other, because the negation zero contains poison
elements.

Fix this by adding an extra parameter to isKnownNegation() to forbid
poison elements.

I've implemented this using manual checks to avoid needing four variants
for the NeedsNSW/AllowPoison combinations. Maybe there is a better way
to do this...

Fixes https://github.com/llvm/llvm-project/issues/89669.

show more ...


# 1baa3850 18-Apr-2024 Nikita Popov <npopov@redhat.com>

[IR][PatternMatch] Only accept poison in getSplatValue() (#89159)

In #88217 a large set of matchers was changed to only accept poison
values in splats, but not undef values. This is because we now

[IR][PatternMatch] Only accept poison in getSplatValue() (#89159)

In #88217 a large set of matchers was changed to only accept poison
values in splats, but not undef values. This is because we now use
poison for non-demanded vector elements, and allowing undef can cause
correctness issues.

This patch covers the remaining matchers by changing the AllowUndef
parameter of getSplatValue() to AllowPoison instead. We also carry out
corresponding renames in matchers.

As a followup, we may want to change the default for things like m_APInt
to m_APIntAllowPoison (as this is much less risky when only allowing
poison), but this change doesn't do that.

There is one caveat here: We have a single place
(X86FixupVectorConstants) which does require handling of vector splats
with undefs. This is because this works on backend constant pool
entries, which currently still use undef instead of poison for
non-demanded elements (because SDAG as a whole does not have an explicit
poison representation). As it's just the single use, I've open-coded a
getSplatValueAllowUndef() helper there, to discourage use in any other
places.

show more ...


Revision tags: llvmorg-18.1.4, llvmorg-18.1.3
# caa22582 26-Mar-2024 Yingwei Zheng <dtcxzyw2333@gmail.com>

[LLVM] Remove nuw neg (#86295)

This patch removes APIs that creating NUW neg. It is a trivial case
because `sub nuw 0, X` always gets simplified into zero.
I believe there is no optimization oppor

[LLVM] Remove nuw neg (#86295)

This patch removes APIs that creating NUW neg. It is a trivial case
because `sub nuw 0, X` always gets simplified into zero.
I believe there is no optimization opportunities in the real-world
applications that we can take advantage of the nuw flag.

Motivated by
https://github.com/llvm/llvm-project/pull/84792#discussion_r1524891134.

Compile-time improvement:
https://llvm-compile-time-tracker.com/compare.php?from=d1f182c895728d89c5c3d198b133e212a5d9d4a3&to=da7b7478b7cbb32c09d760f6b8d0e67901e0d533&stat=instructions:u

show more ...


Revision tags: llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3
# 470c5b80 14-Feb-2024 Yingwei Zheng <dtcxzyw2333@gmail.com>

[InstSimplify][InstCombine] Remove unnecessary `m_c_*` matchers. (#81712)

This patch removes unnecessary `m_c_*` matchers since we always
canonicalize `commutive_op Cst, X` into `commutive_op X, Cs

[InstSimplify][InstCombine] Remove unnecessary `m_c_*` matchers. (#81712)

This patch removes unnecessary `m_c_*` matchers since we always
canonicalize `commutive_op Cst, X` into `commutive_op X, Cst`.

Compile-time impact:
https://llvm-compile-time-tracker.com/compare.php?from=bfc0b7c6891896ee8e9818f22800472510093864&to=d27b058bb9acaa43d3cadbf3cd889e8f79e5c634&stat=instructions:u

show more ...


Revision tags: llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init
# 8b118113 10-Dec-2023 Kazu Hirata <kazu@google.com>

[Transforms] Remove unused forward declarations (NFC)


# a1642936 10-Dec-2023 Kazu Hirata <kazu@google.com>

[Transforms] Remove unnecessary includes (NFC)


# cd865e36 05-Dec-2023 Nikita Popov <npopov@redhat.com>

[InstCombine] Use disjoint flag instead of haveNoCommonBitsSet()

Slightly stronger, if disjoint was inferred earlier with information
that is no longer available.


Revision tags: llvmorg-17.0.6
# f112e469 18-Nov-2023 Noah Goldstein <goldstein.w.n@gmail.com>

[InstCombine] Don't transform `sub X, ~Y` -> `add X, -Y` unless `Y` is actually negatable

This combine was previously adding instruction in some cases (see the
tests).

Closes #72767


Revision tags: llvmorg-17.0.5, llvmorg-17.0.4
# 9c5a5a42 22-Oct-2023 Kazu Hirata <kazu@google.com>

[llvm] Stop including llvm/ADT/iterator_range.h (NFC)

Identified with misc-include-cleaner.


Revision tags: llvmorg-17.0.3
# 80fa5a63 10-Oct-2023 Nikita Popov <npopov@redhat.com>

[ValueTracking] Use SimplifyQuery in haveNoCommonBitsSet() (NFC)

Pass SimplifyQuery instead of unpacked list of arguments.


Revision tags: llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3
# 1fc73cac 21-Aug-2023 Nikita Popov <npopov@redhat.com>

[InstCombine] Propagate nsw flag when negating

When pushing a sub nsw 0, %x negation into an expression, try to
preserve the nsw flag for the cases where this is possible. Do this
by passing the fla

[InstCombine] Propagate nsw flag when negating

When pushing a sub nsw 0, %x negation into an expression, try to
preserve the nsw flag for the cases where this is possible. Do this
by passing the flag through recursive Negator::negate() calls.

Proofs: https://alive2.llvm.org/ce/z/oRPNcY

Differential Revision: https://reviews.llvm.org/D158510

show more ...


Revision tags: llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7
# 6eb0b0a0 15-Dec-2022 Kazu Hirata <kazu@google.com>

Don't include Optional.h

These files no longer use llvm::Optional.


# 21cd58ba 13-Dec-2022 Fangrui Song <i@maskray.me>

[Transforms/InstCombine] llvm::Optional => std::optional


# 405fc404 07-Dec-2022 Kazu Hirata <kazu@google.com>

[ADT] Don't including None.h (NFC)

These source files no longer use None, so they do not need to include
None.h.

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

https://

[ADT] Don't including None.h (NFC)

These source files no longer use None, so they do not need to include
None.h.

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

show more ...


# 343de685 03-Dec-2022 Kazu Hirata <kazu@google.com>

[Transforms] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated. The intent is to reduce
the amount

[Transforms] Use std::nullopt instead of None (NFC)

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

show more ...


Revision tags: llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2
# 0f32a5de 21-Sep-2022 Sanjay Patel <spatel@rotateright.com>

[InstCombine] don't canonicalize shl+sub to mul+add

This stops Negator from transforming:
`C1 - shl X, C2 --> mul X, (1<<C2) + C1`
...in the general case. There does not seem to be any analysis
bene

[InstCombine] don't canonicalize shl+sub to mul+add

This stops Negator from transforming:
`C1 - shl X, C2 --> mul X, (1<<C2) + C1`
...in the general case. There does not seem to be any analysis
benefit to using mul in IR, and there's definitely downside in
codegen (particularly when the multiply has to be expanded).

If `C1` is 0, then there's a stronger argument that the single
mul is a better canonicalization than negate-of-shl, but we may
want to remove that too.

This was noted as a potential conflict for D133667.

Differential Revision: https://reviews.llvm.org/D134310

show more ...


Revision tags: llvmorg-15.0.1, llvmorg-15.0.0
# c6e56024 27-Aug-2022 Sanjay Patel <spatel@rotateright.com>

[InstCombine] fold signbit splat pattern that uses negate

0 - (zext (i8 X u>> 7) to iN) --> sext (i8 X s>> 7) to iN

https://alive2.llvm.org/ce/z/jzv4Ud

This is part of solving issue #57381.


Revision tags: llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2
# de9d80c1 08-Aug-2022 Fangrui Song <i@maskray.me>

[llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFC

With C++17 there is no Clang pedantic warning or MSVC C5051.


# fa66789d 07-Aug-2022 Fangrui Song <i@maskray.me>

[llvm] LLVM_NODISCARD => [[nodiscard]]. NFC

With C++17 there is no Clang pedantic warning.


123