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
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);
+ }
}
}
--- /dev/null
+; 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 = !{}
--- /dev/null
+; 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
+}