|
Revision tags: llvmorg-20.1.0, llvmorg-20.1.0-rc3, llvmorg-20.1.0-rc2, llvmorg-20.1.0-rc1, llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, 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, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7, 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, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, 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, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init |
|
| #
1f695031 |
| 21-Jul-2022 |
Nikita Popov <[email protected]> |
[MemoryBuiltins] Add getReallocatedOperand() function (NFC)
Replace the value-accepting isReallocLikeFn() overload with a getReallocatedOperand() function, which returns which operand is the one bei
[MemoryBuiltins] Add getReallocatedOperand() function (NFC)
Replace the value-accepting isReallocLikeFn() overload with a getReallocatedOperand() function, which returns which operand is the one being reallocated. Currently, this is always the first one, but once allockind(realloc) is respected, the reallocated operand will be determined by the allocptr parameter attribute.
show more ...
|
| #
5e856a85 |
| 21-Jul-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Use getFreedOperand() (NFC)
Use getFreedOperand() instead of isFreeCall() to remove the implicit assumption that any pointer operand to a free function is the operand being freed. This
[InstCombine] Use getFreedOperand() (NFC)
Use getFreedOperand() instead of isFreeCall() to remove the implicit assumption that any pointer operand to a free function is the operand being freed. This won't actually matter until we handle allockind(free).
show more ...
|
| #
c81dff3c |
| 21-Jul-2022 |
Nikita Popov <[email protected]> |
[MemoryBuiltins] Add getFreedOperand() function (NFCI)
We currently assume in a number of places that free-like functions free their first argument. This is true for all hardcoded free-like function
[MemoryBuiltins] Add getFreedOperand() function (NFCI)
We currently assume in a number of places that free-like functions free their first argument. This is true for all hardcoded free-like functions, but with the new attribute-based design, the freed argument is supposed to be indicated by the allocptr attribute.
To make sure we handle this correctly once allockind(free) is respected, add a getFreedOperand() helper which returns the freed argument, rather than just indicating whether the call frees *some* argument.
This migrates most but not all users of isFreeCall() to the new API. The remaining users are a bit more tricky.
show more ...
|
| #
f45ab433 |
| 21-Jul-2022 |
Nikita Popov <[email protected]> |
[MemoryBuiltins] Avoid isAllocationFn() call before checking removable alloc
Alloc directly checking whether a given call is a removable allocation, instead of first checking whether it is an alloca
[MemoryBuiltins] Avoid isAllocationFn() call before checking removable alloc
Alloc directly checking whether a given call is a removable allocation, instead of first checking whether it is an allocation first.
show more ...
|
| #
8a519b3c |
| 15-Jul-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Ensure constant folding in binop of select fold
When folding a binop into a select, we need to ensure that one of the select arms actually does constant fold, otherwise we'll create tw
[InstCombine] Ensure constant folding in binop of select fold
When folding a binop into a select, we need to ensure that one of the select arms actually does constant fold, otherwise we'll create two binop instructions and perform the reverse transform.
Ensure this by performing an explicit constant folding attempt, and failing the transform if neither side simplifies.
A simple alternative here would have been to limit the fold to ImmConstants, but given the current representation of scalable vector splats, this wouldn't be ideal.
show more ...
|
| #
d2870514 |
| 08-Jul-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Avoid ConstantExpr::get() in vector binop fold (NFCI)
Use the ConstantFoldBinaryOpOperands() API instead. This case would bail out on a non-folded result anyway.
|
| #
29c6bf45 |
| 08-Jul-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Avoid ConstantExpr::get() call
Avoid calling ConstantExpr::get() for associative/commutative binops, call ConstantFoldBinaryOpOperands() instead. We only want to perform the reassociat
[InstCombine] Avoid ConstantExpr::get() call
Avoid calling ConstantExpr::get() for associative/commutative binops, call ConstantFoldBinaryOpOperands() instead. We only want to perform the reassociation of the constants actually fold.
show more ...
|
| #
abbd684c |
| 04-Jul-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Avoid ConstantExpr::get() in phi binop fold
Use ConstantFoldBinaryOpOperands() instead, in preparation for not all binops having a supported constant expression.
|
| #
a9119143 |
| 30-Jun-2022 |
William Huang <[email protected]> |
[InstCombine] Changing constant-indexed GEP of GEP to i8* for merging
When merging GEP of GEP with constant indices, if the second GEP's offset is not divisible by the first GEP's element size, conv
[InstCombine] Changing constant-indexed GEP of GEP to i8* for merging
When merging GEP of GEP with constant indices, if the second GEP's offset is not divisible by the first GEP's element size, convert both type to i8* and merge.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D125934
show more ...
|
| #
df698a57 |
| 29-Jun-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Avoid some calls to ConstantExpr::get() (NFCI)
Replace some calls to ConstantExpr::get() with IRBuilder APIs (which will also constant fold if possible).
|
|
Revision tags: llvmorg-14.0.6 |
|
| #
c6b88cb9 |
| 16-Jun-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Push freeze through recurrence phi
We really want to push freezes through recurrence phis, so that we freeze only the start value, rather than the IV value on every iteration. foldOpIn
[InstCombine] Push freeze through recurrence phi
We really want to push freezes through recurrence phis, so that we freeze only the start value, rather than the IV value on every iteration. foldOpIntoPhi() already handles this for the case where the transfer function doesn't produce poison, e.g. %iv.next = add %iv, 1. However, this does not work if nowrap flags are present, e.g. the very common %iv.next = add nuw %iv, 1 case.
This patch adds a fold that pushes freeze instructions to the start value by checking whether all backedge values will be non-poison after poison generating flags have been dropped. This allows pushing freezes out of loops in most cases. I suspect that this also obsoletes the CanonicalizeFreezeInLoops pass, and we can probably drop it.
Fixes https://github.com/llvm/llvm-project/issues/56048.
Differential Revision: https://reviews.llvm.org/D127960
show more ...
|
|
Revision tags: llvmorg-14.0.5 |
|
| #
92a9b1c9 |
| 10-Jun-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Don't push operation across loop phi
When pushing an operation across a phi node, we should avoid doing so across a loop backedge. This is generally non-profitable, because it does not
[InstCombine] Don't push operation across loop phi
When pushing an operation across a phi node, we should avoid doing so across a loop backedge. This is generally non-profitable, because it does not reduce the number of times the operation is executed, and could lead to an infinite combine loop.
The code was already guarding against this, but using an insufficiently strong condition, which did not cover the case where the operation was originally outside the loop (in which case the transform moves the operation from outside the loop into the loop, which is particularly undesirable).
Differential Revision: https://reviews.llvm.org/D127499
show more ...
|
| #
b8c2781f |
| 09-Jun-2022 |
Simon Moll <[email protected]> |
[NFC] format InstructionSimplify & lowerCaseFunctionNames
Clang-format InstructionSimplify and convert all "FunctionName"s to "functionName". This patch does touch a lot of files but gets done with
[NFC] format InstructionSimplify & lowerCaseFunctionNames
Clang-format InstructionSimplify and convert all "FunctionName"s to "functionName". This patch does touch a lot of files but gets done with the cleanup of InstructionSimplify in one commit.
This is the alternative to the less invasive clang-format only patch: D126783
Reviewed By: spatel, rengolin
Differential Revision: https://reviews.llvm.org/D126889
show more ...
|
| #
36cbdaa1 |
| 30-May-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Fix inbounds preservation when swapping GEPs (PR44206)
When reassociating GEPs, we can only keep inbounds if both original GEPs were inbounds, and their offsets have the same sign. For
[InstCombine] Fix inbounds preservation when swapping GEPs (PR44206)
When reassociating GEPs, we can only keep inbounds if both original GEPs were inbounds, and their offsets have the same sign. For the sake of simplicity, I only handle the case where both offsets are non-negative here.
It would probably be fine to just not preserve inbounds at all here, but as I don't see a compile-time impact for adding the isKnownNonNegative() calls I went with this more conservative approach.
Fixes https://github.com/llvm/llvm-project/issues/44206.
Differential Revision: https://reviews.llvm.org/D126687
show more ...
|
| #
872d69e5 |
| 31-May-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Fix inbounds preservation when merging GEPs (PR55722)
Even if the total offset is inbounds, we might represent it by first performing a large negative offset and then a small positive
[InstCombine] Fix inbounds preservation when merging GEPs (PR55722)
Even if the total offset is inbounds, we might represent it by first performing a large negative offset and then a small positive one. With inbounds semantics as currently specified, each offset must be inbounds individually, not just the overall offset of the GEP.
Fix this by checking that the sign of all offsets is the same.
Fixes https://github.com/llvm/llvm-project/issues/55722.
show more ...
|
| #
a770f534 |
| 30-May-2022 |
Nikita Popov <[email protected]> |
[InstCombine] When swapping GEPs, only keep inbounds if both are
If only one of the GEPs is inbounds, then after swapping, there is no guarantee that one of them will be inbounds as well (see e.g. h
[InstCombine] When swapping GEPs, only keep inbounds if both are
If only one of the GEPs is inbounds, then after swapping, there is no guarantee that one of them will be inbounds as well (see e.g. https://alive2.llvm.org/ce/z/agaCnp).
This is only a partial fix, because even if both are inbounds, the result is not necessarily inbounds (if the offsets have different signs).
show more ...
|
| #
2d7bab66 |
| 30-May-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Always create new GEPs when swapping GEPs
As the long explanatory comment attests, performing the modification in place is pretty tricky. Drop this unnecessary complexity and always cr
[InstCombine] Always create new GEPs when swapping GEPs
As the long explanatory comment attests, performing the modification in place is pretty tricky. Drop this unnecessary complexity and always create new instructions.
This should be NFC-ish, but can probably cause difference due to worklist order.
show more ...
|
|
Revision tags: llvmorg-14.0.4 |
|
| #
b2a13d3e |
| 24-May-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Use IRBuilder in freeze pushing transform (PR55619)
Use IRBuilder so that the newly created freeze instructions automatically gets inserted back into the IC worklist.
The changed work
[InstCombine] Use IRBuilder in freeze pushing transform (PR55619)
Use IRBuilder so that the newly created freeze instructions automatically gets inserted back into the IC worklist.
The changed worklist processing order leads to some cosmetic differences in tests.
Fixes https://github.com/llvm/llvm-project/issues/55619.
show more ...
|
| #
ed1cb01b |
| 13-May-2022 |
Nikita Popov <[email protected]> |
[IRBuilder] Add IsInBounds parameter to CreateGEP()
We commonly want to create either an inbounds or non-inbounds GEP based on a boolean value, e.g. when preserving inbounds from existing GEPs. Dire
[IRBuilder] Add IsInBounds parameter to CreateGEP()
We commonly want to create either an inbounds or non-inbounds GEP based on a boolean value, e.g. when preserving inbounds from existing GEPs. Directly accept such a boolean in the API, rather than requiring a ternary between CreateGEP and CreateInBoundsGEP.
This change is not entirely NFC, because we now preserve an inbounds flag in a constant expression edge-case in InstCombine.
show more ...
|
| #
6001bfce |
| 10-May-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Freeze other uses of frozen value
If there is a freeze %x, we currently replace all other uses of %x with freeze %x -- as long as they are dominated by the freeze instruction. This pat
[InstCombine] Freeze other uses of frozen value
If there is a freeze %x, we currently replace all other uses of %x with freeze %x -- as long as they are dominated by the freeze instruction. This patch extends this behavior to cases where we did not originally dominate the use by moving the freeze instruction directly after the definition of the frozen value.
The motivation can be seen in test @combine_and_after_freezing_uses: Canonicalizing everything to freeze %x allows folds that are based on value identity (i.e. same operand occurring in two places) to trigger. This also covers the case from D125248.
Differential Revision: https://reviews.llvm.org/D125321
show more ...
|
|
Revision tags: llvmorg-14.0.3 |
|
| #
c103f5e9 |
| 26-Apr-2022 |
Nikita Popov <[email protected]> |
[InstCombine] Combine opaque pointer GEPs with mismatching element types
Currently, two GEPs will only be combined if the result element type of one is the same as the source element type of the oth
[InstCombine] Combine opaque pointer GEPs with mismatching element types
Currently, two GEPs will only be combined if the result element type of one is the same as the source element type of the other. However, this means we may miss folding opportunities where the second GEP could be rewritten using a different element type. This is especially relevant for opaque pointers, where constant GEPs often use i8 element type.
Address this by converting GEP indices to offsets, adding them, and then converting them back to indices. The first (inner) GEP is allowed to have variable indices as well, in which case only the constant suffix is converted into an offset.
This should address the regression reported in https://reviews.llvm.org/D123300#3467615.
Differential Revision: https://reviews.llvm.org/D124459
show more ...
|
| #
c8ed784e |
| 26-Apr-2022 |
Sanjay Patel <[email protected]> |
[InstCombine] fold freeze of partial undef/poison vector constants
We can always replace the undef elements in a vector constant with regular constants to get rid of the freeze: https://alive2.llvm.
[InstCombine] fold freeze of partial undef/poison vector constants
We can always replace the undef elements in a vector constant with regular constants to get rid of the freeze: https://alive2.llvm.org/ce/z/nfRb4F
The select diffs show that we might do better by adjusting the logic for a frozen select condition. We may also want to refine the vector constant replacement to consider forming a splat.
Differential Revision: https://reviews.llvm.org/D123962
show more ...
|
|
Revision tags: llvmorg-14.0.2 |
|
| #
3a27b51b |
| 18-Apr-2022 |
Sanjay Patel <[email protected]> |
[InstCombine] reduce code for freeze of undef
The description was ambiguous about the behavior when boths select arms are constant or both arms are not constant. I don't think there's any evidence t
[InstCombine] reduce code for freeze of undef
The description was ambiguous about the behavior when boths select arms are constant or both arms are not constant. I don't think there's any evidence to support either way, but this matches the code with a more specified description.
We can extend this to deal with vector constants with undef/poison elements. Currently, those don't get folded anywhere.
show more ...
|
|
Revision tags: llvmorg-14.0.1 |
|
| #
aa15ea47 |
| 23-Mar-2022 |
serge-sans-paille <[email protected]> |
[builtin_object_size] Basic support for posix_memalign
It actually implements support for seeing through loads, using alias analysis to refine the result.
This is rather limited, but I didn't want
[builtin_object_size] Basic support for posix_memalign
It actually implements support for seeing through loads, using alias analysis to refine the result.
This is rather limited, but I didn't want to rely on more than available analysis at that point (to be gentle with compilation time), and it does seem to catch common scenario, as showcased by the included tests.
Differential Revision: https://reviews.llvm.org/D122431
show more ...
|
| #
467cbb62 |
| 08-Apr-2022 |
Chenbing Zheng <[email protected]> |
[InstCombine] fold more constant divisor to select-of-constants divisor
By adding a parameter to function FoldOpIntoSelect, we can fold more Ops to Select. For this example, we tend to fold the divi
[InstCombine] fold more constant divisor to select-of-constants divisor
By adding a parameter to function FoldOpIntoSelect, we can fold more Ops to Select. For this example, we tend to fold the division instruction, so we no longer care whether SelectInst is one use.
This patch slove TODO left in InstCombine/div.ll.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D122967
show more ...
|