From 5003692fbb29c8140f4c9c46a814ab7d670b26a3 Mon Sep 17 00:00:00 2001 From: "Hu, Lin1" Date: Wed, 27 Aug 2025 14:17:43 +0800 Subject: [PATCH] [Sync] Sync patches from openeuler/gcc i386: Remove CLDEMOTE for clients c++: signed __int128_t [PR108099] c++: fix 'unsigned __int128_t' semantics [PR108099] testsuite: Fix up g++.dg/ext/int128-8.C testcase [PR109560] c++: fix 'unsigned typedef-name' extension [PR108099] --- 0398-i386-Remove-CLDEMOTE-for-clients.patch | 54 ++++++ 0399-c-signed-__int128_t-PR108099.patch | 59 ++++++ ...signed-__int128_t-semantics-PR108099.patch | 78 ++++++++ ...-g-.dg-ext-int128-8.C-testcase-PR109.patch | 34 ++++ ...gned-typedef-name-extension-PR108099.patch | 172 ++++++++++++++++++ gcc.spec | 16 +- 6 files changed, 412 insertions(+), 1 deletion(-) create mode 100644 0398-i386-Remove-CLDEMOTE-for-clients.patch create mode 100644 0399-c-signed-__int128_t-PR108099.patch create mode 100644 0400-c-fix-unsigned-__int128_t-semantics-PR108099.patch create mode 100644 0401-testsuite-Fix-up-g-.dg-ext-int128-8.C-testcase-PR109.patch create mode 100644 0402-c-fix-unsigned-typedef-name-extension-PR108099.patch diff --git a/0398-i386-Remove-CLDEMOTE-for-clients.patch b/0398-i386-Remove-CLDEMOTE-for-clients.patch new file mode 100644 index 0000000..2c7cc95 --- /dev/null +++ b/0398-i386-Remove-CLDEMOTE-for-clients.patch @@ -0,0 +1,54 @@ +From 5eb102d763159435648ba4b80d39ff6f3368e68d Mon Sep 17 00:00:00 2001 +From: Haochen Jiang +Date: Wed, 25 Jun 2025 11:04:11 +0800 +Subject: [PATCH] i386: Remove CLDEMOTE for clients + +CLDEMOTE is not enabled on clients according to SDM. SDM only mentioned +it will be enabled on Xeon and Atom servers, not clients. Remove them +since Alder Lake (where it is introduced). + +gcc/ChangeLog: + + * config/i386/i386.h (PTA_ALDERLAKE): Use PTA_GOLDMONT_PLUS + as base to remove PTA_CLDEMOTE. + * doc/invoke.texi: Update texi file. + +(cherry picked from commit ee04d1554aa87d6155bd96e38c91351871273b51) +--- + gcc/config/i386/i386.h | 3 ++- + gcc/doc/invoke.texi | 5 ++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h +index 4bcbcc781d6..cef05da3905 100644 +--- a/gcc/config/i386/i386.h ++++ b/gcc/config/i386/i386.h +@@ -2357,7 +2357,8 @@ constexpr wide_int_bitmask PTA_GOLDMONT_PLUS = PTA_GOLDMONT | PTA_RDPID + | PTA_SGX | PTA_PTWRITE; + constexpr wide_int_bitmask PTA_TREMONT = PTA_GOLDMONT_PLUS | PTA_CLWB + | PTA_GFNI | PTA_MOVDIRI | PTA_MOVDIR64B | PTA_CLDEMOTE | PTA_WAITPKG; +-constexpr wide_int_bitmask PTA_ALDERLAKE = PTA_TREMONT | PTA_ADX | PTA_AVX ++constexpr wide_int_bitmask PTA_ALDERLAKE = PTA_GOLDMONT_PLUS | PTA_CLWB ++ | PTA_GFNI | PTA_MOVDIRI | PTA_MOVDIR64B | PTA_WAITPKG | PTA_ADX | PTA_AVX + | PTA_AVX2 | PTA_BMI | PTA_BMI2 | PTA_F16C | PTA_FMA | PTA_LZCNT + | PTA_PCONFIG | PTA_PKU | PTA_VAES | PTA_VPCLMULQDQ | PTA_SERIALIZE + | PTA_HRESET | PTA_KL | PTA_WIDEKL | PTA_AVXVNNI; +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 3f20cd3b449..f1f0d7057cc 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -31551,9 +31551,8 @@ VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. + Intel Alder Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, + SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES, + XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, +-CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU, +-VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set +-support. ++WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU, VAES, ++VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set support. + + @item sapphirerapids + Intel Sapphire Rapids CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, +-- +2.31.1 + diff --git a/0399-c-signed-__int128_t-PR108099.patch b/0399-c-signed-__int128_t-PR108099.patch new file mode 100644 index 0000000..6cb1993 --- /dev/null +++ b/0399-c-signed-__int128_t-PR108099.patch @@ -0,0 +1,59 @@ +From 9b24448ca8804b5bb99ef6eeba942f80663fca89 Mon Sep 17 00:00:00 2001 +From: Jason Merrill +Date: Thu, 9 Mar 2023 17:35:24 -0500 +Subject: [PATCH 1/4] c++: signed __int128_t [PR108099] + +The code for handling signed + typedef was breaking on __int128_t, because +it isn't a proper typedef: it doesn't have DECL_ORIGINAL_TYPE. + + PR c++/108099 + +gcc/cp/ChangeLog: + + * decl.cc (grokdeclarator): Handle non-typedef typedef_decl. + +gcc/testsuite/ChangeLog: + + * g++.dg/ext/int128-7.C: New test. +--- + gcc/cp/decl.cc | 11 ++++++++--- + gcc/testsuite/g++.dg/ext/int128-7.C | 4 ++++ + 2 files changed, 12 insertions(+), 3 deletions(-) + create mode 100644 gcc/testsuite/g++.dg/ext/int128-7.C + +diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc +index ab9a009fb7e..cbb9f20b7a4 100644 +--- a/gcc/cp/decl.cc ++++ b/gcc/cp/decl.cc +@@ -12300,10 +12300,15 @@ grokdeclarator (const cp_declarator *declarator, + { + if (typedef_decl) + { +- pedwarn (loc, OPT_Wpedantic, "%qs specified with %qT", +- key, type); ++ pedwarn (loc, OPT_Wpedantic, "%qs specified with %qD", ++ key, typedef_decl); + ok = !flag_pedantic_errors; +- type = DECL_ORIGINAL_TYPE (typedef_decl); ++ if (is_typedef_decl (typedef_decl)) ++ type = DECL_ORIGINAL_TYPE (typedef_decl); ++ else ++ /* PR108099: __int128_t comes from c_common_nodes_and_builtins, ++ and is not built as a typedef. */ ++ type = TREE_TYPE (typedef_decl); + typedef_decl = NULL_TREE; + } + else if (declspecs->decltype_p) +diff --git a/gcc/testsuite/g++.dg/ext/int128-7.C b/gcc/testsuite/g++.dg/ext/int128-7.C +new file mode 100644 +index 00000000000..bf5e8c40a4b +--- /dev/null ++++ b/gcc/testsuite/g++.dg/ext/int128-7.C +@@ -0,0 +1,4 @@ ++// PR c++/108099 ++// { dg-do compile { target { c++11 && int128 } } } ++ ++using i128 = signed __int128_t; // { dg-error "specified with" } +-- +2.31.1 + diff --git a/0400-c-fix-unsigned-__int128_t-semantics-PR108099.patch b/0400-c-fix-unsigned-__int128_t-semantics-PR108099.patch new file mode 100644 index 0000000..332084c --- /dev/null +++ b/0400-c-fix-unsigned-__int128_t-semantics-PR108099.patch @@ -0,0 +1,78 @@ +From 1b6cbcd4ee3d8f4cf9b6e589032d08f0b3a3db42 Mon Sep 17 00:00:00 2001 +From: Jason Merrill +Date: Tue, 18 Apr 2023 17:12:17 -0400 +Subject: [PATCH 2/4] c++: fix 'unsigned __int128_t' semantics [PR108099] + +My earlier patch for 108099 made us accept this non-standard pattern but +messed up the semantics, so that e.g. unsigned __int128_t was not a 128-bit +type. + + PR c++/108099 + +gcc/cp/ChangeLog: + + * decl.cc (grokdeclarator): Keep typedef_decl for __int128_t. + +gcc/testsuite/ChangeLog: + + * g++.dg/ext/int128-8.C: New test. +--- + gcc/cp/decl.cc | 6 ++++-- + gcc/testsuite/g++.dg/ext/int128-8.C | 24 ++++++++++++++++++++++++ + 2 files changed, 28 insertions(+), 2 deletions(-) + create mode 100644 gcc/testsuite/g++.dg/ext/int128-8.C + +diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc +index cbb9f20b7a4..f514377dd42 100644 +--- a/gcc/cp/decl.cc ++++ b/gcc/cp/decl.cc +@@ -12304,12 +12304,14 @@ grokdeclarator (const cp_declarator *declarator, + key, typedef_decl); + ok = !flag_pedantic_errors; + if (is_typedef_decl (typedef_decl)) +- type = DECL_ORIGINAL_TYPE (typedef_decl); ++ { ++ type = DECL_ORIGINAL_TYPE (typedef_decl); ++ typedef_decl = NULL_TREE; ++ } + else + /* PR108099: __int128_t comes from c_common_nodes_and_builtins, + and is not built as a typedef. */ + type = TREE_TYPE (typedef_decl); +- typedef_decl = NULL_TREE; + } + else if (declspecs->decltype_p) + error_at (loc, "%qs specified with %", key); +diff --git a/gcc/testsuite/g++.dg/ext/int128-8.C b/gcc/testsuite/g++.dg/ext/int128-8.C +new file mode 100644 +index 00000000000..14bbc49f5c3 +--- /dev/null ++++ b/gcc/testsuite/g++.dg/ext/int128-8.C +@@ -0,0 +1,24 @@ ++// PR c++/108099 ++// { dg-do compile { target c++11 } } ++// { dg-options "" } ++ ++using u128 = unsigned __int128_t; ++using s128 = signed __int128_t; ++template struct integral_constant { ++ static constexpr T value = v; ++}; ++typedef integral_constant false_type; ++typedef integral_constant true_type; ++template ++struct is_same : false_type {}; ++template ++struct is_same : true_type {}; ++static_assert (is_same <__int128, s128>::value, ""); ++static_assert (is_same ::value, ""); ++static_assert (is_same <__int128_t, s128>::value, ""); ++static_assert (is_same ::value, ""); // { dg-bogus "" "" { xfail *-*-* } } ++static_assert (is_same <__uint128_t, u128>::value, ""); // { dg-bogus "" "" { xfail *-*-* } } ++static_assert (sizeof (s128) == sizeof (__int128), ""); ++static_assert (sizeof (u128) == sizeof (unsigned __int128), ""); ++static_assert (s128(-1) < 0, ""); ++static_assert (u128(-1) > 0, ""); +-- +2.31.1 + diff --git a/0401-testsuite-Fix-up-g-.dg-ext-int128-8.C-testcase-PR109.patch b/0401-testsuite-Fix-up-g-.dg-ext-int128-8.C-testcase-PR109.patch new file mode 100644 index 0000000..ff393dd --- /dev/null +++ b/0401-testsuite-Fix-up-g-.dg-ext-int128-8.C-testcase-PR109.patch @@ -0,0 +1,34 @@ +From 947b0828d5cb48939b044d2ed12679fe2890daba Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek +Date: Thu, 20 Apr 2023 09:43:04 +0200 +Subject: [PATCH 3/4] testsuite: Fix up g++.dg/ext/int128-8.C testcase + [PR109560] + +The testcase needs to be restricted to int128 effective targets, +it expectedly fails on i386 and other 32-bit targets. + +2023-04-20 Jakub Jelinek + + PR c++/108099 + PR testsuite/109560 + * g++.dg/ext/int128-8.C: Require int128 effective target. + +(cherry picked from commit bd4a1a547242a924663712ac7a13799433cdf476) +--- + gcc/testsuite/g++.dg/ext/int128-8.C | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/testsuite/g++.dg/ext/int128-8.C b/gcc/testsuite/g++.dg/ext/int128-8.C +index 14bbc49f5c3..7e909d50873 100644 +--- a/gcc/testsuite/g++.dg/ext/int128-8.C ++++ b/gcc/testsuite/g++.dg/ext/int128-8.C +@@ -1,5 +1,5 @@ + // PR c++/108099 +-// { dg-do compile { target c++11 } } ++// { dg-do compile { target { c++11 && int128 } } } + // { dg-options "" } + + using u128 = unsigned __int128_t; +-- +2.31.1 + diff --git a/0402-c-fix-unsigned-typedef-name-extension-PR108099.patch b/0402-c-fix-unsigned-typedef-name-extension-PR108099.patch new file mode 100644 index 0000000..0a48f1d --- /dev/null +++ b/0402-c-fix-unsigned-typedef-name-extension-PR108099.patch @@ -0,0 +1,172 @@ +From bd9fecc1fb91f9cfab1d7d5869fab9e9a828c6bd Mon Sep 17 00:00:00 2001 +From: Jason Merrill +Date: Tue, 18 Apr 2023 21:32:07 -0400 +Subject: [PATCH 4/4] c++: fix 'unsigned typedef-name' extension [PR108099] + +In the comments for PR108099 Jakub provided some testcases that demonstrated +that even before the regression noted in the patch we were getting the +semantics of this extension wrong: in the unsigned case we weren't producing +the corresponding standard unsigned type but another distinct one of the +same size, and in the signed case we were just dropping it on the floor and +not actually returning a signed type at all. + +The former issue is fixed by using c_common_signed_or_unsigned_type instead +of unsigned_type_for, and the latter issue by adding a (signed_p && +typedef_decl) case. + +This patch introduces a failure on std/ranges/iota/max_size_type.cc due to +the latter issue, since the testcase expects 'signed rep_t' to do something +sensible, and previously we didn't. Now that we do, it exposes a bug in the +__max_diff_type::operator>>= handling of sign extension: when we evaluate +-1000 >> 2 in __max_diff_type we keep the MSB set, but leave the +second-most-significant bit cleared. + + PR c++/108099 + +gcc/cp/ChangeLog: + + * decl.cc (grokdeclarator): Don't clear typedef_decl after 'unsigned + typedef' pedwarn. Use c_common_signed_or_unsigned_type. Also + handle 'signed typedef'. + +gcc/testsuite/ChangeLog: + + * g++.dg/ext/int128-7.C: New test. + * g++.dg/ext/int128-8.C: New test. + * g++.dg/ext/unsigned-typedef2.C: New test. + * g++.dg/ext/unsigned-typedef3.C: New test. +--- + gcc/cp/decl.cc | 18 +++++++------- + gcc/testsuite/g++.dg/ext/int128-8.C | 4 ++-- + gcc/testsuite/g++.dg/ext/unsigned-typedef2.C | 25 ++++++++++++++++++++ + gcc/testsuite/g++.dg/ext/unsigned-typedef3.C | 25 ++++++++++++++++++++ + 4 files changed, 60 insertions(+), 12 deletions(-) + create mode 100644 gcc/testsuite/g++.dg/ext/unsigned-typedef2.C + create mode 100644 gcc/testsuite/g++.dg/ext/unsigned-typedef3.C + +diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc +index f514377dd42..5876394247a 100644 +--- a/gcc/cp/decl.cc ++++ b/gcc/cp/decl.cc +@@ -12300,18 +12300,14 @@ grokdeclarator (const cp_declarator *declarator, + { + if (typedef_decl) + { +- pedwarn (loc, OPT_Wpedantic, "%qs specified with %qD", ++ pedwarn (loc, OPT_Wpedantic, ++ "%qs specified with typedef-name %qD", + key, typedef_decl); + ok = !flag_pedantic_errors; ++ /* PR108099: __int128_t comes from c_common_nodes_and_builtins, ++ and is not built as a typedef. */ + if (is_typedef_decl (typedef_decl)) +- { +- type = DECL_ORIGINAL_TYPE (typedef_decl); +- typedef_decl = NULL_TREE; +- } +- else +- /* PR108099: __int128_t comes from c_common_nodes_and_builtins, +- and is not built as a typedef. */ +- type = TREE_TYPE (typedef_decl); ++ type = DECL_ORIGINAL_TYPE (typedef_decl); + } + else if (declspecs->decltype_p) + error_at (loc, "%qs specified with %", key); +@@ -12364,7 +12360,7 @@ grokdeclarator (const cp_declarator *declarator, + else if (type == char_type_node) + type = unsigned_char_type_node; + else if (typedef_decl) +- type = unsigned_type_for (type); ++ type = c_common_unsigned_type (type); + else + type = unsigned_type_node; + } +@@ -12378,6 +12374,8 @@ grokdeclarator (const cp_declarator *declarator, + type = long_integer_type_node; + else if (short_p) + type = short_integer_type_node; ++ else if (signed_p && typedef_decl) ++ type = c_common_signed_type (type); + + if (decl_spec_seq_has_spec_p (declspecs, ds_complex)) + { +diff --git a/gcc/testsuite/g++.dg/ext/int128-8.C b/gcc/testsuite/g++.dg/ext/int128-8.C +index 7e909d50873..07535a9820e 100644 +--- a/gcc/testsuite/g++.dg/ext/int128-8.C ++++ b/gcc/testsuite/g++.dg/ext/int128-8.C +@@ -16,8 +16,8 @@ struct is_same : true_type {}; + static_assert (is_same <__int128, s128>::value, ""); + static_assert (is_same ::value, ""); + static_assert (is_same <__int128_t, s128>::value, ""); +-static_assert (is_same ::value, ""); // { dg-bogus "" "" { xfail *-*-* } } +-static_assert (is_same <__uint128_t, u128>::value, ""); // { dg-bogus "" "" { xfail *-*-* } } ++static_assert (is_same ::value, ""); ++static_assert (is_same <__uint128_t, u128>::value, ""); + static_assert (sizeof (s128) == sizeof (__int128), ""); + static_assert (sizeof (u128) == sizeof (unsigned __int128), ""); + static_assert (s128(-1) < 0, ""); +diff --git a/gcc/testsuite/g++.dg/ext/unsigned-typedef2.C b/gcc/testsuite/g++.dg/ext/unsigned-typedef2.C +new file mode 100644 +index 00000000000..936c0ccb748 +--- /dev/null ++++ b/gcc/testsuite/g++.dg/ext/unsigned-typedef2.C +@@ -0,0 +1,25 @@ ++// PR c++/108099 ++// { dg-do compile { target c++11 } } ++// { dg-options "" } ++ ++typedef long long t64; ++template struct integral_constant { ++ static constexpr T value = v; ++}; ++typedef integral_constant false_type; ++typedef integral_constant true_type; ++template ++struct is_same : false_type {}; ++template ++struct is_same : true_type {}; ++ ++using s64 = signed t64; ++static_assert (is_same ::value, ""); ++static_assert (is_same ::value, ""); ++static_assert (sizeof (s64) == sizeof (long long), ""); ++static_assert (s64(-1) < 0, ""); ++ ++using u64 = unsigned t64; ++static_assert (is_same ::value, ""); ++static_assert (sizeof (u64) == sizeof (unsigned long long), ""); ++static_assert (u64(-1) > 0, ""); +diff --git a/gcc/testsuite/g++.dg/ext/unsigned-typedef3.C b/gcc/testsuite/g++.dg/ext/unsigned-typedef3.C +new file mode 100644 +index 00000000000..bb99ca0ccc9 +--- /dev/null ++++ b/gcc/testsuite/g++.dg/ext/unsigned-typedef3.C +@@ -0,0 +1,25 @@ ++// PR c++/108099 ++// { dg-do compile { target c++11 } } ++// { dg-options "" } ++ ++typedef unsigned long long t64; ++template struct integral_constant { ++ static constexpr T value = v; ++}; ++typedef integral_constant false_type; ++typedef integral_constant true_type; ++template ++struct is_same : false_type {}; ++template ++struct is_same : true_type {}; ++ ++using s64 = signed t64; ++static_assert (is_same ::value, ""); ++static_assert (is_same ::value, ""); ++static_assert (sizeof (s64) == sizeof (long long), ""); ++static_assert (s64(-1) < 0, ""); ++ ++using u64 = unsigned t64; ++static_assert (is_same ::value, ""); ++static_assert (sizeof (u64) == sizeof (unsigned long long), ""); ++static_assert (u64(-1) > 0, ""); +-- +2.31.1 + diff --git a/gcc.spec b/gcc.spec index f424b3d..9da07ba 100644 --- a/gcc.spec +++ b/gcc.spec @@ -2,7 +2,7 @@ %global gcc_major 12 # Note, gcc_release must be integer, if you want to add suffixes to # %%{release}, append them after %%{gcc_release} on Release: line. -%global gcc_release 98 +%global gcc_release 99 %global _unpackaged_files_terminate_build 0 %global _performance_build 1 @@ -507,6 +507,11 @@ Patch394: 0394-SVE-Add-SVE-constraint.patch Patch395: 0395-update-ai-model.patch Patch396: 0396-Add-pattern-for-cmlt-and-change-hip12.patch Patch397: 0397-SVE-Fix-cross-compile-error.patch +Patch398: 0398-i386-Remove-CLDEMOTE-for-clients.patch +Patch399: 0399-c-signed-__int128_t-PR108099.patch +Patch400: 0400-c-fix-unsigned-__int128_t-semantics-PR108099.patch +Patch401: 0401-testsuite-Fix-up-g-.dg-ext-int128-8.C-testcase-PR109.patch +Patch402: 0402-c-fix-unsigned-typedef-name-extension-PR108099.patch # Part 1001-1999 %ifarch sw_64 @@ -1690,6 +1695,11 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch -P395 -p1 %patch -P396 -p1 %patch -P397 -p1 +%patch -P398 -p1 +%patch -P399 -p1 +%patch -P400 -p1 +%patch -P401 -p1 +%patch -P402 -p1 %ifarch sw_64 %patch -P1001 -p1 @@ -4317,6 +4327,10 @@ end %doc rpm.doc/changelogs/libcc1/ChangeLog* %changelog +* Wed Aug 27 2025 Hu,Lin1 - 12.3.1-99 +- Type: Sync +- DESC: Sync patch from openeuler/gcc. + * Mon Sep 1 2025 zhangjingwang - 12.3.1-98 - Type: Sync - DESC: Sync patches from openeuler/gcc. -- Gitee