[clang] [llvm] [AggressiveInstCombine] Shrink loads used in shufflevector rebroadcasts. (PR #128938)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 26 13:24:45 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff f161b1b5265baadc443506b88bd1084adccaef90 b8ec65331def0fce1f70d203f3473accbdd77865 --extensions cpp -- llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
index cbdf99316e..813935499f 100644
--- a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
+++ b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -915,7 +915,7 @@ static bool foldPatternedLoads(Instruction &I, const DataLayout &DL) {
return true;
}
-// If `I` is a load instruction, used only by shufflevector instructions with
+// If `I` is a load instruction, used only by shufflevector instructions with
// poison values, attempt to shrink the load to only the lanes being used.
static bool shrinkLoadsForBroadcast(Instruction &I) {
auto *OldLoad = dyn_cast<LoadInst>(&I);
@@ -936,7 +936,7 @@ static bool shrinkLoadsForBroadcast(Instruction &I) {
using IndexRange = std::pair<unsigned, unsigned>;
auto GetIndexRangeInShuffles = [&]() -> std::optional<IndexRange> {
auto OutputRange = IndexRange(VecTy->getNumElements(), 0u);
- for (auto &Use: I.uses()) {
+ for (auto &Use : I.uses()) {
// All uses must be ShuffleVector instructions.
auto *Shuffle = dyn_cast<ShuffleVectorInst>(Use.getUser());
if (!Shuffle)
@@ -953,7 +953,7 @@ static bool shrinkLoadsForBroadcast(Instruction &I) {
auto *Op0Ty = cast<FixedVectorType>(Op0->getType());
auto NumElems = Op0Ty->getNumElements();
- for (unsigned Index: Mask) {
+ for (unsigned Index : Mask) {
if (Index < NumElems) {
OutputRange.first = std::min(Index, OutputRange.first);
OutputRange.second = std::max(Index, OutputRange.second);
@@ -975,26 +975,25 @@ static bool shrinkLoadsForBroadcast(Instruction &I) {
auto *ElemTy = VecTy->getElementType();
auto *NewVecTy = FixedVectorType::get(ElemTy, NewSize);
auto *NewLoad = cast<LoadInst>(
- Builder.CreateLoad(NewVecTy, OldLoad->getPointerOperand()));
+ Builder.CreateLoad(NewVecTy, OldLoad->getPointerOperand()));
NewLoad->copyMetadata(I);
// Replace all users.
- auto OldShuffles = SmallVector<ShuffleVectorInst*, 4u>{};
- for (auto &Use: I.uses()) {
+ auto OldShuffles = SmallVector<ShuffleVectorInst *, 4u>{};
+ for (auto &Use : I.uses()) {
auto *Shuffle = cast<ShuffleVectorInst>(Use.getUser());
-
+
Builder.SetInsertPoint(Shuffle);
Builder.SetCurrentDebugLocation(Shuffle->getDebugLoc());
auto *NewShuffle = Builder.CreateShuffleVector(
- NewLoad, PoisonValue::get(NewVecTy), Shuffle->getShuffleMask()
- );
+ NewLoad, PoisonValue::get(NewVecTy), Shuffle->getShuffleMask());
Shuffle->replaceAllUsesWith(NewShuffle);
OldShuffles.push_back(Shuffle);
}
// Erase old users.
- for (auto *Shuffle: OldShuffles)
+ for (auto *Shuffle : OldShuffles)
Shuffle->eraseFromParent();
I.eraseFromParent();
``````````
</details>
https://github.com/llvm/llvm-project/pull/128938
More information about the cfe-commits
mailing list