Skip to content

Commit 2bcedd4

Browse files
[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
1 parent 4ace72e commit 2bcedd4

6 files changed

+27
-0
lines changed

llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,15 @@ void SPIRVAsmPrinter::outputExecutionMode(const Module &M) {
447447
Inst.addOperand(MCOperand::createImm(TypeCode));
448448
outputMCInst(Inst);
449449
}
450+
if (!M.getNamedMetadata("spirv.ExecutionMode") &&
451+
!M.getNamedMetadata("opencl.enable.FP_CONTRACT")) {
452+
MCInst Inst;
453+
Inst.setOpcode(SPIRV::OpExecutionMode);
454+
Inst.addOperand(MCOperand::createReg(FReg));
455+
unsigned EM = static_cast<unsigned>(SPIRV::ExecutionMode::ContractionOff);
456+
Inst.addOperand(MCOperand::createImm(EM));
457+
outputMCInst(Inst);
458+
}
450459
}
451460
}
452461

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
2+
3+
; CHECK: OpEntryPoint Kernel %[[#ENTRY:]] "foo"
4+
; CHECK-NOT: OpExecutionMode %[[#ENTRY]] ContractionOff
5+
define spir_kernel void @foo() {
6+
entry:
7+
ret void
8+
}
9+
10+
!opencl.enable.FP_CONTRACT = !{}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
2+
3+
; CHECK: OpEntryPoint Kernel %[[#ENTRY:]] "foo"
4+
; CHECK: OpExecutionMode %[[#ENTRY]] ContractionOff
5+
define spir_kernel void @foo() {
6+
entry:
7+
ret void
8+
}

0 commit comments

Comments
 (0)