@@ -3298,12 +3298,17 @@ bool SPIRVInstructionSelector::selectAllocaArray(Register ResVReg,
3298
3298
// there was an allocation size parameter to the allocation instruction
3299
3299
// that is not 1
3300
3300
MachineBasicBlock &BB = *I.getParent ();
3301
- return BuildMI (BB, I, I.getDebugLoc (),
3302
- TII.get (SPIRV::OpVariableLengthArrayINTEL))
3303
- .addDef (ResVReg)
3304
- .addUse (GR.getSPIRVTypeID (ResType))
3305
- .addUse (I.getOperand (2 ).getReg ())
3306
- .constrainAllUses (TII, TRI, RBI);
3301
+ bool Res = BuildMI (BB, I, I.getDebugLoc (),
3302
+ TII.get (SPIRV::OpVariableLengthArrayINTEL))
3303
+ .addDef (ResVReg)
3304
+ .addUse (GR.getSPIRVTypeID (ResType))
3305
+ .addUse (I.getOperand (2 ).getReg ())
3306
+ .constrainAllUses (TII, TRI, RBI);
3307
+ if (!STI.isVulkanEnv ()) {
3308
+ unsigned Alignment = I.getOperand (3 ).getImm ();
3309
+ buildOpDecorate (ResVReg, I, TII, SPIRV::Decoration::Alignment, {Alignment});
3310
+ }
3311
+ return Res;
3307
3312
}
3308
3313
3309
3314
bool SPIRVInstructionSelector::selectFrameIndex (Register ResVReg,
@@ -3312,12 +3317,18 @@ bool SPIRVInstructionSelector::selectFrameIndex(Register ResVReg,
3312
3317
// Change order of instructions if needed: all OpVariable instructions in a
3313
3318
// function must be the first instructions in the first block
3314
3319
auto It = getOpVariableMBBIt (I);
3315
- return BuildMI (*It->getParent (), It, It->getDebugLoc (),
3316
- TII.get (SPIRV::OpVariable))
3317
- .addDef (ResVReg)
3318
- .addUse (GR.getSPIRVTypeID (ResType))
3319
- .addImm (static_cast <uint32_t >(SPIRV::StorageClass::Function))
3320
- .constrainAllUses (TII, TRI, RBI);
3320
+ bool Res = BuildMI (*It->getParent (), It, It->getDebugLoc (),
3321
+ TII.get (SPIRV::OpVariable))
3322
+ .addDef (ResVReg)
3323
+ .addUse (GR.getSPIRVTypeID (ResType))
3324
+ .addImm (static_cast <uint32_t >(SPIRV::StorageClass::Function))
3325
+ .constrainAllUses (TII, TRI, RBI);
3326
+ if (!STI.isVulkanEnv ()) {
3327
+ unsigned Alignment = I.getOperand (2 ).getImm ();
3328
+ buildOpDecorate (ResVReg, *It, TII, SPIRV::Decoration::Alignment,
3329
+ {Alignment});
3330
+ }
3331
+ return Res;
3321
3332
}
3322
3333
3323
3334
bool SPIRVInstructionSelector::selectBranch (MachineInstr &I) const {
0 commit comments