Skip to content

Commit 3b240f9

Browse files
committed
apply comment, fix test
Signed-off-by: Sidorov, Dmitry <[email protected]>
1 parent f27ce15 commit 3b240f9

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

clang/test/Driver/sycl-foffload-fp32-prec-div-old-model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
// RUN: -foffload-fp32-prec-div %s 2>&1 \
99
// RUN: | FileCheck -check-prefix=JIT %s
1010

11-
// AOT: "ocloc" "-output"{{.*}} "-options" "-ze-fp32-correctly-rounded-divide-sqrt"
11+
// AOT: "-ze-fp32-correctly-rounded-divide-sqrt"
1212

1313
// JIT: clang-offload-wrapper{{.*}} "-compile-opts={{.*}}-foffload-fp32-prec-div"

clang/test/Driver/sycl-foffload-fp32-prec-sqrt-old-model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
// RUN: -foffload-fp32-prec-sqrt %s 2>&1 \
99
// RUN: | FileCheck -check-prefix=JIT %s
1010

11-
// AOT: "ocloc" "-output"{{.*}} "-options" "-ze-fp32-correctly-rounded-divide-sqrt"
11+
// AOT: "-ze-fp32-correctly-rounded-divide-sqrt"
1212

1313
// JIT: clang-offload-wrapper{{.*}} "-compile-opts={{.*}}-foffload-fp32-prec-sqrt"

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -446,19 +446,15 @@ static void appendCompileOptionsFromImage(std::string &CompileOpts,
446446
CompileOpts = NewCompileOpts;
447447
OptPos = CompileOpts.find(TargetRegisterAllocMode);
448448
}
449-
static const char *FP32PrecDiv = "-foffload-fp32-prec-div";
450-
if (auto Pos = CompileOpts.find(FP32PrecDiv); Pos != std::string::npos) {
451-
const char *BackendOption = nullptr;
452-
PlatformImpl->getBackendOption(FP32PrecDiv, &BackendOption);
453-
auto OptLen = strlen(FP32PrecDiv);
454-
CompileOpts.replace(Pos, OptLen, BackendOption);
455-
}
456-
static const char *FP32PrecSqrt = "-foffload-fp32-prec-sqrt";
457-
if (auto Pos = CompileOpts.find(FP32PrecSqrt); Pos != std::string::npos) {
458-
const char *BackendOption = nullptr;
459-
PlatformImpl->getBackendOption(FP32PrecSqrt, &BackendOption);
460-
auto OptLen = strlen(FP32PrecSqrt);
461-
CompileOpts.replace(Pos, OptLen, BackendOption);
449+
constexpr std::string_view ReplaceOpts[] = {"-foffload-fp32-prec-div",
450+
"-foffload-fp32-prec-sqrt"};
451+
for (const std::string_view Opt : ReplaceOpts) {
452+
if (auto Pos = CompileOpts.find(Opt); Pos != std::string::npos) {
453+
const char *BackendOption = nullptr;
454+
PlatformImpl->getBackendOption(std::string(Opt).c_str(),
455+
&BackendOption);
456+
CompileOpts.replace(Pos, Opt.length(), BackendOption);
457+
}
462458
}
463459
}
464460
}

0 commit comments

Comments
 (0)