Skip to content

Commit 73934f8

Browse files
committed
[SPIRV] Disable SPV_KHR_float_control2 for AMD flavored SPIRV
Currently the SPIRV translator doesn't support this extension. If this extension is used we cannot translate the SPIRV back to LLVM-IR.
1 parent b20d35c commit 73934f8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,5 +248,11 @@ SPIRVExtensionsParser::getValidExtensions(const Triple &TT) {
248248
R.insert(ExtensionEnum);
249249
}
250250

251+
if (TT.getVendor() == Triple::AMD) {
252+
// AMD uses the translator to recover LLVM-IR from SPIRV. Currently, the
253+
// translator doesn't implement the SPV_KHR_float_controls2 extension.
254+
R.erase(SPIRV::Extension::SPV_KHR_float_controls2);
255+
}
256+
251257
return R;
252258
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc -mtriple=spirv64-- --spirv-ext=all < %s | FileCheck %s --check-prefix=CHECK
2+
; No need to validate the output of the first command, we just want to ensure that we are on a path that triggers the use of SPV_KHR_float_controls2
3+
4+
; RUN: llc -mtriple=spirv64-amd-amdhsa --spirv-ext=all < %s | FileCheck %s --check-prefix=CHECK-AMD
5+
; RUN: %if spirv-tools %{ llc -mtriple=spirv64-amd-amdhsa --spirv-ext=all < %s -filetype=obj | spirv-val %}
6+
7+
; RUN: llc -mtriple=spirv64-amd-amdhsa --spirv-ext=+SPV_KHR_float_controls2 < %s | FileCheck %s --check-prefix=CHECK-AMD
8+
; RUN: %if spirv-tools %{ llc -mtriple=spirv64-amd-amdhsa --spirv-ext=+SPV_KHR_float_controls2 < %s -filetype=obj | spirv-val %}
9+
10+
; Check that SPV_KHR_float_controls2 is not present when the target is AMD.
11+
; AMD's SPIRV implementation uses the translator to get bitcode from SPIRV,
12+
; which at the moment doesn't implement the SPV_KHR_float_controls2 extension.
13+
14+
; CHECK: SPV_KHR_float_controls2
15+
; CHECK-AMD-NOT: SPV_KHR_float_controls2
16+
17+
define spir_kernel void @foo(float %a, float %b) {
18+
entry:
19+
; Use contract to trigger a use of SPV_KHR_float_controls2
20+
%r1 = fadd contract float %a, %b
21+
ret void
22+
}

0 commit comments

Comments
 (0)