Skip to content

Commit 00ffb5a

Browse files
committed
Added fast-math run lines to LIT tests.
1 parent f8caf83 commit 00ffb5a

File tree

3 files changed

+64
-28
lines changed

3 files changed

+64
-28
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,14 +2958,6 @@ RenderComplexRangeOption(LangOptions::ComplexRangeKind Range) {
29582958
return ComplexRangeStr;
29592959
}
29602960

2961-
static bool shouldUsePreciseDivision(const ArgList &Args) {
2962-
return Args.hasArg(options::OPT_ftarget_prec_div);
2963-
}
2964-
2965-
static bool shouldUsePreciseSqrt(const ArgList &Args) {
2966-
return Args.hasArg(options::OPT_ftarget_prec_sqrt);
2967-
}
2968-
29692961
static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
29702962
bool OFastEnabled, const ArgList &Args,
29712963
ArgStringList &CmdArgs,
@@ -3045,6 +3037,12 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
30453037
: ComplexArithmeticStr(LangOptions::ComplexRangeKind::CX_Basic));
30463038
Range = LangOptions::ComplexRangeKind::CX_Basic;
30473039
SeenUnsafeMathModeOption = true;
3040+
if (JA.isDeviceOffloading(Action::OFK_SYCL)) {
3041+
// when fp-model=fast is used the default precision for division and
3042+
// sqrt is not precise.
3043+
NoTargetPrecDiv = true;
3044+
NoTargetPrecSqrt = true;
3045+
}
30483046
};
30493047

30503048
// Lambda to consolidate common handling for fp-contract
@@ -3211,12 +3209,6 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
32113209
applyFastMath();
32123210
// applyFastMath sets fp-contract="fast"
32133211
LastFpContractOverrideOption = "-ffp-model=fast";
3214-
if (JA.isDeviceOffloading(Action::OFK_SYCL)) {
3215-
// when fp-model=fast is used the default precision for division and
3216-
// sqrt is not precise.
3217-
NoTargetPrecDiv = shouldUsePreciseDivision(Args);
3218-
NoTargetPrecSqrt = shouldUsePreciseSqrt(Args);
3219-
}
32203212
} else if (Val == "precise") {
32213213
FPModel = Val;
32223214
FPContract = "on";

clang/test/CodeGenSYCL/target-prec-sycl-device.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
// RUN: %clang_cc1 %{common_opts} -fno-target-prec-div %s -o - \
1717
// RUN: | FileCheck --check-prefix ROUNDED-DIV %s
1818

19+
// RUN: %clang_cc1 %{common_opts} -ffast-math -fno-target-prec-div \
20+
// RUN: -fno-target-prec-sqrt %s -o - \
21+
// RUN: | FileCheck --check-prefix ROUNDED-SQRT-FAST %s
22+
23+
// RUN: %clang_cc1 %{common_opts} -ffast-math -fno-target-prec-div \
24+
// RUN: -fno-target-prec-sqrt %s -o - \
25+
// RUN: | FileCheck --check-prefix ROUNDED-DIV-FAST %s
1926

2027
#include "sycl.hpp"
2128

@@ -46,9 +53,12 @@ int main() {
4653
[=](id<1> wiID) {
4754
// PREC-SQRT: call spir_func float @fdiv(float noundef {{.*}}, float noundef {{.*}})
4855
// ROUNDED-SQRT: call spir_func float @fdiv(float noundef {{.*}}, float noundef {{.*}})
56+
57+
// ROUNDED-SQRT-FAST: call reassoc nnan ninf nsz arcp afn float @llvm.fpbuiltin.sqrt.f32(float {{.*}}) #[[ATTR_SQRT:[0-9]+]]
58+
4959
// PREC-DIV: call spir_func float @fdiv(float noundef {{.*}}, float noundef {{.*}})
5060
// ROUNDED-DIV: call float @llvm.fpbuiltin.fdiv.f32(float {{.*}}, float {{.*}}) #[[ATTR_DIV:[0-9]+]]
51-
61+
// ROUNDED-DIV-FAST: call reassoc nnan ninf nsz arcp afn float @llvm.fpbuiltin.fdiv.f32(float {{.*}}, float {{.*}}) #[[ATTR_DIV:[0-9]+]]
5262
(void)fdiv(Value1, Value1);
5363
});
5464
});
@@ -57,4 +67,6 @@ return 0;
5767
}
5868

5969
// ROUNDED-SQRT: attributes #[[ATTR_SQRT]] = {{.*}}"fpbuiltin-max-error"="3.0"
70+
// ROUNDED-SQRT-FAST: attributes #[[ATTR_SQRT]] = {{.*}}"fpbuiltin-max-error"="3.0"
6071
// ROUNDED-DIV: attributes #[[ATTR_DIV]] = {{.*}}"fpbuiltin-max-error"="2.5"
72+
// ROUNDED-DIV-FAST: attributes #[[ATTR_DIV]] = {{.*}}"fpbuiltin-max-error"="2.5"
Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,60 @@
11
// RUN: %clang -c -fsycl -### %s 2>&1 | FileCheck %s
2+
23
// RUN: %clang -c -fsycl -ftarget-prec-div -### %s 2>&1 | FileCheck %s
4+
35
// RUN: %clang -c -fsycl -ftarget-prec-sqrt -### %s 2>&1 | FileCheck %s
4-
// RUN: %clang -c -fsycl -ftarget-prec-div -ftarget-prec-sqrt -### %s 2>&1 | FileCheck %s
5-
// RUN: %clang -c -fsycl -ftarget-prec-sqrt -ftarget-prec-div -### %s 2>&1 | FileCheck %s
6-
// RUN: %clang -c -fsycl -fno-target-prec-div -### %s 2>&1 | FileCheck --check-prefix=NO_PREC_DIV %s
7-
// RUN: %clang -c -fsycl -fno-target-prec-sqrt -### %s 2>&1 | FileCheck --check-prefix=NO_PREC_SQRT %s
8-
// RUN: %clang -c -fsycl -fno-target-prec-div -fno-target-prec-sqrt -### %s 2>&1 | FileCheck --check-prefix=NO_PREC_DIV_SQRT %s
9-
// RUN: %clang -c -fsycl -fno-target-prec-sqrt -fno-target-prec-div -### %s 2>&1 | FileCheck --check-prefix=NO_PREC_DIV_SQRT %s
10-
// RUN: %clang -c -fsycl -ffp-accuracy=high -fno-math-errno -fno-target-prec-div -### %s 2>&1 | FileCheck %s --check-prefix=WARN-HIGH-DIV
11-
// RUN: %clang -c -fsycl -fno-target-prec-div -ffp-accuracy=high -fno-math-errno -### %s 2>&1 | FileCheck %s --check-prefix=WARN-HIGH-DIV
12-
// RUN: %clang -c -fsycl -fno-target-prec-sqrt -ffp-accuracy=high -fno-math-errno -### %s 2>&1 | FileCheck %s --check-prefix=WARN-HIGH-SQRT
13-
// RUN: %clang -c -fsycl -ffp-accuracy=high -fno-math-errno -fno-target-prec-sqrt -### %s 2>&1 | FileCheck %s --check-prefix=WARN-HIGH-SQRT
14-
// RUN: %clang -c -fsycl -ffp-accuracy=low -fno-math-errno -fno-target-prec-div -### %s 2>&1 | FileCheck %s --check-prefix=WARN-LOW-DIV
15-
// RUN: %clang -c -fsycl -ffp-accuracy=low -fno-math-errno -fno-target-prec-sqrt -### %s 2>&1 | FileCheck %s --check-prefix=WARN-LOW-SQRT
6+
7+
// RUN: %clang -c -fsycl -ftarget-prec-div -ftarget-prec-sqrt -### %s 2>&1 \
8+
// RUN: | FileCheck %s
9+
10+
// RUN: %clang -c -fsycl -ftarget-prec-sqrt -ftarget-prec-div -### %s 2>&1 \
11+
// RUN: | FileCheck %s
12+
13+
// RUN: %clang -c -fsycl -fno-target-prec-div -### %s 2>&1 \
14+
// RUN: | FileCheck --check-prefix=NO_PREC_DIV %s
15+
16+
// RUN: %clang -c -fsycl -fno-target-prec-sqrt -### %s 2>&1 \
17+
// RUN: | FileCheck --check-prefix=NO_PREC_SQRT %s
18+
19+
// RUN: %clang -c -fsycl -fno-target-prec-div -fno-target-prec-sqrt -### %s 2>&1\
20+
// RUN: | FileCheck --check-prefix=NO_PREC_DIV_SQRT %s
21+
22+
// RUN: %clang -c -fsycl -fno-target-prec-sqrt -fno-target-prec-div -### %s 2>&1\
23+
// RUN: | FileCheck --check-prefix=NO_PREC_DIV_SQRT %s
24+
25+
// RUN: %clang -c -fsycl -ffp-accuracy=high -fno-math-errno \
26+
// RUN: -fno-target-prec-div -### %s 2>&1 \
27+
// RUN: | FileCheck %s --check-prefix=WARN-HIGH-DIV
28+
29+
// RUN: %clang -c -fsycl -fno-target-prec-div -ffp-accuracy=high \
30+
// RUN: -fno-math-errno -### %s 2>&1 \
31+
// RUN: | FileCheck %s --check-prefix=WARN-HIGH-DIV
32+
33+
// RUN: %clang -c -fsycl -fno-target-prec-sqrt -ffp-accuracy=high \
34+
// RUN: -fno-math-errno -### %s 2>&1 \
35+
// RUN: | FileCheck %s --check-prefix=WARN-HIGH-SQRT
36+
37+
// RUN: %clang -c -fsycl -ffp-accuracy=high -fno-math-errno \
38+
// RUN: -fno-target-prec-sqrt -### %s 2>&1 \
39+
// RUN: | FileCheck %s --check-prefix=WARN-HIGH-SQRT
40+
41+
// RUN: %clang -c -fsycl -ffp-accuracy=low -fno-math-errno -fno-target-prec-div \
42+
// RUN: -### %s 2>&1 | FileCheck %s --check-prefix=WARN-LOW-DIV
43+
44+
// RUN: %clang -c -fsycl -ffp-accuracy=low -fno-math-errno \
45+
// RUN: -fno-target-prec-sqrt -### %s 2>&1 \
46+
// RUN: | FileCheck %s --check-prefix=WARN-LOW-SQRT
1647

1748
// CHECK: "-triple" "spir64{{.*}}" "-fsycl-is-device"{{.*}} "-ftarget-prec-div" "-ftarget-prec-sqrt"
1849
// CHECK-NOT: "-triple{{.*}}" "-fsycl-is-host"{{.*}} "-ftarget-prec-div" "-ftarget-prec-sqrt"
1950
// NO_PREC_DIV: "-triple" "spir64{{.*}}"{{.*}} "-fsycl-is-device"{{.*}} "-fno-target-prec-div" "-ftarget-prec-sqrt"
2051
// NO_PREC_SQRT: "-triple" "spir64{{.*}}" "-fsycl-is-device"{{.*}} "-ftarget-prec-div" "-fno-target-prec-sqrt"
2152
// NO_PREC_DIV_SQRT: "-triple" "spir64{{.*}}" "-fsycl-is-device"{{.*}} "-fno-target-prec-div" "-fno-target-prec-sqrt"
53+
// RUN: %clang -c -fsycl -ffp-model=fast -### %s 2>&1 | FileCheck --check-prefix=FAST %s
2254

2355
// WARN-HIGH-DIV: floating point accuracy control 'high' conflicts with explicit target precision option '-fno-target-prec-div'
2456
// WARN-HIGH-SQRT: floating point accuracy control 'high' conflicts with explicit target precision option '-fno-target-prec-sqrt'
2557
// WARN-LOW-DIV: floating point accuracy control 'low' conflicts with explicit target precision option '-fno-target-prec-div'
2658
// WARN-LOW-SQRT: floating point accuracy control 'low' conflicts with explicit target precision option '-fno-target-prec-sqrt'
27-
59+
// FAST: "-triple" "spir64{{.*}}"{{.*}} "-fsycl-is-device"{{.*}} "-fno-target-prec-div" "-fno-target-prec-sqrt"
2860

0 commit comments

Comments
 (0)