Skip to content

Commit 9737855

Browse files
authored
do not lower mad to fma when using only native fma (#1441)
make -cl-mad-enable or -cl-unsafe-math-optimisation required to lower mad to fma. This avoid CTS failure on erf for Nvidia devices
1 parent c4f91b9 commit 9737855

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/ReplaceOpenCLBuiltinPass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,9 +2118,7 @@ bool ReplaceOpenCLBuiltinPass::replaceMul(Function &F, bool is_float,
21182118
bool is_mad) {
21192119
// floating-point fma can be handle later in the flow if they are allowed
21202120
if (is_float && is_mad &&
2121-
(clspv::Option::UseNativeBuiltins().count(
2122-
clspv::Builtins::BuiltinType::kFma) > 0 ||
2123-
clspv::Option::ClMadEnable() || clspv::Option::UnsafeMath())) {
2121+
(clspv::Option::ClMadEnable() || clspv::Option::UnsafeMath())) {
21242122
return false;
21252123
}
21262124
return replaceCallsWithValue(F, [&](CallInst *CI) -> llvm::Value * {

test/mad-float-optimization.cl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
// RUN: FileCheck %s < %t.mad.spvasm
99
// RUN: spirv-val --target-env spv1.0 %t.mad.spv
1010

11+
// CHECK: OpExtInst {{.*}} Fma
12+
1113
// RUN: clspv %target %s -o %t.native.spv --use-native-builtins=fma
1214
// RUN: spirv-dis -o %t.native.spvasm %t.native.spv
13-
// RUN: FileCheck %s < %t.native.spvasm
15+
// RUN: FileCheck %s --check-prefix=NOOPT < %t.native.spvasm
1416
// RUN: spirv-val --target-env spv1.0 %t.native.spv
1517

16-
// CHECK: OpExtInst {{.*}} Fma
17-
1818
// RUN: clspv %target %s -o %t.spv
1919
// RUN: spirv-dis -o %t.spvasm %t.spv
2020
// RUN: FileCheck %s --check-prefix=NOOPT < %t.spvasm

0 commit comments

Comments
 (0)