[llvm] [Scalarizer][DirectX] support structs return types (PR #111569)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 14:19:21 PDT 2024
================
@@ -1030,6 +1077,31 @@ bool ScalarizerVisitor::visitInsertElementInst(InsertElementInst &IEI) {
return true;
}
+bool ScalarizerVisitor::visitExtractValueInst(ExtractValueInst &EVI) {
+ Value *Op = EVI.getOperand(0);
+ Type *OpTy = Op->getType();
+ ValueVector Res;
+ if (!isStructOfMatchingFixedVectors(OpTy))
+ return false;
+ Type *VecType = cast<FixedVectorType>(OpTy->getContainedType(0));
+ std::optional<VectorSplit> VS = getVectorSplit(VecType);
+ if (!VS)
+ return false;
+ IRBuilder<> Builder(&EVI);
+ Scatterer Op0 = scatter(&EVI, Op, *VS);
+ assert(!EVI.getIndices().empty() && "Make sure an index exists");
+ // Note for our use case we only care about the top level index.
+ unsigned Index = EVI.getIndices()[0];
+ for (unsigned OpIdx = 0; OpIdx < Op0.size(); ++OpIdx) {
+ Value *ResElem = Builder.CreateExtractValue(
+ Op0[OpIdx], Index, EVI.getName() + ".elem" + std::to_string(Index));
----------------
nikic wrote:
```suggestion
Op0[OpIdx], Index, EVI.getName() + ".elem" + Twine(Index));
```
https://github.com/llvm/llvm-project/pull/111569
More information about the llvm-commits
mailing list