[PATCH] D141734: [SPIR-V] Emit OpExecutionMode ContractionOff for no FP_CONTRACT metadata
Michal Paszkowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 13 15:32:39 PST 2023
mpaszkowski created this revision.
mpaszkowski added reviewers: iliya-diyachkov, konrad.trifunovic, andreytr, zuban32, rengolin, arsenm, MaskRay.
Herald added subscribers: ThomasRaoux, hiraditya, Anastasia.
Herald added a project: All.
mpaszkowski requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
This change makes the AsmPrinter emit `OpExecutionMode ContractionOff` when both `opencl.enable.FP_CONTRACT` and `spirv.ExecutionMode` metadata are not present. All 16 contractions OpenCL CTS tests pass after this change.
//no_fp_contractions_metadata.ll //and// fp_contractions_metadata.ll //LIT tests were added and other tests checking OpenCL metadata were moved to OpenCL/metadata directory.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141734
Files:
llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
llvm/test/CodeGen/SPIRV/metadata-opencl.ll
llvm/test/CodeGen/SPIRV/opencl/kernel_arg_type_function_metadata.ll
llvm/test/CodeGen/SPIRV/opencl/kernel_arg_type_module_metadata.ll
llvm/test/CodeGen/SPIRV/opencl/metadata/fp_contractions_metadata.ll
llvm/test/CodeGen/SPIRV/opencl/metadata/kernel_arg_type_function_metadata.ll
llvm/test/CodeGen/SPIRV/opencl/metadata/kernel_arg_type_module_metadata.ll
llvm/test/CodeGen/SPIRV/opencl/metadata/no_fp_contractions_metadata.ll
llvm/test/CodeGen/SPIRV/opencl/metadata/opencl_version_metadata.ll
Index: llvm/test/CodeGen/SPIRV/opencl/metadata/no_fp_contractions_metadata.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/SPIRV/opencl/metadata/no_fp_contractions_metadata.ll
@@ -0,0 +1,9 @@
+; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
+
+; CHECK: OpEntryPoint Kernel %[[#ENTRY:]] "foo"
+; CHECK: OpExecutionMode %[[#ENTRY]] ContractionOff
+define spir_kernel void @foo() {
+entry:
+ ret void
+}
+
Index: llvm/test/CodeGen/SPIRV/opencl/metadata/fp_contractions_metadata.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/SPIRV/opencl/metadata/fp_contractions_metadata.ll
@@ -0,0 +1,10 @@
+; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
+
+; CHECK: OpEntryPoint Kernel %[[#ENTRY:]] "foo"
+; CHECK-NOT: OpExecutionMode %[[#ENTRY]] ContractionOff
+define spir_kernel void @foo() {
+entry:
+ ret void
+}
+
+!opencl.enable.FP_CONTRACT = !{}
Index: llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
+++ llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
@@ -447,6 +447,15 @@
Inst.addOperand(MCOperand::createImm(TypeCode));
outputMCInst(Inst);
}
+ if (!M.getNamedMetadata("spirv.ExecutionMode") &&
+ !M.getNamedMetadata("opencl.enable.FP_CONTRACT")) {
+ MCInst Inst;
+ Inst.setOpcode(SPIRV::OpExecutionMode);
+ Inst.addOperand(MCOperand::createReg(FReg));
+ unsigned EM = static_cast<unsigned>(SPIRV::ExecutionMode::ContractionOff);
+ Inst.addOperand(MCOperand::createImm(EM));
+ outputMCInst(Inst);
+ }
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141734.489140.patch
Type: text/x-patch
Size: 1736 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230113/3e159a59/attachment.bin>
More information about the llvm-commits
mailing list