summaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/LoadStoreVectorizer/AMDGPU
AgeCommit message (Collapse)Author
2025-11-19Re-land [Transform][LoadStoreVectorizer] allow redundant in Chain (#168135)Gang Chen
This is the fixed version of https://github.com/llvm/llvm-project/pull/163019
2025-11-14Revert "[Transform][LoadStoreVectorizer] allow redundant in Chain (#1… ↵Gang Chen
(#168105) …63019)" This reverts commit 92e5608ffa6ff39ac3707f29418cc9482471f5d9.
2025-11-13[Transform][LoadStoreVectorizer] allow redundant in Chain (#163019)Gang Chen
This can absorb redundant loads when forming vector load. Can be used to fix the situation created by VectorCombine. See: https://discourse.llvm.org/t/what-is-the-purpose-of-vectorizeloadinsert-in-the-vectorcombine-pass/88532
2025-05-01[NFC] Precommit tests for an LSV patch (#138167)Anshil Gandhi
Autogenerate checks for merge-vectors.ll and introduce merge-vectors-complex.ll with mismatched types. Related PR: https://github.com/llvm/llvm-project/pull/134436 This is a reland of https://github.com/llvm/llvm-project/pull/138155, which was reverted due to missed nits.
2025-05-01Revert "[NFC] Precommit: Autogenerate checks for an LSV test" (#138161)Anshil Gandhi
Reverts llvm/llvm-project#138155
2025-05-01[NFC] Precommit: Autogenerate checks for an LSV test (#138155)Anshil Gandhi
Related PR: https://github.com/llvm/llvm-project/pull/134436
2025-04-30[LoadStoreVectorizer] Remove more unnecessary data layouts from testsAlexander Richardson
The tests in this directory all depend on the AMDGPU target being present so we can let opt infer the data layout. Reviewed By: arsenm Pull Request: https://github.com/llvm/llvm-project/pull/137924
2025-03-07[AMDGPU] Fix edge case of buffer OOB handling (#115479)Piotr Sobczak
Strengthen out-of-bounds guarantees for buffer accesses by disallowing buffer accesses with alignment lower than natural alignment. This is needed to specifically address the edge case where an access starts out-of-bounds and then enters in-bounds, as the hardware would treat the entire access as being out-of-bounds. This is normally not needed for most users, but at least one graphics device extension (VK_EXT_robustness2) has very strict requirements - in-bounds accesses must return correct value, and out-of-bounds accesses must return zero. The direct consequence of the patch is that a buffer access at negative address is not merged by load-store-vectorizer with one at a positive address, which fixes a CTS test. Targets that do not care about the new behavior are advised to use the new target feature relaxed-buffer-oob-mode that maintains the state from before the patch.
2025-02-13[AMDGPU][NFC] Replace gfx940 and gfx941 with gfx942 in llvm/test (#125711)Fabian Ritter
[AMDGPU][NFC] Replace gfx940 and gfx941 with gfx942 in llvm/test gfx940 and gfx941 are no longer supported. This is one of a series of PRs to remove them from the code base. This PR uses gfx942 instead of gfx940 and gfx941 in the test RUN-lines (unless there is already a RUN-line for gfx942). The only notable difference in the test output is that gfx942 does not force the use of sc0 and sc1 on stores while gfx940 and gfx941 do (cf. https://reviews.llvm.org/D149986). For SWDEV-512631
2024-08-23[AMDGPU] Fix crash in allowsMisalignedMemoryAccesses with i1 (#105794)Austin Kerbow
2024-02-05[Transforms] Convert tests to opaque pointers (NFC)Nikita Popov
2023-12-05[Tests] Add disjoint flag to some tests (NFC)Nikita Popov
These tests rely on SCEV looking recognizing an "or" with no common bits as an "add". Add the disjoint flag to relevant or instructions in preparation for switching SCEV to use the flag instead of the ValueTracking query. The IR with disjoint flag matches what InstCombine would produce.
2023-06-09AMDGPU: Extract test out of old patchMatt Arsenault
Don't think the patch is still useful but I don't see equivalent tests for decreased alloca alignment. https://reviews.llvm.org/D23908
2023-06-09[LoadStoreVectorizer] Only upgrade align for allocaBjorn Pettersson
In commit 2be0abb7fe72ed453 (D149893) the load store vectorized was reimplemented. One thing that can happen with the new LSV is that it can increase the align of alloca and global objects. However, the code comments indicate that the intention only was to increase alignment of alloca. Now we will use stripPointerCasts to analyse if the load/store really is accessing an alloca (same as getOrEnforceKnownAlignment is using). And then we only try to change the align if we find an alloca instruction. This way the code will match better with code comments, and we won't change alignment of non-stack variables to use the "StackAdjustedAlignment". Differential Revision: https://reviews.llvm.org/D152386
2023-05-31[LoadStoreVectorizer] Fix index width != pointer width caseKrzysztof Drewniak
Fixes https://github.com/llvm/llvm-project/issues/62856 Reviewed By: jlebar Differential Revision: https://reviews.llvm.org/D151754
2023-05-30[AMDGPU][LoadStoreVectorizer] Pre-commit test for addrspace 7 crashKrzysztof Drewniak
Differential Revision: https://reviews.llvm.org/D151751
2023-05-29[LSV] Return same bitwidth from getConstantOffset.Justin Lebar
Previously, getConstantOffset could return an APInt with a different bitwidth than the input pointers. For example, we might be loading an opaque 64-bit pointer, but stripAndAccumulateInBoundsConstantOffsets might give a 32-bit offset. This was OK in most cases because in gatherChains, we casted the APInt back to the original ASPtrBits. But it was not OK when considering selects. We'd call getConstantOffset twice and compare the resulting APInt's, which might not have the same bit width. This fixes that. Now getConstantOffset always returns offsets with the correct width, so we don't need the hack of casting it in gatherChains, and it works correctly when we're handling selects. Differential Revision: https://reviews.llvm.org/D151640
2023-05-28[LSV] Fix the ContextInst for computeKnownBits.Justin Lebar
Previously we used the later of GEPA or GEPB. This is hacky because really we should be using the later of the two load/store instructions being considered. But also it's flat-out incorrect, because GEPA and GEPB might be in different BBs, in which case we cannot ask which one comes last (assertion failure, https://reviews.llvm.org/D149893#4378332). Fixed, now we use the correct context instruction. Differential Revision: https://reviews.llvm.org/D151630
2023-05-26Rewrite load-store-vectorizer.Justin Lebar
The motivation for this change is a workload generated by the XLA compiler targeting nvidia GPUs. This kernel has a few hundred i8 loads and stores. Merging is critical for performance. The current LSV doesn't merge these well because it only considers instructions within a block of 64 loads+stores. This limit is necessary to contain the O(n^2) behavior of the pass. I'm hesitant to increase the limit, because this pass is already one of the slowest parts of compiling an XLA program. So we rewrite basically the whole thing to use a new algorithm. Before, we compared every load/store to every other to see if they're consecutive. The insight (from tra@) is that this is redundant. If we know the offset from PtrA to PtrB, then we don't need to compare PtrC to both of them in order to tell whether C may be adjacent to A or B. So that's what we do. When scanning a basic block, we maintain a list of chains, where we know the offset from every element in the chain to the first element in the chain. Each instruction gets compared only to the leaders of all the chains. In the worst case, this is still O(n^2), because all chains might be of length 1. To prevent compile time blowup, we only consider the 64 most recently used chains. Thus we do no more comparisons than before, but we have the potential to make much longer chains. This rewrite affects many tests. The changes to tests fall into two categories. 1. The old code had what appears to be a bug when deciding whether a misaligned vectorized load is fast. Suppose TTI reports that load <i32 x 4> align 4 has relative speed 1, and suppose that load i32 align 4 has relative speed 32. The intent of the code seems to be that we prefer the scalar load, because it's faster. But the old code would choose the vectorized load. accessIsMisaligned would set RelativeSpeed to 0 for the scalar load (and not even call into TTI to get the relative speed), because the scalar load is aligned. After this patch, we will prefer the scalar load if it's faster. 2. This patch changes the logic for how we vectorize. Usually this results in vectorizing more. Explanation of changes to tests: - AMDGPU/adjust-alloca-alignment.ll: #1 - AMDGPU/flat_atomic.ll: #2, we vectorize more. - AMDGPU/int_sideeffect.ll: #2, there are two possible locations for the call to @foo, and the pass is brittle to this. Before, we'd vectorize in case 1 and not case 2. Now we vectorize in case 2 and not case 1. So we just move the call. - AMDGPU/adjust-alloca-alignment.ll: #2, we vectorize more - AMDGPU/insertion-point.ll: #2 we vectorize more - AMDGPU/merge-stores-private.ll: #1 (undoes changes from git rev 86f9117d476, which appear to have hit the bug from #1) - AMDGPU/multiple_tails.ll: #1 - AMDGPU/vect-ptr-ptr-size-mismatch.ll: Fix alignment (I think related to #1 above). - AMDGPU CodeGen: I have difficulty commenting on these changes, but many of them look like #2, we vectorize more. - NVPTX/4x2xhalf.ll: Fix alignment (I think related to #1 above). - NVPTX/vectorize_i8.ll: We don't generate <3 x i8> vectors on NVPTX because they're not legal (and eventually get split) - X86/correct-order.ll: #2, we vectorize more, probably because of changes to the chain-splitting logic. - X86/subchain-interleaved.ll: #2, we vectorize more - X86/vector-scalar.ll: #2, we can now vectorize scalar float + <1 x float> - X86/vectorize-i8-nested-add-inseltpoison.ll: Deleted the nuw test because it was nonsensical. It was doing `add nuw %v0, -1`, but this is equivalent to `add nuw %v0, 0xffff'ffff`, which is equivalent to asserting that %v0 == 0. - X86/vectorize-i8-nested-add.ll: Same as nested-add-inseltpoison.ll Differential Revision: https://reviews.llvm.org/D149893
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-05-03Re-land "[AMDGPU] Define data layout entries for buffers""Krzysztof Drewniak
Re-land D145441 with data layout upgrade code fixed to not break OpenMP. This reverts commit 3f2fbe92d0f40bcb46db7636db9ec3f7e7899b27. Differential Revision: https://reviews.llvm.org/D149776
2023-05-03Revert "[AMDGPU] Define data layout entries for buffers"Krzysztof Drewniak
This reverts commit f9c1ede2543b37fabe9f2d8f8fed5073c475d850. Differential Revision: https://reviews.llvm.org/D149758
2023-05-03[AMDGPU] Define data layout entries for buffersKrzysztof Drewniak
Per discussion at https://discourse.llvm.org/t/representing-buffer-descriptors-in-the-amdgpu-target-call-for-suggestions/68798, we define two new address spaces for AMDGCN targets. The first is address space 7, a non-integral address space (which was already in the data layout) that has 160-bit pointers (which are 256-bit aligned) and uses a 32-bit offset. These pointers combine a 128-bit buffer descriptor and a 32-bit offset, and will be usable with normal LLVM operations (load, store, GEP). However, they will be rewritten out of existence before code generation. The second of these is address space 8, the address space for "buffer resources". These will be used to represent the resource arguments to buffer instructions, and new buffer intrinsics will be defined that take them instead of <4 x i32> as resource arguments. ptr addrspace(8). These pointers are 128-bits long (with the same alignment). They must not be used as the arguments to getelementptr or otherwise used in address computations, since they can have arbitrarily complex inherent addressing semantics that can't be represented in LLVM. Even though, like their address space 7 cousins, these pointers have deterministic ptrtoint/inttoptr semantics, they are defined to be non-integral in order to prevent optimizations that rely on pointers being a [0, [addr_max]] value from applying to them. Future work includes: - Defining new buffer intrinsics that take ptr addrspace(8) resources. - A late rewrite to turn address space 7 operations into buffer intrinsics and offset computations. This commit also updates the "fallback address space" for buffer intrinsics to the buffer resource, and updates the alias analysis table. Depends on D143437 Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D145441
2023-03-28[llvm] Use pointer index type for more GEP offsets (pre-codegen)Krzysztof Drewniak
Many uses of getIntPtrType() were using that type to calculate the neened type for GEP offset arguments. However, some time ago, DataLayout was extended to support pointers where the size of the pointer is not equal to the size of the values used to index it. Much code was already migrated to, for example, use getIndexSizeInBits instead of getPtrSizeInBits, but some rewrites still used getIntPtrType() to get the type for GEP offsets. This commit changes uses of getIntPtrType() to getIndexType() where they are involved in a GEP-related calculation. In at least one case (bounds check insertion) this resolves a compiler crash that the new test added here would previously trigger. This commit does not impact - C library-related rewriting (memcpy()), which are operating under the assumption that intptr_t == size_t. While all the mechanisms for breaking this assumption now exist, doing so is outside the scope of this commit. - Code generation and below. Note that the use of getIntPtrType() in CodeGenPrepare will be changed in a future commit. - Usage of getIntPtrType() in any backend Depends on D143435 Reviewed By: arichardson Differential Revision: https://reviews.llvm.org/D143437
2023-03-03[AMDGPU] Vectorize misaligned global loads & storesJeffrey Byrnes
Based on experimentation on gfx906,908,90a and 1030, wider global loads / stores are more performant than multiple narrower ones independent of alignment -- this is especially true when combining 8 bit loads / stores, in which case speedup was usually 2x across all alignments. Differential Revision: https://reviews.llvm.org/D145170 Change-Id: I6ee6c76e6ace7fc373cc1b2aac3818fc1425a0c1
2022-12-27[LoadStoreVectorizer] Convert tests to opaque pointers (NFC)Nikita Popov
2022-12-27[LoadStoreVectorize] Regenerate test checks (NFC)Nikita Popov
2022-12-27[LoadStoreVectorizer] Convert some tests to opaque pointers (NFC)Nikita Popov
2022-12-08[NFC] Port all LoadStoreVectorizer tests to `-passes=` syntaxRoman Lebedev
2022-10-07[opt] Don't translate legacy -analysis flag to require<analysis>Arthur Eubanks
Tests relying on this should explicitly use -passes='require<analysis>,foo'.
2022-10-07[opt] Stop treating alias analysis specially when translating legacy opt syntaxArthur Eubanks
I've attempted to keep AA tests as close to their original intent as possible.
2022-04-15[AMDGPU][FIX] Proper load-store-vectorizer result with opaque pointersJohannes Doerfert
The original code relied on the fact that we needed a bitcast instruction (for non constant base objects). With opaque pointers there might not be a bitcast. Always check if reordering is required instead. Fixes: https://github.com/llvm/llvm-project/issues/54896 Differential Revision: https://reviews.llvm.org/D123694
2022-04-06[AMDGPU] Check SI LDS offset bug in the allowsMisalignedMemoryAccessesStanislav Mekhanoshin
Differential Revision: https://reviews.llvm.org/D123268
2021-10-03[LSV] Change the default value of InstertElement to poisonhyeongyu kim
This patch is changing the InsertElement's placeholder to poison without changing the LSV's behavior. Regardless of whether `StoreTy` is FixedVectorType or not, the poison value will be overwritten with a different value. Therefore, whether the InsertElement's placeholder is poison or undef will not affect the result of the program. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D111005
2020-12-24Precommit transform tests that have poison as insertelement's placeholderJuneyoung Lee
This commit copies existing tests at llvm/Transforms and replaces 'insertelement undef' in those files with 'insertelement poison'. (see https://reviews.llvm.org/D93586) Tests listed using this script: grep -R -E '^[^;]*insertelement <.*> undef,' . | cut -d":" -f1 | uniq | wc -l Tests updated: file_org=llvm/test/Transforms/$1 file=${file_org%.ll}-inseltpoison.ll cp $file_org $file sed -i -E 's/^([^;]*)insertelement <(.*)> undef/\1insertelement <\2> poison/g' $file head -1 $file | grep "Assertions have been autogenerated by utils/update_test_checks.py" -q if [ "$?" == 1 ]; then echo "$file : should be manually updated" # I manually updated the script exit 1 fi python3 ./llvm/utils/update_test_checks.py --opt-binary=./build-releaseassert/bin/opt $file
2020-12-22[AMDGPU] Support unaligned flat scratch in TLIStanislav Mekhanoshin
Adjust SITargetLowering::allowsMisalignedMemoryAccessesImpl for unaligned flat scratch support. Mostly needed for global isel. Differential Revision: https://reviews.llvm.org/D93669
2020-12-09[FileCheck] Enforce --allow-unused-prefixes=false for llvm/test/TransformsMircea Trofin
Explicitly opt-out llvm/test/Transforms/Attributor. Verified by flipping the default value of allow-unused-prefixes and observing that none of the failures were under llvm/test/Transforms. Differential Revision: https://reviews.llvm.org/D92404
2020-11-11Revert "Revert "[AMDGPU] Reorganize GCN subtarget features for unaligned ↵Jay Foad
access"" This reverts commit 8b08fa0103c8d8e624b19fad5a5006e7a783ecb7. The underlying problems were fixed by D90607.
2020-09-29Revert "[AMDGPU] Reorganize GCN subtarget features for unaligned access"Mirko Brkusanin
This reverts commit f5cd7ec9f3fc969ff5e1feed961996844333de3b. Certain rocPRIM/rocThrust/hipCUB tests were failing because of this change.
2020-08-21[AMDGPU] Reorganize GCN subtarget features for unaligned accessMirko Brkusanin
Features UnalignedBufferAccess and UnalignedDSAccess are now used to determine whether hardware supports such access. UnalignedAccessMode should be used to enable them. hasUnalignedBufferAccessEnabled() and hasUnalignedDSAccessEnabled() can be now used to quickly check both. Differential Revision: https://reviews.llvm.org/D84522
2020-08-21[AMDGPU] Fix alignment requirements for 96bit and 128bit local loads and storesMirko Brkusanin
Adjust alignment requirements for ds_read/write_b96/b128. GFX9 and onwards allow misaligned access for reads and writes but only if SH_MEM_CONFIG.alignment_mode allows it. UnalignedDSAccess is set on GCN subtargets from GFX9 onward to let us know if we can relax alignment requirements. UnalignedAccessMode acts similary to UnalignedBufferAccess for DS instructions but only from GFX9 onward and is supposed to match alignment_mode. By default alignment of 4 is required. Differential Revision: https://reviews.llvm.org/D82788
2020-07-24Rename scoped-noalias -> scoped-noalias-aaArthur Eubanks
Summary: To match NewPM name. Also the new name is clearer and more consistent. Subscribers: jvesely, nhaehnle, hiraditya, asbirlea, kerbowa, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D84542
2020-06-26[BasicAA] Rename deprecated -basicaa to -basic-aaFangrui Song
Follow-up to D82607 Revert an accidental change (empty.ll) of D82683
2020-04-01AMDGPU: Fix broken check linesMatt Arsenault
2020-02-11AMDGPU: Don't report 2-byte alignment as fastMatt Arsenault
This is apparently worse than 1-byte alignment. This does not attempt to decompose 2-byte aligned wide stores, but will stop trying to produce them. Also fix bug in LoadStoreVectorizer which was decreasing the alignment and vectorizing stack accesses. It was assuming a stack object was an alloca that could have its base alignment changed, which is not true if the pointer is derived from a function argument.
2019-08-02Handle casts changing pointer size in the vectorizerStanislav Mekhanoshin
Added code to truncate or shrink offsets so that we can continue base pointer search if size has changed along the way. Differential Revision: https://reviews.llvm.org/D65612 llvm-svn: 367646
2019-08-01Relax load store vectorizer pointer strip checksStanislav Mekhanoshin
The previous change to fix crash in the vectorizer introduced performance regressions. The condition to preserve pointer address space during the search is too tight, we only need to match the size. Differential Revision: https://reviews.llvm.org/D65600 llvm-svn: 367624
2019-07-31[AMDGPU] Fix for vectorizer crash with pointers of different sizeStanislav Mekhanoshin
When vectorizer strips pointers it can eventually end up with pointers of two different sizes, then SCEV will crash. Differential Revision: https://reviews.llvm.org/D65480 llvm-svn: 367443
2019-06-17[lit] Delete empty lines at the end of lit.local.cfg NFCFangrui Song
llvm-svn: 363538
2019-04-17Revert "Temporarily Revert "Add basic loop fusion pass.""Eric Christopher
The reversion apparently deleted the test/Transforms directory. Will be re-reverting again. llvm-svn: 358552