Skip to content

Commit cb069fe

Browse files
authored
[SYCL][Driver] Do not customize optimizations for non-SPIR targets (#2799)
All targets other than SPIR should be able to use standard optimization pipeline.
1 parent 8b82c67 commit cb069fe

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4249,7 +4249,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
42494249
options::OPT_fno_sycl_early_optimizations,
42504250
Triple.getSubArch() != llvm::Triple::SPIRSubArch_fpga))
42514251
CmdArgs.push_back("-fno-sycl-early-optimizations");
4252-
else if (IsSYCLDevice) {
4252+
else if (RawTriple.isSPIR()) {
42534253
// Set `sycl-opt` option to configure LLVM passes for SPIR target
42544254
CmdArgs.push_back("-mllvm");
42554255
CmdArgs.push_back("-sycl-opt");
@@ -6184,7 +6184,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
61846184
// selected. For optimization levels that want vectorization we use the alias
61856185
// option to simplify the hasFlag logic.
61866186
bool EnableVec = shouldEnableVectorizerAtOLevel(Args, false);
6187-
if (UseSYCLTriple && EnableSYCLEarlyOptimizations)
6187+
if (UseSYCLTriple && RawTriple.isSPIR() && EnableSYCLEarlyOptimizations)
61886188
EnableVec = false; // But disable vectorization for SYCL device code
61896189
OptSpecifier VectorizeAliasOption =
61906190
EnableVec ? options::OPT_O_Group : options::OPT_fvectorize;
@@ -6194,7 +6194,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
61946194

61956195
// -fslp-vectorize is enabled based on the optimization level selected.
61966196
bool EnableSLPVec = shouldEnableVectorizerAtOLevel(Args, true);
6197-
if (UseSYCLTriple && EnableSYCLEarlyOptimizations)
6197+
if (UseSYCLTriple && RawTriple.isSPIR() && EnableSYCLEarlyOptimizations)
61986198
EnableSLPVec = false; // But disable vectorization for SYCL device code
61996199
OptSpecifier SLPVectAliasOption =
62006200
EnableSLPVec ? options::OPT_O_Group : options::OPT_fslp_vectorize;

clang/test/Driver/sycl-offload-nvptx.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// RUN: -fsycl-libspirv-path=%S/Inputs/SYCL/libspirv.bc %s 2>&1 \
1010
// RUN: | FileCheck -check-prefix=CHK-ACTIONS %s
1111
// CHK-ACTIONS: "-cc1" "-triple" "nvptx64-nvidia-nvcl-sycldevice"{{.*}} "-fsycl-is-device"{{.*}} "-aux-triple" "x86_64-unknown-linux-gnu"{{.*}} "-Wno-sycl-strict" "-sycl-std=2020" {{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libspirv.bc"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libdevice{{.*}}.10.bc"{{.*}} "-target-feature" "+ptx42"{{.*}} "-target-sdk-version=[[CUDA_VERSION:[0-9.]+]]"{{.*}} "-target-cpu" "sm_50"{{.*}} "-std=c++11"{{.*}}
12+
// CHK-ACTIONS-NOT: "-mllvm -sycl-opt"
1213
// CHK-ACTIONS: clang-offload-wrapper"{{.*}} "-host=x86_64-unknown-linux-gnu" "-target=nvptx64" "-kind=sycl"{{.*}}
1314
// CHK-ACTIONS: "-cc1" "-triple" "nvptx64-nvidia-nvcl-sycldevice"{{.*}} "-fsycl-is-device"{{.*}} "-aux-triple" "x86_64-unknown-linux-gnu"{{.*}} "-Wno-sycl-strict" "-sycl-std=2020" {{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libspirv.bc"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libdevice{{.*}}.10.bc"{{.*}} "-target-feature" "+ptx42"{{.*}} "-target-sdk-version=[[CUDA_VERSION]]"{{.*}} "-target-cpu" "sm_50"{{.*}} "-std=c++11"{{.*}}
1415

0 commit comments

Comments
 (0)