[llvm] 2bcedd4 - [SPIR-V] Emit OpExecutionMode ContractionOff for no FP_CONTRACT metadata
Michal Paszkowski via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 19 06:27:15 PST 2023
Author: Michal Paszkowski
Date: 2023-01-19T15:26:34+01:00
New Revision: 2bcedd464348e170587b6f798d021f4e182f62e2
URL: https://github.com/llvm/llvm-project/commit/2bcedd464348e170587b6f798d021f4e182f62e2
DIFF: https://github.com/llvm/llvm-project/commit/2bcedd464348e170587b6f798d021f4e182f62e2.diff
LOG: [SPIR-V] Emit OpExecutionMode ContractionOff for no FP_CONTRACT metadata
This change makes the AsmPrinter emit OpExecutionMode ContractionOff
when both opencl.enable.FP_CONTRACT and spirv.ExecutionMode
metadata are not present.
Differential Revision: https://reviews.llvm.org/D141734
Added:
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
Modified:
llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
Removed:
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
################################################################################
diff --git a/llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp b/llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
index f32d70eb4e711..2e822a318ea63 100644
--- a/llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
@@ -447,6 +447,15 @@ void SPIRVAsmPrinter::outputExecutionMode(const Module &M) {
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);
+ }
}
}
diff --git a/llvm/test/CodeGen/SPIRV/opencl/metadata/fp_contractions_metadata.ll b/llvm/test/CodeGen/SPIRV/opencl/metadata/fp_contractions_metadata.ll
new file mode 100644
index 0000000000000..2b09f52f183be
--- /dev/null
+++ b/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 = !{}
diff --git a/llvm/test/CodeGen/SPIRV/opencl/kernel_arg_type_function_metadata.ll b/llvm/test/CodeGen/SPIRV/opencl/metadata/kernel_arg_type_function_metadata.ll
similarity index 100%
rename from llvm/test/CodeGen/SPIRV/opencl/kernel_arg_type_function_metadata.ll
rename to llvm/test/CodeGen/SPIRV/opencl/metadata/kernel_arg_type_function_metadata.ll
diff --git a/llvm/test/CodeGen/SPIRV/opencl/kernel_arg_type_module_metadata.ll b/llvm/test/CodeGen/SPIRV/opencl/metadata/kernel_arg_type_module_metadata.ll
similarity index 100%
rename from llvm/test/CodeGen/SPIRV/opencl/kernel_arg_type_module_metadata.ll
rename to llvm/test/CodeGen/SPIRV/opencl/metadata/kernel_arg_type_module_metadata.ll
diff --git a/llvm/test/CodeGen/SPIRV/opencl/metadata/no_fp_contractions_metadata.ll b/llvm/test/CodeGen/SPIRV/opencl/metadata/no_fp_contractions_metadata.ll
new file mode 100644
index 0000000000000..10840125b9f61
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/opencl/metadata/no_fp_contractions_metadata.ll
@@ -0,0 +1,8 @@
+; 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
+}
diff --git a/llvm/test/CodeGen/SPIRV/metadata-opencl.ll b/llvm/test/CodeGen/SPIRV/opencl/metadata/opencl_version_metadata.ll
similarity index 100%
rename from llvm/test/CodeGen/SPIRV/metadata-opencl.ll
rename to llvm/test/CodeGen/SPIRV/opencl/metadata/opencl_version_metadata.ll
More information about the llvm-commits
mailing list