summaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/LoopVectorize/SystemZ
AgeCommit message (Collapse)Author
2025-05-20[VPlan] Introduce constant folder in simplifyRecipe (#125365)Ramkumar Ramachandra
Introduce a VPlan-level constant folder in simplifyRecipe that tries to fold a recipe to a constant using TargetFolder.
2025-05-18[VPlan] Add narrowToSingleScalarRecipe transform. (#139150)Florian Hahn
Add a new convertToUniformRecipes transform which uses VPlan-based uniformity analysis to determine if wide recipes and replicate recipes can be converted to uniform recipes. There are a few places where we ad-hoc convert recipes to uniform recipes, which this transform will eventually replace. There are a few more generalizations required to do so which I plan to do as follow-ups. By converting the recipes to uniform recipes, we effectively materialize the information from the VPlan-based analysis. Note that there is one regression at the moment in SystemZ/pr47665.ll due to trivial constant folding opportunities in the input IR. This will be fixed by VPlan-based constant folding (https://github.com/llvm/llvm-project/pull/125365/) PR: https://github.com/llvm/llvm-project/pull/139150
2025-04-14[InstCombine] Handle "add like" in ADD+GEP->GEP+GEP rewrites (#135156)Björn Pettersson
Considering that "or disjoint" is the canonical for certain add operations, then I think we want to support such "add like" operations when doing ADD+GEP->GEP+GEP rewrites to make things more consistent. Problem was found when improving ValueTracking, which turned an ADD into OR, and then suddenly optimizations got worse due to these rewrites no longer triggering.
2025-04-13[VPlan] Check captured operand when simplifying redundant OR.Florian Hahn
Follow-up to 0f607f to actually use the captured operand X instead of Y.
2025-04-13[VPlan] Simplify 'or x, true' -> true.Florian Hahn
Add additional OR simplification to fix a divergence between legacy and VPlan-based cost model. This adds a new m_AllOnes matcher by generalizing specific_intval to int_pred_ty, which takes a predicate to check to support matching both specific APInts and other APInt predices, like isAllOnes. Fixes https://github.com/llvm/llvm-project/issues/131359.
2025-04-04[VPlan] Add initial CFG simplification, removing BranchOnCond true. (#106748)Florian Hahn
Add an initial CFG simplification transform, which removes the dead edges for blocks terminated with BranchOnCond true. At the moment, this removes the edge between middle block and scalar preheader when folding the tail. PR: https://github.com/llvm/llvm-project/pull/106748
2025-03-28[LV] Optimize VPWidenIntOrFpInductionRecipe for known TC (#118828)Hari Limaye
Optimize the IR generated for a VPWidenIntOrFpInductionRecipe to use the narrowest type necessary, when the trip-count of a loop is known to be constant and the only use of the recipe is the condition used by the vector loop's backedge branch.
2025-01-29[IR] Convert from nocapture to captures(none) (#123181)Nikita Popov
This PR removes the old `nocapture` attribute, replacing it with the new `captures` attribute introduced in #116990. This change is intended to be essentially NFC, replacing existing uses of `nocapture` with `captures(none)` without adding any new analysis capabilities. Making use of non-`none` values is left for a followup. Some notes: * `nocapture` will be upgraded to `captures(none)` by the bitcode reader. * `nocapture` will also be upgraded by the textual IR reader. This is to make it easier to use old IR files and somewhat reduce the test churn in this PR. * Helper APIs like `doesNotCapture()` will check for `captures(none)`. * MLIR import will convert `captures(none)` into an `llvm.nocapture` attribute. The representation in the LLVM IR dialect should be updated separately.
2025-01-05[VPlan] Remove loop region in optimizeForVFAndUF. (#108378)Florian Hahn
Update optimizeForVFAndUF to completely remove the vector loop region when possible. At the moment, we cannot remove the region if it contains * widened IVs: the recipe is needed to generate the step vector * reductions: ComputeReductionResults requires the reduction phi recipe for codegen. Both cases can be addressed by more explicit modeling. The patch also includes a number of updates to allow executing VPlans without a vector loop region. Depends on https://github.com/llvm/llvm-project/pull/110004
2024-12-29[VPlan] Compute induction end values in VPlan. (#112145)Florian Hahn
Use createDerivedIV to compute IV end values directly in VPlan, instead of creating them up-front. This allows updating IV users outside the loop as follow-up. Depends on https://github.com/llvm/llvm-project/pull/110004 and https://github.com/llvm/llvm-project/pull/109975. PR: https://github.com/llvm/llvm-project/pull/112145
2024-11-28[LV] Use IVUpdateMayOverflow to set HasNUW. (#111758)Florian Hahn
If IVUpdateMayOverflow is false, we proved that the induction increment cannot overflow in the vector loop. This allows setting NUW in some cases when folding the tail. PR: https://github.com/llvm/llvm-project/pull/111758
2024-11-19[LoopVectorize][NFC] Rewrite tests to check output of vplan cost model (#113697)David Sherwood
Currently it's very difficult to improve the cost model for tail-folded loops because as soon as you add a VPInstruction::computeCost function that adds the costs of instructions such as VPInstruction::ActiveLaneMask and VPInstruction::ExplicitVectorLength the assert in LoopVectorizationPlanner::computeBestVF fails for some tests. This is because the VF chosen by the legacy cost model doesn't match the vplan cost model. See PR #90191. This assert is currently making it difficult to improve the cost model. Hopefully we will be in a position to remove the assert soon, however in order to do that we have to fix up a whole bunch of tests that rely upon the legacy cost model output. I've tried my best to update these tests to use vplan output instead. There is still work needed for the VF=1 case because the vplan cost model is not printed out in this case. I've not attempted to fix those in this patch.
2024-11-06[LLVM][IR] Use splat syntax when printing Constant[Data]Vector. (#112548)Paul Walker
2024-09-20[VPlan] Generalize VPValue::isDefinedOutsideLoopRegions.Florian Hahn
Update isDefinedOutsideLoopRegions to check if a recipe is defined outside any region. Split off already approved https://github.com/llvm/llvm-project/pull/95842 now that this can be tested separately after landing VPlan-based LICM https://github.com/llvm/llvm-project/issues/107501
2024-09-20[VPlan] Add initial loop-invariant code motion transform. (#107894)Florian Hahn
Add initial transform to move out loop-invariant recipes. This also helps to fix a divergence between legacy and VPlan-based cost model due to legacy using ScalarEvolution::isLoopInvariant in some cases. Fixes https://github.com/llvm/llvm-project/issues/107501. PR: https://github.com/llvm/llvm-project/pull/107894
2024-09-11[LV] Assign cost to all interleave members when not interleaving.Florian Hahn
At the moment, the full cost of all interleave group members is assigned to the instruction at the group's insert position, even if the decision was to not form an interleave group. This can lead to inaccurate cost estimates, e.g. if the instruction at the insert position is dead. If the decision is to not vectorize but scalarize or scather/gather, then the cost will be to total cost for all members. In those cases, assign individual the cost per member, to more closely reflect to choice per instruction. This fixes a divergence between legacy and VPlan-based cost model. Fixes https://github.com/llvm/llvm-project/issues/108098.
2024-07-23[VPlan] Only use force-target-instruction-cost for recipes with insts.Florian Hahn
To match the behavior of the legacy cost model, only apply -force-target-instruction-cost to recipes with underlying instructions for now, as only original IR instructions are considered by the legacy cost model. This fixes a difference between legacy and VPlan based cost model, triggering the verification assertion, reported by @JonPsson1.
2024-07-21[LV] Update tests to not have dead interleave groups.Florian Hahn
Update existing tests with dead interleave groups by adding users. This ensures the tests keep testing what they were intended to test with a planned change to skip unused instructions in cost computations.
2024-07-19[VPlan] Relax assertion retrieving a scalar from VPTransformState::get.Florian Hahn
The current assertion VPTransformState::get when retrieving a single scalar only does not account for cases where a def has multiple users, some demanding all scalar lanes, some demanding only a single scalar. For an example, see the modified test case. Relax the assertion by also allowing requesting scalar lanes only when the Def doesn't have only its first lane used. Fixes https://github.com/llvm/llvm-project/issues/88849.
2024-07-19[LV] Add test with users both demanding all lanes and first-lane-only.Florian Hahn
Add a test case where scalar steps are used by both a VPReplicateRecipe (demands all scalar lanes) and a VPInstruction that only demands the first lane. Test case for https://github.com/llvm/llvm-project/issues/88849.
2024-07-11[VPlan] Introduce ResumePhi VPInstruction, use to create phi for FOR. (#94760)Florian Hahn
This patch introduces a new ResumePhi VPInstruction which creates a phi in a leaf block of a VPlan. The first use is to create the phi node for fixed-order recurrence resume values in the scalar preheader. The VPInstruction takes 2 operands: 1) the incoming value from the middle-block and a default value to be used for all other incoming blocks. In follow-up changes, it will also be used to create phis for reduction and induction resume values. Depends on https://github.com/llvm/llvm-project/pull/92651 PR: https://github.com/llvm/llvm-project/pull/94760
2024-07-07[LV] Move check if any vector insts will be generated to VPlan. (#96622)Florian Hahn
This patch moves the check if any vector instructions will be generated from getInstructionCost to be based on VPlan. This simplifies getInstructionCost, is more accurate as we check the final result and also allows us to exit early once we visit a recipe that generates vector instructions. The helper can then be re-used by the VPlan-based cost model to match the legacy selectVectorizationFactor behavior, this fixing a crash and paving the way to recommit https://github.com/llvm/llvm-project/pull/92555. PR: https://github.com/llvm/llvm-project/pull/96622
2024-07-05[LV] Regenerate test checks for zero_unroll.ll (NFC).Florian Hahn
Regenerate test checks to better show impact of https://github.com/llvm/llvm-project/pull/96622.
2024-07-05[VPlan] Model branch cond to enter scalar epilogue in VPlan. (#92651)Florian Hahn
This patch moves branch condition creation to enter the scalar epilogue loop to VPlan. Modeling the branch in the middle block also requires modeling the successor blocks. This is done using the recently introduced VPIRBasicBlock. Note that the middle.block is still created as part of the skeleton and then patched in during VPlan execution. Unfortunately the skeleton needs to create the middle.block early on, as it is also used for induction resume value creation and is also needed to properly update the dominator tree during skeleton creation. After this patch lands, I plan to move induction resume value and phi node creation in the scalar preheader to VPlan. Once that is done, we should be able to create the middle.block in VPlan directly. This is a re-worked version based on the earlier https://reviews.llvm.org/D150398 and the main change is the use of VPIRBasicBlock. Depends on https://github.com/llvm/llvm-project/pull/92525 PR: https://github.com/llvm/llvm-project/pull/92651
2024-06-26[InstCombine] Canonicalize non-i8 gep of mul to i8 (#96606)David Green
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.
2024-05-24[LV] fix logical error in trunc cost (#91136)Ramkumar Ramachandra
In LoopVectorizationCostModel::getInstructionCost(), when the condition canTruncateToMinimalBitwidth() is satisfied, for a trunc, the source type is computed as the smallest type of the source vector and the destination vector, and the destination type is computed as the largest type of the instruction and destination type. This is clearly a logical error, as the original source vector type could be smaller than the original destination vector type, and the trunc semantics are broken because we're attempting to widen. Fixes #47665.
2024-05-24[LV] add test for #47665, #88802 (#91135)Ramkumar Ramachandra
2024-02-05[LV] Remove loop trip count threshold for deciding whether to interleave a ↵Nilanjana Basu
loop (#67725) A set of microbenchmarks (https://github.com/llvm/llvm-test-suite/pull/26) showed that loop interleaving can be beneficial for loops with low trip count as well. Loop interleaving count computation is updated accordingly in prior patches while this patch removes the loop trip count threshold for interleaving.
2024-01-15[SystemZ] Don't assert for i128 vectors in getInterleavedMemoryOpCost() (#78009)Jonas Paulsson
This assert does not seem justified given that the LoopVectorizer can form interleave groups containing i128 elements where the number of elements per vector is indeed just one.
2023-12-02[InstCombine] Infer disjoint flag on Or instructions. (#72912)Craig Topper
The disjoint flag was recently added to IR in #72583 We already set it when we turn an add into an or. This patch sets it on Ors that weren't converted from an Add.
2023-11-27[InstCombine] Set disjoint flag when turning Add into Or. (#72702)Craig Topper
The disjoint flag was recently added to IR in #72583
2023-06-12[LoopVectorize] Convert test to opaque pointers (NFC)Nikita Popov
I'm keeping the bitcast in the input here, because without it we end up introducing a stride 1 assumption and end up testing a different case.
2023-05-17[NFC][Py Reformat] Reformat lit.local.cfg python files in llvmTobias Hieta
This is a follow-up to b71edfaa4ec3c998aadb35255ce2f60bba2940b0 since I forgot the lit.local.cfg files in that one. Reformatting is done with `black`. If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run git checkout --ours <yourfile> and then reformat it with black. If you run into any problems, post to discourse about it and we will try to help. RFC Thread below: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Reviewed By: barannikov88, kwk Differential Revision: https://reviews.llvm.org/D150762
2023-04-10[VPlan] Only create extracts for recurrence exits if there are live-outs.Florian Hahn
Move the code to collect live-out earlier and only generate extracts for exit values if there are any live-outs that use them. Depends on D147472. Reviewed By: Ayal Differential Revision: https://reviews.llvm.org/D147567
2023-01-18[AsmParser] Remove typed pointer auto-detectionNikita Popov
IR is now always parsed in opaque pointer mode, unless -opaque-pointers=0 is explicitly given. There is no automatic detection of typed pointers anymore. The -opaque-pointers=0 option is added to any remaining IR tests that haven't been migrated yet. Differential Revision: https://reviews.llvm.org/D141912
2023-01-04[LoopVectorize] Convert some tests to opaque pointers (NFC)Nikita Popov
Check lines for some of these tests were regenerated. The difference is that with opaque pointers SCEVExpander always emits i8 GEPs, making the address calculation explicit. This is a known problem that will be solved long term by making all address calculations explicit.
2022-12-14[LoopVectorize] Convert some tests to opaque pointers (NFC)Nikita Popov
2022-12-08[test] Remove duplicate RUN lines in Transform testsBjorn Pettersson
2022-12-05[NFC] Port all runlines for LoopVectorize pass tests to -passes syntaxRoman Lebedev
2022-07-23fix tests for commit 9df0b254d24eca098Nuno Lopes
2022-04-04Revert "[NFCI] Regenerate SROA/LoopVectorize test checks"Dávid Bolvanský
This reverts commit 14e3450fb57305aa9ff3e9e60687b458e43835c9.
2022-04-03[NFCI] Regenerate LoopVectorize test checksDávid Bolvanský
2022-03-07[NFC][LV] Use different braces in debug outputRoman Lebedev
The analysis passes output function name encapsulated in `'` braces, but LV uses `"`. Harmonizing this may help in creating an update script for the LV costmodel test checks. Reviewed By: fhahn Differential Revision: https://reviews.llvm.org/D121105
2021-12-13[instcombine] Canonicalize constant index type to i64 for ↵Philip Reames
extractelement/insertelement The basic idea to this is that a) having a single canonical type makes CSE easier, and b) many of our transforms are inconsistent about which types we end up with based on visit order. I'm restricting this to constants as for non-constants, we'd have to decide whether the simplicity was worth extra instructions. For constants, there are no extra instructions. We chose the canonical type as i64 arbitrarily. We might consider changing this to something else in the future if we have cause. Differential Revision: https://reviews.llvm.org/D115387
2021-12-13Autogen a bunch of instcombine and vectorizer testsPhilip Reames
Done in advance of D115387. These are all the ones which my local script could handle, there's a couple more which need manual updates.
2021-11-10Revert "[LoopVectorize] Extract the last lane from a uniform store"Kerry McLaughlin
This reverts commit 0d748b4d32cbddf58a1ff83f3ff178ec1ad49edc. This is causing some failures when building Spec2017 with scalable vectors. Reverting to investigate.
2021-11-09[LoopVectorize] Extract the last lane from a uniform storeKerry McLaughlin
Changes VPReplicateRecipe to extract the last lane from an unconditional, uniform store instruction. collectLoopUniforms will also add stores to the list of uniform instructions where Legal->isUniformMemOp is true. setCostBasedWideningDecision now sets the widening decision for all uniform memory ops to Scalarize, where previously GatherScatter may have been chosen for scalable stores. This fixes an assert ("Cannot yet scalarize uniform stores") in setCostBasedWideningDecision when we have a loop containing a uniform i1 store and a scalable VF, which we cannot create a scatter for. Reviewed By: sdesmalen, david-arm, fhahn Differential Revision: https://reviews.llvm.org/D112725
2021-01-06[SLP,LV] Use poison constant vector for shufflevector/initial insertelementJuneyoung Lee
This patch makes SLP and LV emit operations with initial vectors set to poison constant instead of undef. This is a part of efforts for using poison vector instead of undef to represent "doesn't care" vector. The goal is to make nice shufflevector optimizations valid that is currently incorrect due to the tricky interaction between undef and poison (see https://bugs.llvm.org/show_bug.cgi?id=44185 ). Reviewed By: fhahn Differential Revision: https://reviews.llvm.org/D94061
2020-12-27[LV] Set up branch from middle block earlier.Florian Hahn
Previously the branch from the middle block to the scalar preheader & exit was being set-up at the end of skeleton creation in completeLoopSkeleton. Inserting SCEV or runtime checks may result in LCSSA phis being created, if they are required. Adjusting branches afterwards may break those PHIs. To avoid this, we can instead create the branch from the middle block to the exit after we created the middle block, so we have the final CFG before potentially adjusting/creating PHIs. This fixes a crash for the included test case. For the non-crashing case, this is almost a NFC with respect to the generated code. The only change is the order of the predecessors of the involved branch targets. Note an assertion was moved from LoopVersioning() to LoopVersioning::versionLoop. Adjusting the branches means loop-simplify form may be broken before constructing LoopVersioning. But LV only uses LoopVersioning to annotate the loop instructions with !noalias metadata, which does not require loop-simplify form. This is a fix for an existing issue uncovered by D93317.
2020-10-14[LV] Unroll factor is expected to be > 0Evgeniy Brevnov
LV fails with assertion checking that UF > 0. We already set UF to 1 if it is 0 except the case when IC > MaxInterleaveCount. The fix is to set UF to 1 for that case as well. Reviewed By: fhahn Differential Revision: https://reviews.llvm.org/D87679