[PATCH] D99482: [PoC][Clang][CodeGen] Do not use getelementptr for scalable struct.
Hsiangkai Wang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 30 06:52:39 PDT 2021
HsiangKai updated this revision to Diff 334145.
HsiangKai edited the summary of this revision.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99482/new/
https://reviews.llvm.org/D99482
Files:
clang/lib/CodeGen/CGCall.cpp
Index: clang/lib/CodeGen/CGCall.cpp
===================================================================
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1298,10 +1298,14 @@
bool DestIsVolatile) {
// Prefer scalar stores to first-class aggregate stores.
if (llvm::StructType *STy = dyn_cast<llvm::StructType>(Val->getType())) {
- for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
- Address EltPtr = Builder.CreateStructGEP(Dest, i);
- llvm::Value *Elt = Builder.CreateExtractValue(Val, i);
- Builder.CreateStore(Elt, EltPtr, DestIsVolatile);
+ if (STy->containsScalableVectorType())
+ Builder.CreateStore(Val, Dest, DestIsVolatile);
+ else {
+ for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
+ Address EltPtr = Builder.CreateStructGEP(Dest, i);
+ llvm::Value *Elt = Builder.CreateExtractValue(Val, i);
+ Builder.CreateStore(Elt, EltPtr, DestIsVolatile);
+ }
}
} else {
Builder.CreateStore(Val, Dest, DestIsVolatile);
@@ -2857,11 +2861,21 @@
}
assert(STy->getNumElements() == NumIRArgs);
- for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
- auto AI = Fn->getArg(FirstIRArg + i);
- AI->setName(Arg->getName() + ".coerce" + Twine(i));
- Address EltPtr = Builder.CreateStructGEP(AddrToStoreInto, i);
- Builder.CreateStore(AI, EltPtr);
+ if (STy->containsScalableVectorType()) {
+ llvm::Value *Val = llvm::UndefValue::get(STy);
+ for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
+ auto AI = Fn->getArg(FirstIRArg + i);
+ AI->setName(Arg->getName() + ".coerce" + Twine(i));
+ Val = Builder.CreateInsertValue(Val, AI, i);
+ }
+ Builder.CreateStore(Val, AddrToStoreInto);
+ } else {
+ for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
+ auto AI = Fn->getArg(FirstIRArg + i);
+ AI->setName(Arg->getName() + ".coerce" + Twine(i));
+ Address EltPtr = Builder.CreateStructGEP(AddrToStoreInto, i);
+ Builder.CreateStore(AI, EltPtr);
+ }
}
if (SrcSize > DstSize) {
@@ -4920,10 +4934,18 @@
}
assert(NumIRArgs == STy->getNumElements());
- for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
- Address EltPtr = Builder.CreateStructGEP(Src, i);
- llvm::Value *LI = Builder.CreateLoad(EltPtr);
- IRCallArgs[FirstIRArg + i] = LI;
+ if (STy->containsScalableVectorType()) {
+ llvm::Value *Val = Builder.CreateLoad(Src);
+ for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
+ llvm::Value *LI = Builder.CreateExtractValue(Val, i);
+ IRCallArgs[FirstIRArg + i] = LI;
+ }
+ } else {
+ for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
+ Address EltPtr = Builder.CreateStructGEP(Src, i);
+ llvm::Value *LI = Builder.CreateLoad(EltPtr);
+ IRCallArgs[FirstIRArg + i] = LI;
+ }
}
} else {
// In the simple case, just pass the coerced loaded value.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99482.334145.patch
Type: text/x-patch
Size: 3286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210330/30fe1406/attachment.bin>
More information about the cfe-commits
mailing list