Skip to content

[SYCL] Adjust GCC workaround and its scope #13144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions sycl/source/builtins/relational_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,36 @@ REL_BUILTIN(ONE_ARG, isnormal)
REL_BUILTIN(TWO_ARGS, isunordered)
REL_BUILTIN_CUSTOM(TWO_ARGS, isordered,
([](auto x, auto y) { return !sycl::isunordered(x, y); }))
#if defined(__GNUC__) && !defined(__clang__)

#define _SYCL_BUILTINS_GCC_VER \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)

#if defined(__GNUC__) && !defined(__clang__) && \
((_SYCL_BUILTINS_GCC_VER >= 100000 && _SYCL_BUILTINS_GCC_VER < 110000) || \
(_SYCL_BUILTINS_GCC_VER >= 110000 && _SYCL_BUILTINS_GCC_VER < 110500) || \
(_SYCL_BUILTINS_GCC_VER >= 120000 && _SYCL_BUILTINS_GCC_VER < 120400) || \
(_SYCL_BUILTINS_GCC_VER >= 130000 && _SYCL_BUILTINS_GCC_VER < 130300))
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112816
#pragma GCC push_options
#pragma GCC optimize("-O2")
// The reproducers in that ticket only affect GCCs 10 to 13. Release
// branches 11.5, 12.4, and 13.3 have been updated with the fix; release branch
// 10 hasn't, so all GCCs 10.x are considered affected.
#define GCC_PR112816_DISABLE_OPT \
_Pragma("GCC push_options") _Pragma("GCC optimize(\"-O1\")")
#define GCC_PR112816_RESTORE_OPT _Pragma("GCC pop_options")
#else
#define GCC_PR112816_DISABLE_OPT
#define GCC_PR112816_RESTORE_OPT
#endif

GCC_PR112816_DISABLE_OPT

REL_BUILTIN(ONE_ARG, signbit)

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC pop_options
#endif
GCC_PR112816_RESTORE_OPT

#undef GCC_PR112816_RESTORE_OPT
#undef GCC_PR112816_DISABLE_OPT
#undef _SYCL_BUILTINS_GCC_VER

HOST_IMPL(bitselect, [](auto x, auto y, auto z) {
using T0 = decltype(x);
Expand Down