[llvm] [DirectX] Make DXILOpLowering split vector coordinates, offsets, and gradient operands (PR #223091)
Joshua Batista via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 15:48:23 PDT 2026
================
@@ -946,49 +987,23 @@ class OpLowerer {
static std::array<Value *, 4> splitStoreData(IRBuilder<> &IRB, Value *Data,
uint64_t NumElements,
bool FillWithUndef) {
- Type *DataTy = Data->getType();
- Type *ScalarTy = DataTy->getScalarType();
-
std::array<Value *, 4> DataElements{nullptr, nullptr, nullptr, nullptr};
- if (DataTy == ScalarTy)
- DataElements[0] = Data;
- else {
- // Since we're post-scalarizer, if we see a vector here it's likely
- // constructed solely for the argument of the store. Just use the scalar
- // values from before they're inserted into the temporary.
- auto *IEI = dyn_cast<InsertElementInst>(Data);
- while (IEI) {
- auto *IndexOp = dyn_cast<ConstantInt>(IEI->getOperand(2));
- if (!IndexOp)
- break;
- size_t IndexVal = IndexOp->getZExtValue();
- assert(IndexVal < 4 && "Too many elements for resource store");
- DataElements[IndexVal] = IEI->getOperand(1);
- IEI = dyn_cast<InsertElementInst>(IEI->getOperand(0));
- }
- }
-
- // If for some reason we weren't able to forward the arguments from the
- // scalarizer artifact, then we may need to actually extract elements from
- // the vector.
- for (uint64_t I = 0, E = NumElements; I < E; ++I)
- if (DataElements[I] == nullptr)
- DataElements[I] = IRB.CreateExtractElement(
- Data, ConstantInt::get(IRB.getInt32Ty(), I));
+ extractElementsIntoArgs(IRB, DataElements, 0, Data, 4);
// For any elements beyond the length of the vector, we should fill it up
// with undef - however, for typed UAVs we repeat the first element to
// match DXC.
for (uint64_t I = NumElements, E = 4; I < E; ++I)
if (DataElements[I] == nullptr)
DataElements[I] =
- FillWithUndef ? UndefValue::get(ScalarTy) : DataElements[0];
+ FillWithUndef ? UndefValue::get(Data->getType()->getScalarType())
----------------
bob80905 wrote:
Are we really guaranteed all results of getType() will have a method getScalarType()?
https://github.com/llvm/llvm-project/pull/223091
More information about the llvm-commits
mailing list