History log of /llvm-project/llvm/test/Transforms/InstCombine/getelementptr.ll (Results 1 – 25 of 157)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6
# 10f315dc 09-Dec-2024 Nikita Popov <npopov@redhat.com>

[ConstantFolding] Infer getelementptr nuw flag (#119214)

Infer nuw from nusw and nneg. This is the constant expression variant of
https://github.com/llvm/llvm-project/pull/111144.

Proof: https:/

[ConstantFolding] Infer getelementptr nuw flag (#119214)

Infer nuw from nusw and nneg. This is the constant expression variant of
https://github.com/llvm/llvm-project/pull/111144.

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

show more ...


# 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 ...


Revision tags: llvmorg-19.1.5
# 56c091ea 21-Nov-2024 Paul Walker <paul.walker@arm.com>

[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)

This brings the printing of scalable vector constant splats inline with
their fixed length counterparts.


Revision tags: llvmorg-19.1.4
# 38fffa63 06-Nov-2024 Paul Walker <paul.walker@arm.com>

[LLVM][IR] Use splat syntax when printing Constant[Data]Vector. (#112548)


Revision tags: llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0
# 1c298c92 13-Sep-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Preserve nuw flags when merging geps

These transforms all perform a variant of (gep (gep p, x), y)
to (gep p, (x + y)). We can preserve both inbounds and nuw
during such transforms (ht

[InstCombine] Preserve nuw flags when merging geps

These transforms all perform a variant of (gep (gep p, x), y)
to (gep p, (x + y)). We can preserve both inbounds and nuw
during such transforms (https://alive2.llvm.org/ce/z/Stu4cN), but
not nusw, which would require proving that the new add is nsw.

For the constant offset case, I've conservatively retained the
logic that checks for negative intermediate offsets, though I'm
not sure it's still reachable nowadays.

show more ...


# 940f8925 13-Sep-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Do not modify GEP in place

This was modifying the GEP in place, with code to adjust the
inbounds flag. This was correct at the time, but now fails to
account for other GEP flags like n

[InstCombine] Do not modify GEP in place

This was modifying the GEP in place, with code to adjust the
inbounds flag. This was correct at the time, but now fails to
account for other GEP flags like nuw, leading to miscompilations.

Remove the special case, and always create a new GEP instruction.
Logic for preserving nuw in the cases where it is valid will be
added in a followup patch.

show more ...


Revision tags: llvmorg-19.1.0-rc4
# a1058776 21-Aug-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Remove some of the complexity-based canonicalization (#91185)

The idea behind this canonicalization is that it allows us to handle less
patterns, because we know that some will be can

[InstCombine] Remove some of the complexity-based canonicalization (#91185)

The idea behind this canonicalization is that it allows us to handle less
patterns, because we know that some will be canonicalized away. This is
indeed very useful to e.g. know that constants are always on the right.

However, this is only useful if the canonicalization is actually
reliable. This is the case for constants, but not for arguments: Moving
these to the right makes it look like the "more complex" expression is
guaranteed to be on the left, but this is not actually the case in
practice. It fails as soon as you replace the argument with another
instruction.

The end result is that it looks like things correctly work in tests,
while they actually don't. We use the "thwart complexity-based
canonicalization" trick to handle this in tests, but it's often a
challenge for new contributors to get this right, and based on the
regressions this PR originally exposed, we clearly don't get this right
in many cases.

For this reason, I think that it's better to remove this complexity
canonicalization. It will make it much easier to write tests for
commuted cases and make sure that they are handled.

show more ...


Revision tags: llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init
# 26326800 27-Jun-2024 Noah Goldstein <goldstein.w.n@gmail.com>

[InstCombine] Canonicalize `(gep <not i8> p, (div exact X, C))`

If C % sizeof(gep_element_type) is zero, we can canonicalize to `i8` via:
`(gep i8 p, (div exact X, C / (sizeof(gep_element_type))

[InstCombine] Canonicalize `(gep <not i8> p, (div exact X, C))`

If C % sizeof(gep_element_type) is zero, we can canonicalize to `i8` via:
`(gep i8 p, (div exact X, C / (sizeof(gep_element_type))))`

Closes #96898

show more ...


# c03d3a85 27-Jun-2024 Noah Goldstein <goldstein.w.n@gmail.com>

[InstCombine] Add tests for canonicalizing `(gep <not i8> p, (exact_ins X, C))`; NFC


# 352a8361 26-Jun-2024 David Green <david.green@arm.com>

[InstCombine] Canonicalize non-i8 gep of mul to i8 (#96606)

This is a small canonicalization for `gep i32, p, (mul x, C)` -> `gep
i8, p, (mul x, C*4)`, so that the mul can combine both of the const

[InstCombine] Canonicalize non-i8 gep of mul to i8 (#96606)

This is a small canonicalization for `gep i32, p, (mul x, C)` -> `gep
i8, p, (mul x, C*4)`, so that the mul can combine both of the constant
multiplications, and we take a small step towards canonicalizing more
geps to i8.

It currently doesn't attempt to check for multiple uses on the mul, but
that should be possible if it sounds better. Let me know what you think
of the idea in general.

show more ...


# 60984f5b 19-Jun-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Preserve all gep flags in gep of exact div fold


# 80722224 19-Jun-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Preserve all gep flags in gep of select fold


Revision tags: llvmorg-18.1.8, llvmorg-18.1.7
# da5f45f5 04-Jun-2024 Nikita Popov <npopov@redhat.com>

[ConstantFolding] Preserve nowrap flags in gep of gep fold

A caveat here is that we can only preserve nusw if the offset
additions did not overflow.

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


# cc158d4c 31-May-2024 Nikita Popov <npopov@redhat.com>

Reapply [ConstantFold] Remove non-trivial gep-of-gep fold (#93823)

Reapply after https://github.com/llvm/llvm-project/pull/93956, which
changed clang array initialization codegen to avoid size regre

Reapply [ConstantFold] Remove non-trivial gep-of-gep fold (#93823)

Reapply after https://github.com/llvm/llvm-project/pull/93956, which
changed clang array initialization codegen to avoid size regressions
for unoptimized builds.

-----

This fold is subtly incorrect, because DL-unaware constant folding does
not know the correct index type to use, and just performs the addition
in the type that happens to already be there. This is incorrect, since
sext(X)+sext(Y) is generally not the same as sext(X+Y). See the
`@constexpr_gep_of_gep_with_narrow_type()` for a miscompile with the
current implementation.

One could try to restrict the fold to cases where no overflow occurs,
but I'm not bothering with that here, because the DL-aware constant
folding will take care of this anyway. I've only kept the
straightforward zero-index case, where we just concatenate two GEPs.

show more ...


# e57308b0 04-Jun-2024 Nikita Popov <npopov@redhat.com>

[IR] Accept GEPNoWrapFlags in creation APIs

Add overloads of GetElementPtrInst::Create() that accept
GEPNoWrapFlags, and switch the bool parameters in IRBuilder to
accept it instead as well.

As a s

[IR] Accept GEPNoWrapFlags in creation APIs

Add overloads of GetElementPtrInst::Create() that accept
GEPNoWrapFlags, and switch the bool parameters in IRBuilder to
accept it instead as well.

As a sample use, switch GEP i8 canonicalization in InstCombine to
preserve the original flags.

show more ...


# 3138c590 04-Jun-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Add more gep index canonicalization tests (NFC)

Flags are already fully preserved for the instruction case,
but lost on constant expressions.


# 51e459a5 31-May-2024 Nikita Popov <npopov@redhat.com>

Revert "[ConstantFold] Remove non-trivial gep-of-gep fold (#93823)"

This reverts commit e1cc9e4eaddcc295b4e775512e33b947b1514c17.

This causes some non-trivial text size increases in unoptimized
bui

Revert "[ConstantFold] Remove non-trivial gep-of-gep fold (#93823)"

This reverts commit e1cc9e4eaddcc295b4e775512e33b947b1514c17.

This causes some non-trivial text size increases in unoptimized
builds for Bullet. Revert while I investigate.

show more ...


# e1cc9e4e 31-May-2024 Nikita Popov <npopov@redhat.com>

[ConstantFold] Remove non-trivial gep-of-gep fold (#93823)

This fold is subtly incorrect, because DL-unaware constant folding does
not know the correct index type to use, and just performs the addi

[ConstantFold] Remove non-trivial gep-of-gep fold (#93823)

This fold is subtly incorrect, because DL-unaware constant folding does
not know the correct index type to use, and just performs the addition
in the type that happens to already be there. This is incorrect, since
sext(X)+sext(Y) is generally not the same as sext(X+Y). See the
`@constexpr_gep_of_gep_with_narrow_type()` for a miscompile with the
current implementation.

One could try to restrict the fold to cases where no overflow occurs,
but I'm not bothering with that here, because the DL-aware constant
folding will take care of this anyway. I've only kept the
straightforward zero-index case, where we just concatenate two GEPs.

show more ...


# 63dc31b6 22-May-2024 Nikita Popov <npopov@redhat.com>

Reapply [IR] Avoid creating icmp/fcmp constant expressions (#92885)

Reapply after https://github.com/llvm/llvm-project/pull/93548,
which should address the lldb failure on macos.

-----

Do not crea

Reapply [IR] Avoid creating icmp/fcmp constant expressions (#92885)

Reapply after https://github.com/llvm/llvm-project/pull/93548,
which should address the lldb failure on macos.

-----

Do not create icmp/fcmp constant expressions in IRBuilder etc anymore,
i.e. treat them as "undesirable". This is in preparation for removing
them entirely.

Part of:
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179

show more ...


# 2b9c158e 30-May-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Add test for miscompile in gep-of-gep fold (NFC)


# 8baf96f3 22-May-2024 Daniel Thornburgh <dthorn@google.com>

Revert "[IR] Avoid creating icmp/fcmp constant expressions" (#93087)

Reverts llvm/llvm-project#92885 due to LLDB CI breakages.


# 108575f0 22-May-2024 Nikita Popov <npopov@redhat.com>

[IR] Avoid creating icmp/fcmp constant expressions (#92885)

Do not create icmp/fcmp constant expressions in IRBuilder etc anymore,
i.e. treat them as "undesirable". This is in preparation for remov

[IR] Avoid creating icmp/fcmp constant expressions (#92885)

Do not create icmp/fcmp constant expressions in IRBuilder etc anymore,
i.e. treat them as "undesirable". This is in preparation for removing
them entirely.

Part of:
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179

show more ...


# 74f1e291 21-May-2024 Nikita Popov <npopov@redhat.com>

[Tests] Regenerate test checks (NFC)

To minimize future diffs.


# 8e8d2595 20-May-2024 Nikita Popov <npopov@redhat.com>

[ConstantFolding] Canonicalize constexpr GEPs to i8 (#89872)

This patch canonicalizes constant expression GEPs to use i8 source
element type, aka ptradd. This is the ConstantFolding equivalent of t

[ConstantFolding] Canonicalize constexpr GEPs to i8 (#89872)

This patch canonicalizes constant expression GEPs to use i8 source
element type, aka ptradd. This is the ConstantFolding equivalent of the
InstCombine canonicalization introduced in #68882.

I believe all our optimizations working on constant expression GEPs
(like GlobalOpt etc) have already been switched to work on offsets, so I
don't expect any significant fallout from this change.

This is part of:
https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699

show more ...


Revision tags: llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3
# 26d4afc3 20-Feb-2024 Nikita Popov <npopov@redhat.com>

[InstCombine] Fold gep of exact unsigned division (#82334)

Extend the transform added in
https://github.com/llvm/llvm-project/pull/76458 to also handle unsigned
division. X exact/ Y * Y == X holds

[InstCombine] Fold gep of exact unsigned division (#82334)

Extend the transform added in
https://github.com/llvm/llvm-project/pull/76458 to also handle unsigned
division. X exact/ Y * Y == X holds independently of whether the
division is signed or unsigned.

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

show more ...


1234567