@@ -6383,46 +6383,42 @@ class OffloadingActionBuilder final {
63836383 ToolChains, [&](auto &TC) { return TT == TC->getTriple (); });
63846384 assert (TCIt != ToolChains.end () &&
63856385 " Toolchain was not created for this platform" );
6386- if (!TT.isNVPTX () && !TT.isAMDGCN ()) {
6387- // When users specify the target as 'intel_gpu_*', the proper
6388- // triple is 'spir64_gen'. The given string from intel_gpu_*
6389- // is the target device.
6390- if (TT.isSPIR () &&
6391- TT.getSubArch () == llvm::Triple::SPIRSubArch_gen) {
6392- // Multiple spir64_gen targets are allowed to be used via the
6393- // -fsycl-targets=spir64_gen and -fsycl-targets=intel_gpu_*
6394- // specifiers. Using an index through the known GpuArchList
6395- // values, increment through them accordingly to allow for
6396- // the multiple settings as well as preventing re-use.
6397- while (TT != GpuArchList[GenIndex].first &&
6398- GenIndex < GpuArchList.size ())
6399- ++GenIndex;
6400- if (GpuArchList[GenIndex].first != TT)
6401- // No match.
6402- continue ;
6403- StringRef Device (GpuArchList[GenIndex].second );
6404- SYCLTargetInfoList.emplace_back (
6405- *TCIt, Device.empty () ? nullptr : Device.data ());
6406- ++GenIndex;
6407- continue ;
6408- }
6409- SYCLTargetInfoList.emplace_back (*TCIt, nullptr );
6410- } else {
6411- const char *OffloadArch = nullptr ;
6386+ if (TT.isNVPTX () || TT.isAMDGCN ()) {
64126387 for (auto &TargetTripleArchPair : GpuArchList) {
64136388 if (TT == TargetTripleArchPair.first ) {
6414- OffloadArch = TargetTripleArchPair.second ;
6415- // Add an arch to the SYCLTargetInfoList
6416- // only if it is not already present in the list.
6417- auto Arch = llvm::find_if (
6418- SYCLTargetInfoList, [&](auto &DeviceTargetInfo) {
6419- return OffloadArch == DeviceTargetInfo.BoundArch ;
6420- });
6421-
6422- if (Arch == SYCLTargetInfoList.end ())
6389+ const char *OffloadArch = TargetTripleArchPair.second ;
6390+ // Add an arch to the SYCLTargetInfoList only if it is not
6391+ // already present in the list.
6392+ if (llvm::none_of (
6393+ SYCLTargetInfoList, [&](auto &DeviceTargetInfo) {
6394+ return OffloadArch == DeviceTargetInfo.BoundArch ;
6395+ }))
64236396 SYCLTargetInfoList.emplace_back (*TCIt, OffloadArch);
64246397 }
64256398 }
6399+ } else if (TT.isSPIR () &&
6400+ TT.getSubArch () == llvm::Triple::SPIRSubArch_gen) {
6401+ // When users specify the target as 'intel_gpu_*', the proper
6402+ // triple is 'spir64_gen'. The given string from intel_gpu_* is
6403+ // the target device.
6404+
6405+ // Multiple spir64_gen targets are allowed to be used via the
6406+ // -fsycl-targets=spir64_gen and -fsycl-targets=intel_gpu_*
6407+ // specifiers. Using an index through the known GpuArchList
6408+ // values, increment through them accordingly to allow for the
6409+ // multiple settings as well as preventing re-use.
6410+ while (TT != GpuArchList[GenIndex].first &&
6411+ GenIndex < GpuArchList.size ())
6412+ ++GenIndex;
6413+ if (GpuArchList[GenIndex].first != TT)
6414+ // No match.
6415+ continue ;
6416+ StringRef Device (GpuArchList[GenIndex].second );
6417+ SYCLTargetInfoList.emplace_back (
6418+ *TCIt, Device.empty () ? nullptr : Device.data ());
6419+ ++GenIndex;
6420+ } else {
6421+ SYCLTargetInfoList.emplace_back (*TCIt, nullptr );
64266422 }
64276423 }
64286424 } else if (HasValidSYCLRuntime) {
0 commit comments