Skip to content

Commit

Permalink
Always generate MemoryAccessAlignedMask (#1357)
Browse files Browse the repository at this point in the history
Drivers can use the stronger alignments to vectorize loads/stores.

Fix #1356
  • Loading branch information
olvaffe authored May 22, 2024
1 parent 769daac commit c1ca1b8
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/SPIRVProducerPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5608,11 +5608,10 @@ void SPIRVProducerPassImpl::GenerateInstruction(Instruction &I) {
SPIRVOperandVec Ops;
Ops << result_type_id << ptr;

// Align MemoryOperand is required for PhysicalStorageBuffer
if (clspv::Option::PhysicalStorageBuffers()) {
Ops << spv::MemoryAccessAlignedMask;
Ops << static_cast<uint32_t>(LD->getAlign().value());
}
// Align MemoryOperand helps load vectorization and is required for
// PhysicalStorageBuffer
Ops << spv::MemoryAccessAlignedMask;
Ops << static_cast<uint32_t>(LD->getAlign().value());

RID = addSPIRVInst(spv::OpLoad, Ops);

Expand Down Expand Up @@ -5666,11 +5665,10 @@ void SPIRVProducerPassImpl::GenerateInstruction(Instruction &I) {
Ops << ST->getValueOperand();
}

// Align MemoryOperand is required for PhysicalStorageBuffer
if (clspv::Option::PhysicalStorageBuffers()) {
Ops << spv::MemoryAccessAlignedMask;
Ops << static_cast<uint32_t>(ST->getAlign().value());
}
// Align MemoryOperand helps store vectorization and is required for
// PhysicalStorageBuffer
Ops << spv::MemoryAccessAlignedMask;
Ops << static_cast<uint32_t>(ST->getAlign().value());

RID = addSPIRVInst(spv::OpStore, Ops);
break;
Expand Down

0 comments on commit c1ca1b8

Please sign in to comment.