Skip to content

Commit

Permalink
Use fp_fast_mode extension with the capability (KhronosGroup#2028)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaaskel authored May 31, 2023
1 parent 42de1b4 commit 17cfdbd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
19 changes: 9 additions & 10 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ void transAliasingMemAccess(SPIRVModule *BM, MDNode *AliasingListMD,
std::vector<uint32_t> &MemoryAccess,
SPIRVWord MemAccessMask) {
if (!BM->isAllowedToUseExtension(
ExtensionID::SPV_INTEL_memory_access_aliasing))
ExtensionID::SPV_INTEL_memory_access_aliasing))
return;
auto *MemAliasList = addMemAliasingINTELInstructions(BM, AliasingListMD);
if (!MemAliasList)
Expand Down Expand Up @@ -2619,10 +2619,12 @@ bool LLVMToSPIRVBase::transDecoration(Value *V, SPIRVValue *BV) {
if (FMF.allowContract()) {
M |= FPFastMathModeAllowContractFastINTELMask;
BM->addCapability(CapabilityFPFastMathModeINTEL);
BM->addExtension(ExtensionID::SPV_INTEL_fp_fast_math_mode);
}
if (FMF.allowReassoc()) {
M |= FPFastMathModeAllowReassocINTELMask;
BM->addCapability(CapabilityFPFastMathModeINTEL);
BM->addExtension(ExtensionID::SPV_INTEL_fp_fast_math_mode);
}
}
}
Expand Down Expand Up @@ -2669,20 +2671,17 @@ bool LLVMToSPIRVBase::transAlign(Value *V, SPIRVValue *BV) {
void LLVMToSPIRVBase::transMemAliasingINTELDecorations(Instruction *Inst,
SPIRVValue *BV) {
if (!BM->isAllowedToUseExtension(
ExtensionID::SPV_INTEL_memory_access_aliasing))
ExtensionID::SPV_INTEL_memory_access_aliasing))
return;
if (MDNode *AliasingListMD =
Inst->getMetadata(LLVMContext::MD_alias_scope)) {
auto *MemAliasList =
addMemAliasingINTELInstructions(BM, AliasingListMD);
if (MDNode *AliasingListMD = Inst->getMetadata(LLVMContext::MD_alias_scope)) {
auto *MemAliasList = addMemAliasingINTELInstructions(BM, AliasingListMD);
if (!MemAliasList)
return;
BV->addDecorate(new SPIRVDecorateId(DecorationAliasScopeINTEL, BV,
MemAliasList->getId()));
}
if (MDNode *AliasingListMD = Inst->getMetadata(LLVMContext::MD_noalias)) {
auto *MemAliasList =
addMemAliasingINTELInstructions(BM, AliasingListMD);
auto *MemAliasList = addMemAliasingINTELInstructions(BM, AliasingListMD);
if (!MemAliasList)
return;
BV->addDecorate(
Expand Down Expand Up @@ -4102,8 +4101,8 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
else
// Other LLVM intrinsics shouldn't get to SPIRV, because they
// can't be represented in SPIRV or aren't implemented yet.
BM->SPIRVCK(
false, InvalidFunctionCall, II->getCalledOperand()->getName().str());
BM->SPIRVCK(false, InvalidFunctionCall,
II->getCalledOperand()->getName().str());
}
return nullptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_fp_fast_math_mode -spirv-text %t.bc -o - | FileCheck %s --check-prefix=CHECK-SPIRV-ON
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_fp_fast_math_mode %t.bc -o %t.spv
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-LLVM

; CHECK-SPIRV-ON: 2 Capability FPFastMathModeINTEL
; CHECK-SPIRV-ON: 8 Extension "SPV_INTEL_fp_fast_math_mode"
; CHECK-SPIRV-ON: 3 Name [[mu:[0-9]+]] "mul"
; CHECK-SPIRV-ON: 3 Name [[su:[0-9]+]] "sub"
; CHECK-SPIRV-ON-DAG: 4 Decorate [[mu]] FPFastMathMode 65536
Expand Down

0 comments on commit 17cfdbd

Please sign in to comment.