@@ -305,6 +305,7 @@ SpirvStore *SpirvBuilder::createStore(SpirvInstruction *address,
305305 }
306306
307307 SpirvInstruction *source = value;
308+ SpirvLoad *bitfieldLoad = nullptr ;
308309 const auto &bitfieldInfo = address->getBitfieldInfo ();
309310 if (bitfieldInfo.hasValue ()) {
310311 // Generate SPIR-V type for value. This is required to know the final
@@ -313,11 +314,12 @@ SpirvStore *SpirvBuilder::createStore(SpirvInstruction *address,
313314 lowerTypeVisitor.visitInstruction (value);
314315 context.addToInstructionsWithLoweredType (value);
315316
316- auto *base = createLoad (value->getResultType (), address, loc, range);
317- source = createBitFieldInsert (/* QualType*/ {}, base , value,
317+ bitfieldLoad = createLoad (value->getResultType (), address, loc, range);
318+ source = createBitFieldInsert (/* QualType*/ {}, bitfieldLoad , value,
318319 bitfieldInfo->offsetInBits ,
319320 bitfieldInfo->sizeInBits , loc, range);
320321 source->setResultType (value->getResultType ());
322+ source->setAstResultType (value->getAstResultType ());
321323 }
322324
323325 auto *instruction =
@@ -337,6 +339,8 @@ SpirvStore *SpirvBuilder::createStore(SpirvInstruction *address,
337339 std::tie (align, size) = alignmentCalc.getAlignmentAndSize (
338340 source->getAstResultType (), address->getLayoutRule (), llvm::None,
339341 &stride);
342+ if (bitfieldLoad)
343+ bitfieldLoad->setAlignment (align);
340344 instruction->setAlignment (align);
341345 }
342346
0 commit comments