[llvm] [CGP] Reassociate GEPs to separate scalar and vector indexing (PR #146379)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 30 09:01:21 PDT 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 HEAD~1 HEAD --extensions cpp -- llvm/lib/CodeGen/CodeGenPrepare.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 2138862f5..d4319c5c3 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -6297,11 +6297,13 @@ Value *CodeGenPrepare::splitLastVectorIndex(Instruction *MemoryInst,
// If the final index isn't a vector, emit a scalar GEP containing all ops
// and a vector GEP with all zeroes final index.
if (!Ops[FinalIndex]->getType()->isVectorTy()) {
- Value *NewAddr = Builder.CreateGEP(SourceTy, Ops[0], ArrayRef(Ops).drop_front());
+ Value *NewAddr =
+ Builder.CreateGEP(SourceTy, Ops[0], ArrayRef(Ops).drop_front());
auto *IndexTy = VectorType::get(ScalarIndexTy, NumElts);
- auto *SecondTy = GetElementPtrInst::getIndexedType(
- SourceTy, ArrayRef(Ops).drop_front());
- return Builder.CreateGEP(SecondTy, NewAddr, Constant::getNullValue(IndexTy));
+ auto *SecondTy =
+ GetElementPtrInst::getIndexedType(SourceTy, ArrayRef(Ops).drop_front());
+ return Builder.CreateGEP(SecondTy, NewAddr,
+ Constant::getNullValue(IndexTy));
}
Value *Base = Ops[0];
@@ -6311,10 +6313,10 @@ Value *CodeGenPrepare::splitLastVectorIndex(Instruction *MemoryInst,
if (Ops.size() != 2) {
// Replace the last index with 0.
Ops[FinalIndex] =
- Constant::getNullValue(Ops[FinalIndex]->getType()->getScalarType());
+ Constant::getNullValue(Ops[FinalIndex]->getType()->getScalarType());
Base = Builder.CreateGEP(SourceTy, Base, ArrayRef(Ops).drop_front());
- SourceTy = GetElementPtrInst::getIndexedType(
- SourceTy, ArrayRef(Ops).drop_front());
+ SourceTy =
+ GetElementPtrInst::getIndexedType(SourceTy, ArrayRef(Ops).drop_front());
}
// Now create the GEP with scalar pointer and vector index.
@@ -6380,14 +6382,11 @@ Value *CodeGenPrepare::reassociateVectorOps(Instruction *MemoryInst,
IRBuilder<> Builder(MemoryInst);
Type *SourceTy = GEP->getSourceElementType();
Value *Base = Ops[0];
- Base =
- Builder.CreateGEP(SourceTy, Base, ArrayRef(ScalarOps).drop_front());
- Base =
- Builder.CreateGEP(SourceTy, Base, ArrayRef(VectorOps).drop_front());
+ Base = Builder.CreateGEP(SourceTy, Base, ArrayRef(ScalarOps).drop_front());
+ Base = Builder.CreateGEP(SourceTy, Base, ArrayRef(VectorOps).drop_front());
return Base;
}
-
/// Rewrite GEP input to gather/scatter to enable SelectionDAGBuilder to find
/// a uniform base to use for ISD::MGATHER/MSCATTER. SelectionDAGBuilder can
/// only handle a GEP with a scalar pointer and one non-zero vector index in
``````````
</details>
https://github.com/llvm/llvm-project/pull/146379
More information about the llvm-commits
mailing list