summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp
AgeCommit message (Collapse)Author
2025-06-28[GlobalISel] Remove an unnecessary cast (NFC) (#146249)Kazu Hirata
Idx is already of unsigned.
2025-06-16[llvm] Remove unused includes (NFC) (#144293)Kazu Hirata
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-06-12[DLCov][NFC] Propagate annotated DebugLocs through transformations (#138047)Stephen Tozer
Part of the coverage-tracking feature, following #107279. In order for DebugLoc coverage testing to work, we firstly have to set annotations for intentionally-empty DebugLocs, and secondly we have to ensure that we do not drop these annotations as we propagate DebugLocs throughout compilation. As the annotations exist as part of the DebugLoc class, and not the underlying DILocation, they will not survive a DebugLoc->DILocation->DebugLoc roundtrip. Therefore this patch modifies a number of places in the compiler to propagate DebugLocs directly rather than via the underlying DILocation. This has no effect on the output of normal builds; it only ensures that during coverage builds, we do not drop incorrectly annotations and therefore create false positives. The bulk of these changes are in replacing DILocation::getMergedLocation(s) with a DebugLoc equivalent, and in changing the IRBuilder to store a DebugLoc directly rather than storing DILocations in its general Metadata array. We also use a new function, `DebugLoc::orElse`, which selects the "best" DebugLoc out of a pair (valid location > annotated > empty), preferring the current DebugLoc on a tie - this encapsulates the existing behaviour at a few sites where we _may_ assign a DebugLoc to an existing instruction, while extending the logic to handle annotation DebugLocs at the same time.
2025-05-22[LLVM][CodeGen] Add convenience accessors for MachineFunctionProperties ↵users/pcc/spr/main.elf-add-branch-to-branch-optimizationRahul Joshi
(#140002) Add per-property has<Prop>/set<Prop>/reset<Prop> functions to MachineFunctionProperties.
2025-03-28[llvm] Remove extraneous calls to make_range (NFC) (#133551)Kazu Hirata
2025-03-23[CodeGen] Use *Set::insert_range (NFC) (#132651)Kazu Hirata
We can use *Set::insert_range to collapse: for (auto Elem : Range) Set.insert(E); down to: Set.insert_range(Range);
2024-12-13[GlobalISel] Fix warningsKazu Hirata
This patch fixes: llvm/lib/CodeGen/GlobalISel/CombinerHelperCasts.cpp:167:21: error: unused variable 'DL' [-Werror,-Wunused-variable] llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp:320:15: error: unused variable 'DL' [-Werror,-Wunused-variable]
2024-12-13[GISel] Remove unused DataLayout operand from getApproximateEVTForLLT (#119833)Craig Topper
2024-11-08[GlobalISel] Remove unused includes (NFC) (#115429)Kazu Hirata
Identified with misc-include-cleaner.
2024-06-28[IR] Add getDataLayout() helpers to Function and GlobalValue (#96919)Nikita Popov
Similar to https://github.com/llvm/llvm-project/pull/96902, this adds `getDataLayout()` helpers to Function and GlobalValue, replacing the current `getParent()->getDataLayout()` pattern.
2024-04-30[GlobalISel] Fix store merging incorrectly classifying an unknown index expr ↵Amara Emerson
as 0. (#90375) During analysis, we incorrectly leave the offset part of an address info struct as zero, when in actual fact we failed to decompose it into base + offset. This results in incorrectly assuming that the address is adjacent to another store addr. To fix this we wrap the offset in an optional<> so we can distinguish between real zero and unknown. Fixes issue #90242
2024-03-23[CodeGen] Update for scalable MemoryType in MMO (#70452)Harvin Iriawan
Remove getSizeOrUnknown call when MachineMemOperand is created. For Scalable TypeSize, the MemoryType created becomes a scalable_vector. 2 MMOs that have scalable memory access can then use the updated BasicAA that understands scalable LocationSize. Original Patch by Harvin Iriawan Co-authored-by: David Green <david.green@arm.com>
2024-03-17[CodeGen] Use LocationSize for MMO getSize (#84751)David Green
This is part of #70452 that changes the type used for the external interface of MMO to LocationSize as opposed to uint64_t. This means the constructors take LocationSize, and convert ~UINT64_C(0) to LocationSize::beforeOrAfter(). The getSize methods return a LocationSize. This allows us to be more precise with unknown sizes, not accidentally treating them as unsigned values, and in the future should allow us to add proper scalable vector support but none of that is included in this patch. It should mostly be an NFC. Global ISel is still expected to use the underlying LLT as it needs, and are not expected to see unknown sizes for generic operations. Most of the changes are hopefully fairly mechanical, adding a lot of getValue() calls and protecting them with hasValue() where needed.
2024-03-06[GlobalISel] Use LocationSize in GISelAddressing. NFC (#83885)David Green
This is similar to #83017 but for the areas in GlobalISel's LoadStoreOpt, and should help simplify #70452 a little. It will likely change a little again once the sizes can be scalable.
2023-08-13[llvm] Drop some more typed pointer bitcasts etc.Bjorn Pettersson
2023-04-25Move CodeGen/LowLevelType => CodeGen/LowLevelTypeUtilsNAKAMURA Takumi
Before restoring `CodeGen/LowLevelType`, rename this to `LowLevelTypeUtils`. Differential Revision: https://reviews.llvm.org/D148768
2023-04-12[GlobalISel] Move the truncstore_merge combine to the LoadStoreOpt pass and ↵Amara Emerson
add support for an extra case. If we have set of mergeable stores of shifts, but the original source value being shifted is wider than the merged size, we should still be able to merge if we truncate first. To do this however we need to search for stores speculatively up the block, without knowing exactly how many stores we should see before we stop. The old algorithm has to match an exact number of stores to fit the wide type, or it dies. The new one will try to set the wide type to however many stores we found in the upwards block traversal and use later checks to verify if they're a valid mergeable set. The reason I need to move this to LoadStoreOpt is because the combiner works going top down inside a block, which means that we end up doing partial merges because we haven't seen all the possible stores before we mutate the MIR. In LoadStoreOpt we can go bottom up. As a side effect of this change, we also end up doing better on an existing test case (missing_store) since we manage to do a partial merge there.
2023-02-19[GlobalISel] Fix a store-merging bug due to use of >= instead of >.Amara Emerson
This fixes a corner case where we would skip doing an alias check because of a >= vs > bug, due to the presence of a non-aliasing instruction, in this case the load %safeld. Fixes issue #59376
2023-01-28[llvm] Use llvm::bit_floor instead of llvm::PowerOf2Floor (NFC)Kazu Hirata
2023-01-11[NFC] Use TypeSize::geFixedValue() instead of TypeSize::getFixedSize()Guillaume Chatelet
This change is one of a series to implement the discussion from https://reviews.llvm.org/D141134.
2022-11-01[GlobalISel] Compute debug location when merging stores more accuratelyAnton Sidorenko
Originaly the loop did almost nothing as the calculated location was overwritten on the next iteration. Differential Revision: https://reviews.llvm.org/D136937
2022-07-17[CodeGen] Qualify auto variables in for loops (NFC)Kazu Hirata
2022-06-25GlobalISel: Make LoadStoreOpt preserve allMatt Arsenault
Avoids dropping CSE info analysis
2022-03-14[GlobalISel] Fix store merging incorrectly merging volatile stores.Amara Emerson
The existing volatile checks only handle aliasing hazards between stores, but that isn't enough since by that point volatile stores may have already been added to the current candidate group.
2021-12-03[CodeGen] Use range-based for loops (NFC)Kazu Hirata
2021-11-16Fix unused variable warning in LoadStoreOpt.cpp with (void)Frederik Gossen
2021-11-16Revert "Fix unused variable in llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cpp"Frederik Gossen
This reverts commit 40a609aebe4ab51174a164852b6399f322bf6d9a.
2021-11-16Revert "Fix unused variable warning."Frederik Gossen
This reverts commit a062e2a8ca27b615cf3d02ed5c551ca85efc0325.
2021-11-16Revert "Fix another unused variable error."Frederik Gossen
This reverts commit 5b84ae7c48083bd0f40199837990cf915a2053b8.
2021-11-16Fix another unused variable error.Adrian Kuegel
2021-11-16Fix unused variable warning.Adrian Kuegel
2021-11-16Fix unused variable in llvm/lib/CodeGen/GlobalISel/LoadStoreOpt.cppFrederik Gossen
2021-11-16Remove unnecessary <any> include.Amara Emerson
2021-11-15[GlobalISel] Add a store-merging optimization pass and enable for AArch64.Amara Emerson
This is a first attempt at a constant value consecutive store merging pass, a counterpart to the DAGCombiner's store merging optimization. The high level goals of this pass: * Have a simple and efficient algorithm. As close to linear time as we can get. Thus, prioritizing scalability of the algorithm over merging every corner case we can find. The DAGCombiner's store merging code has been the source of compile time and complexity issues in the past and I wanted to avoid that. * Don't introduce any new data structures for ordering memory operations. In MIR, we don't have the concept of chains like we do in the DAG, and the instruction order is stricter than enforcing ordering with graph edges. Although I considered adding something similar, I couldn't justify the overhead. The pass is current split into 3 main parts. The main store merging code focuses on identifying candidate stores and managing the candidate group that's under consideration for merging. Analyzing addressing of stores is a potentially complex part and for now there's just a basic implementation to identify easy cases. Finally, the other main bit of complexity is the alias analysis, which tries to follow the same logic as the DAG's AA. Currently this implementation only supports merging of constant stores. Stores of arbitrary variables are technically possible with a very small change, but the DAG chooses not to do this. Doing so here makes most code worse since there's extra overhead in merging values into wider registers. On AArch64 -Os, this optimization results in very minor savings on CTMark. Differential Revision: https://reviews.llvm.org/D109131