History log of /llvm-project/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp (Results 1 – 25 of 1032)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init
# 212f344b 27-Jan-2025 Nikita Popov <npopov@redhat.com>

[InstCombine] Handle constant expression result in tryFactorization()

If IRBuilder folds the result to a constant expression, don't try
to set nowrap flags on it.

Fixes https://github.com/llvm/llvm

[InstCombine] Handle constant expression result in tryFactorization()

If IRBuilder folds the result to a constant expression, don't try
to set nowrap flags on it.

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

show more ...


# 8e702735 24-Jan-2025 Jeremy Morse <jeremy.morse@sony.com>

[NFC][DebugInfo] Use iterator moveBefore at many call-sites (#123583)

As part of the "RemoveDIs" project, BasicBlock::iterator now carries a
debug-info bit that's needed when getFirstNonPHI and sim

[NFC][DebugInfo] Use iterator moveBefore at many call-sites (#123583)

As part of the "RemoveDIs" project, BasicBlock::iterator now carries a
debug-info bit that's needed when getFirstNonPHI and similar feed into
instruction insertion positions. Call-sites where that's necessary were
updated a year ago; but to ensure some type safety however, we'd like to
have all calls to moveBefore use iterators.

This patch adds a (guaranteed dereferenceable) iterator-taking
moveBefore, and changes a bunch of call-sites where it's obviously safe
to change to use it by just calling getIterator() on an instruction
pointer. A follow-up patch will contain less-obviously-safe changes.

We'll eventually deprecate and remove the instruction-pointer
insertBefore, but not before adding concise documentation of what
considerations are needed (very few).

show more ...


# 0e13ce77 17-Jan-2025 Yingwei Zheng <dtcxzyw2333@gmail.com>

[InstCombine] Handle mul in `maintainNoSignedWrap` (#123299)

Alive2: https://alive2.llvm.org/ce/z/Kgamks
Closes https://github.com/llvm/llvm-project/issues/123175.

For `@foo1`, the nsw flag is p

[InstCombine] Handle mul in `maintainNoSignedWrap` (#123299)

Alive2: https://alive2.llvm.org/ce/z/Kgamks
Closes https://github.com/llvm/llvm-project/issues/123175.

For `@foo1`, the nsw flag is propagated because we first convert it into
`mul nsw nuw (shl nsw nuw X, 1), 3`.

show more ...


Revision tags: llvmorg-19.1.7
# b8337dc4 09-Jan-2025 Yingwei Zheng <dtcxzyw2333@gmail.com>

[InstCombine] Handle commuted patterns in `foldBinOpShiftWithShift` (#122126)

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


# a8072a0b 07-Jan-2025 Nikita Popov <npopov@redhat.com>

[InstCombine] Eliminate icmp+zext pairs over phis more aggressively (#121767)

When folding icmp over phi, add a special case for `icmp eq (zext(bool),
0)`, which is known to fold to `!bool` and thu

[InstCombine] Eliminate icmp+zext pairs over phis more aggressively (#121767)

When folding icmp over phi, add a special case for `icmp eq (zext(bool),
0)`, which is known to fold to `!bool` and thus won't increase the
instruction count. This helps convert more phis to i1, esp. in loops.

This is based on existing logic we have to support this for icmp of
ucmp/scmp.

show more ...


# a4d92400 03-Jan-2025 Yingwei Zheng <dtcxzyw2333@gmail.com>

[InstCombine] Fix GEPNoWrapFlags propagation in `foldGEPOfPhi` (#121572)

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


# 23a23926 18-Dec-2024 Alexander Kornienko <alexfh@google.com>

Revert "[InstCombine] Infer nuw for gep inbounds from base of object" (#120460)

Reverts llvm/llvm-project#119225 due to the lack of sanitizer support,
large potential of breaking code containing la

Revert "[InstCombine] Infer nuw for gep inbounds from base of object" (#120460)

Reverts llvm/llvm-project#119225 due to the lack of sanitizer support,
large potential of breaking code containing latent UB, non-trivial
localization and investigation, and what seems to be a bad interaction
with msan (a test is in the works).

Related discussions:
https://github.com/llvm/llvm-project/pull/119225#issuecomment-2551904822
https://github.com/llvm/llvm-project/pull/118472#issuecomment-2549986255

show more ...


Revision tags: llvmorg-19.1.6
# 4a0d53a0 13-Dec-2024 Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com>

PatternMatch: migrate to CmpPredicate (#118534)

With the introduction of CmpPredicate in 51a895a (IR: introduce struct
with CmpInst::Predicate and samesign), PatternMatch is one of the first
key p

PatternMatch: migrate to CmpPredicate (#118534)

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.

show more ...


# 76875480 13-Dec-2024 Matthias Braun <matze@braunis.de>

[InstCombine] Optimistically allow multiple shufflevector uses in foldOpPhi (#114278)

We would like to optimize situations of the form that happen after loop
vectorization+SROA:
```
loop:
%p

[InstCombine] Optimistically allow multiple shufflevector uses in foldOpPhi (#114278)

We would like to optimize situations of the form that happen after loop
vectorization+SROA:
```
loop:
%phi = phi zeroinitializer, %interleaved

%deinterleave_a = shufflevector %phi, poison ; pick half of the lanes
%deinterleave_b = shufflevector %phi, posion ; pick remaining lanes

... %a = ... %b = ...

%interleaved = shufflevector %a, %b ; interleave lanes of a+b
```
where the interleave and de-interleave shuffle operations cancel each
other out.
This could be handled by `foldOpPhi` but does not currently work because
it does
not proceed when there are multiple uses of the `Phi` operation.

This extends `foldOpPhi` to allow multiple `shufflevector` uses when
they are
shown to simplify for all `Phi` input values.

show more ...


# e21ab4d1 10-Dec-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Infer nuw for gep inbounds from base of object (#119225)

When we have a gep inbounds from the base of an object (e.g. alloca or
global), we know that the index cannot be negative, as

[InstCombine] Infer nuw for gep inbounds from base of object (#119225)

When we have a gep inbounds from the base of an object (e.g. alloca or
global), we know that the index cannot be negative, as this would go out
of bounds. As such, we can infer nuw as well.

The implementation is a bit stricter than necessary, we could also
accept one unknown index followed by known-non-negative indices.

Proof: https://alive2.llvm.org/ce/z/Hp7-6w (Note that alive2 currently
incorrectly doesn't require the inbounds for the alloca case, see
https://github.com/AliveToolkit/alive2/issues/1138).

show more ...


# f7685af4 05-Dec-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Move gep of phi fold into separate function

This makes sure that an early return during this fold doesn't end
up skipping later gep folds.


# 462cb3cd 05-Dec-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Infer nusw + nneg -> nuw for getelementptr (#111144)

If the gep is nusw (usually via inbounds) and the offset is
non-negative, we can infer nuw.

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

[InstCombine] Infer nusw + nneg -> nuw for getelementptr (#111144)

If the gep is nusw (usually via inbounds) and the offset is
non-negative, we can infer nuw.

Proof: https://alive2.llvm.org/ce/z/ihztLy

show more ...


# 51a895ad 03-Dec-2024 Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com>

IR: introduce struct with CmpInst::Predicate and samesign (#116867)

Introduce llvm::CmpPredicate, an abstraction over a floating-point
predicate, and a pack of an integer predicate with samesign in

IR: introduce struct with CmpInst::Predicate and samesign (#116867)

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.

show more ...


Revision tags: llvmorg-19.1.5, llvmorg-19.1.4
# 9a844a36 18-Nov-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Use InstSimplify in FoldOpIntoSelect (#116073)

Instead of only trying to constant fold the select arms, try to simplify
them. This subsumes https://github.com/llvm/llvm-project/pull/1

[InstCombine] Use InstSimplify in FoldOpIntoSelect (#116073)

Instead of only trying to constant fold the select arms, try to simplify
them. This subsumes https://github.com/llvm/llvm-project/pull/115969
which implements this for extractvalue only.

This is still fairly limited in that we will usually only call
FoldOpIntoSelect in the first place if we have a constant operand. This
can be relaxed in the future if worthwhile.

show more ...


# f5e4ffaa 07-Nov-2024 serge-sans-paille <sguelton@mozilla.com>

Revert "[llvm] Use computeConstantRange to improve llvm.objectsize computation (#114673)"

This reverts commit 5f342816efe1854333f2be41a03fdd25fa0db433.

This seems to break various builders, such as

Revert "[llvm] Use computeConstantRange to improve llvm.objectsize computation (#114673)"

This reverts commit 5f342816efe1854333f2be41a03fdd25fa0db433.

This seems to break various builders, such as

https://lab.llvm.org/buildbot/#/builders/41/builds/3259
https://lab.llvm.org/buildbot/#/builders/76/builds/4298

show more ...


# 5f342816 07-Nov-2024 serge-sans-paille <sguelton@mozilla.com>

[llvm] Use computeConstantRange to improve llvm.objectsize computation (#114673)

Using LazyValueInfo, it is possible to compute valuable information for
allocation functions, GEP and alloca, even i

[llvm] Use computeConstantRange to improve llvm.objectsize computation (#114673)

Using LazyValueInfo, it is possible to compute valuable information for
allocation functions, GEP and alloca, even in the presence of dynamic
information.

llvm.objectsize plays an important role in _FORTIFY_SOURCE definitions,
so improving its diagnostic in turns improves the security of compiled
application.

As a side note, as a result of recent optimization improvements, clang
no longer passes
https://github.com/serge-sans-paille/builtin_object_size-test-suite This
commit restores the situation and greatly improves the scope of code
handled by the static version of __builtin_object_size.

show more ...


# cacbe71a 06-Nov-2024 Yingwei Zheng <dtcxzyw2333@gmail.com>

[Analysis] Avoid running transform passes that have just been run (#112092)

This patch adds a new analysis pass to track a set of passes and their
parameters to see if we can avoid running transfor

[Analysis] Avoid running transform passes that have just been run (#112092)

This patch adds a new analysis pass to track a set of passes and their
parameters to see if we can avoid running transform passes that have
just been run. The current implementation only skips redundant
InstCombine runs. I will add support for other passes in follow-up
patches.

RFC link:
https://discourse.llvm.org/t/rfc-pipeline-avoid-running-transform-passes-that-have-just-been-run/82467

Compile time improvement:
http://llvm-compile-time-tracker.com/compare.php?from=76007138f4ffd4e0f510d12b5e8cad529c21f24d&to=64134cf07ea7eb39c60320087c0c5afdc16c3a2b&stat=instructions%3Au

show more ...


Revision tags: llvmorg-19.1.3
# f78610af 28-Oct-2024 Yingwei Zheng <dtcxzyw2333@gmail.com>

[InstCombine] Add function attribute `instcombine-no-verify-fixpoint` (#113822)

This patch introduces a function attribute
`instcombine-no-verify-fixpoint` to avoids disabling fix-point
verificati

[InstCombine] Add function attribute `instcombine-no-verify-fixpoint` (#113822)

This patch introduces a function attribute
`instcombine-no-verify-fixpoint` to avoids disabling fix-point
verification for unrelated tests in the same file.
Address comment
https://github.com/llvm/llvm-project/pull/112642#discussion_r1804714387.

show more ...


# 5155c38c 28-Oct-2024 Yingwei Zheng <dtcxzyw2333@gmail.com>

[InstCombine] Don't check uses of constant exprs (#113684)

This patch skips constant expressions to avoid iterating over uses on
other functions.

Fix crash reported in
https://github.com/llvm/l

[InstCombine] Don't check uses of constant exprs (#113684)

This patch skips constant expressions to avoid iterating over uses on
other functions.

Fix crash reported in
https://github.com/llvm/llvm-project/pull/105510#issuecomment-2437521147.

show more ...


# 90cdc03e 25-Oct-2024 Jay Foad <jay.foad@amd.com>

[IR] Fix undiagnosed cases of structs containing scalable vectors (#113455)

Type::isScalableTy and StructType::containsScalableVectorType failed to
detect some cases of structs containing scalable

[IR] Fix undiagnosed cases of structs containing scalable vectors (#113455)

Type::isScalableTy and StructType::containsScalableVectorType failed to
detect some cases of structs containing scalable vectors because
containsScalableVectorType did not call back into isScalableTy to check
the element types. Fix this, which requires sharing the same Visited set
in both functions. Also change the external API so that callers are
never required to pass in a Visited set, and normalize the naming to
isScalableTy.

show more ...


# 7b65971e 18-Oct-2024 Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com>

InstCombine: sink loads with invariant.load metadata (#112692)


Revision tags: llvmorg-19.1.2
# fa789dff 11-Oct-2024 Rahul Joshi <rjoshi@nvidia.com>

[NFC] Rename `Intrinsic::getDeclaration` to `getOrInsertDeclaration` (#111752)

Rename the function to reflect its correct behavior and to be consistent
with `Module::getOrInsertFunction`. This is a

[NFC] Rename `Intrinsic::getDeclaration` to `getOrInsertDeclaration` (#111752)

Rename the function to reflect its correct behavior and to be consistent
with `Module::getOrInsertFunction`. This is also in preparation of
adding a new `Intrinsic::getDeclaration` that will have behavior similar
to `Module::getFunction` (i.e, just lookup, no creation).

show more ...


# d2408c41 06-Oct-2024 David Green <david.green@arm.com>

[InstCombine] Canonicalize more geps with constant gep bases and constant offsets. (#110033)

This is another small but hopefully not performance negative step to
canonicalizing towards i8 geps. We

[InstCombine] Canonicalize more geps with constant gep bases and constant offsets. (#110033)

This is another small but hopefully not performance negative step to
canonicalizing towards i8 geps. We looks for geps with a constant offset
base pointer of the form `gep (gep @glob, C1), x, C2` and expand the gep
instruction, so that the constant can hopefully be combined together (or
the x offset can be computed in common).

show more ...


# caa265e0 03-Oct-2024 Stephen Tozer <stephen.tozer@sony.com>

[DebugInfo][InstCombine] Do not overwrite prior DILocation for new Insts (#108565)

When InstCombine replaces an old instruction with a new instruction, it
copies !dbg and !annotation metadata from

[DebugInfo][InstCombine] Do not overwrite prior DILocation for new Insts (#108565)

When InstCombine replaces an old instruction with a new instruction, it
copies !dbg and !annotation metadata from old to new. For some
InstCombine patterns we set a specific DILocation on the new instruction
prior to insertion, however, which more accurately reflects the new
instruction. This more specific DILocation may be overwritten on
insertion by a less appropriate one, resulting in a less correct line
mapping. This patch changes this behaviour to only copy the DILocation
from old to new if the new instruction has no existing DILocation (which
will always be the case for a new instruction unless InstCombine has
specifically set one).

show more ...


# e565a4fa 01-Oct-2024 Nikita Popov <npopov@redhat.com>

[IR] Extract helper for GEPNoWrapFlags intersection (NFC)

When combining two geps into one by adding the offsets, we have
to take some care when intersecting the flags, because nusw flags
cannot be

[IR] Extract helper for GEPNoWrapFlags intersection (NFC)

When combining two geps into one by adding the offsets, we have
to take some care when intersecting the flags, because nusw flags
cannot be straightforwardly preserved.

Add a helper for this on GEPNoWrapFlags so we won't have to repeat
this logic in various places.

show more ...


12345678910>>...42