* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-09-07 22:42 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-09-07 22:42 UTC (permalink / raw
To: gentoo-commits
commit: 023edc6a713f1e901baf37b8a94cb794eb63b7eb
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 7 22:42:05 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Sep 7 22:42:05 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=023edc6a
16.0.0: cut patchset 14
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/README.history | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 5b19927..3a58f30 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,4 +1,4 @@
-14 ????
+14 7 September 2025
- 91_all_PR121699-mesa.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-09-17 18:41 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-09-17 18:41 UTC (permalink / raw
To: gentoo-commits
commit: 9ce7a56d3f95fb805601d2f9630f2ae311f323fa
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 17 18:40:51 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Sep 17 18:40:58 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=9ce7a56d
16.0.0: drop upstream patches
Signed-off-by: Sam James <sam <AT> gentoo.org>
.../87_all_PR121962-forwprop-hang-prereq.patch | 244 ---------------------
16.0.0/gentoo/88_all_PR121962-forwprop-hang.patch | 161 --------------
16.0.0/gentoo/README.history | 5 -
3 files changed, 410 deletions(-)
diff --git a/16.0.0/gentoo/87_all_PR121962-forwprop-hang-prereq.patch b/16.0.0/gentoo/87_all_PR121962-forwprop-hang-prereq.patch
deleted file mode 100644
index 245a78b..0000000
--- a/16.0.0/gentoo/87_all_PR121962-forwprop-hang-prereq.patch
+++ /dev/null
@@ -1,244 +0,0 @@
-From 41dc015782a42cb64680a55f6766ed5504c4ca53 Mon Sep 17 00:00:00 2001
-Message-ID: <41dc015782a42cb64680a55f6766ed5504c4ca53.1758078219.git.sam@gentoo.org>
-From: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
-Date: Mon, 15 Sep 2025 10:19:13 -0700
-Subject: [PATCH] forwprop: Handle memcpy for arguments with respect to copies
-
-This moves the code used in optimize_agr_copyprop_1 (r16-3887-g597b50abb0d)
-to handle this same case into its new function and use it inside
-optimize_agr_copyprop_arg. This allows to remove more copies that show up only
-in arguments.
-
-Bootstrapped and tested on x86_64-linux-gnu.
-
-gcc/ChangeLog:
-
- * tree-ssa-forwprop.cc (optimize_agr_copyprop_1): Split out
- the case where `operand_equal_p (dest, src2)` is false into ...
- (new_src_based_on_copy): This. New function.
- (optimize_agr_copyprop_arg): Use new_src_based_on_copy
- instead of operand_equal_p to find the new src.
-
-gcc/testsuite/ChangeLog:
-
- * gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c: New test.
-
-Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
----
- .../tree-ssa/copy-prop-aggregate-arg-2.c | 33 +++++
- gcc/tree-ssa-forwprop.cc | 135 ++++++++++--------
- 2 files changed, 106 insertions(+), 62 deletions(-)
- create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c
-
-diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c
-new file mode 100644
-index 000000000000..11f0768c1112
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c
-@@ -0,0 +1,33 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O1 -fdump-tree-forwprop1-details -fdump-tree-optimized" } */
-+
-+
-+struct s1
-+{
-+ int t[1024];
-+};
-+
-+struct s2 {
-+ struct s1 t;
-+};
-+
-+struct s3
-+{
-+ struct s2 t;
-+};
-+
-+void g(struct s3);
-+
-+void f(struct s1 s)
-+{
-+ struct s2 removeme;
-+ removeme.t = s;
-+ struct s3 removeme2;
-+ removeme2.t = removeme;
-+ g(removeme2);
-+}
-+
-+
-+/* { dg-final { scan-tree-dump-times "after previous" 2 "forwprop1" } } */
-+/* { dg-final { scan-tree-dump-not "removeme " "optimized" } } */
-+/* { dg-final { scan-tree-dump-not "removeme2 " "optimized" } } */
-diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
-index 1eacff01587c..f58a7b8c591d 100644
---- a/gcc/tree-ssa-forwprop.cc
-+++ b/gcc/tree-ssa-forwprop.cc
-@@ -1458,6 +1458,72 @@ split_core_and_offset_size (tree expr,
- return core;
- }
-
-+/* Returns a new src based on the
-+ copy `DEST = SRC` and for the old SRC2.
-+ Returns null if SRC2 is not related to DEST. */
-+
-+static tree
-+new_src_based_on_copy (tree src2, tree dest, tree src)
-+{
-+ /* If the second src is not exactly the same as dest,
-+ try to handle it seperately; see it is address/size equivalent.
-+ Handles `a` and `a.b` and `MEM<char[N]>(&a)` which all have
-+ the same size and offsets as address/size equivalent.
-+ This allows copying over a memcpy and also one for copying
-+ where one field is the same size as the whole struct. */
-+ if (operand_equal_p (dest, src2))
-+ return src;
-+ /* A VCE can't be used with imag/real or BFR so reject them early. */
-+ if (TREE_CODE (src) == IMAGPART_EXPR
-+ || TREE_CODE (src) == REALPART_EXPR
-+ || TREE_CODE (src) == BIT_FIELD_REF)
-+ return NULL_TREE;
-+ tree core1, core2;
-+ poly_int64 bytepos1, bytepos2;
-+ poly_int64 bytesize1, bytesize2;
-+ tree toffset1, toffset2;
-+ int reversep1 = 0;
-+ int reversep2 = 0;
-+ poly_int64 diff = 0;
-+ core1 = split_core_and_offset_size (dest, &bytesize1, &bytepos1,
-+ &toffset1, &reversep1);
-+ core2 = split_core_and_offset_size (src2, &bytesize2, &bytepos2,
-+ &toffset2, &reversep2);
-+ if (!core1 || !core2)
-+ return NULL_TREE;
-+ if (reversep1 != reversep2)
-+ return NULL_TREE;
-+ /* The sizes of the 2 accesses need to be the same. */
-+ if (!known_eq (bytesize1, bytesize2))
-+ return NULL_TREE;
-+ if (!operand_equal_p (core1, core2, 0))
-+ return NULL_TREE;
-+
-+ if (toffset1 && toffset2)
-+ {
-+ tree type = TREE_TYPE (toffset1);
-+ if (type != TREE_TYPE (toffset2))
-+ toffset2 = fold_convert (type, toffset2);
-+
-+ tree tdiff = fold_build2 (MINUS_EXPR, type, toffset1, toffset2);
-+ if (!cst_and_fits_in_hwi (tdiff))
-+ return NULL_TREE;
-+
-+ diff = int_cst_value (tdiff);
-+ }
-+ else if (toffset1 || toffset2)
-+ {
-+ /* If only one of the offsets is non-constant, the difference cannot
-+ be a constant. */
-+ return NULL_TREE;
-+ }
-+ diff += bytepos1 - bytepos2;
-+ /* The offset between the 2 need to be 0. */
-+ if (!known_eq (diff, 0))
-+ return NULL_TREE;
-+ return fold_build1 (VIEW_CONVERT_EXPR,TREE_TYPE (src2), src);
-+}
-+
- /* Helper function for optimize_agr_copyprop.
- For aggregate copies in USE_STMT, see if DEST
- is on the lhs of USE_STMT and replace it with SRC. */
-@@ -1474,66 +1540,9 @@ optimize_agr_copyprop_1 (gimple *stmt, gimple *use_stmt,
- /* If the new store is `src2 = src2;` skip over it. */
- if (operand_equal_p (src2, dest2, 0))
- return false;
-- /* If the second src is not exactly the same as dest,
-- try to handle it seperately; see it is address/size equivalent.
-- Handles `a` and `a.b` and `MEM<char[N]>(&a)` which all have
-- the same size and offsets as address/size equivalent.
-- This allows copying over a memcpy and also one for copying
-- where one field is the same size as the whole struct. */
-- if (!operand_equal_p (dest, src2, 0))
-- {
-- /* A VCE can't be used with imag/real or BFR so reject them early. */
-- if (TREE_CODE (src) == IMAGPART_EXPR
-- || TREE_CODE (src) == REALPART_EXPR
-- || TREE_CODE (src) == BIT_FIELD_REF)
-- return false;
-- tree core1, core2;
-- poly_int64 bytepos1, bytepos2;
-- poly_int64 bytesize1, bytesize2;
-- tree toffset1, toffset2;
-- int reversep1 = 0;
-- int reversep2 = 0;
-- poly_int64 diff = 0;
-- core1 = split_core_and_offset_size (dest, &bytesize1, &bytepos1,
-- &toffset1, &reversep1);
-- core2 = split_core_and_offset_size (src2, &bytesize2, &bytepos2,
-- &toffset2, &reversep2);
-- if (!core1 || !core2)
-- return false;
-- if (reversep1 != reversep2)
-- return false;
-- /* The sizes of the 2 accesses need to be the same. */
-- if (!known_eq (bytesize1, bytesize2))
-- return false;
-- if (!operand_equal_p (core1, core2, 0))
-- return false;
--
-- if (toffset1 && toffset2)
-- {
-- tree type = TREE_TYPE (toffset1);
-- if (type != TREE_TYPE (toffset2))
-- toffset2 = fold_convert (type, toffset2);
--
-- tree tdiff = fold_build2 (MINUS_EXPR, type, toffset1, toffset2);
-- if (!cst_and_fits_in_hwi (tdiff))
-- return false;
--
-- diff = int_cst_value (tdiff);
-- }
-- else if (toffset1 || toffset2)
-- {
-- /* If only one of the offsets is non-constant, the difference cannot
-- be a constant. */
-- return false;
-- }
-- diff += bytepos1 - bytepos2;
-- /* The offset between the 2 need to be 0. */
-- if (!known_eq (diff, 0))
-- return false;
-- src = fold_build1_loc (gimple_location (use_stmt),
-- VIEW_CONVERT_EXPR,
-- TREE_TYPE (src2), src);
-- }
-+ src = new_src_based_on_copy (src2, dest, src);
-+ if (!src)
-+ return false;
- /* For 2 memory refences and using a temporary to do the copy,
- don't remove the temporary as the 2 memory references might overlap.
- Note t does not need to be decl as it could be field.
-@@ -1634,8 +1643,10 @@ optimize_agr_copyprop_arg (gimple *defstmt, gcall *call,
- || is_gimple_min_invariant (*argptr)
- || TYPE_VOLATILE (TREE_TYPE (*argptr)))
- continue;
-- if (!operand_equal_p (*argptr, dest, 0))
-+ tree newsrc = new_src_based_on_copy (*argptr, dest, src);
-+ if (!newsrc)
- continue;
-+
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fprintf (dump_file, "Simplified\n ");
-@@ -1643,7 +1654,7 @@ optimize_agr_copyprop_arg (gimple *defstmt, gcall *call,
- fprintf (dump_file, "after previous\n ");
- print_gimple_stmt (dump_file, defstmt, 0, dump_flags);
- }
-- *argptr = unshare_expr (src);
-+ *argptr = unshare_expr (newsrc);
- changed = true;
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
-
-base-commit: e690b97761e18daccb4fff0151c97c1d0115b55f
---
-2.51.0
-
diff --git a/16.0.0/gentoo/88_all_PR121962-forwprop-hang.patch b/16.0.0/gentoo/88_all_PR121962-forwprop-hang.patch
deleted file mode 100644
index 52d25d6..0000000
--- a/16.0.0/gentoo/88_all_PR121962-forwprop-hang.patch
+++ /dev/null
@@ -1,161 +0,0 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121962#c11
-
-From 9463f1db7bc409b9a59dab1d11b6e82e423c4466 Mon Sep 17 00:00:00 2001
-From: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
-Date: Tue, 16 Sep 2025 10:55:03 -0700
-Subject: [PATCH] forwprop: Fix up "nop" copies after recent changes [PR121962]
-
-After r16-3887-g597b50abb0d2fc, the check to see if the copy is
-a nop copy becomes inefficient. The code going into an infinite
-loop as the copy keeps on being propagated over and over again.
-
-That is if we have:
-```
- struct s1 *b = &a.t;
- a.t = *b;
- p = *b;
-```
-
-This goes into an infinite loop propagating over and over again the
-`MEM[&a]`.
-To solve this a new function is needed for the comparison that is
-similar to new_src_based_on_copy.
-
- PR tree-optimization/121962
-
-gcc/ChangeLog:
-
- * tree-ssa-forwprop.cc (same_for_assignment): New function.
- (optimize_agr_copyprop_1): Use same_for_assignment to check for
- nop copies.
- (optimize_agr_copyprop): Likewise.
-
-gcc/testsuite/ChangeLog:
-
- * gcc.dg/torture/pr121962-1.c: New test.
-
-Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
----
- gcc/testsuite/gcc.dg/torture/pr121962-1.c | 21 ++++++++
- gcc/tree-ssa-forwprop.cc | 64 ++++++++++++++++++++++-
- 2 files changed, 83 insertions(+), 2 deletions(-)
- create mode 100644 gcc/testsuite/gcc.dg/torture/pr121962-1.c
-
-diff --git a/gcc/testsuite/gcc.dg/torture/pr121962-1.c b/gcc/testsuite/gcc.dg/torture/pr121962-1.c
-new file mode 100644
-index 00000000000..97f88ad5734
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/torture/pr121962-1.c
-@@ -0,0 +1,21 @@
-+/* PR tree-optimization/121962 */
-+struct s1
-+{
-+ int t;
-+};
-+
-+struct s2
-+{
-+ struct s1 t;
-+};
-+
-+struct s1 p;
-+
-+void f(struct s2 a)
-+{
-+ struct s1 *b = &a.t;
-+ /* this is a nop load/store and should be ignored
-+ by copy propagation for aggregates. */
-+ a.t = *b;
-+ p = *b;
-+}
-diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
-index 9d389e1b9bf..833a354ce2c 100644
---- a/gcc/tree-ssa-forwprop.cc
-+++ b/gcc/tree-ssa-forwprop.cc
-@@ -1528,6 +1528,66 @@ new_src_based_on_copy (tree src2, tree dest, tree src)
- return fold_build1 (VIEW_CONVERT_EXPR,TREE_TYPE (src2), src);
- }
-
-+/* Returns true if SRC and DEST are the same address such that
-+ `SRC == DEST;` is conisdered a nop. This is more than an
-+ operand_equal_p check as it needs to be similar to
-+ new_src_based_on_copy. */
-+
-+static bool
-+same_for_assignment (tree src, tree dest)
-+{
-+ if (operand_equal_p (dest, src, 0))
-+ return true;
-+ /* if both dest and src2 are decls, then we know these 2
-+ accesses can't be the same. */
-+ if (DECL_P (dest) && DECL_P (src))
-+ return false;
-+
-+ tree core1, core2;
-+ poly_int64 bytepos1, bytepos2;
-+ poly_int64 bytesize1, bytesize2;
-+ tree toffset1, toffset2;
-+ int reversep1 = 0;
-+ int reversep2 = 0;
-+ poly_int64 diff = 0;
-+ core1 = split_core_and_offset_size (dest, &bytesize1, &bytepos1,
-+ &toffset1, &reversep1);
-+ core2 = split_core_and_offset_size (src, &bytesize2, &bytepos2,
-+ &toffset2, &reversep2);
-+ if (!core1 || !core2)
-+ return false;
-+ if (reversep1 != reversep2)
-+ return false;
-+ /* The sizes of the 2 accesses need to be the same. */
-+ if (!known_eq (bytesize1, bytesize2))
-+ return false;
-+ if (!operand_equal_p (core1, core2, 0))
-+ return false;
-+ if (toffset1 && toffset2)
-+ {
-+ tree type = TREE_TYPE (toffset1);
-+ if (type != TREE_TYPE (toffset2))
-+ toffset2 = fold_convert (type, toffset2);
-+
-+ tree tdiff = fold_build2 (MINUS_EXPR, type, toffset1, toffset2);
-+ if (!cst_and_fits_in_hwi (tdiff))
-+ return false;
-+
-+ diff = int_cst_value (tdiff);
-+ }
-+ else if (toffset1 || toffset2)
-+ {
-+ /* If only one of the offsets is non-constant, the difference cannot
-+ be a constant. */
-+ return false;
-+ }
-+ diff += bytepos1 - bytepos2;
-+ /* The offset between the 2 need to be 0. */
-+ if (!known_eq (diff, 0))
-+ return false;
-+ return true;
-+}
-+
- /* Helper function for optimize_agr_copyprop.
- For aggregate copies in USE_STMT, see if DEST
- is on the lhs of USE_STMT and replace it with SRC. */
-@@ -1542,7 +1602,7 @@ optimize_agr_copyprop_1 (gimple *stmt, gimple *use_stmt,
- tree dest2 = gimple_assign_lhs (use_stmt);
- tree src2 = gimple_assign_rhs1 (use_stmt);
- /* If the new store is `src2 = src2;` skip over it. */
-- if (operand_equal_p (src2, dest2, 0))
-+ if (same_for_assignment (src2, dest2))
- return false;
- src = new_src_based_on_copy (src2, dest, src);
- if (!src)
-@@ -1702,7 +1762,7 @@ optimize_agr_copyprop (gimple_stmt_iterator *gsip)
- tree dest = gimple_assign_lhs (stmt);
- tree src = gimple_assign_rhs1 (stmt);
- /* If the statement is `src = src;` then ignore it. */
-- if (operand_equal_p (dest, src, 0))
-+ if (same_for_assignment (dest, src))
- return false;
-
- tree vdef = gimple_vdef (stmt);
---
-2.43.0
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 023c43f..3a58f30 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,8 +1,3 @@
-15 ????
-
- + 87_all_PR121962-forwprop-hang-prereq.patch
- + 88_all_PR121962-forwprop-hang.patch
-
14 7 September 2025
- 91_all_PR121699-mesa.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-09-17 3:04 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-09-17 3:04 UTC (permalink / raw
To: gentoo-commits
commit: 46883551fe0614e80638fa08805e1f1bc7710a96
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 17 03:04:26 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Sep 17 03:04:26 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=46883551
16.0.0: add a prereq patch for the forwprop hang
Signed-off-by: Sam James <sam <AT> gentoo.org>
.../87_all_PR121962-forwprop-hang-prereq.patch | 244 +++++++++++++++++++++
...g.patch => 88_all_PR121962-forwprop-hang.patch} | 0
16.0.0/gentoo/README.history | 3 +-
3 files changed, 246 insertions(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/87_all_PR121962-forwprop-hang-prereq.patch b/16.0.0/gentoo/87_all_PR121962-forwprop-hang-prereq.patch
new file mode 100644
index 0000000..245a78b
--- /dev/null
+++ b/16.0.0/gentoo/87_all_PR121962-forwprop-hang-prereq.patch
@@ -0,0 +1,244 @@
+From 41dc015782a42cb64680a55f6766ed5504c4ca53 Mon Sep 17 00:00:00 2001
+Message-ID: <41dc015782a42cb64680a55f6766ed5504c4ca53.1758078219.git.sam@gentoo.org>
+From: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
+Date: Mon, 15 Sep 2025 10:19:13 -0700
+Subject: [PATCH] forwprop: Handle memcpy for arguments with respect to copies
+
+This moves the code used in optimize_agr_copyprop_1 (r16-3887-g597b50abb0d)
+to handle this same case into its new function and use it inside
+optimize_agr_copyprop_arg. This allows to remove more copies that show up only
+in arguments.
+
+Bootstrapped and tested on x86_64-linux-gnu.
+
+gcc/ChangeLog:
+
+ * tree-ssa-forwprop.cc (optimize_agr_copyprop_1): Split out
+ the case where `operand_equal_p (dest, src2)` is false into ...
+ (new_src_based_on_copy): This. New function.
+ (optimize_agr_copyprop_arg): Use new_src_based_on_copy
+ instead of operand_equal_p to find the new src.
+
+gcc/testsuite/ChangeLog:
+
+ * gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c: New test.
+
+Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
+---
+ .../tree-ssa/copy-prop-aggregate-arg-2.c | 33 +++++
+ gcc/tree-ssa-forwprop.cc | 135 ++++++++++--------
+ 2 files changed, 106 insertions(+), 62 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c
+
+diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c
+new file mode 100644
+index 000000000000..11f0768c1112
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-2.c
+@@ -0,0 +1,33 @@
++/* { dg-do compile } */
++/* { dg-options "-O1 -fdump-tree-forwprop1-details -fdump-tree-optimized" } */
++
++
++struct s1
++{
++ int t[1024];
++};
++
++struct s2 {
++ struct s1 t;
++};
++
++struct s3
++{
++ struct s2 t;
++};
++
++void g(struct s3);
++
++void f(struct s1 s)
++{
++ struct s2 removeme;
++ removeme.t = s;
++ struct s3 removeme2;
++ removeme2.t = removeme;
++ g(removeme2);
++}
++
++
++/* { dg-final { scan-tree-dump-times "after previous" 2 "forwprop1" } } */
++/* { dg-final { scan-tree-dump-not "removeme " "optimized" } } */
++/* { dg-final { scan-tree-dump-not "removeme2 " "optimized" } } */
+diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
+index 1eacff01587c..f58a7b8c591d 100644
+--- a/gcc/tree-ssa-forwprop.cc
++++ b/gcc/tree-ssa-forwprop.cc
+@@ -1458,6 +1458,72 @@ split_core_and_offset_size (tree expr,
+ return core;
+ }
+
++/* Returns a new src based on the
++ copy `DEST = SRC` and for the old SRC2.
++ Returns null if SRC2 is not related to DEST. */
++
++static tree
++new_src_based_on_copy (tree src2, tree dest, tree src)
++{
++ /* If the second src is not exactly the same as dest,
++ try to handle it seperately; see it is address/size equivalent.
++ Handles `a` and `a.b` and `MEM<char[N]>(&a)` which all have
++ the same size and offsets as address/size equivalent.
++ This allows copying over a memcpy and also one for copying
++ where one field is the same size as the whole struct. */
++ if (operand_equal_p (dest, src2))
++ return src;
++ /* A VCE can't be used with imag/real or BFR so reject them early. */
++ if (TREE_CODE (src) == IMAGPART_EXPR
++ || TREE_CODE (src) == REALPART_EXPR
++ || TREE_CODE (src) == BIT_FIELD_REF)
++ return NULL_TREE;
++ tree core1, core2;
++ poly_int64 bytepos1, bytepos2;
++ poly_int64 bytesize1, bytesize2;
++ tree toffset1, toffset2;
++ int reversep1 = 0;
++ int reversep2 = 0;
++ poly_int64 diff = 0;
++ core1 = split_core_and_offset_size (dest, &bytesize1, &bytepos1,
++ &toffset1, &reversep1);
++ core2 = split_core_and_offset_size (src2, &bytesize2, &bytepos2,
++ &toffset2, &reversep2);
++ if (!core1 || !core2)
++ return NULL_TREE;
++ if (reversep1 != reversep2)
++ return NULL_TREE;
++ /* The sizes of the 2 accesses need to be the same. */
++ if (!known_eq (bytesize1, bytesize2))
++ return NULL_TREE;
++ if (!operand_equal_p (core1, core2, 0))
++ return NULL_TREE;
++
++ if (toffset1 && toffset2)
++ {
++ tree type = TREE_TYPE (toffset1);
++ if (type != TREE_TYPE (toffset2))
++ toffset2 = fold_convert (type, toffset2);
++
++ tree tdiff = fold_build2 (MINUS_EXPR, type, toffset1, toffset2);
++ if (!cst_and_fits_in_hwi (tdiff))
++ return NULL_TREE;
++
++ diff = int_cst_value (tdiff);
++ }
++ else if (toffset1 || toffset2)
++ {
++ /* If only one of the offsets is non-constant, the difference cannot
++ be a constant. */
++ return NULL_TREE;
++ }
++ diff += bytepos1 - bytepos2;
++ /* The offset between the 2 need to be 0. */
++ if (!known_eq (diff, 0))
++ return NULL_TREE;
++ return fold_build1 (VIEW_CONVERT_EXPR,TREE_TYPE (src2), src);
++}
++
+ /* Helper function for optimize_agr_copyprop.
+ For aggregate copies in USE_STMT, see if DEST
+ is on the lhs of USE_STMT and replace it with SRC. */
+@@ -1474,66 +1540,9 @@ optimize_agr_copyprop_1 (gimple *stmt, gimple *use_stmt,
+ /* If the new store is `src2 = src2;` skip over it. */
+ if (operand_equal_p (src2, dest2, 0))
+ return false;
+- /* If the second src is not exactly the same as dest,
+- try to handle it seperately; see it is address/size equivalent.
+- Handles `a` and `a.b` and `MEM<char[N]>(&a)` which all have
+- the same size and offsets as address/size equivalent.
+- This allows copying over a memcpy and also one for copying
+- where one field is the same size as the whole struct. */
+- if (!operand_equal_p (dest, src2, 0))
+- {
+- /* A VCE can't be used with imag/real or BFR so reject them early. */
+- if (TREE_CODE (src) == IMAGPART_EXPR
+- || TREE_CODE (src) == REALPART_EXPR
+- || TREE_CODE (src) == BIT_FIELD_REF)
+- return false;
+- tree core1, core2;
+- poly_int64 bytepos1, bytepos2;
+- poly_int64 bytesize1, bytesize2;
+- tree toffset1, toffset2;
+- int reversep1 = 0;
+- int reversep2 = 0;
+- poly_int64 diff = 0;
+- core1 = split_core_and_offset_size (dest, &bytesize1, &bytepos1,
+- &toffset1, &reversep1);
+- core2 = split_core_and_offset_size (src2, &bytesize2, &bytepos2,
+- &toffset2, &reversep2);
+- if (!core1 || !core2)
+- return false;
+- if (reversep1 != reversep2)
+- return false;
+- /* The sizes of the 2 accesses need to be the same. */
+- if (!known_eq (bytesize1, bytesize2))
+- return false;
+- if (!operand_equal_p (core1, core2, 0))
+- return false;
+-
+- if (toffset1 && toffset2)
+- {
+- tree type = TREE_TYPE (toffset1);
+- if (type != TREE_TYPE (toffset2))
+- toffset2 = fold_convert (type, toffset2);
+-
+- tree tdiff = fold_build2 (MINUS_EXPR, type, toffset1, toffset2);
+- if (!cst_and_fits_in_hwi (tdiff))
+- return false;
+-
+- diff = int_cst_value (tdiff);
+- }
+- else if (toffset1 || toffset2)
+- {
+- /* If only one of the offsets is non-constant, the difference cannot
+- be a constant. */
+- return false;
+- }
+- diff += bytepos1 - bytepos2;
+- /* The offset between the 2 need to be 0. */
+- if (!known_eq (diff, 0))
+- return false;
+- src = fold_build1_loc (gimple_location (use_stmt),
+- VIEW_CONVERT_EXPR,
+- TREE_TYPE (src2), src);
+- }
++ src = new_src_based_on_copy (src2, dest, src);
++ if (!src)
++ return false;
+ /* For 2 memory refences and using a temporary to do the copy,
+ don't remove the temporary as the 2 memory references might overlap.
+ Note t does not need to be decl as it could be field.
+@@ -1634,8 +1643,10 @@ optimize_agr_copyprop_arg (gimple *defstmt, gcall *call,
+ || is_gimple_min_invariant (*argptr)
+ || TYPE_VOLATILE (TREE_TYPE (*argptr)))
+ continue;
+- if (!operand_equal_p (*argptr, dest, 0))
++ tree newsrc = new_src_based_on_copy (*argptr, dest, src);
++ if (!newsrc)
+ continue;
++
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "Simplified\n ");
+@@ -1643,7 +1654,7 @@ optimize_agr_copyprop_arg (gimple *defstmt, gcall *call,
+ fprintf (dump_file, "after previous\n ");
+ print_gimple_stmt (dump_file, defstmt, 0, dump_flags);
+ }
+- *argptr = unshare_expr (src);
++ *argptr = unshare_expr (newsrc);
+ changed = true;
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+
+base-commit: e690b97761e18daccb4fff0151c97c1d0115b55f
+--
+2.51.0
+
diff --git a/16.0.0/gentoo/87_all_PR121962-forwprop-hang.patch b/16.0.0/gentoo/88_all_PR121962-forwprop-hang.patch
similarity index 100%
rename from 16.0.0/gentoo/87_all_PR121962-forwprop-hang.patch
rename to 16.0.0/gentoo/88_all_PR121962-forwprop-hang.patch
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 7db3c43..023c43f 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,7 @@
15 ????
- + 87_all_PR121962-forwprop-hang.patch
+ + 87_all_PR121962-forwprop-hang-prereq.patch
+ + 88_all_PR121962-forwprop-hang.patch
14 7 September 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-09-16 19:23 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-09-16 19:23 UTC (permalink / raw
To: gentoo-commits
commit: ca74e5013ee7a20aefc727dade6cc0f6b0724940
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 16 19:22:41 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Sep 16 19:22:41 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=ca74e501
16.0.0: add fix for forwprop hang
Bug: https://gcc.gnu.org/PR121962
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/87_all_PR121962-forwprop-hang.patch | 161 ++++++++++++++++++++++
16.0.0/gentoo/README.history | 4 +
2 files changed, 165 insertions(+)
diff --git a/16.0.0/gentoo/87_all_PR121962-forwprop-hang.patch b/16.0.0/gentoo/87_all_PR121962-forwprop-hang.patch
new file mode 100644
index 0000000..52d25d6
--- /dev/null
+++ b/16.0.0/gentoo/87_all_PR121962-forwprop-hang.patch
@@ -0,0 +1,161 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121962#c11
+
+From 9463f1db7bc409b9a59dab1d11b6e82e423c4466 Mon Sep 17 00:00:00 2001
+From: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
+Date: Tue, 16 Sep 2025 10:55:03 -0700
+Subject: [PATCH] forwprop: Fix up "nop" copies after recent changes [PR121962]
+
+After r16-3887-g597b50abb0d2fc, the check to see if the copy is
+a nop copy becomes inefficient. The code going into an infinite
+loop as the copy keeps on being propagated over and over again.
+
+That is if we have:
+```
+ struct s1 *b = &a.t;
+ a.t = *b;
+ p = *b;
+```
+
+This goes into an infinite loop propagating over and over again the
+`MEM[&a]`.
+To solve this a new function is needed for the comparison that is
+similar to new_src_based_on_copy.
+
+ PR tree-optimization/121962
+
+gcc/ChangeLog:
+
+ * tree-ssa-forwprop.cc (same_for_assignment): New function.
+ (optimize_agr_copyprop_1): Use same_for_assignment to check for
+ nop copies.
+ (optimize_agr_copyprop): Likewise.
+
+gcc/testsuite/ChangeLog:
+
+ * gcc.dg/torture/pr121962-1.c: New test.
+
+Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
+---
+ gcc/testsuite/gcc.dg/torture/pr121962-1.c | 21 ++++++++
+ gcc/tree-ssa-forwprop.cc | 64 ++++++++++++++++++++++-
+ 2 files changed, 83 insertions(+), 2 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.dg/torture/pr121962-1.c
+
+diff --git a/gcc/testsuite/gcc.dg/torture/pr121962-1.c b/gcc/testsuite/gcc.dg/torture/pr121962-1.c
+new file mode 100644
+index 00000000000..97f88ad5734
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/torture/pr121962-1.c
+@@ -0,0 +1,21 @@
++/* PR tree-optimization/121962 */
++struct s1
++{
++ int t;
++};
++
++struct s2
++{
++ struct s1 t;
++};
++
++struct s1 p;
++
++void f(struct s2 a)
++{
++ struct s1 *b = &a.t;
++ /* this is a nop load/store and should be ignored
++ by copy propagation for aggregates. */
++ a.t = *b;
++ p = *b;
++}
+diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
+index 9d389e1b9bf..833a354ce2c 100644
+--- a/gcc/tree-ssa-forwprop.cc
++++ b/gcc/tree-ssa-forwprop.cc
+@@ -1528,6 +1528,66 @@ new_src_based_on_copy (tree src2, tree dest, tree src)
+ return fold_build1 (VIEW_CONVERT_EXPR,TREE_TYPE (src2), src);
+ }
+
++/* Returns true if SRC and DEST are the same address such that
++ `SRC == DEST;` is conisdered a nop. This is more than an
++ operand_equal_p check as it needs to be similar to
++ new_src_based_on_copy. */
++
++static bool
++same_for_assignment (tree src, tree dest)
++{
++ if (operand_equal_p (dest, src, 0))
++ return true;
++ /* if both dest and src2 are decls, then we know these 2
++ accesses can't be the same. */
++ if (DECL_P (dest) && DECL_P (src))
++ return false;
++
++ tree core1, core2;
++ poly_int64 bytepos1, bytepos2;
++ poly_int64 bytesize1, bytesize2;
++ tree toffset1, toffset2;
++ int reversep1 = 0;
++ int reversep2 = 0;
++ poly_int64 diff = 0;
++ core1 = split_core_and_offset_size (dest, &bytesize1, &bytepos1,
++ &toffset1, &reversep1);
++ core2 = split_core_and_offset_size (src, &bytesize2, &bytepos2,
++ &toffset2, &reversep2);
++ if (!core1 || !core2)
++ return false;
++ if (reversep1 != reversep2)
++ return false;
++ /* The sizes of the 2 accesses need to be the same. */
++ if (!known_eq (bytesize1, bytesize2))
++ return false;
++ if (!operand_equal_p (core1, core2, 0))
++ return false;
++ if (toffset1 && toffset2)
++ {
++ tree type = TREE_TYPE (toffset1);
++ if (type != TREE_TYPE (toffset2))
++ toffset2 = fold_convert (type, toffset2);
++
++ tree tdiff = fold_build2 (MINUS_EXPR, type, toffset1, toffset2);
++ if (!cst_and_fits_in_hwi (tdiff))
++ return false;
++
++ diff = int_cst_value (tdiff);
++ }
++ else if (toffset1 || toffset2)
++ {
++ /* If only one of the offsets is non-constant, the difference cannot
++ be a constant. */
++ return false;
++ }
++ diff += bytepos1 - bytepos2;
++ /* The offset between the 2 need to be 0. */
++ if (!known_eq (diff, 0))
++ return false;
++ return true;
++}
++
+ /* Helper function for optimize_agr_copyprop.
+ For aggregate copies in USE_STMT, see if DEST
+ is on the lhs of USE_STMT and replace it with SRC. */
+@@ -1542,7 +1602,7 @@ optimize_agr_copyprop_1 (gimple *stmt, gimple *use_stmt,
+ tree dest2 = gimple_assign_lhs (use_stmt);
+ tree src2 = gimple_assign_rhs1 (use_stmt);
+ /* If the new store is `src2 = src2;` skip over it. */
+- if (operand_equal_p (src2, dest2, 0))
++ if (same_for_assignment (src2, dest2))
+ return false;
+ src = new_src_based_on_copy (src2, dest, src);
+ if (!src)
+@@ -1702,7 +1762,7 @@ optimize_agr_copyprop (gimple_stmt_iterator *gsip)
+ tree dest = gimple_assign_lhs (stmt);
+ tree src = gimple_assign_rhs1 (stmt);
+ /* If the statement is `src = src;` then ignore it. */
+- if (operand_equal_p (dest, src, 0))
++ if (same_for_assignment (dest, src))
+ return false;
+
+ tree vdef = gimple_vdef (stmt);
+--
+2.43.0
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 3a58f30..7db3c43 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+15 ????
+
+ + 87_all_PR121962-forwprop-hang.patch
+
14 7 September 2025
- 91_all_PR121699-mesa.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-09-14 11:26 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-09-14 11:26 UTC (permalink / raw
To: gentoo-commits
commit: b77c0ff8641f04bc3844647fdb568f05b6f89a7e
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 14 11:26:41 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Sep 14 11:26:41 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=b77c0ff8
16.0.0: drop now upstream patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/87_all_PR121932-gdb-lto.patch | 13 -------------
16.0.0/gentoo/README.history | 4 ----
2 files changed, 17 deletions(-)
diff --git a/16.0.0/gentoo/87_all_PR121932-gdb-lto.patch b/16.0.0/gentoo/87_all_PR121932-gdb-lto.patch
deleted file mode 100644
index 786cc4d..0000000
--- a/16.0.0/gentoo/87_all_PR121932-gdb-lto.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121932#c7
---- a/gcc/ipa-free-lang-data.cc
-+++ b/gcc/ipa-free-lang-data.cc
-@@ -735,7 +735,8 @@ find_decls_types_r (tree *tp, int *ws, void *data)
-
- if (TREE_CODE (t) == FUNCTION_DECL)
- {
-- fld_worklist_push (DECL_ARGUMENTS (t), fld);
-+ for (tree arg = DECL_ARGUMENTS (t); arg; arg = DECL_CHAIN (arg))
-+ fld_worklist_push (arg, fld);
- fld_worklist_push (DECL_RESULT (t), fld);
- }
- else if (TREE_CODE (t) == FIELD_DECL)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 208891f..3a58f30 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,7 +1,3 @@
-15 ????
-
- + 87_all_PR121932-gdb-lto.patch
-
14 7 September 2025
- 91_all_PR121699-mesa.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-09-13 13:16 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-09-13 13:16 UTC (permalink / raw
To: gentoo-commits
commit: 822516c431a2d0bd9ea4fa540c0b7d943c4f8299
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 13 13:16:14 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Sep 13 13:16:14 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=822516c4
16.0.0: add LTO streaming fix
Bug: https://gcc.gnu.org/PR121932
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/87_all_PR121932-gdb-lto.patch | 13 +++++++++++++
16.0.0/gentoo/README.history | 4 ++++
2 files changed, 17 insertions(+)
diff --git a/16.0.0/gentoo/87_all_PR121932-gdb-lto.patch b/16.0.0/gentoo/87_all_PR121932-gdb-lto.patch
new file mode 100644
index 0000000..786cc4d
--- /dev/null
+++ b/16.0.0/gentoo/87_all_PR121932-gdb-lto.patch
@@ -0,0 +1,13 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121932#c7
+--- a/gcc/ipa-free-lang-data.cc
++++ b/gcc/ipa-free-lang-data.cc
+@@ -735,7 +735,8 @@ find_decls_types_r (tree *tp, int *ws, void *data)
+
+ if (TREE_CODE (t) == FUNCTION_DECL)
+ {
+- fld_worklist_push (DECL_ARGUMENTS (t), fld);
++ for (tree arg = DECL_ARGUMENTS (t); arg; arg = DECL_CHAIN (arg))
++ fld_worklist_push (arg, fld);
+ fld_worklist_push (DECL_RESULT (t), fld);
+ }
+ else if (TREE_CODE (t) == FIELD_DECL)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 3a58f30..208891f 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+15 ????
+
+ + 87_all_PR121932-gdb-lto.patch
+
14 7 September 2025
- 91_all_PR121699-mesa.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-09-06 2:42 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-09-06 2:42 UTC (permalink / raw
To: gentoo-commits
commit: 9321ede0c5e71b623e63e7c5595afd85c0ea6d75
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 6 02:42:16 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Sep 6 02:42:16 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=9321ede0
16.0.0: drop upstreamed patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/87_all_PR121806-fortran-uninit.patch | 27 ----------------------
16.0.0/gentoo/README.history | 1 -
2 files changed, 28 deletions(-)
diff --git a/16.0.0/gentoo/87_all_PR121806-fortran-uninit.patch b/16.0.0/gentoo/87_all_PR121806-fortran-uninit.patch
deleted file mode 100644
index 8b47240..0000000
--- a/16.0.0/gentoo/87_all_PR121806-fortran-uninit.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From a3748f8a02ae510d2631fb7db4829efae12733bb Mon Sep 17 00:00:00 2001
-From: Andre Vehreschild <vehre@gcc.gnu.org>
-Date: Thu, 4 Sep 2025 08:20:04 +0200
-Subject: [PATCH] Fix uninitialized variable in frontend.
-
-gcc/ChangeLog:
-
- * gcc.cc (for_each_path): Initialize return value.
----
- gcc/gcc.cc | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/gcc/gcc.cc b/gcc/gcc.cc
-index 722d42c6968..8da821e92ac 100644
---- a/gcc/gcc.cc
-+++ b/gcc/gcc.cc
-@@ -2788,7 +2788,7 @@ for_each_path (const struct path_prefix *paths,
- const char *multi_suffix;
- const char *just_multi_suffix;
- char *path = NULL;
-- decltype (callback (nullptr)) ret;
-+ decltype (callback (nullptr)) ret = nullptr;
- bool skip_multi_dir = false;
- bool skip_multi_os_dir = false;
-
---
-2.51.0
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index eeeb65a..5b19927 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,7 +1,6 @@
14 ????
- 91_all_PR121699-mesa.patch
- + 87_all_PR121806-fortran-uninit.patch
13 31 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-09-05 12:44 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-09-05 12:44 UTC (permalink / raw
To: gentoo-commits
commit: 1c2de5bf7542dca179c0770f19cc70821033f59f
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 12:44:37 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Sep 5 12:44:37 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=1c2de5bf
16.0.0: add uninit fix
Bug: https://gcc.gnu.org/PR121806
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/87_all_PR121806-fortran-uninit.patch | 27 ++++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 28 insertions(+)
diff --git a/16.0.0/gentoo/87_all_PR121806-fortran-uninit.patch b/16.0.0/gentoo/87_all_PR121806-fortran-uninit.patch
new file mode 100644
index 0000000..8b47240
--- /dev/null
+++ b/16.0.0/gentoo/87_all_PR121806-fortran-uninit.patch
@@ -0,0 +1,27 @@
+From a3748f8a02ae510d2631fb7db4829efae12733bb Mon Sep 17 00:00:00 2001
+From: Andre Vehreschild <vehre@gcc.gnu.org>
+Date: Thu, 4 Sep 2025 08:20:04 +0200
+Subject: [PATCH] Fix uninitialized variable in frontend.
+
+gcc/ChangeLog:
+
+ * gcc.cc (for_each_path): Initialize return value.
+---
+ gcc/gcc.cc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/gcc/gcc.cc b/gcc/gcc.cc
+index 722d42c6968..8da821e92ac 100644
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -2788,7 +2788,7 @@ for_each_path (const struct path_prefix *paths,
+ const char *multi_suffix;
+ const char *just_multi_suffix;
+ char *path = NULL;
+- decltype (callback (nullptr)) ret;
++ decltype (callback (nullptr)) ret = nullptr;
+ bool skip_multi_dir = false;
+ bool skip_multi_os_dir = false;
+
+--
+2.51.0
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 5b19927..eeeb65a 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,7 @@
14 ????
- 91_all_PR121699-mesa.patch
+ + 87_all_PR121806-fortran-uninit.patch
13 31 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-09-01 8:04 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-09-01 8:04 UTC (permalink / raw
To: gentoo-commits
commit: e3556ae516c0cb9b930c6042c2eea25fa8daee35
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 1 08:04:25 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Sep 1 08:04:25 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=e3556ae5
16.0.0: drop Mesa patch merged upstream
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/91_all_PR121699-mesa.patch | 114 -------------------------------
16.0.0/gentoo/README.history | 4 ++
2 files changed, 4 insertions(+), 114 deletions(-)
diff --git a/16.0.0/gentoo/91_all_PR121699-mesa.patch b/16.0.0/gentoo/91_all_PR121699-mesa.patch
deleted file mode 100644
index 09f8bcc..0000000
--- a/16.0.0/gentoo/91_all_PR121699-mesa.patch
+++ /dev/null
@@ -1,114 +0,0 @@
-From 2a9fff30d30b591bce9ce43710bfb5426a9b193d Mon Sep 17 00:00:00 2001
-Message-ID: <2a9fff30d30b591bce9ce43710bfb5426a9b193d.1756541078.git.sam@gentoo.org>
-From: liuhongt <hongtao.liu@intel.com>
-Date: Sat, 30 Aug 2025 00:59:30 -0700
-Subject: [PATCH] Fix ICE due to wrong operand is passed to
- ix86_vgf2p8affine_shift_matrix.
-
-1) Fix predicate of operands[3] in cond_<insn><mode> since only
-const_vec_dup_operand is excepted for masked operations, and pass real
-count to ix86_vgf2p8affine_shift_matrix.
-
-2) Pass operands[2] instead of operands[1] to
-gen_vgf2p8affineqb_<mode>_mask which excepted the operand to shifted,
-but operands[1] is mask operand in cond_<insn><mode>.
-
-Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
-Ready push to trunk.
-
-gcc/ChangeLog:
-
- PR target/121699
- * config/i386/predicates.md (const_vec_dup_operand): New
- predicate.
- * config/i386/sse.md (cond_<insn><mode>): Fix predicate of
- operands[3], and fix wrong operands passed to
- ix86_vgf2p8affine_shift_matrix and
- gen_vgf2p8affineqb_<mode>_mask.
-
-gcc/testsuite/ChangeLog:
-
-* gcc.target/i386/pr121699.c: New test.
----
- gcc/config/i386/predicates.md | 3 +++
- gcc/config/i386/sse.md | 8 ++++----
- gcc/testsuite/gcc.target/i386/pr121699.c | 23 +++++++++++++++++++++++
- 3 files changed, 30 insertions(+), 4 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121699.c
-
-diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
-index 175798cff69b..5dbe444847fd 100644
---- a/gcc/config/i386/predicates.md
-+++ b/gcc/config/i386/predicates.md
-@@ -1319,6 +1319,9 @@ (define_predicate "nonimmediate_or_const_vec_dup_operand"
- (ior (match_operand 0 "nonimmediate_operand")
- (match_test "const_vec_duplicate_p (op)")))
-
-+(define_predicate "const_vec_dup_operand"
-+ (match_test "const_vec_duplicate_p (op)"))
-+
- ;; Return true when OP is either register operand, or any
- ;; CONST_VECTOR.
- (define_predicate "reg_or_const_vector_operand"
-diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
-index 505095040f75..73906b85d899 100644
---- a/gcc/config/i386/sse.md
-+++ b/gcc/config/i386/sse.md
-@@ -27001,19 +27001,19 @@ (define_expand "<insn><mode>3"
- DONE;
- })
-
--; not generated by vectorizer?
- (define_expand "cond_<insn><mode>"
- [(set (match_operand:VI1_AVX512VL 0 "register_operand")
- (vec_merge:VI1_AVX512VL
- (any_shift:VI1_AVX512VL
- (match_operand:VI1_AVX512VL 2 "register_operand")
-- (match_operand:VI1_AVX512VL 3 "nonimmediate_or_const_vec_dup_operand"))
-+ (match_operand:VI1_AVX512VL 3 "const_vec_dup_operand"))
- (match_operand:VI1_AVX512VL 4 "nonimm_or_0_operand")
- (match_operand:<avx512fmaskmode> 1 "register_operand")))]
- "TARGET_GFNI && TARGET_AVX512F"
- {
-- rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], operands[2], <CODE>);
-- emit_insn (gen_vgf2p8affineqb_<mode>_mask (operands[0], operands[1], matrix,
-+ rtx count = XVECEXP (operands[3], 0, 0);
-+ rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], count, <CODE>);
-+ emit_insn (gen_vgf2p8affineqb_<mode>_mask (operands[0], operands[2], matrix,
- const0_rtx, operands[4],
- operands[1]));
- DONE;
-diff --git a/gcc/testsuite/gcc.target/i386/pr121699.c b/gcc/testsuite/gcc.target/i386/pr121699.c
-new file mode 100644
-index 000000000000..80c1404bebed
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121699.c
-@@ -0,0 +1,23 @@
-+/* { dg-do compile } */
-+/* { dg-options "-march=znver4 -O3" } */
-+
-+typedef struct
-+{
-+ int u32;
-+} nir_const_value;
-+
-+nir_const_value *evaluate_prmt_nv__dst_val;
-+
-+int evaluate_prmt_nv__src_0, evaluate_prmt_nv_src;
-+
-+void
-+evaluate_prmt_nv (unsigned num_components)
-+{
-+ for (unsigned _i = 0; _i < num_components; _i++)
-+ {
-+ char x = evaluate_prmt_nv_src;
-+ if (evaluate_prmt_nv__src_0)
-+ x = x >> 7;
-+ evaluate_prmt_nv__dst_val[_i].u32 = x;
-+ }
-+}
-
-base-commit: bfa70ddb650ec91c2511d351b2b3c3f78dfad6d4
---
-2.51.0
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 9e7eb1a..5b19927 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+14 ????
+
+ - 91_all_PR121699-mesa.patch
+
13 31 August 2025
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-31 22:43 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-31 22:43 UTC (permalink / raw
To: gentoo-commits
commit: f2a83a27853cafcd75c866aeff4ebebe50b41576
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 31 22:42:38 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 31 22:42:38 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=f2a83a27
16.0.0: cut patchset 13
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/README.history | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 95bc5dd..9e7eb1a 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,4 +1,4 @@
-13 ????
+13 31 August 2025
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
+ 91_all_PR121699-mesa.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-30 14:06 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-30 14:06 UTC (permalink / raw
To: gentoo-commits
commit: b40afae619f7e54eebfaccd612ca27b0c2c8eb8a
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 30 14:06:07 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug 30 14:06:07 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=b40afae6
16.0.0: drop patch merged upstream
Signed-off-by: Sam James <sam <AT> gentoo.org>
...UNSPEC_DTPOFF-to-check-source-operand-in-.patch | 158 ---------------------
16.0.0/gentoo/README.history | 2 -
2 files changed, 160 deletions(-)
diff --git a/16.0.0/gentoo/90_all_PR121725-x86-64-Use-UNSPEC_DTPOFF-to-check-source-operand-in-.patch b/16.0.0/gentoo/90_all_PR121725-x86-64-Use-UNSPEC_DTPOFF-to-check-source-operand-in-.patch
deleted file mode 100644
index 35641f2..0000000
--- a/16.0.0/gentoo/90_all_PR121725-x86-64-Use-UNSPEC_DTPOFF-to-check-source-operand-in-.patch
+++ /dev/null
@@ -1,158 +0,0 @@
-From 04e11f7b467e53c513548d59e0c4ac256adb2c30 Mon Sep 17 00:00:00 2001
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Fri, 29 Aug 2025 12:53:18 -0700
-Subject: [PATCH] x86-64: Use UNSPEC_DTPOFF to check source operand in
- TLS64_COMBINE
-
-Since the first operand of PLUS in the source of TLS64_COMBINE pattern:
-
-(set (reg/f:DI 128)
- (plus:DI (unspec:DI [
- (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
- (reg:DI 126)
- (reg/f:DI 7 sp)
- ] UNSPEC_TLSDESC)
- (const:DI (unspec:DI [
- (symbol_ref:DI ("bfd_error") [flags 0x1a] <var_decl 0x7fffe99d6e40 bfd_error>)
- ] UNSPEC_DTPOFF))))
-
-is unused, use the second operand of PLUS:
-
-(const:DI (unspec:DI [
- (symbol_ref:DI ("bfd_error") [flags 0x1a] <var_decl 0x7fffe99d6e40 bfd_error>)
- ] UNSPEC_DTPOFF))
-
-to check if 2 TLS_COMBINE patterns have the same source.
-
-gcc/
-
- PR target/121725
- * config/i386/i386-features.cc
- (pass_x86_cse::candidate_gnu2_tls_p): Use the UNSPEC_DTPOFF
- operand to check source operand in TLS64_COMBINE pattern.
-
-gcc/testsuite/
-
- PR target/121725
- * gcc.target/i386/pr121725-1a.c: New test.
- * gcc.target/i386/pr121725-1b.c: Likewise.
-
-Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
----
- gcc/config/i386/i386-features.cc | 32 +++++-----------
- gcc/testsuite/gcc.target/i386/pr121725-1a.c | 41 +++++++++++++++++++++
- gcc/testsuite/gcc.target/i386/pr121725-1b.c | 6 +++
- 3 files changed, 57 insertions(+), 22 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121725-1a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121725-1b.c
-
-diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index 5440a02c442..0608dd2f9ac 100644
---- a/gcc/config/i386/i386-features.cc
-+++ b/gcc/config/i386/i386-features.cc
-@@ -4291,34 +4291,22 @@ pass_x86_cse::candidate_gnu2_tls_p (rtx set, attr_tls64 tls64)
- */
-
- scalar_mode = mode = GET_MODE (src);
-- rtx src0 = XEXP (src, 0);
-- tls_symbol = XVECEXP (src0, 0, 0);
-- rtx src1 = XVECEXP (src0, 0, 1);
-- if (REG_P (src1))
-- {
-- set_insn = tls_set_insn_from_symbol (src1, tls_symbol);
-- gcc_assert (set_insn);
-- }
-- else
-- {
-- set_insn = nullptr;
-- gcc_assert (GET_CODE (src1) == UNSPEC
-- && XINT (src1, 1) == UNSPEC_TLSDESC
-- && SYMBOL_REF_P (XVECEXP (src1, 0, 0))
-- && rtx_equal_p (XVECEXP (src1, 0, 0), tls_symbol));
-- }
-
-- /* Use TLS_SYMBOL and
-+ /* Since the first operand of PLUS in the source TLS_COMBINE
-+ pattern is unused, use the second operand of PLUS:
-
- (const:DI (unspec:DI [
- (symbol_ref:DI ("e") [flags 0x1a])
- ] UNSPEC_DTPOFF))
-
-- as VAL to check if 2 patterns have the same source. */
--
-- rtvec vec = gen_rtvec (2, tls_symbol, XEXP (src, 1));
-- val = gen_rtx_UNSPEC (mode, vec, UNSPEC_TLSDESC);
-- def_insn = set_insn;
-+ as VAL to check if 2 TLS_COMBINE patterns have the same
-+ source. */
-+ val = XEXP (src, 1);
-+ gcc_assert (GET_CODE (val) == CONST
-+ && GET_CODE (XEXP (val, 0)) == UNSPEC
-+ && XINT (XEXP (val, 0), 1) == UNSPEC_DTPOFF
-+ && SYMBOL_REF_P (XVECEXP (XEXP (val, 0), 0, 0)));
-+ def_insn = nullptr;
- return true;
- }
-
-diff --git a/gcc/testsuite/gcc.target/i386/pr121725-1a.c b/gcc/testsuite/gcc.target/i386/pr121725-1a.c
-new file mode 100644
-index 00000000000..d0a498cace9
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121725-1a.c
-@@ -0,0 +1,41 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-O3 -fpic -fplt -mtls-dialect=gnu" } */
-+
-+typedef enum
-+{
-+ bfd_error_invalid_error_code
-+} bfd_error_type;
-+static thread_local bfd_error_type bfd_error;
-+extern int sections;
-+extern void *bfd_alloc_ret;
-+extern int bfd_alloc___o;
-+extern long bfd_alloc_size;
-+
-+extern void _objalloc_alloc (int *, long);
-+
-+bfd_error_type
-+bfd_get_error ()
-+{
-+ return bfd_error;
-+}
-+
-+bool
-+s7_bfd_score_elf_late_size_sections ()
-+{
-+ for (; sections;)
-+ {
-+ if (bfd_alloc_size)
-+ {
-+ bfd_error_type error_tag;
-+ bfd_error = error_tag;
-+ }
-+ _objalloc_alloc (&bfd_alloc___o, 0);
-+ if (bfd_alloc_ret)
-+ {
-+ bfd_error_type error_tag;
-+ bfd_error = error_tag;
-+ }
-+ }
-+}
-+
-+/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 2 { target { ! ia32 } } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr121725-1b.c b/gcc/testsuite/gcc.target/i386/pr121725-1b.c
-new file mode 100644
-index 00000000000..0b97a8a4cb6
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121725-1b.c
-@@ -0,0 +1,6 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-O3 -fpic -fplt -mtls-dialect=gnu2" } */
-+
-+#include "pr121725-1a.c"
-+
-+/* { dg-final { scan-assembler-times "call\[ \t\]\\*bfd_error@TLSCALL\\(%(?:r|e)ax\\)" 2 { target { ! ia32 } } } } */
---
-2.51.0
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 7bdc805..95bc5dd 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,9 +1,7 @@
13 ????
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
- + 90_all_PR121725-x86-64-Use-UNSPEC_DTPOFF-to-check-source-operand-in-.patch
+ 91_all_PR121699-mesa.patch
- + 92_all_PR121718-underlinked.patch
12 24 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-30 8:05 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-30 8:05 UTC (permalink / raw
To: gentoo-commits
commit: 34ba35b4d9b9fad11c0d783b3d2282d1886e90c7
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 30 08:04:59 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug 30 08:04:59 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=34ba35b4
16.0.0: switch to submitted Mesa patch
Functionally the same.
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/91_all_PR121699-mesa.patch | 89 +++++++++++++++++++++++++++++---
1 file changed, 82 insertions(+), 7 deletions(-)
diff --git a/16.0.0/gentoo/91_all_PR121699-mesa.patch b/16.0.0/gentoo/91_all_PR121699-mesa.patch
index 977aeda..09f8bcc 100644
--- a/16.0.0/gentoo/91_all_PR121699-mesa.patch
+++ b/16.0.0/gentoo/91_all_PR121699-mesa.patch
@@ -1,10 +1,43 @@
- 1) Fix predicate of operands[3] in cond_<insn><mode> since only
- const_vec_dup_operand is excepted for masked operations, and pass real
- count to ix86_vgf2p8affine_shift_matrix.
+From 2a9fff30d30b591bce9ce43710bfb5426a9b193d Mon Sep 17 00:00:00 2001
+Message-ID: <2a9fff30d30b591bce9ce43710bfb5426a9b193d.1756541078.git.sam@gentoo.org>
+From: liuhongt <hongtao.liu@intel.com>
+Date: Sat, 30 Aug 2025 00:59:30 -0700
+Subject: [PATCH] Fix ICE due to wrong operand is passed to
+ ix86_vgf2p8affine_shift_matrix.
- 2) Pass operands[2] instead of operands[1] to
- gen_vgf2p8affineqb_<mode>_mask which excepted the operand to shifted,
- but operands[1] is mask operand in cond_<insn><mode>.
+1) Fix predicate of operands[3] in cond_<insn><mode> since only
+const_vec_dup_operand is excepted for masked operations, and pass real
+count to ix86_vgf2p8affine_shift_matrix.
+
+2) Pass operands[2] instead of operands[1] to
+gen_vgf2p8affineqb_<mode>_mask which excepted the operand to shifted,
+but operands[1] is mask operand in cond_<insn><mode>.
+
+Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
+Ready push to trunk.
+
+gcc/ChangeLog:
+
+ PR target/121699
+ * config/i386/predicates.md (const_vec_dup_operand): New
+ predicate.
+ * config/i386/sse.md (cond_<insn><mode>): Fix predicate of
+ operands[3], and fix wrong operands passed to
+ ix86_vgf2p8affine_shift_matrix and
+ gen_vgf2p8affineqb_<mode>_mask.
+
+gcc/testsuite/ChangeLog:
+
+* gcc.target/i386/pr121699.c: New test.
+---
+ gcc/config/i386/predicates.md | 3 +++
+ gcc/config/i386/sse.md | 8 ++++----
+ gcc/testsuite/gcc.target/i386/pr121699.c | 23 +++++++++++++++++++++++
+ 3 files changed, 30 insertions(+), 4 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121699.c
+
+diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
+index 175798cff69b..5dbe444847fd 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -1319,6 +1319,9 @@ (define_predicate "nonimmediate_or_const_vec_dup_operand"
@@ -17,9 +50,17 @@
;; Return true when OP is either register operand, or any
;; CONST_VECTOR.
(define_predicate "reg_or_const_vector_operand"
+diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
+index 505095040f75..73906b85d899 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
-@@ -27007,13 +27007,14 @@ (define_expand "cond_<insn><mode>"
+@@ -27001,19 +27001,19 @@ (define_expand "<insn><mode>3"
+ DONE;
+ })
+
+-; not generated by vectorizer?
+ (define_expand "cond_<insn><mode>"
+ [(set (match_operand:VI1_AVX512VL 0 "register_operand")
(vec_merge:VI1_AVX512VL
(any_shift:VI1_AVX512VL
(match_operand:VI1_AVX512VL 2 "register_operand")
@@ -37,3 +78,37 @@
const0_rtx, operands[4],
operands[1]));
DONE;
+diff --git a/gcc/testsuite/gcc.target/i386/pr121699.c b/gcc/testsuite/gcc.target/i386/pr121699.c
+new file mode 100644
+index 000000000000..80c1404bebed
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121699.c
+@@ -0,0 +1,23 @@
++/* { dg-do compile } */
++/* { dg-options "-march=znver4 -O3" } */
++
++typedef struct
++{
++ int u32;
++} nir_const_value;
++
++nir_const_value *evaluate_prmt_nv__dst_val;
++
++int evaluate_prmt_nv__src_0, evaluate_prmt_nv_src;
++
++void
++evaluate_prmt_nv (unsigned num_components)
++{
++ for (unsigned _i = 0; _i < num_components; _i++)
++ {
++ char x = evaluate_prmt_nv_src;
++ if (evaluate_prmt_nv__src_0)
++ x = x >> 7;
++ evaluate_prmt_nv__dst_val[_i].u32 = x;
++ }
++}
+
+base-commit: bfa70ddb650ec91c2511d351b2b3c3f78dfad6d4
+--
+2.51.0
+
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-30 6:57 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-30 6:57 UTC (permalink / raw
To: gentoo-commits
commit: ceb2940007f2331913d327d5d5444154641e2f66
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 30 06:56:39 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug 30 06:56:39 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=ceb29400
16.0.0: drop underlinked DFP patch
The upstream patch has been reverted for now.
Bug: https://gcc.gnu.org/PR121718
Closes: https://bugs.gentoo.org/962167
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/92_all_PR121718-underlinked.patch | 1990 -----------------------
1 file changed, 1990 deletions(-)
diff --git a/16.0.0/gentoo/92_all_PR121718-underlinked.patch b/16.0.0/gentoo/92_all_PR121718-underlinked.patch
deleted file mode 100644
index a68b73b..0000000
--- a/16.0.0/gentoo/92_all_PR121718-underlinked.patch
+++ /dev/null
@@ -1,1990 +0,0 @@
-From 8ed3eaa75908ec5ddb364625e05b3bcac5765a25 Mon Sep 17 00:00:00 2001
-Message-ID: <8ed3eaa75908ec5ddb364625e05b3bcac5765a25.1756512714.git.sam@gentoo.org>
-From: Sam James <sam@gentoo.org>
-Date: Sat, 30 Aug 2025 01:11:52 +0100
-Subject: [PATCH] Revert "Fix _Decimal128 arithmetic error under FE_UPWARD."
-
-This reverts commit 50064b2898edfb83bc37f2597a35cbd3c1c853e3.
----
- gcc/testsuite/gcc.target/i386/pr120691.c | 18 -
- libgcc/config/libbid/bid128_div.c | 135 +-----
- libgcc/config/libbid/bid128_rem.c | 34 --
- libgcc/config/libbid/bid128_sqrt.c | 43 +-
- libgcc/config/libbid/bid64_div.c | 530 +++++++++--------------
- libgcc/config/libbid/bid64_sqrt.c | 41 +-
- 6 files changed, 215 insertions(+), 586 deletions(-)
- delete mode 100644 gcc/testsuite/gcc.target/i386/pr120691.c
- mode change 100755 => 100644 libgcc/config/libbid/bid128_div.c
- mode change 100755 => 100644 libgcc/config/libbid/bid128_rem.c
- mode change 100755 => 100644 libgcc/config/libbid/bid128_sqrt.c
- mode change 100755 => 100644 libgcc/config/libbid/bid64_div.c
- mode change 100755 => 100644 libgcc/config/libbid/bid64_sqrt.c
-
-diff --git a/gcc/testsuite/gcc.target/i386/pr120691.c b/gcc/testsuite/gcc.target/i386/pr120691.c
-deleted file mode 100644
-index 241a34faa457..000000000000
---- a/gcc/testsuite/gcc.target/i386/pr120691.c
-+++ /dev/null
-@@ -1,18 +0,0 @@
--/* { dg-do run { target { ! ia32 } } } */
--/* { dg-options "-O0 -mfpmath=sse" } */
--/* { dg-require-effective-target fenv } */
--/* { dg-require-effective-target dfp } */
--
--#include <fenv.h>
--
--int main() {
-- fesetround( FE_UPWARD );
-- _Decimal128 x1 = 9825, x2 = 10000 ;
--
-- double c = (double) (x1 / x2);
--
-- if (c != 0.9825)
-- __builtin_abort ();
--
-- return 0 ;
--}
-diff --git a/libgcc/config/libbid/bid128_div.c b/libgcc/config/libbid/bid128_div.c
-old mode 100755
-new mode 100644
-index 04955f27d38d..925bf14a3361
---- a/libgcc/config/libbid/bid128_div.c
-+++ b/libgcc/config/libbid/bid128_div.c
-@@ -24,16 +24,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
- #define BID_128RES
- #include "bid_div_macros.h"
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-+#include <fenv.h>
-+
- #define FE_ALL_FLAGS FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT
- #endif
--#include <stdio.h>
--#include <fenv.h>
-
- extern UINT32 convert_table[5][128][2];
- extern SINT8 factors[][2];
- extern UINT8 packed_10000_zeros[];
-
--
- BID128_FUNCTION_ARG2 (bid128_div, x, y)
-
- UINT256 CA4, CA4r, P256;
-@@ -46,18 +45,10 @@ BID128_FUNCTION_ARG2 (bid128_div, x, y)
- digits_q, amount;
- int nzeros, i, j, k, d5;
- unsigned rmode;
-- int old_rm, rm_changed=0;
--
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
-
--// Set it to round-to-nearest (if different)
--if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
--}
--
- valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
-
- // unpack arguments, check for NaN or Infinity
-@@ -71,8 +62,6 @@ if ((x.w[1] & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
- #endif
- res.w[1] = (CX.w[1]) & QUIET_MASK64;
- res.w[0] = CX.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x is Infinity?
-@@ -86,8 +75,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
- #endif
- res.w[1] = 0x7c00000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is NaN?
-@@ -98,8 +85,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
- res.w[1] = ((x.w[1] ^ y.w[1]) & 0x8000000000000000ull) |
- 0x7800000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -112,8 +97,6 @@ if ((y.w[1] & 0x7800000000000000ull) < 0x7800000000000000ull) {
- // x=y=0, return NaN
- res.w[1] = 0x7c00000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // return 0
-@@ -125,8 +108,6 @@ if ((y.w[1] & 0x7800000000000000ull) < 0x7800000000000000ull) {
- exponent_x = 0;
- res.w[1] |= (((UINT64) exponent_x) << 49);
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -141,8 +122,6 @@ if (!valid_y) {
- #endif
- res.w[1] = CY.w[1] & QUIET_MASK64;
- res.w[0] = CY.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is Infinity?
-@@ -150,8 +129,6 @@ if (!valid_y) {
- // return +/-0
- res.w[1] = sign_x ^ sign_y;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is 0, return +/-Inf
-@@ -161,8 +138,6 @@ if (!valid_y) {
- res.w[1] =
- ((x.w[1] ^ y.w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -211,8 +186,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // get number of decimal digits in CQ
-@@ -406,8 +379,6 @@ if (!CA4.w[0] && !CA4.w[1])
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #endif
-@@ -498,8 +469,6 @@ if (diff_expon >= 0) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-
- }
-@@ -508,8 +477,6 @@ get_BID128 (&res, sign_x ^ sign_y, diff_expon, CQ, &rnd_mode, pfpsf);
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
--// restore the rounding mode back if it has been changed
--if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -529,17 +496,10 @@ TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2 (UINT128, bid128dd_div, UINT64, x,
- digits_q, amount;
- int nzeros, i, j, k, d5;
- unsigned rmode;
-- int old_rm, rm_changed=0;
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
-
--// Set it to round-to-nearest (if different)
--if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
--}
--
- valid_y = unpack_BID64 (&sign_y, &exponent_y, &CY.w[0], y);
-
- // unpack arguments, check for NaN or Infinity
-@@ -559,8 +519,6 @@ if ((x & NAN_MASK64) == NAN_MASK64) {
- res.w[0] = (CX.w[0] & 0x0003ffffffffffffull);
- __mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
- res.w[1] |= ((CX.w[0]) & 0xfc00000000000000ull);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x is Infinity?
-@@ -574,17 +532,13 @@ if (((x) & 0x7800000000000000ull) == 0x7800000000000000ull) {
- #endif
- res.w[1] = 0x7c00000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-+ BID_RETURN (res);
- }
- if ((((y) & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
- // otherwise return +/-Inf
- res.w[1] =
- (((x) ^ (y)) & 0x8000000000000000ull) | 0x7800000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -597,8 +551,6 @@ if ((((y) & 0x7800000000000000ull) != 0x7800000000000000ull)) {
- // x=y=0, return NaN
- res.w[1] = 0x7c00000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // return 0
-@@ -614,8 +566,6 @@ else if (exponent_x < 0)
- exponent_x = 0;
- res.w[1] |= (((UINT64) exponent_x) << 49);
- res.w[0] = 0;
--// restore the rounding mode back if it has been changed
--if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -633,17 +583,13 @@ if (!valid_y) {
- res.w[0] = (CY.w[0] & 0x0003ffffffffffffull);
- __mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
- res.w[1] |= ((CY.w[0]) & 0xfc00000000000000ull);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-+ BID_RETURN (res);
- }
- // y is Infinity?
- if (((y) & 0x7800000000000000ull) == 0x7800000000000000ull) {
- // return +/-0
- res.w[1] = sign_x ^ sign_y;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is 0, return +/-Inf
-@@ -653,8 +599,6 @@ if (!valid_y) {
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -703,8 +647,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // get number of decimal digits in CQ
-@@ -901,8 +843,6 @@ __div_256_by_128 (&CQ, &CA4, CY);
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #endif
-@@ -992,8 +932,6 @@ if (diff_expon >= 0) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-
- }
-@@ -1002,8 +940,6 @@ get_BID128 (&res, sign_x ^ sign_y, diff_expon, CQ, &rnd_mode, pfpsf);
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
--// restore the rounding mode back if it has been changed
--if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -1019,17 +955,10 @@ BID128_FUNCTION_ARGTYPE1_ARG128 (bid128dq_div, UINT64, x, y)
- digits_q, amount;
- int nzeros, i, j, k, d5;
- unsigned rmode;
-- int old_rm, rm_changed=0;
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
-
--// Set it to round-to-nearest (if different)
--if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
--}
--
- valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
-
- // unpack arguments, check for NaN or Infinity
-@@ -1049,8 +978,6 @@ if ((x & NAN_MASK64) == NAN_MASK64) {
- res.w[0] = (CX.w[0] & 0x0003ffffffffffffull);
- __mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
- res.w[1] |= ((CX.w[0]) & 0xfc00000000000000ull);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x is Infinity?
-@@ -1064,8 +991,6 @@ if ((x & 0x7800000000000000ull) == 0x7800000000000000ull) {
- #endif
- res.w[1] = 0x7c00000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
-@@ -1073,8 +998,6 @@ if ((x & 0x7800000000000000ull) == 0x7800000000000000ull) {
- res.w[1] =
- ((x ^ y.w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -1087,8 +1010,6 @@ if ((y.w[1] & INFINITY_MASK64) != INFINITY_MASK64) {
- // x=y=0, return NaN
- res.w[1] = 0x7c00000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // return 0
-@@ -1100,8 +1021,6 @@ if ((y.w[1] & INFINITY_MASK64) != INFINITY_MASK64) {
- exponent_x = 0;
- res.w[1] |= (((UINT64) exponent_x) << 49);
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -1118,8 +1037,6 @@ if (!valid_y) {
- #endif
- res.w[1] = CY.w[1] & QUIET_MASK64;
- res.w[0] = CY.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is Infinity?
-@@ -1127,8 +1044,6 @@ if (!valid_y) {
- // return +/-0
- res.w[1] = sign_x ^ sign_y;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is 0, return +/-Inf
-@@ -1138,8 +1053,6 @@ if (!valid_y) {
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -1188,8 +1101,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // get number of decimal digits in CQ
-@@ -1389,8 +1300,6 @@ __div_256_by_128 (&CQ, &CA4, CY);
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #endif
-@@ -1480,8 +1389,6 @@ if (diff_expon >= 0) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -1489,8 +1396,6 @@ get_BID128 (&res, sign_x ^ sign_y, diff_expon, CQ, &rnd_mode, pfpsf);
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
--// restore the rounding mode back if it has been changed
--if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-
- }
-@@ -1506,16 +1411,10 @@ BID128_FUNCTION_ARG128_ARGTYPE2 (bid128qd_div, x, UINT64, y)
- int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
- digits_q, amount;
- int nzeros, i, j, k, d5, rmode;
-- int old_rm, rm_changed=0;
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
-
--// Set it to round-to-nearest (if different)
--if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
--}
-
- valid_y = unpack_BID64 (&sign_y, &exponent_y, &CY.w[0], y);
- // unpack arguments, check for NaN or Infinity
-@@ -1529,8 +1428,6 @@ if ((x.w[1] & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
- #endif
- res.w[1] = (CX.w[1]) & QUIET_MASK64;
- res.w[0] = CX.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x is Infinity?
-@@ -1544,8 +1441,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
- #endif
- res.w[1] = 0x7c00000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is NaN?
-@@ -1556,8 +1451,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
- res.w[1] = ((x.w[1] ^ y) & 0x8000000000000000ull) |
- 0x7800000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -1570,8 +1463,6 @@ if ((y & 0x7800000000000000ull) < 0x7800000000000000ull) {
- // x=y=0, return NaN
- res.w[1] = 0x7c00000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // return 0
-@@ -1583,8 +1474,6 @@ if ((y & 0x7800000000000000ull) < 0x7800000000000000ull) {
- exponent_x = 0;
- res.w[1] |= (((UINT64) exponent_x) << 49);
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -1601,17 +1490,13 @@ if (!valid_y) {
- res.w[0] = (CY.w[0] & 0x0003ffffffffffffull);
- __mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
- res.w[1] |= ((CY.w[0]) & 0xfc00000000000000ull);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-+ BID_RETURN (res);
- }
- // y is Infinity?
- if ((y & INFINITY_MASK64) == INFINITY_MASK64) {
- // return +/-0
- res.w[1] = ((x.w[1] ^ y) & 0x8000000000000000ull);
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is 0
-@@ -1620,8 +1505,6 @@ if (!valid_y) {
- #endif
- res.w[1] = (sign_x ^ sign_y) | INFINITY_MASK64;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -1670,8 +1553,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // get number of decimal digits in CQ
-@@ -1868,8 +1749,6 @@ __div_256_by_128 (&CQ, &CA4, CY);
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #endif
-@@ -1959,8 +1838,6 @@ if (diff_expon >= 0) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-
- }
-@@ -1969,8 +1846,6 @@ get_BID128 (&res, sign_x ^ sign_y, diff_expon, CQ, &rnd_mode, pfpsf);
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
--// restore the rounding mode back if it has been changed
--if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-
- }
-diff --git a/libgcc/config/libbid/bid128_rem.c b/libgcc/config/libbid/bid128_rem.c
-old mode 100755
-new mode 100644
-index 68a88d25234f..f229b2869af3
---- a/libgcc/config/libbid/bid128_rem.c
-+++ b/libgcc/config/libbid/bid128_rem.c
-@@ -23,7 +23,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
-
- #define BID_128RES
- #include "bid_div_macros.h"
--#include <fenv.h>
-
-
- BID128_FUNCTION_ARG2_NORND_CUSTOMRESTYPE (UINT128, bid128_rem, x, y)
-@@ -35,16 +34,9 @@ BID128_FUNCTION_ARG2_NORND_CUSTOMRESTYPE (UINT128, bid128_rem, x, y)
- int_float f64, fx;
- int exponent_x, exponent_y, diff_expon, bin_expon_cx, scale,
- scale0;
-- int old_rm, rm_changed=0;
-
- // unpack arguments, check for NaN or Infinity
-
--// Set it to round-to-nearest (if different)
--if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
--}
--
- valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
-
- if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
-@@ -60,8 +52,6 @@ if ((x.w[1] & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
- #endif
- res.w[1] = CX.w[1] & QUIET_MASK64;
- res.w[0] = CX.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x is Infinity?
-@@ -76,8 +66,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
- #endif
- res.w[1] = 0x7c00000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -91,8 +79,6 @@ if ((!CY.w[1]) && (!CY.w[0])) {
- // x=y=0, return NaN
- res.w[1] = 0x7c00000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- if (valid_y || ((y.w[1] & NAN_MASK64) == INFINITY_MASK64)) {
-@@ -103,8 +89,6 @@ if (valid_y || ((y.w[1] & NAN_MASK64) == INFINITY_MASK64)) {
-
- res.w[1] = sign_x | (((UINT64) exponent_x) << 49);
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -119,8 +103,6 @@ if (!valid_y) {
- #endif
- res.w[1] = CY.w[1] & QUIET_MASK64;
- res.w[0] = CY.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is Infinity?
-@@ -128,8 +110,6 @@ if (!valid_y) {
- // return x
- res.w[1] = x.w[1];
- res.w[0] = x.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is 0
-@@ -139,8 +119,6 @@ if (!valid_y) {
- #endif
- res.w[1] = 0x7c00000000000000ull;
- res.w[0] = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -152,8 +130,6 @@ if (diff_expon <= 0) {
- if (diff_expon > 34) {
- // |x|<|y| in this case
- res = x;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // set exponent of y to exponent_x, scale coefficient_y
-@@ -163,8 +139,6 @@ if (diff_expon <= 0) {
- if (P256.w[2] || P256.w[3]) {
- // |x|<|y| in this case
- res = x;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -173,8 +147,6 @@ if (diff_expon <= 0) {
- if (__unsigned_compare_ge_128 (P256, CX2)) {
- // |x|<|y| in this case
- res = x;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -192,8 +164,6 @@ if (diff_expon <= 0) {
- }
-
- get_BID128_very_fast (&res, sign_x, exponent_x, CR);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // 2^64
-@@ -230,8 +200,6 @@ while (diff_expon > 0) {
- // check for remainder == 0
- if (!CX.w[1] && !CX.w[0]) {
- get_BID128_very_fast (&res, sign_x, exponent_y, CX);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -245,7 +213,5 @@ if ((__unsigned_compare_gt_128 (CX2, CY))
- }
-
- get_BID128_very_fast (&res, sign_x, exponent_y, CX);
--// restore the rounding mode back if it has been changed
--if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-diff --git a/libgcc/config/libbid/bid128_sqrt.c b/libgcc/config/libbid/bid128_sqrt.c
-old mode 100755
-new mode 100644
-index 577ece928876..b28038389ad1
---- a/libgcc/config/libbid/bid128_sqrt.c
-+++ b/libgcc/config/libbid/bid128_sqrt.c
-@@ -24,8 +24,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
- #define BID_128RES
- #include "bid_internal.h"
- #include "bid_sqrt_macros.h"
--#include <fenv.h>
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-+#include <fenv.h>
-+
- #define FE_ALL_FLAGS FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT
- #endif
-
-@@ -38,17 +39,10 @@ BID128_FUNCTION_ARG1 (bid128_sqrt, x)
- int_float fx, f64;
- int exponent_x, bin_expon_cx;
- int digits, scale, exponent_q;
-- int old_rm, rm_changed=0;
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
-
--// Set it to round-to-nearest (if different)
--if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
--}
--
- // unpack arguments, check for NaN or Infinity
- if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- res.w[1] = CX.w[1];
-@@ -60,8 +54,6 @@ if ((x.w[1] & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
- res.w[1] = CX.w[1] & QUIET_MASK64;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x is Infinity?
-@@ -74,8 +66,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
- }
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x is 0 otherwise
-@@ -84,8 +74,6 @@ res.w[1] =
- sign_x |
- ((((UINT64) (exponent_x + DECIMAL_EXPONENT_BIAS_128)) >> 1) << 49);
- res.w[0] = 0;
--// restore the rounding mode back if it has been changed
--if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- if (sign_x) {
-@@ -94,8 +82,6 @@ if (sign_x) {
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -131,8 +117,6 @@ if (CS.w[0] * CS.w[0] == A10.w[0]) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -304,8 +288,6 @@ get_BID128_fast (&res, 0,
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
--// restore the rounding mode back if it has been changed
--if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -320,18 +302,10 @@ BID128_FUNCTION_ARGTYPE1 (bid128d_sqrt, UINT64, x)
- int_float fx, f64;
- int exponent_x, bin_expon_cx;
- int digits, scale, exponent_q;
-- int old_rm, rm_changed=0;
--
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
-
--// Set it to round-to-nearest (if different)
--if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
--}
--
- // unpack arguments, check for NaN or Infinity
- // unpack arguments, check for NaN or Infinity
- CX.w[1] = 0;
-@@ -347,8 +321,6 @@ if ((x & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
- res.w[0] = (CX.w[0] & 0x0003ffffffffffffull);
- __mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
- res.w[1] |= ((CX.w[0]) & 0xfc00000000000000ull);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x is Infinity?
-@@ -360,8 +332,6 @@ if ((x & 0x7800000000000000ull) == 0x7800000000000000ull) {
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
- }
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x is 0 otherwise
-@@ -372,8 +342,6 @@ res.w[1] =
- sign_x | ((((UINT64) (exponent_x + DECIMAL_EXPONENT_BIAS_128)) >> 1)
- << 49);
- res.w[0] = 0;
--// restore the rounding mode back if it has been changed
--if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- if (sign_x) {
-@@ -382,8 +350,6 @@ if (sign_x) {
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -421,8 +387,6 @@ if (CS.w[0] * CS.w[0] == A10.w[0]) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -594,8 +558,7 @@ get_BID128_fast (&res, 0, (exponent_q + DECIMAL_EXPONENT_BIAS_128) >> 1,
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
--// restore the rounding mode back if it has been changed
--if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-
-+
- }
-diff --git a/libgcc/config/libbid/bid64_div.c b/libgcc/config/libbid/bid64_div.c
-old mode 100755
-new mode 100644
-index 7f34556c6d61..69758482b89e
---- a/libgcc/config/libbid/bid64_div.c
-+++ b/libgcc/config/libbid/bid64_div.c
-@@ -55,8 +55,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
-
- #include "bid_internal.h"
- #include "bid_div_macros.h"
--#include <fenv.h>
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-+#include <fenv.h>
-+
- #define FE_ALL_FLAGS FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT
- #endif
-
-@@ -64,6 +65,7 @@ extern UINT32 convert_table[5][128][2];
- extern SINT8 factors[][2];
- extern UINT8 packed_10000_zeros[];
-
-+
- #if DECIMAL_CALL_BY_REFERENCE
-
- void
-@@ -92,7 +94,6 @@ bid64_div (UINT64 x,
- int rmode, amount;
- int nzeros, i, j, k, d5;
- UINT32 QX32, tdigit[3], digit, digit_h, digit_low;
-- int old_rm, rm_changed=0;
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
-@@ -105,12 +106,6 @@ bid64_div (UINT64 x,
- y = *py;
- #endif
-
-- // Set it to round-to-nearest (if different)
-- if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
-- }
--
- valid_x = unpack_BID64 (&sign_x, &exponent_x, &coefficient_x, x);
- valid_y = unpack_BID64 (&sign_y, &exponent_y, &coefficient_y, y);
-
-@@ -128,8 +123,6 @@ bid64_div (UINT64 x,
- if ((x & SNAN_MASK64) == SNAN_MASK64) // sNaN
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (coefficient_x & QUIET_MASK64);
- }
- // x is Infinity?
-@@ -141,14 +134,10 @@ bid64_div (UINT64 x,
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (NAN_MASK64);
- }
- } else {
- // otherwise return +/-Inf
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (((x ^ y) & 0x8000000000000000ull) |
- INFINITY_MASK64);
- }
-@@ -160,8 +149,6 @@ bid64_div (UINT64 x,
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (NAN_MASK64);
- }
- if (((y & INFINITY_MASK64) != INFINITY_MASK64)) {
-@@ -176,8 +163,6 @@ bid64_div (UINT64 x,
- exponent_x = DECIMAL_MAX_EXPON_64;
- else if (exponent_x < 0)
- exponent_x = 0;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN ((sign_x ^ sign_y) | (((UINT64) exponent_x) << 53));
- }
-
-@@ -191,23 +176,17 @@ bid64_div (UINT64 x,
- if ((y & SNAN_MASK64) == SNAN_MASK64) // sNaN
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (coefficient_y & QUIET_MASK64);
- }
- // y is Infinity?
- if ((y & INFINITY_MASK64) == INFINITY_MASK64) {
- // return +/-0
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (((x ^ y) & 0x8000000000000000ull));
- }
- // y is 0
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN ((sign_x ^ sign_y) | INFINITY_MASK64);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -276,8 +255,6 @@ bid64_div (UINT64 x,
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // get decimal digits of Q
-@@ -447,8 +424,6 @@ bid64_div (UINT64 x,
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -519,8 +494,6 @@ bid64_div (UINT64 x,
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- } else {
- // UF occurs
-@@ -537,8 +510,6 @@ bid64_div (UINT64 x,
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-
- }
-@@ -557,17 +528,10 @@ int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
- digits_q, amount;
- int nzeros, i, j, k, d5, done = 0;
- unsigned rmode;
--int old_rm, rm_changed=0;
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
-
--// Set it to round-to-nearest (if different)
--if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
--}
--
- valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
-
- // unpack arguments, check for NaN or Infinity
-@@ -581,8 +545,6 @@ if (!unpack_BID64 (&sign_x, &exponent_x, &CX.w[0], (x))) {
- // test if x is NaN
- if (((x) & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
- res = CX.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res & QUIET_MASK64);
- }
- // x is Infinity?
-@@ -595,18 +557,14 @@ if (!unpack_BID64 (&sign_x, &exponent_x, &CX.w[0], (x))) {
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
- res = 0x7c00000000000000ull;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-- }
-- if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
-- // otherwise return +/-Inf
-- res =
-- (((x) ^ y.w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-+ if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
-+ // otherwise return +/-Inf
-+ res =
-+ (((x) ^ y.w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
-+ BID_RETURN (res);
-+ }
- }
- // x is 0
- if ((y.w[1] & INFINITY_MASK64) != INFINITY_MASK64) {
-@@ -616,8 +574,6 @@ if (!unpack_BID64 (&sign_x, &exponent_x, &CX.w[0], (x))) {
- #endif
- // x=y=0, return NaN
- res = 0x7c00000000000000ull;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // return 0
-@@ -628,8 +584,6 @@ if (!unpack_BID64 (&sign_x, &exponent_x, &CX.w[0], (x))) {
- else if (exponent_x < 0)
- exponent_x = 0;
- res |= (((UINT64) exponent_x) << 53);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -650,16 +604,12 @@ if (!valid_y) {
- amount = recip_scale[18];
- __shr_128 (Tmp, Qh, amount);
- res = (CY.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is Infinity?
- if ((y.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
- // return +/-0
- res = sign_x ^ sign_y;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is 0, return +/-Inf
-@@ -668,8 +618,6 @@ if (!valid_y) {
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -732,8 +680,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -870,17 +816,15 @@ if (!done) {
-
- }
- }
-- if(diff_expon>=0){
-- res =
-- fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
-- rnd_mode, pfpsf);
-+ if(diff_expon>=0){
-+ res =
-+ fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
-+ rnd_mode, pfpsf);
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-- }
-+ BID_RETURN (res);
-+ }
- }
- #endif
-
-@@ -961,8 +905,6 @@ if (!done) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- } else {
- // UF occurs
-@@ -979,9 +921,8 @@ if (!done) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-+
- }
-
- }
-@@ -1001,18 +942,10 @@ int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
- digits_q, amount;
- int nzeros, i, j, k, d5, done = 0;
- unsigned rmode;
--int old_rm, rm_changed=0;
--
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
-
--// Set it to round-to-nearest (if different)
--if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
--}
--
- valid_y = unpack_BID64 (&sign_y, &exponent_y, &CY.w[0], (y));
-
- // unpack arguments, check for NaN or Infinity
-@@ -1031,9 +964,7 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- amount = recip_scale[18];
- __shr_128 (Tmp, Qh, amount);
- res = (CX.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-+ BID_RETURN (res);
- }
- // x is Infinity?
- if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
-@@ -1045,18 +976,14 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
- res = 0x7c00000000000000ull;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-- }
-- if (((y & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
-- // otherwise return +/-Inf
-- res =
-- ((x.w[1] ^ (y)) & 0x8000000000000000ull) | 0x7800000000000000ull;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-+ if (((y & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
-+ // otherwise return +/-Inf
-+ res =
-+ ((x.w[1] ^ (y)) & 0x8000000000000000ull) | 0x7800000000000000ull;
-+ BID_RETURN (res);
-+ }
- }
- // x is 0
- if (((y & INFINITY_MASK64) != INFINITY_MASK64) &&
-@@ -1066,21 +993,17 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- #endif
- // x=y=0, return NaN
- res = 0x7c00000000000000ull;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // return 0
- if (((y & 0x7800000000000000ull) != 0x7800000000000000ull)) {
-- if (!CY.w[0]) {
-+ if (!CY.w[0]) {
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
- res = 0x7c00000000000000ull;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-- }
-+ }
- exponent_x =
- exponent_x - exponent_y - DECIMAL_EXPONENT_BIAS_128 +
- (DECIMAL_EXPONENT_BIAS << 1);
-@@ -1089,8 +1012,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- else if (exponent_x < 0)
- exponent_x = 0;
- res = (sign_x ^ sign_y) | (((UINT64) exponent_x) << 53);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -1104,16 +1025,12 @@ if (!valid_y) {
- if ((y & SNAN_MASK64) == SNAN_MASK64) // sNaN
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (CY.w[0] & QUIET_MASK64);
- }
- // y is Infinity?
- if (((y) & 0x7800000000000000ull) == 0x7800000000000000ull) {
- // return +/-0
- res = sign_x ^ sign_y;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is 0, return +/-Inf
-@@ -1122,8 +1039,6 @@ if (!valid_y) {
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -1188,8 +1103,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -1246,104 +1159,102 @@ if (!done) {
- #endif
- #ifndef LEAVE_TRAILING_ZEROS
- // check whether result is exact
-- {
-- if(!done) {
-- // check whether CX, CY are short
-- if (!CX.w[1] && !CY.w[1] && (CX.w[0] <= 1024) && (CY.w[0] <= 1024)) {
-- i = (int) CY.w[0] - 1;
-- j = (int) CX.w[0] - 1;
-- // difference in powers of 2 factors for Y and X
-- nzeros = ed2 - factors[i][0] + factors[j][0];
-- // difference in powers of 5 factors
-- d5 = ed2 - factors[i][1] + factors[j][1];
-- if (d5 < nzeros)
-- nzeros = d5;
-+ {
-+ if(!done) {
-+ // check whether CX, CY are short
-+ if (!CX.w[1] && !CY.w[1] && (CX.w[0] <= 1024) && (CY.w[0] <= 1024)) {
-+ i = (int) CY.w[0] - 1;
-+ j = (int) CX.w[0] - 1;
-+ // difference in powers of 2 factors for Y and X
-+ nzeros = ed2 - factors[i][0] + factors[j][0];
-+ // difference in powers of 5 factors
-+ d5 = ed2 - factors[i][1] + factors[j][1];
-+ if (d5 < nzeros)
-+ nzeros = d5;
-+ // get P*(2^M[extra_digits])/10^extra_digits
-+ __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
-+ //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2];
-+
-+ // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
-+ amount = recip_scale[nzeros];
-+ __shr_128_long (CQ, Qh, amount);
-+
-+ diff_expon += nzeros;
-+ } else {
-+ // decompose Q as Qh*10^17 + Ql
-+ //T128 = reciprocals10_128[17];
-+ Q_low = CQ.w[0];
-+
-+ {
-+ tdigit[0] = Q_low & 0x3ffffff;
-+ tdigit[1] = 0;
-+ QX = Q_low >> 26;
-+ QX32 = QX;
-+ nzeros = 0;
-+
-+ for (j = 0; QX32; j++, QX32 >>= 7) {
-+ k = (QX32 & 127);
-+ tdigit[0] += convert_table[j][k][0];
-+ tdigit[1] += convert_table[j][k][1];
-+ if (tdigit[0] >= 100000000) {
-+ tdigit[0] -= 100000000;
-+ tdigit[1]++;
-+ }
-+ }
-+
-+ if (tdigit[1] >= 100000000) {
-+ tdigit[1] -= 100000000;
-+ if (tdigit[1] >= 100000000)
-+ tdigit[1] -= 100000000;
-+ }
-+
-+ digit = tdigit[0];
-+ if (!digit && !tdigit[1])
-+ nzeros += 16;
-+ else {
-+ if (!digit) {
-+ nzeros += 8;
-+ digit = tdigit[1];
-+ }
-+ // decompose digit
-+ PD = (UINT64) digit *0x068DB8BBull;
-+ digit_h = (UINT32) (PD >> 40);
-+ digit_low = digit - digit_h * 10000;
-+
-+ if (!digit_low)
-+ nzeros += 4;
-+ else
-+ digit_h = digit_low;
-+
-+ if (!(digit_h & 1))
-+ nzeros +=
-+ 3 & (UINT32) (packed_10000_zeros[digit_h >> 3] >>
-+ (digit_h & 7));
-+ }
-+
-+ if (nzeros) {
- // get P*(2^M[extra_digits])/10^extra_digits
- __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
-- //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2];
-
- // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
- amount = recip_scale[nzeros];
-- __shr_128_long (CQ, Qh, amount);
--
-- diff_expon += nzeros;
-- } else {
-- // decompose Q as Qh*10^17 + Ql
-- //T128 = reciprocals10_128[17];
-- Q_low = CQ.w[0];
--
-- {
-- tdigit[0] = Q_low & 0x3ffffff;
-- tdigit[1] = 0;
-- QX = Q_low >> 26;
-- QX32 = QX;
-- nzeros = 0;
--
-- for (j = 0; QX32; j++, QX32 >>= 7) {
-- k = (QX32 & 127);
-- tdigit[0] += convert_table[j][k][0];
-- tdigit[1] += convert_table[j][k][1];
-- if (tdigit[0] >= 100000000) {
-- tdigit[0] -= 100000000;
-- tdigit[1]++;
-- }
-- }
--
-- if (tdigit[1] >= 100000000) {
-- tdigit[1] -= 100000000;
-- if (tdigit[1] >= 100000000)
-- tdigit[1] -= 100000000;
-- }
--
-- digit = tdigit[0];
-- if (!digit && !tdigit[1])
-- nzeros += 16;
-- else {
-- if (!digit) {
-- nzeros += 8;
-- digit = tdigit[1];
-- }
-- // decompose digit
-- PD = (UINT64) digit *0x068DB8BBull;
-- digit_h = (UINT32) (PD >> 40);
-- digit_low = digit - digit_h * 10000;
--
-- if (!digit_low)
-- nzeros += 4;
-- else
-- digit_h = digit_low;
--
-- if (!(digit_h & 1))
-- nzeros +=
-- 3 & (UINT32) (packed_10000_zeros[digit_h >> 3] >>
-- (digit_h & 7));
-- }
--
-- if (nzeros) {
-- // get P*(2^M[extra_digits])/10^extra_digits
-- __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
--
-- // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
-- amount = recip_scale[nzeros];
-- __shr_128 (CQ, Qh, amount);
-- }
-- diff_expon += nzeros;
--
-- }
-+ __shr_128 (CQ, Qh, amount);
- }
-+ diff_expon += nzeros;
-+
- }
-- if(diff_expon>=0){
-- res =
-- fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
-- rnd_mode, pfpsf);
-+ }
-+ }
-+ if(diff_expon>=0){
-+ res =
-+ fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
-+ rnd_mode, pfpsf);
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
-+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-- }
-- }
-+ BID_RETURN (res);
-+ }
-+ }
- #endif
-
- if (diff_expon >= 0) {
-@@ -1426,8 +1337,6 @@ if (!done) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- } else {
- // UF occurs
-@@ -1444,9 +1353,8 @@ if (!done) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-+
- }
-
- }
-@@ -1471,17 +1379,10 @@ int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
- digits_q, amount;
- int nzeros, i, j, k, d5, done = 0;
- unsigned rmode;
--int old_rm, rm_changed=0;
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
-
--// Set it to round-to-nearest (if different)
--if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
--}
--
- valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
-
- // unpack arguments, check for NaN or Infinity
-@@ -1500,9 +1401,7 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- amount = recip_scale[18];
- __shr_128 (Tmp, Qh, amount);
- res = (CX.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-+ BID_RETURN (res);
- }
- // x is Infinity?
- if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
-@@ -1514,19 +1413,15 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
- res = 0x7c00000000000000ull;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-- }
-- if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
-- // otherwise return +/-Inf
-- res =
-- ((x.w[1] ^ y.
-- w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-+ if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
-+ // otherwise return +/-Inf
-+ res =
-+ ((x.w[1] ^ y.
-+ w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
-+ BID_RETURN (res);
-+ }
- }
- // x is 0
- if (((y.w[1] & 0x7800000000000000ull) != 0x7800000000000000ull)) {
-@@ -1536,8 +1431,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- #endif
- // x=y=0, return NaN
- res = 0x7c00000000000000ull;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // return 0
-@@ -1548,8 +1441,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- else if (exponent_x < 0)
- exponent_x = 0;
- res |= (((UINT64) exponent_x) << 53);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -1569,16 +1460,12 @@ if (!valid_y) {
- amount = recip_scale[18];
- __shr_128 (Tmp, Qh, amount);
- res = (CY.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-+ BID_RETURN (res);
- }
- // y is Infinity?
- if ((y.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
- // return +/-0
- res = sign_x ^ sign_y;
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // y is 0, return +/-Inf
-@@ -1587,8 +1474,6 @@ if (!valid_y) {
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -1651,8 +1536,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -1711,102 +1594,100 @@ if (!done) {
- #ifndef LEAVE_TRAILING_ZEROS
- // check whether result is exact
- {
-- if(!done) {
-- // check whether CX, CY are short
-- if (!CX.w[1] && !CY.w[1] && (CX.w[0] <= 1024) && (CY.w[0] <= 1024)) {
-- i = (int) CY.w[0] - 1;
-- j = (int) CX.w[0] - 1;
-- // difference in powers of 2 factors for Y and X
-- nzeros = ed2 - factors[i][0] + factors[j][0];
-- // difference in powers of 5 factors
-- d5 = ed2 - factors[i][1] + factors[j][1];
-- if (d5 < nzeros)
-- nzeros = d5;
-- // get P*(2^M[extra_digits])/10^extra_digits
-- __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
-- //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2];
--
-- // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
-- amount = recip_scale[nzeros];
-- __shr_128_long (CQ, Qh, amount);
--
-- diff_expon += nzeros;
-- } else {
-- // decompose Q as Qh*10^17 + Ql
-- //T128 = reciprocals10_128[17];
-- Q_low = CQ.w[0];
--
-- {
-- tdigit[0] = Q_low & 0x3ffffff;
-- tdigit[1] = 0;
-- QX = Q_low >> 26;
-- QX32 = QX;
-- nzeros = 0;
--
-- for (j = 0; QX32; j++, QX32 >>= 7) {
-- k = (QX32 & 127);
-- tdigit[0] += convert_table[j][k][0];
-- tdigit[1] += convert_table[j][k][1];
-- if (tdigit[0] >= 100000000) {
-- tdigit[0] -= 100000000;
-- tdigit[1]++;
-- }
-+ if(!done) {
-+ // check whether CX, CY are short
-+ if (!CX.w[1] && !CY.w[1] && (CX.w[0] <= 1024) && (CY.w[0] <= 1024)) {
-+ i = (int) CY.w[0] - 1;
-+ j = (int) CX.w[0] - 1;
-+ // difference in powers of 2 factors for Y and X
-+ nzeros = ed2 - factors[i][0] + factors[j][0];
-+ // difference in powers of 5 factors
-+ d5 = ed2 - factors[i][1] + factors[j][1];
-+ if (d5 < nzeros)
-+ nzeros = d5;
-+ // get P*(2^M[extra_digits])/10^extra_digits
-+ __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
-+ //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2];
-+
-+ // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
-+ amount = recip_scale[nzeros];
-+ __shr_128_long (CQ, Qh, amount);
-+
-+ diff_expon += nzeros;
-+ } else {
-+ // decompose Q as Qh*10^17 + Ql
-+ //T128 = reciprocals10_128[17];
-+ Q_low = CQ.w[0];
-+
-+ {
-+ tdigit[0] = Q_low & 0x3ffffff;
-+ tdigit[1] = 0;
-+ QX = Q_low >> 26;
-+ QX32 = QX;
-+ nzeros = 0;
-+
-+ for (j = 0; QX32; j++, QX32 >>= 7) {
-+ k = (QX32 & 127);
-+ tdigit[0] += convert_table[j][k][0];
-+ tdigit[1] += convert_table[j][k][1];
-+ if (tdigit[0] >= 100000000) {
-+ tdigit[0] -= 100000000;
-+ tdigit[1]++;
- }
-+ }
-
-- if (tdigit[1] >= 100000000) {
-+ if (tdigit[1] >= 100000000) {
-+ tdigit[1] -= 100000000;
-+ if (tdigit[1] >= 100000000)
- tdigit[1] -= 100000000;
-- if (tdigit[1] >= 100000000)
-- tdigit[1] -= 100000000;
-- }
-+ }
-
-- digit = tdigit[0];
-- if (!digit && !tdigit[1])
-- nzeros += 16;
-- else {
-- if (!digit) {
-- nzeros += 8;
-- digit = tdigit[1];
-- }
-- // decompose digit
-- PD = (UINT64) digit *0x068DB8BBull;
-- digit_h = (UINT32) (PD >> 40);
-- digit_low = digit - digit_h * 10000;
--
-- if (!digit_low)
-- nzeros += 4;
-- else
-- digit_h = digit_low;
--
-- if (!(digit_h & 1))
-- nzeros +=
-- 3 & (UINT32) (packed_10000_zeros[digit_h >> 3] >>
-- (digit_h & 7));
-+ digit = tdigit[0];
-+ if (!digit && !tdigit[1])
-+ nzeros += 16;
-+ else {
-+ if (!digit) {
-+ nzeros += 8;
-+ digit = tdigit[1];
- }
-+ // decompose digit
-+ PD = (UINT64) digit *0x068DB8BBull;
-+ digit_h = (UINT32) (PD >> 40);
-+ digit_low = digit - digit_h * 10000;
-+
-+ if (!digit_low)
-+ nzeros += 4;
-+ else
-+ digit_h = digit_low;
-
-- if (nzeros) {
-- // get P*(2^M[extra_digits])/10^extra_digits
-- __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
-+ if (!(digit_h & 1))
-+ nzeros +=
-+ 3 & (UINT32) (packed_10000_zeros[digit_h >> 3] >>
-+ (digit_h & 7));
-+ }
-
-- // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
-- amount = recip_scale[nzeros];
-- __shr_128 (CQ, Qh, amount);
-- }
-- diff_expon += nzeros;
-+ if (nzeros) {
-+ // get P*(2^M[extra_digits])/10^extra_digits
-+ __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
-
-+ // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
-+ amount = recip_scale[nzeros];
-+ __shr_128 (CQ, Qh, amount);
- }
-+ diff_expon += nzeros;
-+
- }
- }
-- if(diff_expon>=0){
-- res =
-- fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
-- rnd_mode, pfpsf);
-+ }
-+ if(diff_expon>=0){
-+ res =
-+ fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
-+ rnd_mode, pfpsf);
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
-+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
-- BID_RETURN (res);
-- }
-+ BID_RETURN (res);
-+ }
- }
- #endif
-
-@@ -1891,8 +1772,6 @@ if (!done) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- } else {
- // UF occurs
-@@ -1909,9 +1788,8 @@ if (!done) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-+
- }
-
- }
-diff --git a/libgcc/config/libbid/bid64_sqrt.c b/libgcc/config/libbid/bid64_sqrt.c
-old mode 100755
-new mode 100644
-index 6309c425e811..29f4cf1f819f
---- a/libgcc/config/libbid/bid64_sqrt.c
-+++ b/libgcc/config/libbid/bid64_sqrt.c
-@@ -41,8 +41,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
-
- #include "bid_internal.h"
- #include "bid_sqrt_macros.h"
--#include <fenv.h>
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-+#include <fenv.h>
-+
- #define FE_ALL_FLAGS FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT
- #endif
-
-@@ -72,8 +73,6 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
- int exponent_x, exponent_q, bin_expon_cx;
- int digits_x;
- int scale;
-- int old_rm, rm_changed=0;
--
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
-@@ -85,12 +84,6 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
- x = *px;
- #endif
-
-- // Set it to round-to-nearest (if different)
-- if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
-- }
--
- // unpack arguments, check for NaN or Infinity
- if (!unpack_BID64 (&sign_x, &exponent_x, &coefficient_x, x)) {
- // x is Inf. or NaN or 0
-@@ -107,15 +100,11 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
- if ((x & SNAN_MASK64) == SNAN_MASK64) // sNaN
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res & QUIET_MASK64);
- }
- // x is 0
- exponent_x = (exponent_x + DECIMAL_EXPONENT_BIAS) >> 1;
- res = sign_x | (((UINT64) exponent_x) << 53);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x<0?
-@@ -124,8 +113,6 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -154,8 +141,6 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // if exponent is odd, scale coefficient by 10
-@@ -221,8 +206,6 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
-
-@@ -240,13 +223,6 @@ int digits, scale, exponent_q = 0, exact = 1, amount, extra_digits;
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- fexcept_t binaryflags = 0;
- #endif
--int old_rm, rm_changed=0;
--
--// Set it to round-to-nearest (if different)
--if ((old_rm=fegetround()) != FE_TONEAREST) {
-- rm_changed=1;
-- fesetround(FE_TONEAREST);
--}
-
- // unpack arguments, check for NaN or Infinity
- if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
-@@ -264,8 +240,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- amount = recip_scale[18];
- __shr_128 (Tmp, Qh, amount);
- res = (CX.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x is Infinity?
-@@ -277,8 +251,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
- }
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- // x is 0 otherwise
-@@ -292,8 +264,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
- exponent_x = DECIMAL_MAX_EXPON_64;
- //res= sign_x | (((UINT64)exponent_x)<<53);
- res = get_BID64 (sign_x, exponent_x, 0, rnd_mode, pfpsf);
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- if (sign_x) {
-@@ -301,8 +271,6 @@ if (sign_x) {
- #ifdef SET_STATUS_FLAGS
- __set_status_flags (pfpsf, INVALID_EXCEPTION);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
-@@ -344,8 +312,6 @@ if (CS.w[0] < 10000000000000000ull) {
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
-- // restore the rounding mode back if it has been changed
-- if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
- }
- }
-@@ -580,8 +546,7 @@ res = get_BID64 (0, exponent_q, CS.w[0], rnd_mode, pfpsf);
- #ifdef UNCHANGED_BINARY_STATUS_FLAGS
- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
- #endif
--// restore the rounding mode back if it has been changed
--if (rm_changed) fesetround(old_rm);
- BID_RETURN (res);
-
-+
- }
-
-base-commit: 78d19ea3fea308a08d2844de88d43154465daa78
---
-2.51.0
-
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-30 0:12 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-30 0:12 UTC (permalink / raw
To: gentoo-commits
commit: 7e40e5c5c5e6af26ac56d05799a3fbfaaed8c6c2
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 30 00:12:21 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug 30 00:12:21 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=7e40e5c5
16.0.0: revert patch causing mpfr to be underlinked
Bug: https://gcc.gnu.org/PR121718
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/92_all_PR121718-underlinked.patch | 1990 +++++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 1991 insertions(+)
diff --git a/16.0.0/gentoo/92_all_PR121718-underlinked.patch b/16.0.0/gentoo/92_all_PR121718-underlinked.patch
new file mode 100644
index 0000000..a68b73b
--- /dev/null
+++ b/16.0.0/gentoo/92_all_PR121718-underlinked.patch
@@ -0,0 +1,1990 @@
+From 8ed3eaa75908ec5ddb364625e05b3bcac5765a25 Mon Sep 17 00:00:00 2001
+Message-ID: <8ed3eaa75908ec5ddb364625e05b3bcac5765a25.1756512714.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Sat, 30 Aug 2025 01:11:52 +0100
+Subject: [PATCH] Revert "Fix _Decimal128 arithmetic error under FE_UPWARD."
+
+This reverts commit 50064b2898edfb83bc37f2597a35cbd3c1c853e3.
+---
+ gcc/testsuite/gcc.target/i386/pr120691.c | 18 -
+ libgcc/config/libbid/bid128_div.c | 135 +-----
+ libgcc/config/libbid/bid128_rem.c | 34 --
+ libgcc/config/libbid/bid128_sqrt.c | 43 +-
+ libgcc/config/libbid/bid64_div.c | 530 +++++++++--------------
+ libgcc/config/libbid/bid64_sqrt.c | 41 +-
+ 6 files changed, 215 insertions(+), 586 deletions(-)
+ delete mode 100644 gcc/testsuite/gcc.target/i386/pr120691.c
+ mode change 100755 => 100644 libgcc/config/libbid/bid128_div.c
+ mode change 100755 => 100644 libgcc/config/libbid/bid128_rem.c
+ mode change 100755 => 100644 libgcc/config/libbid/bid128_sqrt.c
+ mode change 100755 => 100644 libgcc/config/libbid/bid64_div.c
+ mode change 100755 => 100644 libgcc/config/libbid/bid64_sqrt.c
+
+diff --git a/gcc/testsuite/gcc.target/i386/pr120691.c b/gcc/testsuite/gcc.target/i386/pr120691.c
+deleted file mode 100644
+index 241a34faa457..000000000000
+--- a/gcc/testsuite/gcc.target/i386/pr120691.c
++++ /dev/null
+@@ -1,18 +0,0 @@
+-/* { dg-do run { target { ! ia32 } } } */
+-/* { dg-options "-O0 -mfpmath=sse" } */
+-/* { dg-require-effective-target fenv } */
+-/* { dg-require-effective-target dfp } */
+-
+-#include <fenv.h>
+-
+-int main() {
+- fesetround( FE_UPWARD );
+- _Decimal128 x1 = 9825, x2 = 10000 ;
+-
+- double c = (double) (x1 / x2);
+-
+- if (c != 0.9825)
+- __builtin_abort ();
+-
+- return 0 ;
+-}
+diff --git a/libgcc/config/libbid/bid128_div.c b/libgcc/config/libbid/bid128_div.c
+old mode 100755
+new mode 100644
+index 04955f27d38d..925bf14a3361
+--- a/libgcc/config/libbid/bid128_div.c
++++ b/libgcc/config/libbid/bid128_div.c
+@@ -24,16 +24,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ #define BID_128RES
+ #include "bid_div_macros.h"
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
++#include <fenv.h>
++
+ #define FE_ALL_FLAGS FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT
+ #endif
+-#include <stdio.h>
+-#include <fenv.h>
+
+ extern UINT32 convert_table[5][128][2];
+ extern SINT8 factors[][2];
+ extern UINT8 packed_10000_zeros[];
+
+-
+ BID128_FUNCTION_ARG2 (bid128_div, x, y)
+
+ UINT256 CA4, CA4r, P256;
+@@ -46,18 +45,10 @@ BID128_FUNCTION_ARG2 (bid128_div, x, y)
+ digits_q, amount;
+ int nzeros, i, j, k, d5;
+ unsigned rmode;
+- int old_rm, rm_changed=0;
+-
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+
+-// Set it to round-to-nearest (if different)
+-if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+-}
+-
+ valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
+
+ // unpack arguments, check for NaN or Infinity
+@@ -71,8 +62,6 @@ if ((x.w[1] & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
+ #endif
+ res.w[1] = (CX.w[1]) & QUIET_MASK64;
+ res.w[0] = CX.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x is Infinity?
+@@ -86,8 +75,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ #endif
+ res.w[1] = 0x7c00000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is NaN?
+@@ -98,8 +85,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ res.w[1] = ((x.w[1] ^ y.w[1]) & 0x8000000000000000ull) |
+ 0x7800000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -112,8 +97,6 @@ if ((y.w[1] & 0x7800000000000000ull) < 0x7800000000000000ull) {
+ // x=y=0, return NaN
+ res.w[1] = 0x7c00000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // return 0
+@@ -125,8 +108,6 @@ if ((y.w[1] & 0x7800000000000000ull) < 0x7800000000000000ull) {
+ exponent_x = 0;
+ res.w[1] |= (((UINT64) exponent_x) << 49);
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -141,8 +122,6 @@ if (!valid_y) {
+ #endif
+ res.w[1] = CY.w[1] & QUIET_MASK64;
+ res.w[0] = CY.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is Infinity?
+@@ -150,8 +129,6 @@ if (!valid_y) {
+ // return +/-0
+ res.w[1] = sign_x ^ sign_y;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is 0, return +/-Inf
+@@ -161,8 +138,6 @@ if (!valid_y) {
+ res.w[1] =
+ ((x.w[1] ^ y.w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -211,8 +186,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // get number of decimal digits in CQ
+@@ -406,8 +379,6 @@ if (!CA4.w[0] && !CA4.w[1])
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #endif
+@@ -498,8 +469,6 @@ if (diff_expon >= 0) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+
+ }
+@@ -508,8 +477,6 @@ get_BID128 (&res, sign_x ^ sign_y, diff_expon, CQ, &rnd_mode, pfpsf);
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+-// restore the rounding mode back if it has been changed
+-if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -529,17 +496,10 @@ TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2 (UINT128, bid128dd_div, UINT64, x,
+ digits_q, amount;
+ int nzeros, i, j, k, d5;
+ unsigned rmode;
+- int old_rm, rm_changed=0;
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+
+-// Set it to round-to-nearest (if different)
+-if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+-}
+-
+ valid_y = unpack_BID64 (&sign_y, &exponent_y, &CY.w[0], y);
+
+ // unpack arguments, check for NaN or Infinity
+@@ -559,8 +519,6 @@ if ((x & NAN_MASK64) == NAN_MASK64) {
+ res.w[0] = (CX.w[0] & 0x0003ffffffffffffull);
+ __mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
+ res.w[1] |= ((CX.w[0]) & 0xfc00000000000000ull);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x is Infinity?
+@@ -574,17 +532,13 @@ if (((x) & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ #endif
+ res.w[1] = 0x7c00000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
++ BID_RETURN (res);
+ }
+ if ((((y) & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
+ // otherwise return +/-Inf
+ res.w[1] =
+ (((x) ^ (y)) & 0x8000000000000000ull) | 0x7800000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -597,8 +551,6 @@ if ((((y) & 0x7800000000000000ull) != 0x7800000000000000ull)) {
+ // x=y=0, return NaN
+ res.w[1] = 0x7c00000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // return 0
+@@ -614,8 +566,6 @@ else if (exponent_x < 0)
+ exponent_x = 0;
+ res.w[1] |= (((UINT64) exponent_x) << 49);
+ res.w[0] = 0;
+-// restore the rounding mode back if it has been changed
+-if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -633,17 +583,13 @@ if (!valid_y) {
+ res.w[0] = (CY.w[0] & 0x0003ffffffffffffull);
+ __mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
+ res.w[1] |= ((CY.w[0]) & 0xfc00000000000000ull);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
++ BID_RETURN (res);
+ }
+ // y is Infinity?
+ if (((y) & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ // return +/-0
+ res.w[1] = sign_x ^ sign_y;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is 0, return +/-Inf
+@@ -653,8 +599,6 @@ if (!valid_y) {
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -703,8 +647,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // get number of decimal digits in CQ
+@@ -901,8 +843,6 @@ __div_256_by_128 (&CQ, &CA4, CY);
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #endif
+@@ -992,8 +932,6 @@ if (diff_expon >= 0) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+
+ }
+@@ -1002,8 +940,6 @@ get_BID128 (&res, sign_x ^ sign_y, diff_expon, CQ, &rnd_mode, pfpsf);
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+-// restore the rounding mode back if it has been changed
+-if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -1019,17 +955,10 @@ BID128_FUNCTION_ARGTYPE1_ARG128 (bid128dq_div, UINT64, x, y)
+ digits_q, amount;
+ int nzeros, i, j, k, d5;
+ unsigned rmode;
+- int old_rm, rm_changed=0;
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+
+-// Set it to round-to-nearest (if different)
+-if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+-}
+-
+ valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
+
+ // unpack arguments, check for NaN or Infinity
+@@ -1049,8 +978,6 @@ if ((x & NAN_MASK64) == NAN_MASK64) {
+ res.w[0] = (CX.w[0] & 0x0003ffffffffffffull);
+ __mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
+ res.w[1] |= ((CX.w[0]) & 0xfc00000000000000ull);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x is Infinity?
+@@ -1064,8 +991,6 @@ if ((x & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ #endif
+ res.w[1] = 0x7c00000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
+@@ -1073,8 +998,6 @@ if ((x & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ res.w[1] =
+ ((x ^ y.w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -1087,8 +1010,6 @@ if ((y.w[1] & INFINITY_MASK64) != INFINITY_MASK64) {
+ // x=y=0, return NaN
+ res.w[1] = 0x7c00000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // return 0
+@@ -1100,8 +1021,6 @@ if ((y.w[1] & INFINITY_MASK64) != INFINITY_MASK64) {
+ exponent_x = 0;
+ res.w[1] |= (((UINT64) exponent_x) << 49);
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -1118,8 +1037,6 @@ if (!valid_y) {
+ #endif
+ res.w[1] = CY.w[1] & QUIET_MASK64;
+ res.w[0] = CY.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is Infinity?
+@@ -1127,8 +1044,6 @@ if (!valid_y) {
+ // return +/-0
+ res.w[1] = sign_x ^ sign_y;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is 0, return +/-Inf
+@@ -1138,8 +1053,6 @@ if (!valid_y) {
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -1188,8 +1101,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // get number of decimal digits in CQ
+@@ -1389,8 +1300,6 @@ __div_256_by_128 (&CQ, &CA4, CY);
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #endif
+@@ -1480,8 +1389,6 @@ if (diff_expon >= 0) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -1489,8 +1396,6 @@ get_BID128 (&res, sign_x ^ sign_y, diff_expon, CQ, &rnd_mode, pfpsf);
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+-// restore the rounding mode back if it has been changed
+-if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+
+ }
+@@ -1506,16 +1411,10 @@ BID128_FUNCTION_ARG128_ARGTYPE2 (bid128qd_div, x, UINT64, y)
+ int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
+ digits_q, amount;
+ int nzeros, i, j, k, d5, rmode;
+- int old_rm, rm_changed=0;
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+
+-// Set it to round-to-nearest (if different)
+-if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+-}
+
+ valid_y = unpack_BID64 (&sign_y, &exponent_y, &CY.w[0], y);
+ // unpack arguments, check for NaN or Infinity
+@@ -1529,8 +1428,6 @@ if ((x.w[1] & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
+ #endif
+ res.w[1] = (CX.w[1]) & QUIET_MASK64;
+ res.w[0] = CX.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x is Infinity?
+@@ -1544,8 +1441,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ #endif
+ res.w[1] = 0x7c00000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is NaN?
+@@ -1556,8 +1451,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ res.w[1] = ((x.w[1] ^ y) & 0x8000000000000000ull) |
+ 0x7800000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -1570,8 +1463,6 @@ if ((y & 0x7800000000000000ull) < 0x7800000000000000ull) {
+ // x=y=0, return NaN
+ res.w[1] = 0x7c00000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // return 0
+@@ -1583,8 +1474,6 @@ if ((y & 0x7800000000000000ull) < 0x7800000000000000ull) {
+ exponent_x = 0;
+ res.w[1] |= (((UINT64) exponent_x) << 49);
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -1601,17 +1490,13 @@ if (!valid_y) {
+ res.w[0] = (CY.w[0] & 0x0003ffffffffffffull);
+ __mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
+ res.w[1] |= ((CY.w[0]) & 0xfc00000000000000ull);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
++ BID_RETURN (res);
+ }
+ // y is Infinity?
+ if ((y & INFINITY_MASK64) == INFINITY_MASK64) {
+ // return +/-0
+ res.w[1] = ((x.w[1] ^ y) & 0x8000000000000000ull);
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is 0
+@@ -1620,8 +1505,6 @@ if (!valid_y) {
+ #endif
+ res.w[1] = (sign_x ^ sign_y) | INFINITY_MASK64;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -1670,8 +1553,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // get number of decimal digits in CQ
+@@ -1868,8 +1749,6 @@ __div_256_by_128 (&CQ, &CA4, CY);
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #endif
+@@ -1959,8 +1838,6 @@ if (diff_expon >= 0) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+
+ }
+@@ -1969,8 +1846,6 @@ get_BID128 (&res, sign_x ^ sign_y, diff_expon, CQ, &rnd_mode, pfpsf);
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+-// restore the rounding mode back if it has been changed
+-if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+
+ }
+diff --git a/libgcc/config/libbid/bid128_rem.c b/libgcc/config/libbid/bid128_rem.c
+old mode 100755
+new mode 100644
+index 68a88d25234f..f229b2869af3
+--- a/libgcc/config/libbid/bid128_rem.c
++++ b/libgcc/config/libbid/bid128_rem.c
+@@ -23,7 +23,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+
+ #define BID_128RES
+ #include "bid_div_macros.h"
+-#include <fenv.h>
+
+
+ BID128_FUNCTION_ARG2_NORND_CUSTOMRESTYPE (UINT128, bid128_rem, x, y)
+@@ -35,16 +34,9 @@ BID128_FUNCTION_ARG2_NORND_CUSTOMRESTYPE (UINT128, bid128_rem, x, y)
+ int_float f64, fx;
+ int exponent_x, exponent_y, diff_expon, bin_expon_cx, scale,
+ scale0;
+- int old_rm, rm_changed=0;
+
+ // unpack arguments, check for NaN or Infinity
+
+-// Set it to round-to-nearest (if different)
+-if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+-}
+-
+ valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
+
+ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+@@ -60,8 +52,6 @@ if ((x.w[1] & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
+ #endif
+ res.w[1] = CX.w[1] & QUIET_MASK64;
+ res.w[0] = CX.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x is Infinity?
+@@ -76,8 +66,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ #endif
+ res.w[1] = 0x7c00000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -91,8 +79,6 @@ if ((!CY.w[1]) && (!CY.w[0])) {
+ // x=y=0, return NaN
+ res.w[1] = 0x7c00000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ if (valid_y || ((y.w[1] & NAN_MASK64) == INFINITY_MASK64)) {
+@@ -103,8 +89,6 @@ if (valid_y || ((y.w[1] & NAN_MASK64) == INFINITY_MASK64)) {
+
+ res.w[1] = sign_x | (((UINT64) exponent_x) << 49);
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -119,8 +103,6 @@ if (!valid_y) {
+ #endif
+ res.w[1] = CY.w[1] & QUIET_MASK64;
+ res.w[0] = CY.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is Infinity?
+@@ -128,8 +110,6 @@ if (!valid_y) {
+ // return x
+ res.w[1] = x.w[1];
+ res.w[0] = x.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is 0
+@@ -139,8 +119,6 @@ if (!valid_y) {
+ #endif
+ res.w[1] = 0x7c00000000000000ull;
+ res.w[0] = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -152,8 +130,6 @@ if (diff_expon <= 0) {
+ if (diff_expon > 34) {
+ // |x|<|y| in this case
+ res = x;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // set exponent of y to exponent_x, scale coefficient_y
+@@ -163,8 +139,6 @@ if (diff_expon <= 0) {
+ if (P256.w[2] || P256.w[3]) {
+ // |x|<|y| in this case
+ res = x;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -173,8 +147,6 @@ if (diff_expon <= 0) {
+ if (__unsigned_compare_ge_128 (P256, CX2)) {
+ // |x|<|y| in this case
+ res = x;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -192,8 +164,6 @@ if (diff_expon <= 0) {
+ }
+
+ get_BID128_very_fast (&res, sign_x, exponent_x, CR);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // 2^64
+@@ -230,8 +200,6 @@ while (diff_expon > 0) {
+ // check for remainder == 0
+ if (!CX.w[1] && !CX.w[0]) {
+ get_BID128_very_fast (&res, sign_x, exponent_y, CX);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -245,7 +213,5 @@ if ((__unsigned_compare_gt_128 (CX2, CY))
+ }
+
+ get_BID128_very_fast (&res, sign_x, exponent_y, CX);
+-// restore the rounding mode back if it has been changed
+-if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+diff --git a/libgcc/config/libbid/bid128_sqrt.c b/libgcc/config/libbid/bid128_sqrt.c
+old mode 100755
+new mode 100644
+index 577ece928876..b28038389ad1
+--- a/libgcc/config/libbid/bid128_sqrt.c
++++ b/libgcc/config/libbid/bid128_sqrt.c
+@@ -24,8 +24,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ #define BID_128RES
+ #include "bid_internal.h"
+ #include "bid_sqrt_macros.h"
+-#include <fenv.h>
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
++#include <fenv.h>
++
+ #define FE_ALL_FLAGS FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT
+ #endif
+
+@@ -38,17 +39,10 @@ BID128_FUNCTION_ARG1 (bid128_sqrt, x)
+ int_float fx, f64;
+ int exponent_x, bin_expon_cx;
+ int digits, scale, exponent_q;
+- int old_rm, rm_changed=0;
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+
+-// Set it to round-to-nearest (if different)
+-if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+-}
+-
+ // unpack arguments, check for NaN or Infinity
+ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ res.w[1] = CX.w[1];
+@@ -60,8 +54,6 @@ if ((x.w[1] & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+ res.w[1] = CX.w[1] & QUIET_MASK64;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x is Infinity?
+@@ -74,8 +66,6 @@ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+ }
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x is 0 otherwise
+@@ -84,8 +74,6 @@ res.w[1] =
+ sign_x |
+ ((((UINT64) (exponent_x + DECIMAL_EXPONENT_BIAS_128)) >> 1) << 49);
+ res.w[0] = 0;
+-// restore the rounding mode back if it has been changed
+-if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ if (sign_x) {
+@@ -94,8 +82,6 @@ if (sign_x) {
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -131,8 +117,6 @@ if (CS.w[0] * CS.w[0] == A10.w[0]) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -304,8 +288,6 @@ get_BID128_fast (&res, 0,
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+-// restore the rounding mode back if it has been changed
+-if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -320,18 +302,10 @@ BID128_FUNCTION_ARGTYPE1 (bid128d_sqrt, UINT64, x)
+ int_float fx, f64;
+ int exponent_x, bin_expon_cx;
+ int digits, scale, exponent_q;
+- int old_rm, rm_changed=0;
+-
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+
+-// Set it to round-to-nearest (if different)
+-if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+-}
+-
+ // unpack arguments, check for NaN or Infinity
+ // unpack arguments, check for NaN or Infinity
+ CX.w[1] = 0;
+@@ -347,8 +321,6 @@ if ((x & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
+ res.w[0] = (CX.w[0] & 0x0003ffffffffffffull);
+ __mul_64x64_to_128 (res, res.w[0], power10_table_128[18].w[0]);
+ res.w[1] |= ((CX.w[0]) & 0xfc00000000000000ull);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x is Infinity?
+@@ -360,8 +332,6 @@ if ((x & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+ }
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x is 0 otherwise
+@@ -372,8 +342,6 @@ res.w[1] =
+ sign_x | ((((UINT64) (exponent_x + DECIMAL_EXPONENT_BIAS_128)) >> 1)
+ << 49);
+ res.w[0] = 0;
+-// restore the rounding mode back if it has been changed
+-if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ if (sign_x) {
+@@ -382,8 +350,6 @@ if (sign_x) {
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -421,8 +387,6 @@ if (CS.w[0] * CS.w[0] == A10.w[0]) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -594,8 +558,7 @@ get_BID128_fast (&res, 0, (exponent_q + DECIMAL_EXPONENT_BIAS_128) >> 1,
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+-// restore the rounding mode back if it has been changed
+-if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+
++
+ }
+diff --git a/libgcc/config/libbid/bid64_div.c b/libgcc/config/libbid/bid64_div.c
+old mode 100755
+new mode 100644
+index 7f34556c6d61..69758482b89e
+--- a/libgcc/config/libbid/bid64_div.c
++++ b/libgcc/config/libbid/bid64_div.c
+@@ -55,8 +55,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+
+ #include "bid_internal.h"
+ #include "bid_div_macros.h"
+-#include <fenv.h>
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
++#include <fenv.h>
++
+ #define FE_ALL_FLAGS FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT
+ #endif
+
+@@ -64,6 +65,7 @@ extern UINT32 convert_table[5][128][2];
+ extern SINT8 factors[][2];
+ extern UINT8 packed_10000_zeros[];
+
++
+ #if DECIMAL_CALL_BY_REFERENCE
+
+ void
+@@ -92,7 +94,6 @@ bid64_div (UINT64 x,
+ int rmode, amount;
+ int nzeros, i, j, k, d5;
+ UINT32 QX32, tdigit[3], digit, digit_h, digit_low;
+- int old_rm, rm_changed=0;
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+@@ -105,12 +106,6 @@ bid64_div (UINT64 x,
+ y = *py;
+ #endif
+
+- // Set it to round-to-nearest (if different)
+- if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+- }
+-
+ valid_x = unpack_BID64 (&sign_x, &exponent_x, &coefficient_x, x);
+ valid_y = unpack_BID64 (&sign_y, &exponent_y, &coefficient_y, y);
+
+@@ -128,8 +123,6 @@ bid64_div (UINT64 x,
+ if ((x & SNAN_MASK64) == SNAN_MASK64) // sNaN
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (coefficient_x & QUIET_MASK64);
+ }
+ // x is Infinity?
+@@ -141,14 +134,10 @@ bid64_div (UINT64 x,
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (NAN_MASK64);
+ }
+ } else {
+ // otherwise return +/-Inf
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (((x ^ y) & 0x8000000000000000ull) |
+ INFINITY_MASK64);
+ }
+@@ -160,8 +149,6 @@ bid64_div (UINT64 x,
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (NAN_MASK64);
+ }
+ if (((y & INFINITY_MASK64) != INFINITY_MASK64)) {
+@@ -176,8 +163,6 @@ bid64_div (UINT64 x,
+ exponent_x = DECIMAL_MAX_EXPON_64;
+ else if (exponent_x < 0)
+ exponent_x = 0;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN ((sign_x ^ sign_y) | (((UINT64) exponent_x) << 53));
+ }
+
+@@ -191,23 +176,17 @@ bid64_div (UINT64 x,
+ if ((y & SNAN_MASK64) == SNAN_MASK64) // sNaN
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (coefficient_y & QUIET_MASK64);
+ }
+ // y is Infinity?
+ if ((y & INFINITY_MASK64) == INFINITY_MASK64) {
+ // return +/-0
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (((x ^ y) & 0x8000000000000000ull));
+ }
+ // y is 0
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN ((sign_x ^ sign_y) | INFINITY_MASK64);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -276,8 +255,6 @@ bid64_div (UINT64 x,
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // get decimal digits of Q
+@@ -447,8 +424,6 @@ bid64_div (UINT64 x,
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -519,8 +494,6 @@ bid64_div (UINT64 x,
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ } else {
+ // UF occurs
+@@ -537,8 +510,6 @@ bid64_div (UINT64 x,
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+
+ }
+@@ -557,17 +528,10 @@ int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
+ digits_q, amount;
+ int nzeros, i, j, k, d5, done = 0;
+ unsigned rmode;
+-int old_rm, rm_changed=0;
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+
+-// Set it to round-to-nearest (if different)
+-if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+-}
+-
+ valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
+
+ // unpack arguments, check for NaN or Infinity
+@@ -581,8 +545,6 @@ if (!unpack_BID64 (&sign_x, &exponent_x, &CX.w[0], (x))) {
+ // test if x is NaN
+ if (((x) & 0x7c00000000000000ull) == 0x7c00000000000000ull) {
+ res = CX.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res & QUIET_MASK64);
+ }
+ // x is Infinity?
+@@ -595,18 +557,14 @@ if (!unpack_BID64 (&sign_x, &exponent_x, &CX.w[0], (x))) {
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+ res = 0x7c00000000000000ull;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
+- }
+- if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
+- // otherwise return +/-Inf
+- res =
+- (((x) ^ y.w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
++ if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
++ // otherwise return +/-Inf
++ res =
++ (((x) ^ y.w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
++ BID_RETURN (res);
++ }
+ }
+ // x is 0
+ if ((y.w[1] & INFINITY_MASK64) != INFINITY_MASK64) {
+@@ -616,8 +574,6 @@ if (!unpack_BID64 (&sign_x, &exponent_x, &CX.w[0], (x))) {
+ #endif
+ // x=y=0, return NaN
+ res = 0x7c00000000000000ull;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // return 0
+@@ -628,8 +584,6 @@ if (!unpack_BID64 (&sign_x, &exponent_x, &CX.w[0], (x))) {
+ else if (exponent_x < 0)
+ exponent_x = 0;
+ res |= (((UINT64) exponent_x) << 53);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -650,16 +604,12 @@ if (!valid_y) {
+ amount = recip_scale[18];
+ __shr_128 (Tmp, Qh, amount);
+ res = (CY.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is Infinity?
+ if ((y.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ // return +/-0
+ res = sign_x ^ sign_y;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is 0, return +/-Inf
+@@ -668,8 +618,6 @@ if (!valid_y) {
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -732,8 +680,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -870,17 +816,15 @@ if (!done) {
+
+ }
+ }
+- if(diff_expon>=0){
+- res =
+- fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
+- rnd_mode, pfpsf);
++ if(diff_expon>=0){
++ res =
++ fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
++ rnd_mode, pfpsf);
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
+- }
++ BID_RETURN (res);
++ }
+ }
+ #endif
+
+@@ -961,8 +905,6 @@ if (!done) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ } else {
+ // UF occurs
+@@ -979,9 +921,8 @@ if (!done) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
++
+ }
+
+ }
+@@ -1001,18 +942,10 @@ int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
+ digits_q, amount;
+ int nzeros, i, j, k, d5, done = 0;
+ unsigned rmode;
+-int old_rm, rm_changed=0;
+-
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+
+-// Set it to round-to-nearest (if different)
+-if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+-}
+-
+ valid_y = unpack_BID64 (&sign_y, &exponent_y, &CY.w[0], (y));
+
+ // unpack arguments, check for NaN or Infinity
+@@ -1031,9 +964,7 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ amount = recip_scale[18];
+ __shr_128 (Tmp, Qh, amount);
+ res = (CX.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
++ BID_RETURN (res);
+ }
+ // x is Infinity?
+ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
+@@ -1045,18 +976,14 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+ res = 0x7c00000000000000ull;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
+- }
+- if (((y & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
+- // otherwise return +/-Inf
+- res =
+- ((x.w[1] ^ (y)) & 0x8000000000000000ull) | 0x7800000000000000ull;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
++ if (((y & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
++ // otherwise return +/-Inf
++ res =
++ ((x.w[1] ^ (y)) & 0x8000000000000000ull) | 0x7800000000000000ull;
++ BID_RETURN (res);
++ }
+ }
+ // x is 0
+ if (((y & INFINITY_MASK64) != INFINITY_MASK64) &&
+@@ -1066,21 +993,17 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ #endif
+ // x=y=0, return NaN
+ res = 0x7c00000000000000ull;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // return 0
+ if (((y & 0x7800000000000000ull) != 0x7800000000000000ull)) {
+- if (!CY.w[0]) {
++ if (!CY.w[0]) {
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+ res = 0x7c00000000000000ull;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+- }
++ }
+ exponent_x =
+ exponent_x - exponent_y - DECIMAL_EXPONENT_BIAS_128 +
+ (DECIMAL_EXPONENT_BIAS << 1);
+@@ -1089,8 +1012,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ else if (exponent_x < 0)
+ exponent_x = 0;
+ res = (sign_x ^ sign_y) | (((UINT64) exponent_x) << 53);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -1104,16 +1025,12 @@ if (!valid_y) {
+ if ((y & SNAN_MASK64) == SNAN_MASK64) // sNaN
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (CY.w[0] & QUIET_MASK64);
+ }
+ // y is Infinity?
+ if (((y) & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ // return +/-0
+ res = sign_x ^ sign_y;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is 0, return +/-Inf
+@@ -1122,8 +1039,6 @@ if (!valid_y) {
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -1188,8 +1103,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -1246,104 +1159,102 @@ if (!done) {
+ #endif
+ #ifndef LEAVE_TRAILING_ZEROS
+ // check whether result is exact
+- {
+- if(!done) {
+- // check whether CX, CY are short
+- if (!CX.w[1] && !CY.w[1] && (CX.w[0] <= 1024) && (CY.w[0] <= 1024)) {
+- i = (int) CY.w[0] - 1;
+- j = (int) CX.w[0] - 1;
+- // difference in powers of 2 factors for Y and X
+- nzeros = ed2 - factors[i][0] + factors[j][0];
+- // difference in powers of 5 factors
+- d5 = ed2 - factors[i][1] + factors[j][1];
+- if (d5 < nzeros)
+- nzeros = d5;
++ {
++ if(!done) {
++ // check whether CX, CY are short
++ if (!CX.w[1] && !CY.w[1] && (CX.w[0] <= 1024) && (CY.w[0] <= 1024)) {
++ i = (int) CY.w[0] - 1;
++ j = (int) CX.w[0] - 1;
++ // difference in powers of 2 factors for Y and X
++ nzeros = ed2 - factors[i][0] + factors[j][0];
++ // difference in powers of 5 factors
++ d5 = ed2 - factors[i][1] + factors[j][1];
++ if (d5 < nzeros)
++ nzeros = d5;
++ // get P*(2^M[extra_digits])/10^extra_digits
++ __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
++ //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2];
++
++ // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
++ amount = recip_scale[nzeros];
++ __shr_128_long (CQ, Qh, amount);
++
++ diff_expon += nzeros;
++ } else {
++ // decompose Q as Qh*10^17 + Ql
++ //T128 = reciprocals10_128[17];
++ Q_low = CQ.w[0];
++
++ {
++ tdigit[0] = Q_low & 0x3ffffff;
++ tdigit[1] = 0;
++ QX = Q_low >> 26;
++ QX32 = QX;
++ nzeros = 0;
++
++ for (j = 0; QX32; j++, QX32 >>= 7) {
++ k = (QX32 & 127);
++ tdigit[0] += convert_table[j][k][0];
++ tdigit[1] += convert_table[j][k][1];
++ if (tdigit[0] >= 100000000) {
++ tdigit[0] -= 100000000;
++ tdigit[1]++;
++ }
++ }
++
++ if (tdigit[1] >= 100000000) {
++ tdigit[1] -= 100000000;
++ if (tdigit[1] >= 100000000)
++ tdigit[1] -= 100000000;
++ }
++
++ digit = tdigit[0];
++ if (!digit && !tdigit[1])
++ nzeros += 16;
++ else {
++ if (!digit) {
++ nzeros += 8;
++ digit = tdigit[1];
++ }
++ // decompose digit
++ PD = (UINT64) digit *0x068DB8BBull;
++ digit_h = (UINT32) (PD >> 40);
++ digit_low = digit - digit_h * 10000;
++
++ if (!digit_low)
++ nzeros += 4;
++ else
++ digit_h = digit_low;
++
++ if (!(digit_h & 1))
++ nzeros +=
++ 3 & (UINT32) (packed_10000_zeros[digit_h >> 3] >>
++ (digit_h & 7));
++ }
++
++ if (nzeros) {
+ // get P*(2^M[extra_digits])/10^extra_digits
+ __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
+- //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2];
+
+ // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
+ amount = recip_scale[nzeros];
+- __shr_128_long (CQ, Qh, amount);
+-
+- diff_expon += nzeros;
+- } else {
+- // decompose Q as Qh*10^17 + Ql
+- //T128 = reciprocals10_128[17];
+- Q_low = CQ.w[0];
+-
+- {
+- tdigit[0] = Q_low & 0x3ffffff;
+- tdigit[1] = 0;
+- QX = Q_low >> 26;
+- QX32 = QX;
+- nzeros = 0;
+-
+- for (j = 0; QX32; j++, QX32 >>= 7) {
+- k = (QX32 & 127);
+- tdigit[0] += convert_table[j][k][0];
+- tdigit[1] += convert_table[j][k][1];
+- if (tdigit[0] >= 100000000) {
+- tdigit[0] -= 100000000;
+- tdigit[1]++;
+- }
+- }
+-
+- if (tdigit[1] >= 100000000) {
+- tdigit[1] -= 100000000;
+- if (tdigit[1] >= 100000000)
+- tdigit[1] -= 100000000;
+- }
+-
+- digit = tdigit[0];
+- if (!digit && !tdigit[1])
+- nzeros += 16;
+- else {
+- if (!digit) {
+- nzeros += 8;
+- digit = tdigit[1];
+- }
+- // decompose digit
+- PD = (UINT64) digit *0x068DB8BBull;
+- digit_h = (UINT32) (PD >> 40);
+- digit_low = digit - digit_h * 10000;
+-
+- if (!digit_low)
+- nzeros += 4;
+- else
+- digit_h = digit_low;
+-
+- if (!(digit_h & 1))
+- nzeros +=
+- 3 & (UINT32) (packed_10000_zeros[digit_h >> 3] >>
+- (digit_h & 7));
+- }
+-
+- if (nzeros) {
+- // get P*(2^M[extra_digits])/10^extra_digits
+- __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
+-
+- // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
+- amount = recip_scale[nzeros];
+- __shr_128 (CQ, Qh, amount);
+- }
+- diff_expon += nzeros;
+-
+- }
++ __shr_128 (CQ, Qh, amount);
+ }
++ diff_expon += nzeros;
++
+ }
+- if(diff_expon>=0){
+- res =
+- fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
+- rnd_mode, pfpsf);
++ }
++ }
++ if(diff_expon>=0){
++ res =
++ fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
++ rnd_mode, pfpsf);
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
++ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
+- }
+- }
++ BID_RETURN (res);
++ }
++ }
+ #endif
+
+ if (diff_expon >= 0) {
+@@ -1426,8 +1337,6 @@ if (!done) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ } else {
+ // UF occurs
+@@ -1444,9 +1353,8 @@ if (!done) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
++
+ }
+
+ }
+@@ -1471,17 +1379,10 @@ int exponent_x, exponent_y, bin_index, bin_expon, diff_expon, ed2,
+ digits_q, amount;
+ int nzeros, i, j, k, d5, done = 0;
+ unsigned rmode;
+-int old_rm, rm_changed=0;
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+
+-// Set it to round-to-nearest (if different)
+-if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+-}
+-
+ valid_y = unpack_BID128_value (&sign_y, &exponent_y, &CY, y);
+
+ // unpack arguments, check for NaN or Infinity
+@@ -1500,9 +1401,7 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ amount = recip_scale[18];
+ __shr_128 (Tmp, Qh, amount);
+ res = (CX.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
++ BID_RETURN (res);
+ }
+ // x is Infinity?
+ if ((x.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
+@@ -1514,19 +1413,15 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+ res = 0x7c00000000000000ull;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
+- }
+- if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
+- // otherwise return +/-Inf
+- res =
+- ((x.w[1] ^ y.
+- w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
++ if (((y.w[1] & 0x7c00000000000000ull) != 0x7c00000000000000ull)) {
++ // otherwise return +/-Inf
++ res =
++ ((x.w[1] ^ y.
++ w[1]) & 0x8000000000000000ull) | 0x7800000000000000ull;
++ BID_RETURN (res);
++ }
+ }
+ // x is 0
+ if (((y.w[1] & 0x7800000000000000ull) != 0x7800000000000000ull)) {
+@@ -1536,8 +1431,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ #endif
+ // x=y=0, return NaN
+ res = 0x7c00000000000000ull;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // return 0
+@@ -1548,8 +1441,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ else if (exponent_x < 0)
+ exponent_x = 0;
+ res |= (((UINT64) exponent_x) << 53);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -1569,16 +1460,12 @@ if (!valid_y) {
+ amount = recip_scale[18];
+ __shr_128 (Tmp, Qh, amount);
+ res = (CY.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
++ BID_RETURN (res);
+ }
+ // y is Infinity?
+ if ((y.w[1] & 0x7800000000000000ull) == 0x7800000000000000ull) {
+ // return +/-0
+ res = sign_x ^ sign_y;
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // y is 0, return +/-Inf
+@@ -1587,8 +1474,6 @@ if (!valid_y) {
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, ZERO_DIVIDE_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -1651,8 +1536,6 @@ if (__unsigned_compare_gt_128 (CY, CX)) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -1711,102 +1594,100 @@ if (!done) {
+ #ifndef LEAVE_TRAILING_ZEROS
+ // check whether result is exact
+ {
+- if(!done) {
+- // check whether CX, CY are short
+- if (!CX.w[1] && !CY.w[1] && (CX.w[0] <= 1024) && (CY.w[0] <= 1024)) {
+- i = (int) CY.w[0] - 1;
+- j = (int) CX.w[0] - 1;
+- // difference in powers of 2 factors for Y and X
+- nzeros = ed2 - factors[i][0] + factors[j][0];
+- // difference in powers of 5 factors
+- d5 = ed2 - factors[i][1] + factors[j][1];
+- if (d5 < nzeros)
+- nzeros = d5;
+- // get P*(2^M[extra_digits])/10^extra_digits
+- __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
+- //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2];
+-
+- // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
+- amount = recip_scale[nzeros];
+- __shr_128_long (CQ, Qh, amount);
+-
+- diff_expon += nzeros;
+- } else {
+- // decompose Q as Qh*10^17 + Ql
+- //T128 = reciprocals10_128[17];
+- Q_low = CQ.w[0];
+-
+- {
+- tdigit[0] = Q_low & 0x3ffffff;
+- tdigit[1] = 0;
+- QX = Q_low >> 26;
+- QX32 = QX;
+- nzeros = 0;
+-
+- for (j = 0; QX32; j++, QX32 >>= 7) {
+- k = (QX32 & 127);
+- tdigit[0] += convert_table[j][k][0];
+- tdigit[1] += convert_table[j][k][1];
+- if (tdigit[0] >= 100000000) {
+- tdigit[0] -= 100000000;
+- tdigit[1]++;
+- }
++ if(!done) {
++ // check whether CX, CY are short
++ if (!CX.w[1] && !CY.w[1] && (CX.w[0] <= 1024) && (CY.w[0] <= 1024)) {
++ i = (int) CY.w[0] - 1;
++ j = (int) CX.w[0] - 1;
++ // difference in powers of 2 factors for Y and X
++ nzeros = ed2 - factors[i][0] + factors[j][0];
++ // difference in powers of 5 factors
++ d5 = ed2 - factors[i][1] + factors[j][1];
++ if (d5 < nzeros)
++ nzeros = d5;
++ // get P*(2^M[extra_digits])/10^extra_digits
++ __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
++ //__mul_128x128_to_256(P256, CQ, reciprocals10_128[nzeros]);Qh.w[1]=P256.w[3];Qh.w[0]=P256.w[2];
++
++ // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
++ amount = recip_scale[nzeros];
++ __shr_128_long (CQ, Qh, amount);
++
++ diff_expon += nzeros;
++ } else {
++ // decompose Q as Qh*10^17 + Ql
++ //T128 = reciprocals10_128[17];
++ Q_low = CQ.w[0];
++
++ {
++ tdigit[0] = Q_low & 0x3ffffff;
++ tdigit[1] = 0;
++ QX = Q_low >> 26;
++ QX32 = QX;
++ nzeros = 0;
++
++ for (j = 0; QX32; j++, QX32 >>= 7) {
++ k = (QX32 & 127);
++ tdigit[0] += convert_table[j][k][0];
++ tdigit[1] += convert_table[j][k][1];
++ if (tdigit[0] >= 100000000) {
++ tdigit[0] -= 100000000;
++ tdigit[1]++;
+ }
++ }
+
+- if (tdigit[1] >= 100000000) {
++ if (tdigit[1] >= 100000000) {
++ tdigit[1] -= 100000000;
++ if (tdigit[1] >= 100000000)
+ tdigit[1] -= 100000000;
+- if (tdigit[1] >= 100000000)
+- tdigit[1] -= 100000000;
+- }
++ }
+
+- digit = tdigit[0];
+- if (!digit && !tdigit[1])
+- nzeros += 16;
+- else {
+- if (!digit) {
+- nzeros += 8;
+- digit = tdigit[1];
+- }
+- // decompose digit
+- PD = (UINT64) digit *0x068DB8BBull;
+- digit_h = (UINT32) (PD >> 40);
+- digit_low = digit - digit_h * 10000;
+-
+- if (!digit_low)
+- nzeros += 4;
+- else
+- digit_h = digit_low;
+-
+- if (!(digit_h & 1))
+- nzeros +=
+- 3 & (UINT32) (packed_10000_zeros[digit_h >> 3] >>
+- (digit_h & 7));
++ digit = tdigit[0];
++ if (!digit && !tdigit[1])
++ nzeros += 16;
++ else {
++ if (!digit) {
++ nzeros += 8;
++ digit = tdigit[1];
+ }
++ // decompose digit
++ PD = (UINT64) digit *0x068DB8BBull;
++ digit_h = (UINT32) (PD >> 40);
++ digit_low = digit - digit_h * 10000;
++
++ if (!digit_low)
++ nzeros += 4;
++ else
++ digit_h = digit_low;
+
+- if (nzeros) {
+- // get P*(2^M[extra_digits])/10^extra_digits
+- __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
++ if (!(digit_h & 1))
++ nzeros +=
++ 3 & (UINT32) (packed_10000_zeros[digit_h >> 3] >>
++ (digit_h & 7));
++ }
+
+- // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
+- amount = recip_scale[nzeros];
+- __shr_128 (CQ, Qh, amount);
+- }
+- diff_expon += nzeros;
++ if (nzeros) {
++ // get P*(2^M[extra_digits])/10^extra_digits
++ __mul_128x128_high (Qh, CQ, reciprocals10_128[nzeros]);
+
++ // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128
++ amount = recip_scale[nzeros];
++ __shr_128 (CQ, Qh, amount);
+ }
++ diff_expon += nzeros;
++
+ }
+ }
+- if(diff_expon>=0){
+- res =
+- fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
+- rnd_mode, pfpsf);
++ }
++ if(diff_expon>=0){
++ res =
++ fast_get_BID64_check_OF (sign_x ^ sign_y, diff_expon, CQ.w[0],
++ rnd_mode, pfpsf);
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+- (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
++ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+- BID_RETURN (res);
+- }
++ BID_RETURN (res);
++ }
+ }
+ #endif
+
+@@ -1891,8 +1772,6 @@ if (!done) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ } else {
+ // UF occurs
+@@ -1909,9 +1788,8 @@ if (!done) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
++
+ }
+
+ }
+diff --git a/libgcc/config/libbid/bid64_sqrt.c b/libgcc/config/libbid/bid64_sqrt.c
+old mode 100755
+new mode 100644
+index 6309c425e811..29f4cf1f819f
+--- a/libgcc/config/libbid/bid64_sqrt.c
++++ b/libgcc/config/libbid/bid64_sqrt.c
+@@ -41,8 +41,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+
+ #include "bid_internal.h"
+ #include "bid_sqrt_macros.h"
+-#include <fenv.h>
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
++#include <fenv.h>
++
+ #define FE_ALL_FLAGS FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT
+ #endif
+
+@@ -72,8 +73,6 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
+ int exponent_x, exponent_q, bin_expon_cx;
+ int digits_x;
+ int scale;
+- int old_rm, rm_changed=0;
+-
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+@@ -85,12 +84,6 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
+ x = *px;
+ #endif
+
+- // Set it to round-to-nearest (if different)
+- if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+- }
+-
+ // unpack arguments, check for NaN or Infinity
+ if (!unpack_BID64 (&sign_x, &exponent_x, &coefficient_x, x)) {
+ // x is Inf. or NaN or 0
+@@ -107,15 +100,11 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
+ if ((x & SNAN_MASK64) == SNAN_MASK64) // sNaN
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res & QUIET_MASK64);
+ }
+ // x is 0
+ exponent_x = (exponent_x + DECIMAL_EXPONENT_BIAS) >> 1;
+ res = sign_x | (((UINT64) exponent_x) << 53);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x<0?
+@@ -124,8 +113,6 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -154,8 +141,6 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // if exponent is odd, scale coefficient by 10
+@@ -221,8 +206,6 @@ bid64_sqrt (UINT64 x _RND_MODE_PARAM _EXC_FLAGS_PARAM
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+
+@@ -240,13 +223,6 @@ int digits, scale, exponent_q = 0, exact = 1, amount, extra_digits;
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ fexcept_t binaryflags = 0;
+ #endif
+-int old_rm, rm_changed=0;
+-
+-// Set it to round-to-nearest (if different)
+-if ((old_rm=fegetround()) != FE_TONEAREST) {
+- rm_changed=1;
+- fesetround(FE_TONEAREST);
+-}
+
+ // unpack arguments, check for NaN or Infinity
+ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+@@ -264,8 +240,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ amount = recip_scale[18];
+ __shr_128 (Tmp, Qh, amount);
+ res = (CX.w[1] & 0xfc00000000000000ull) | Tmp.w[0];
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x is Infinity?
+@@ -277,8 +251,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+ }
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ // x is 0 otherwise
+@@ -292,8 +264,6 @@ if (!unpack_BID128_value (&sign_x, &exponent_x, &CX, x)) {
+ exponent_x = DECIMAL_MAX_EXPON_64;
+ //res= sign_x | (((UINT64)exponent_x)<<53);
+ res = get_BID64 (sign_x, exponent_x, 0, rnd_mode, pfpsf);
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ if (sign_x) {
+@@ -301,8 +271,6 @@ if (sign_x) {
+ #ifdef SET_STATUS_FLAGS
+ __set_status_flags (pfpsf, INVALID_EXCEPTION);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+@@ -344,8 +312,6 @@ if (CS.w[0] < 10000000000000000ull) {
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+- // restore the rounding mode back if it has been changed
+- if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+ }
+ }
+@@ -580,8 +546,7 @@ res = get_BID64 (0, exponent_q, CS.w[0], rnd_mode, pfpsf);
+ #ifdef UNCHANGED_BINARY_STATUS_FLAGS
+ (void) fesetexceptflag (&binaryflags, FE_ALL_FLAGS);
+ #endif
+-// restore the rounding mode back if it has been changed
+-if (rm_changed) fesetround(old_rm);
+ BID_RETURN (res);
+
++
+ }
+
+base-commit: 78d19ea3fea308a08d2844de88d43154465daa78
+--
+2.51.0
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index bf2028a..7bdc805 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -3,6 +3,7 @@
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
+ 90_all_PR121725-x86-64-Use-UNSPEC_DTPOFF-to-check-source-operand-in-.patch
+ 91_all_PR121699-mesa.patch
+ + 92_all_PR121718-underlinked.patch
12 24 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-29 21:26 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-29 21:26 UTC (permalink / raw
To: gentoo-commits
commit: 6af421171ec76c155d2d1087d4f4eb3bf78fe58f
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 29 21:26:43 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 29 21:26:43 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=6af42117
16.0.0: drop patch merged upstream for m2
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/89_all_PR121709-fix-build.patch | 172 --------------------------
16.0.0/gentoo/README.history | 1 -
2 files changed, 173 deletions(-)
diff --git a/16.0.0/gentoo/89_all_PR121709-fix-build.patch b/16.0.0/gentoo/89_all_PR121709-fix-build.patch
deleted file mode 100644
index 250cfc4..0000000
--- a/16.0.0/gentoo/89_all_PR121709-fix-build.patch
+++ /dev/null
@@ -1,172 +0,0 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121709#c10
-diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi
-index 4147a287c45..d908aeaaa05 100644
---- a/gcc/doc/gm2.texi
-+++ b/gcc/doc/gm2.texi
-@@ -1455,13 +1455,17 @@ PIM4 dialect. This is a temporary implementation situation.
-
- This section describes the default module search path and how this
- might be changed. By default the compiler will search the current
--directory, site wide modules and lastly gcc version specific modules.
-+directory, local include dir, prefix include dir, gcc version specific
-+modules and lastly native system header dir. The exact location and
-+whether all these directories are used depends upon the configuration
-+options used when building GCC.
-
- The @samp{-I} option option can be used to introduce new directories
- in the module search path and for convenience the options @samp{-flibs=}
- and @samp{-fm2-pathname-root=} are also provided.
-
--The site wide modules are located at @var{prefix}@file{/include/m2}
-+The site wide modules are typically located at
-+@var{prefix}@file{/include/m2}
- whereas the version specific modules are located in
- @var{libsubdir}@file{/m2}. Both of these @file{/m2} directories
- are organized such that the non dialect specific modules are at the
-diff --git a/gcc/m2/gm2-lang.cc b/gcc/m2/gm2-lang.cc
-index d378d1bc212..cc074d550fc 100644
---- a/gcc/m2/gm2-lang.cc
-+++ b/gcc/m2/gm2-lang.cc
-@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see
- #include "m2-tree.h"
- #include "convert.h"
- #include "rtegraph.h"
-+#include "cppdefault.h"
-
- static void write_globals (void);
-
-@@ -60,6 +61,7 @@ static bool allow_libraries = true;
- static const char *flibs = nullptr;
- static const char *iprefix = nullptr;
- static const char *imultilib = nullptr;
-+static const char *target_system_root = nullptr;
- static std::vector<named_path>Ipaths;
- static std::vector<const char*>isystem;
- static std::vector<const char*>iquote;
-@@ -537,17 +539,86 @@ get_module_source_dir (void)
- return lib;
- }
-
-+/* concat_component returns a string containing the path left/right.
-+ Pre-requisite, left and right are null terminated strings. The contents of
-+ left and right are held on the heap. Post-requisite, left and right are
-+ freed and a new combined string is malloced. */
-+
-+static char *
-+concat_component (char *left, char *right)
-+{
-+ size_t len = strlen (left)
-+ + strlen (right)
-+ + get_dir_sep_size ()
-+ + 1;
-+ char *new_str = (char *) xmalloc (len);
-+ strcpy (new_str, left);
-+ add_path_component (new_str, right);
-+ free (left);
-+ free (right);
-+ return new_str;
-+}
-+
-+/* find_cpp_entry return the element of the cpp_include_defaults array
-+ whose fname matches name. */
-+
-+static const struct default_include *
-+find_cpp_entry (const char *name)
-+{
-+ const struct default_include *p;
-+
-+ for (p = cpp_include_defaults; p->fname; p++)
-+ if (strcmp (p->fname, name) == 0)
-+ return p;
-+ return NULL;
-+}
-+
-+/* lookup_cpp_default lookup the entry in cppdefault then add the directory to
-+ the m2 search path. It also honours sysroot, imultilib and imultiarch. */
-+
-+static void
-+lookup_cpp_default (const char *sysroot, const char *flibs, const char *name)
-+{
-+ const struct default_include *p = find_cpp_entry (name);
-+
-+ if (p != NULL)
-+ {
-+ char *full_str = xstrdup (p->fname);
-+
-+ /* Should this directory start with the sysroot? */
-+ if (sysroot && p->add_sysroot)
-+ full_str = concat_component (xstrdup (sysroot), full_str);
-+ /* Should we append the imultilib component? */
-+ if (p->multilib == 1 && imultilib)
-+ full_str = concat_component (full_str, xstrdup (imultilib));
-+ /* Or append the imultiarch component? */
-+ else if (p->multilib == 2 && imultiarch)
-+ full_str = concat_component (full_str, xstrdup (imultiarch));
-+ else
-+ full_str = xstrdup (p->fname);
-+ foreach_lib_gen_import_path (flibs, full_str);
-+ free (full_str);
-+ }
-+}
-+
- /* add_default_include_paths add include paths for site wide definition modules
- and also gcc version specific definition modules. */
-
- static void
- add_default_include_paths (const char *flibs)
- {
-- /* Add the site wide include path. */
-- foreach_lib_gen_import_path (flibs, PREFIX_INCLUDE_DIR);
-+ /* Follow the order found in cppdefaults.cc. */
-+#ifdef LOCAL_INCLUDE_DIR
-+ lookup_cpp_default (target_system_root, flibs, LOCAL_INCLUDE_DIR);
-+#endif
-+#ifdef PREFIX_INCLUDE_DIR
-+ lookup_cpp_default (target_system_root, flibs, PREFIX_INCLUDE_DIR);
-+#endif
- /* Add the gcc version specific include path. */
-- foreach_lib_gen_import_path (flibs,
-- get_module_source_dir ());
-+ foreach_lib_gen_import_path (flibs, get_module_source_dir ());
-+#ifdef NATIVE_SYSTEM_HEADER_DIR
-+ lookup_cpp_default (target_system_root, flibs, NATIVE_SYSTEM_HEADER_DIR);
-+#endif
- }
-
- /* assign_flibs assign flibs to a default providing that allow_libraries
-@@ -565,26 +636,6 @@ assign_flibs (void)
- }
- }
-
--/* m2_pathname_root creates a new set of include paths for the
-- subdirectory m2 inside libroot. The ordering of the paths
-- follows the dialect library order. */
--
--static void
--m2_pathname_root (const char *libroot)
--{
-- const char *copy_flibs = flibs;
--
-- if (copy_flibs == NULL)
-- {
-- if (iso)
-- copy_flibs = "m2iso,m2cor,m2pim,m2log";
-- else
-- copy_flibs = "m2pim,m2iso,m2cor,m2log";
-- }
-- foreach_lib_gen_import_path (copy_flibs, libroot);
--}
--
--
- /* Handle gm2 specific options. Return 0 if we didn't do anything. */
-
- bool
-@@ -858,7 +909,7 @@ gm2_langhook_handle_option (
- return 1;
- break;
- case OPT_isysroot:
-- /* Otherwise, ignored, at least for now. */
-+ target_system_root = arg;
- return 1;
- break;
- case OPT_fm2_whole_program:
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 7dbbab6..bf2028a 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,7 +1,6 @@
13 ????
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
- + 89_all_PR121709-fix-build.patch
+ 90_all_PR121725-x86-64-Use-UNSPEC_DTPOFF-to-check-source-operand-in-.patch
+ 91_all_PR121699-mesa.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-29 21:02 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-29 21:02 UTC (permalink / raw
To: gentoo-commits
commit: 50164485d7faf10e8f84f19a339bd826173faec0
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 29 21:02:11 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 29 21:02:11 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=50164485
16.0.0: iupdate m2 patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/89_all_PR121709-fix-build.patch | 50 +++++++++++++++++++++------
1 file changed, 40 insertions(+), 10 deletions(-)
diff --git a/16.0.0/gentoo/89_all_PR121709-fix-build.patch b/16.0.0/gentoo/89_all_PR121709-fix-build.patch
index 0d185a5..250cfc4 100644
--- a/16.0.0/gentoo/89_all_PR121709-fix-build.patch
+++ b/16.0.0/gentoo/89_all_PR121709-fix-build.patch
@@ -1,6 +1,30 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121709#c8
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121709#c10
+diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi
+index 4147a287c45..d908aeaaa05 100644
+--- a/gcc/doc/gm2.texi
++++ b/gcc/doc/gm2.texi
+@@ -1455,13 +1455,17 @@ PIM4 dialect. This is a temporary implementation situation.
+
+ This section describes the default module search path and how this
+ might be changed. By default the compiler will search the current
+-directory, site wide modules and lastly gcc version specific modules.
++directory, local include dir, prefix include dir, gcc version specific
++modules and lastly native system header dir. The exact location and
++whether all these directories are used depends upon the configuration
++options used when building GCC.
+
+ The @samp{-I} option option can be used to introduce new directories
+ in the module search path and for convenience the options @samp{-flibs=}
+ and @samp{-fm2-pathname-root=} are also provided.
+
+-The site wide modules are located at @var{prefix}@file{/include/m2}
++The site wide modules are typically located at
++@var{prefix}@file{/include/m2}
+ whereas the version specific modules are located in
+ @var{libsubdir}@file{/m2}. Both of these @file{/m2} directories
+ are organized such that the non dialect specific modules are at the
diff --git a/gcc/m2/gm2-lang.cc b/gcc/m2/gm2-lang.cc
-index d378d1bc212..1b1b94a1f1d 100644
+index d378d1bc212..cc074d550fc 100644
--- a/gcc/m2/gm2-lang.cc
+++ b/gcc/m2/gm2-lang.cc
@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see
@@ -19,15 +43,17 @@ index d378d1bc212..1b1b94a1f1d 100644
static std::vector<named_path>Ipaths;
static std::vector<const char*>isystem;
static std::vector<const char*>iquote;
-@@ -537,17 +539,80 @@ get_module_source_dir (void)
+@@ -537,17 +539,86 @@ get_module_source_dir (void)
return lib;
}
-+/* concat_component returns a string containing the path
-+ left/right. */
++/* concat_component returns a string containing the path left/right.
++ Pre-requisite, left and right are null terminated strings. The contents of
++ left and right are held on the heap. Post-requisite, left and right are
++ freed and a new combined string is malloced. */
+
+static char *
-+concat_component (const char *left, const char *right)
++concat_component (char *left, char *right)
+{
+ size_t len = strlen (left)
+ + strlen (right)
@@ -36,6 +62,8 @@ index d378d1bc212..1b1b94a1f1d 100644
+ char *new_str = (char *) xmalloc (len);
+ strcpy (new_str, left);
+ add_path_component (new_str, right);
++ free (left);
++ free (right);
+ return new_str;
+}
+
@@ -70,10 +98,12 @@ index d378d1bc212..1b1b94a1f1d 100644
+ full_str = concat_component (xstrdup (sysroot), full_str);
+ /* Should we append the imultilib component? */
+ if (p->multilib == 1 && imultilib)
-+ full_str = concat_component (full_str, imultilib);
++ full_str = concat_component (full_str, xstrdup (imultilib));
+ /* Or append the imultiarch component? */
+ else if (p->multilib == 2 && imultiarch)
-+ full_str = concat_component (full_str, imultiarch);
++ full_str = concat_component (full_str, xstrdup (imultiarch));
++ else
++ full_str = xstrdup (p->fname);
+ foreach_lib_gen_import_path (flibs, full_str);
+ free (full_str);
+ }
@@ -104,7 +134,7 @@ index d378d1bc212..1b1b94a1f1d 100644
}
/* assign_flibs assign flibs to a default providing that allow_libraries
-@@ -565,26 +630,6 @@ assign_flibs (void)
+@@ -565,26 +636,6 @@ assign_flibs (void)
}
}
@@ -131,7 +161,7 @@ index d378d1bc212..1b1b94a1f1d 100644
/* Handle gm2 specific options. Return 0 if we didn't do anything. */
bool
-@@ -858,7 +903,7 @@ gm2_langhook_handle_option (
+@@ -858,7 +909,7 @@ gm2_langhook_handle_option (
return 1;
break;
case OPT_isysroot:
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-29 20:24 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-29 20:24 UTC (permalink / raw
To: gentoo-commits
commit: d986b3c66151eab326edf7b8175a6c97490dc38e
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 29 20:24:33 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 29 20:24:33 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=d986b3c6
16.0.0: fix mesa ICE w/ avx512
Bug: https://gcc.gnu.org/PR121699
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/91_all_PR121699-mesa.patch | 39 ++++++++++++++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 40 insertions(+)
diff --git a/16.0.0/gentoo/91_all_PR121699-mesa.patch b/16.0.0/gentoo/91_all_PR121699-mesa.patch
new file mode 100644
index 0000000..977aeda
--- /dev/null
+++ b/16.0.0/gentoo/91_all_PR121699-mesa.patch
@@ -0,0 +1,39 @@
+ 1) Fix predicate of operands[3] in cond_<insn><mode> since only
+ const_vec_dup_operand is excepted for masked operations, and pass real
+ count to ix86_vgf2p8affine_shift_matrix.
+
+ 2) Pass operands[2] instead of operands[1] to
+ gen_vgf2p8affineqb_<mode>_mask which excepted the operand to shifted,
+ but operands[1] is mask operand in cond_<insn><mode>.
+--- a/gcc/config/i386/predicates.md
++++ b/gcc/config/i386/predicates.md
+@@ -1319,6 +1319,9 @@ (define_predicate "nonimmediate_or_const_vec_dup_operand"
+ (ior (match_operand 0 "nonimmediate_operand")
+ (match_test "const_vec_duplicate_p (op)")))
+
++(define_predicate "const_vec_dup_operand"
++ (match_test "const_vec_duplicate_p (op)"))
++
+ ;; Return true when OP is either register operand, or any
+ ;; CONST_VECTOR.
+ (define_predicate "reg_or_const_vector_operand"
+--- a/gcc/config/i386/sse.md
++++ b/gcc/config/i386/sse.md
+@@ -27007,13 +27007,14 @@ (define_expand "cond_<insn><mode>"
+ (vec_merge:VI1_AVX512VL
+ (any_shift:VI1_AVX512VL
+ (match_operand:VI1_AVX512VL 2 "register_operand")
+- (match_operand:VI1_AVX512VL 3 "nonimmediate_or_const_vec_dup_operand"))
++ (match_operand:VI1_AVX512VL 3 "const_vec_dup_operand"))
+ (match_operand:VI1_AVX512VL 4 "nonimm_or_0_operand")
+ (match_operand:<avx512fmaskmode> 1 "register_operand")))]
+ "TARGET_GFNI && TARGET_AVX512F"
+ {
+- rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], operands[2], <CODE>);
+- emit_insn (gen_vgf2p8affineqb_<mode>_mask (operands[0], operands[1], matrix,
++ rtx count = XVECEXP (operands[3], 0, 0);
++ rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], count, <CODE>);
++ emit_insn (gen_vgf2p8affineqb_<mode>_mask (operands[0], operands[2], matrix,
+ const0_rtx, operands[4],
+ operands[1]));
+ DONE;
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 249ec3a..7dbbab6 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -3,6 +3,7 @@
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
+ 89_all_PR121709-fix-build.patch
+ 90_all_PR121725-x86-64-Use-UNSPEC_DTPOFF-to-check-source-operand-in-.patch
+ + 91_all_PR121699-mesa.patch
12 24 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-29 20:18 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-29 20:18 UTC (permalink / raw
To: gentoo-commits
commit: 6cd6ca56bc232a255a93eff4318e56ef35757482
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 29 20:18:23 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 29 20:18:23 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=6cd6ca56
16.0.0: add another TLS patch
Bug: https://gcc.gnu.org/PR121725
Signed-off-by: Sam James <sam <AT> gentoo.org>
...UNSPEC_DTPOFF-to-check-source-operand-in-.patch | 158 +++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 159 insertions(+)
diff --git a/16.0.0/gentoo/90_all_PR121725-x86-64-Use-UNSPEC_DTPOFF-to-check-source-operand-in-.patch b/16.0.0/gentoo/90_all_PR121725-x86-64-Use-UNSPEC_DTPOFF-to-check-source-operand-in-.patch
new file mode 100644
index 0000000..35641f2
--- /dev/null
+++ b/16.0.0/gentoo/90_all_PR121725-x86-64-Use-UNSPEC_DTPOFF-to-check-source-operand-in-.patch
@@ -0,0 +1,158 @@
+From 04e11f7b467e53c513548d59e0c4ac256adb2c30 Mon Sep 17 00:00:00 2001
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Fri, 29 Aug 2025 12:53:18 -0700
+Subject: [PATCH] x86-64: Use UNSPEC_DTPOFF to check source operand in
+ TLS64_COMBINE
+
+Since the first operand of PLUS in the source of TLS64_COMBINE pattern:
+
+(set (reg/f:DI 128)
+ (plus:DI (unspec:DI [
+ (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
+ (reg:DI 126)
+ (reg/f:DI 7 sp)
+ ] UNSPEC_TLSDESC)
+ (const:DI (unspec:DI [
+ (symbol_ref:DI ("bfd_error") [flags 0x1a] <var_decl 0x7fffe99d6e40 bfd_error>)
+ ] UNSPEC_DTPOFF))))
+
+is unused, use the second operand of PLUS:
+
+(const:DI (unspec:DI [
+ (symbol_ref:DI ("bfd_error") [flags 0x1a] <var_decl 0x7fffe99d6e40 bfd_error>)
+ ] UNSPEC_DTPOFF))
+
+to check if 2 TLS_COMBINE patterns have the same source.
+
+gcc/
+
+ PR target/121725
+ * config/i386/i386-features.cc
+ (pass_x86_cse::candidate_gnu2_tls_p): Use the UNSPEC_DTPOFF
+ operand to check source operand in TLS64_COMBINE pattern.
+
+gcc/testsuite/
+
+ PR target/121725
+ * gcc.target/i386/pr121725-1a.c: New test.
+ * gcc.target/i386/pr121725-1b.c: Likewise.
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+---
+ gcc/config/i386/i386-features.cc | 32 +++++-----------
+ gcc/testsuite/gcc.target/i386/pr121725-1a.c | 41 +++++++++++++++++++++
+ gcc/testsuite/gcc.target/i386/pr121725-1b.c | 6 +++
+ 3 files changed, 57 insertions(+), 22 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121725-1a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121725-1b.c
+
+diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
+index 5440a02c442..0608dd2f9ac 100644
+--- a/gcc/config/i386/i386-features.cc
++++ b/gcc/config/i386/i386-features.cc
+@@ -4291,34 +4291,22 @@ pass_x86_cse::candidate_gnu2_tls_p (rtx set, attr_tls64 tls64)
+ */
+
+ scalar_mode = mode = GET_MODE (src);
+- rtx src0 = XEXP (src, 0);
+- tls_symbol = XVECEXP (src0, 0, 0);
+- rtx src1 = XVECEXP (src0, 0, 1);
+- if (REG_P (src1))
+- {
+- set_insn = tls_set_insn_from_symbol (src1, tls_symbol);
+- gcc_assert (set_insn);
+- }
+- else
+- {
+- set_insn = nullptr;
+- gcc_assert (GET_CODE (src1) == UNSPEC
+- && XINT (src1, 1) == UNSPEC_TLSDESC
+- && SYMBOL_REF_P (XVECEXP (src1, 0, 0))
+- && rtx_equal_p (XVECEXP (src1, 0, 0), tls_symbol));
+- }
+
+- /* Use TLS_SYMBOL and
++ /* Since the first operand of PLUS in the source TLS_COMBINE
++ pattern is unused, use the second operand of PLUS:
+
+ (const:DI (unspec:DI [
+ (symbol_ref:DI ("e") [flags 0x1a])
+ ] UNSPEC_DTPOFF))
+
+- as VAL to check if 2 patterns have the same source. */
+-
+- rtvec vec = gen_rtvec (2, tls_symbol, XEXP (src, 1));
+- val = gen_rtx_UNSPEC (mode, vec, UNSPEC_TLSDESC);
+- def_insn = set_insn;
++ as VAL to check if 2 TLS_COMBINE patterns have the same
++ source. */
++ val = XEXP (src, 1);
++ gcc_assert (GET_CODE (val) == CONST
++ && GET_CODE (XEXP (val, 0)) == UNSPEC
++ && XINT (XEXP (val, 0), 1) == UNSPEC_DTPOFF
++ && SYMBOL_REF_P (XVECEXP (XEXP (val, 0), 0, 0)));
++ def_insn = nullptr;
+ return true;
+ }
+
+diff --git a/gcc/testsuite/gcc.target/i386/pr121725-1a.c b/gcc/testsuite/gcc.target/i386/pr121725-1a.c
+new file mode 100644
+index 00000000000..d0a498cace9
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121725-1a.c
+@@ -0,0 +1,41 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O3 -fpic -fplt -mtls-dialect=gnu" } */
++
++typedef enum
++{
++ bfd_error_invalid_error_code
++} bfd_error_type;
++static thread_local bfd_error_type bfd_error;
++extern int sections;
++extern void *bfd_alloc_ret;
++extern int bfd_alloc___o;
++extern long bfd_alloc_size;
++
++extern void _objalloc_alloc (int *, long);
++
++bfd_error_type
++bfd_get_error ()
++{
++ return bfd_error;
++}
++
++bool
++s7_bfd_score_elf_late_size_sections ()
++{
++ for (; sections;)
++ {
++ if (bfd_alloc_size)
++ {
++ bfd_error_type error_tag;
++ bfd_error = error_tag;
++ }
++ _objalloc_alloc (&bfd_alloc___o, 0);
++ if (bfd_alloc_ret)
++ {
++ bfd_error_type error_tag;
++ bfd_error = error_tag;
++ }
++ }
++}
++
++/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 2 { target { ! ia32 } } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr121725-1b.c b/gcc/testsuite/gcc.target/i386/pr121725-1b.c
+new file mode 100644
+index 00000000000..0b97a8a4cb6
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121725-1b.c
+@@ -0,0 +1,6 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O3 -fpic -fplt -mtls-dialect=gnu2" } */
++
++#include "pr121725-1a.c"
++
++/* { dg-final { scan-assembler-times "call\[ \t\]\\*bfd_error@TLSCALL\\(%(?:r|e)ax\\)" 2 { target { ! ia32 } } } } */
+--
+2.51.0
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 2ab24b0..249ec3a 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -2,6 +2,7 @@
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
+ 89_all_PR121709-fix-build.patch
+ + 90_all_PR121725-x86-64-Use-UNSPEC_DTPOFF-to-check-source-operand-in-.patch
12 24 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-29 18:38 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-29 18:38 UTC (permalink / raw
To: gentoo-commits
commit: 2c67ddeb0a9e5772f772d8d62f6205016857b2dc
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 29 18:38:39 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 29 18:38:39 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=2c67ddeb
16.0.0: use modula2 patch instead of revert
Signed-off-by: Sam James <sam <AT> gentoo.org>
...modula2-121629-adding-third-party-modules.patch | 771 ---------------------
16.0.0/gentoo/89_all_PR121709-fix-build.patch | 142 ++++
16.0.0/gentoo/README.history | 3 +-
3 files changed, 143 insertions(+), 773 deletions(-)
diff --git a/16.0.0/gentoo/89_all_PR121709-Revert-PR-modula2-121629-adding-third-party-modules.patch b/16.0.0/gentoo/89_all_PR121709-Revert-PR-modula2-121629-adding-third-party-modules.patch
deleted file mode 100644
index dccb31a..0000000
--- a/16.0.0/gentoo/89_all_PR121709-Revert-PR-modula2-121629-adding-third-party-modules.patch
+++ /dev/null
@@ -1,771 +0,0 @@
-From 3bbb5c9c356d34f3593d8beb512b13c2f9cae7fe Mon Sep 17 00:00:00 2001
-Message-ID: <3bbb5c9c356d34f3593d8beb512b13c2f9cae7fe.1756403767.git.sam@gentoo.org>
-From: Sam James <sam@gentoo.org>
-Date: Thu, 28 Aug 2025 18:55:53 +0100
-Subject: [PATCH] Revert "PR modula2/121629: adding third party modules"
-
-This reverts commit 69faef01dff124cd2e657b7525ba6cc574626853.
-
-Bug: https://gcc.gnu.org/PR121709
----
- gcc/doc/gm2.texi | 69 +----
- gcc/m2/gm2-compiler/PathName.mod | 21 --
- gcc/m2/gm2-lang.cc | 283 +++++-------------
- gcc/m2/gm2spec.cc | 31 +-
- gcc/m2/lang.opt | 10 +-
- .../pass/switches-pathnameroot-pass.exp | 48 ---
- .../gm2/switches/pathnameroot/pass/test.mod | 6 -
- .../pathnameroot/pass/testlib/m2/foo.def | 7 -
- .../pathnameroot/pass/testlib/m2/foo.mod | 3 -
- 9 files changed, 94 insertions(+), 384 deletions(-)
- delete mode 100755 gcc/testsuite/gm2/switches/pathnameroot/pass/switches-pathnameroot-pass.exp
- delete mode 100644 gcc/testsuite/gm2/switches/pathnameroot/pass/test.mod
- delete mode 100644 gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.def
- delete mode 100644 gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.mod
-
-diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi
-index 4147a287c45d..9bd0f0d22142 100644
---- a/gcc/doc/gm2.texi
-+++ b/gcc/doc/gm2.texi
-@@ -143,7 +143,11 @@ available and access to assembly programming is achieved using the
- same syntax as that used by GCC.
-
- The gm2 driver allows third party libraries to be installed alongside
--gm2 libraries. @xref{Module Search Path}.
-+gm2 libraries. For example if the user specifies library @code{foo}
-+using @code{-flibs=foo} the driver will check the standard GCC install
-+directory for a sub directory @code{foo} containing the library
-+contents. The library module search path is altered accordingly
-+for compile and link.
-
- @node Development, Features, Why use GNU Modula-2, Overview
- @section How to get source code using git
-@@ -225,7 +229,6 @@ such as the AVR and the ARM).
- * Standard procedures:: Permanently accessible base procedures.
- * High procedure function:: Behavior of the high procedure function.
- * Dialect:: GNU Modula-2 supported dialects.
--* Module Search Path:: How to add library modules.
- * Exceptions:: Exception implementation
- * Semantic checking:: How to detect run time problems at compile time.
- * Extensions:: GNU Modula-2 language extensions.
-@@ -522,15 +525,6 @@ following include paths.
- for internal use only: used by the driver to copy the user facing @samp{-I}
- option.
-
--@item -fm2-pathname-root=@file{pathroot}
--add search paths derived from the specified @file{pathroot}.
--@xref{Module Search Path} for examples.
--
--@item -fm2-pathname-rootI
--for internal use only: used by the driver to copy every user
--@samp{-fm2-pathname-root=} facing option in order with all other
--@samp{-I} options.
--
- @item -fm2-plugin
- insert plugin to identify run time errors at compile time (default on).
-
-@@ -1385,7 +1379,7 @@ Actual parameter | HIGH (a) | a[HIGH (a)] = nul
- str3 | 3 | TRUE
- @end example
-
--@node Dialect, Module Search Path, High procedure function, Using
-+@node Dialect, Exceptions, High procedure function, Using
- @section GNU Modula-2 supported dialects
-
- This section describes the dialects understood by GNU Modula-2.
-@@ -1450,39 +1444,6 @@ implemented as above, apart from the exception calling in the ISO
- dialect. Instead of exception handling the results are the same as the
- PIM4 dialect. This is a temporary implementation situation.
-
--@node Module Search Path, Exceptions, Dialect, Using
--@section Module Search Path
--
--This section describes the default module search path and how this
--might be changed. By default the compiler will search the current
--directory, site wide modules and lastly gcc version specific modules.
--
--The @samp{-I} option option can be used to introduce new directories
--in the module search path and for convenience the options @samp{-flibs=}
--and @samp{-fm2-pathname-root=} are also provided.
--
--The site wide modules are located at @var{prefix}@file{/include/m2}
--whereas the version specific modules are located in
--@var{libsubdir}@file{/m2}. Both of these @file{/m2} directories
--are organized such that the non dialect specific modules are at the
--top and dialect specific modules are in subdirectories.
--
--The @samp{-fm2-pathname-root=} option is equivalent to adding a
--@samp{-I} path for every library dialect. For example if the library
--dialect order is selected by @samp{-flibs=pim,iso,log} and
--@samp{-fm2-pathname-root=foo} is supplied then this is equivalent to
--the following pairs of options:
--
--@example
---fm2-pathname=m2pim -I@file{foo/m2/m2pim}
---fm2-pathname=m2iso -I@file{foo/m2/m2iso}
---fm2-pathname=m2log -I@file{foo/m2/m2log}
---fm2-pathname=- -I@file{foo/m2}
--@end example
--
--The option @samp{-fsources} will show the source module, path and
--pathname for each module parsed.
--
- @node Exceptions, Semantic checking, Dialect, Using
- @section Exception implementation
-
-@@ -2062,7 +2023,7 @@ CONST
-
- VAR
- head: List ;
--@end group
-+@end group
- @end example
-
- @example
-@@ -2073,13 +2034,13 @@ VAR
- BEGIN
- p := head^.next ;
- printf ("\nunique data\n");
-- printf ("===========\n");
-+ printf ("===========\n");
- WHILE p # NIL DO
- printf ("%d\n", p^.value);
- p := p^.next
- END
- END Display ;
--@end group
-+@end group
- @end example
-
- @example
-@@ -2092,7 +2053,7 @@ BEGIN
- next := NIL
- END
- END Add ;
--@end group
-+@end group
- @end example
-
- @example
-@@ -2114,17 +2075,17 @@ EXCEPT
- THEN
- printf ("list was empty, add sentinal\n");
- Add (head, -1) ;
-- RETRY (* Jump back to the begin statement. *)
-+ RETRY (* Jump back to the begin statement. *)
- ELSIF p^.next = NIL
- THEN
- printf ("growing the list\n");
- Add (p^.next, val) ;
- RETRY (* Jump back to the begin statement. *)
- ELSE
-- printf ("should never reach here!\n");
-+ printf ("should never reach here!\n");
- END
- END Unique ;
--@end group
-+@end group
- @end example
-
- @example
-@@ -2143,7 +2104,7 @@ BEGIN
- head := NIL ;
- unique
- END lazyunique.
--@end group
-+@end group
- @end example
-
- @example
-@@ -2166,7 +2127,7 @@ unique data
- 0
- 2
- 1
--@end group
-+@end group
- @end example
-
- @node Unbounded by reference, Building a shared library, Exception handling, Using
-diff --git a/gcc/m2/gm2-compiler/PathName.mod b/gcc/m2/gm2-compiler/PathName.mod
-index 0ba902408204..6fc7612d08f3 100644
---- a/gcc/m2/gm2-compiler/PathName.mod
-+++ b/gcc/m2/gm2-compiler/PathName.mod
-@@ -1,24 +1,3 @@
--(* M2PathName.mod maintain a dictionary of named paths.
--
--Copyright (C) 2023-2025 Free Software Foundation, Inc.
--Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
--
--This file is part of GNU Modula-2.
--
--GNU Modula-2 is free software; you can redistribute it and/or modify
--it under the terms of the GNU General Public License as published by
--the Free Software Foundation; either version 3, or (at your option)
--any later version.
--
--GNU Modula-2 is distributed in the hope that it will be useful, but
--WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--General Public License for more details.
--
--You should have received a copy of the GNU General Public License
--along with GNU Modula-2; see the file COPYING3. If not see
--<http://www.gnu.org/licenses/>. *)
--
- IMPLEMENTATION MODULE PathName ;
-
- FROM Storage IMPORT ALLOCATE, DEALLOCATE ;
-diff --git a/gcc/m2/gm2-lang.cc b/gcc/m2/gm2-lang.cc
-index d378d1bc2122..31a2e46475dc 100644
---- a/gcc/m2/gm2-lang.cc
-+++ b/gcc/m2/gm2-lang.cc
-@@ -51,7 +51,6 @@ static bool iso = false;
- typedef struct named_path_s {
- std::vector<const char*>path;
- const char *name;
-- bool lib_root;
- } named_path;
-
-
-@@ -373,7 +372,6 @@ push_back_Ipath (const char *arg)
- named_path np;
- np.path.push_back (arg);
- np.name = xstrdup (M2Options_GetM2PathName ());
-- np.lib_root = false;
- Ipaths.push_back (np);
- }
- else
-@@ -386,205 +384,11 @@ push_back_Ipath (const char *arg)
- named_path np;
- np.path.push_back (arg);
- np.name = xstrdup (M2Options_GetM2PathName ());
-- np.lib_root = false;
- Ipaths.push_back (np);
- }
- }
- }
-
--/* push_back_lib_root pushes a lib_root onto the Ipaths vector.
-- The ordering of the -fm2_add_lib_root=, -I and named paths
-- must be preserved. */
--
--static void
--push_back_lib_root (const char *arg)
--{
-- named_path np;
-- np.name = arg;
-- np.lib_root = true;
-- Ipaths.push_back (np);
--}
--
--/* get_dir_sep_size return the length of the DIR_SEPARATOR string. */
--
--static size_t
--get_dir_sep_size (void)
--{
-- const char dir_sep[] = {DIR_SEPARATOR, (char)0};
-- size_t dir_sep_size = strlen (dir_sep);
-- return dir_sep_size;
--}
--
--/* add_path_component strcats src into dest and adds a directory seperator
-- if necessary. */
--
--static void
--add_path_component (char *dest, const char *src)
--{
-- size_t len = strlen (dest);
-- const char dir_sep[] = {DIR_SEPARATOR, (char)0};
-- size_t dir_sep_size = strlen (dir_sep);
--
-- if (len > 0)
-- {
-- /* Only add a seperator if dest is not empty and does not end
-- with a seperator. */
-- if (len >= dir_sep_size
-- && (strcmp (&dest[len-dir_sep_size], dir_sep) != 0))
-- strcat (dest, dir_sep);
-- }
-- strcat (dest, src);
--}
--
--/* This prefixes LIBNAME with the current compiler prefix (if it has been
-- relocated) or the LIBSUBDIR, if not. */
--
--static void
--add_one_import_path (const char *libpath, const char *libname)
--{
-- size_t dir_sep_size = get_dir_sep_size ();
-- size_t mlib_len = 0;
--
-- if (imultilib)
-- {
-- mlib_len = strlen (imultilib);
-- mlib_len += dir_sep_size;
-- }
--
-- char *lib = (char *)alloca (strlen (libpath) + dir_sep_size
-- + strlen ("m2") + dir_sep_size
-- + strlen (libname) + 1
-- + mlib_len + 1);
-- strcpy (lib, libpath);
-- if (imultilib)
-- add_path_component (lib, imultilib);
-- add_path_component (lib, "m2");
-- add_path_component (lib, libname);
-- M2Options_SetM2PathName (libname);
-- M2Options_SetSearchPath (lib);
--}
--
--/* add_non_dialect_specific_path add non dialect specific includes
-- given a base libpath. */
--
--static void
--add_non_dialect_specific_path (const char *libpath)
--{
-- char *incpath = (char *)alloca (strlen (libpath)
-- + strlen ("m2")
-- + get_dir_sep_size ()
-- + 1);
-- strcpy (incpath, libpath);
-- add_path_component (incpath, "m2");
-- M2Options_SetM2PathName (""); /* No pathname for non dialect specific libs. */
-- M2Options_SetSearchPath (incpath);
--}
--
--/* For each comma-separated standard library name in LIBLIST, add the
-- corresponding include path. */
--
--static void
--foreach_lib_gen_import_path (const char *liblist, const char *libpath)
--{
-- while (*liblist != 0 && *liblist != '-')
-- {
-- const char *comma = strstr (liblist, ",");
-- size_t len;
-- if (comma)
-- len = comma - liblist;
-- else
-- len = strlen (liblist);
-- char *libname = (char *) alloca (len+1);
-- strncpy (libname, liblist, len);
-- libname[len] = 0;
-- add_one_import_path (libpath, libname);
-- liblist += len;
-- if (*liblist == ',')
-- liblist++;
-- }
-- add_non_dialect_specific_path (libpath);
--}
--
--/* get_module_source_dir return the libpath/{multilib/} as a malloc'd
-- string. */
--
--static const char *
--get_module_source_dir (void)
--{
-- const char *libpath = iprefix ? iprefix : LIBSUBDIR;
-- const char dir_sep[] = {DIR_SEPARATOR, (char)0};
-- size_t dir_sep_size = strlen (dir_sep);
-- unsigned int mlib_len = 0;
--
-- if (imultilib)
-- {
-- mlib_len = strlen (imultilib);
-- mlib_len += strlen (dir_sep);
-- }
-- char *lib = (char *) xmalloc (strlen (libpath)
-- + dir_sep_size
-- + mlib_len + 1);
-- strcpy (lib, libpath);
-- /* iprefix has a trailing dir separator, LIBSUBDIR does not. */
-- if (!iprefix)
-- strcat (lib, dir_sep);
--
-- if (imultilib)
-- {
-- strcat (lib, imultilib);
-- strcat (lib, dir_sep);
-- }
-- return lib;
--}
--
--/* add_default_include_paths add include paths for site wide definition modules
-- and also gcc version specific definition modules. */
--
--static void
--add_default_include_paths (const char *flibs)
--{
-- /* Add the site wide include path. */
-- foreach_lib_gen_import_path (flibs, PREFIX_INCLUDE_DIR);
-- /* Add the gcc version specific include path. */
-- foreach_lib_gen_import_path (flibs,
-- get_module_source_dir ());
--}
--
--/* assign_flibs assign flibs to a default providing that allow_libraries
-- is true and flibs has not been set. */
--
--static void
--assign_flibs (void)
--{
-- if (allow_libraries && (flibs == NULL))
-- {
-- if (iso)
-- flibs = "m2iso,m2cor,m2pim,m2log";
-- else
-- flibs = "m2pim,m2iso,m2cor,m2log";
-- }
--}
--
--/* m2_pathname_root creates a new set of include paths for the
-- subdirectory m2 inside libroot. The ordering of the paths
-- follows the dialect library order. */
--
--static void
--m2_pathname_root (const char *libroot)
--{
-- const char *copy_flibs = flibs;
--
-- if (copy_flibs == NULL)
-- {
-- if (iso)
-- copy_flibs = "m2iso,m2cor,m2pim,m2log";
-- else
-- copy_flibs = "m2pim,m2iso,m2cor,m2log";
-- }
-- foreach_lib_gen_import_path (copy_flibs, libroot);
--}
--
--
- /* Handle gm2 specific options. Return 0 if we didn't do anything. */
-
- bool
-@@ -631,9 +435,6 @@ gm2_langhook_handle_option (
- case OPT_fpositive_mod_floor_div:
- M2Options_SetPositiveModFloor (value);
- return 1;
-- case OPT_fm2_pathname_rootI_:
-- push_back_lib_root (arg);
-- return 1;
- case OPT_flibs_:
- allow_libraries = value;
- flibs = arg;
-@@ -909,6 +710,66 @@ gm2_langhook_handle_option (
- return 0;
- }
-
-+/* This prefixes LIBNAME with the current compiler prefix (if it has been
-+ relocated) or the LIBSUBDIR, if not. */
-+static void
-+add_one_import_path (const char *libname)
-+{
-+ const char *libpath = iprefix ? iprefix : LIBSUBDIR;
-+ const char dir_sep[] = {DIR_SEPARATOR, (char)0};
-+ size_t dir_sep_size = strlen (dir_sep);
-+ unsigned int mlib_len = 0;
-+
-+ if (imultilib)
-+ {
-+ mlib_len = strlen (imultilib);
-+ mlib_len += strlen (dir_sep);
-+ }
-+
-+ char *lib = (char *)alloca (strlen (libpath) + dir_sep_size
-+ + strlen ("m2") + dir_sep_size
-+ + strlen (libname) + 1
-+ + mlib_len + 1);
-+ strcpy (lib, libpath);
-+ /* iprefix has a trailing dir separator, LIBSUBDIR does not. */
-+ if (!iprefix)
-+ strcat (lib, dir_sep);
-+
-+ if (imultilib)
-+ {
-+ strcat (lib, imultilib);
-+ strcat (lib, dir_sep);
-+ }
-+ strcat (lib, "m2");
-+ strcat (lib, dir_sep);
-+ strcat (lib, libname);
-+ M2Options_SetM2PathName (libname);
-+ M2Options_SetSearchPath (lib);
-+}
-+
-+/* For each comma-separated standard library name in LIBLIST, add the
-+ corresponding include path. */
-+static void
-+add_m2_import_paths (const char *liblist)
-+{
-+ while (*liblist != 0 && *liblist != '-')
-+ {
-+ const char *comma = strstr (liblist, ",");
-+ size_t len;
-+ if (comma)
-+ len = comma - liblist;
-+ else
-+ len = strlen (liblist);
-+ char *libname = (char *) alloca (len+1);
-+ strncpy (libname, liblist, len);
-+ libname[len] = 0;
-+ add_one_import_path (libname);
-+ liblist += len;
-+ if (*liblist == ',')
-+ liblist++;
-+ }
-+}
-+
- /* Run after parsing options. */
-
- static bool
-@@ -923,7 +784,16 @@ gm2_langhook_post_options (const char **pfilename)
- /* Add the include paths as per the libraries specified.
- NOTE: This assumes that the driver has validated the input and makes
- no attempt to be defensive of nonsense input in flibs=. */
-- assign_flibs ();
-+ if (allow_libraries)
-+ {
-+ if (!flibs)
-+ {
-+ if (iso)
-+ flibs = "m2iso,m2cor,m2pim,m2log";
-+ else
-+ flibs = "m2pim,m2iso,m2cor,m2log";
-+ }
-+ }
-
- /* Add search paths.
- We are not handling all of the cases yet (e.g idirafter).
-@@ -937,14 +807,9 @@ gm2_langhook_post_options (const char **pfilename)
- iquote.clear();
- for (auto np : Ipaths)
- {
-- if (np.lib_root)
-- foreach_lib_gen_import_path (flibs, np.name);
-- else
-- {
-- M2Options_SetM2PathName (np.name);
-- for (auto *s : np.path)
-- M2Options_SetSearchPath (s);
-- }
-+ M2Options_SetM2PathName (np.name);
-+ for (auto *s : np.path)
-+ M2Options_SetSearchPath (s);
- }
- Ipaths.clear();
- for (auto *s : isystem)
-@@ -953,7 +818,7 @@ gm2_langhook_post_options (const char **pfilename)
- /* FIXME: this is not a good way to suppress the addition of the import
- paths. */
- if (allow_libraries)
-- add_default_include_paths (flibs);
-+ add_m2_import_paths (flibs);
-
- /* Returning false means that the backend should be used. */
- return M2Options_GetPPOnly ();
-diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
-index 18d9ce7a630b..868e5c5619ed 100644
---- a/gcc/m2/gm2spec.cc
-+++ b/gcc/m2/gm2spec.cc
-@@ -158,12 +158,10 @@ static const char *m2_path_name = "";
- typedef struct named_path_s {
- std::vector<const char*>path;
- const char *name;
-- bool lib_root;
- } named_path;
-
- static std::vector<named_path>Ipaths;
-
--/* push_back_Ipath pushes a named path to the Ipaths global variable. */
-
- static void
- push_back_Ipath (const char *arg)
-@@ -173,7 +171,6 @@ push_back_Ipath (const char *arg)
- named_path np;
- np.path.push_back (arg);
- np.name = m2_path_name;
-- np.lib_root = false;
- Ipaths.push_back (np);
- }
- else
-@@ -186,25 +183,11 @@ push_back_Ipath (const char *arg)
- named_path np;
- np.path.push_back (arg);
- np.name = m2_path_name;
-- np.lib_root = false;
- Ipaths.push_back (np);
- }
- }
- }
-
--/* push_back_lib_root pushes a lib_root onto the Ipaths vector.
-- The ordering of the -fm2_add_lib_root=, -I and named paths
-- must be preserved. */
--
--static void
--push_back_lib_root (const char *arg)
--{
-- named_path np;
-- np.name = arg;
-- np.lib_root = true;
-- Ipaths.push_back (np);
--}
--
- /* Return whether strings S1 and S2 are both NULL or both the same
- string. */
-
-@@ -396,18 +379,15 @@ convert_abbreviations (const char *libraries)
- return full_libraries;
- }
-
--/* add_m2_I_path appends -fm2-pathname, -fm2-pathnameI and -fm2-add-lib-root
-- options to the command line which are contructed in the saved Ipaths.
-- The order of these options must be maintained. */
-+/* add_m2_I_path appends -fm2-pathname and -fm2-pathnameI options to
-+ the command line which are contructed in the saved Ipaths. */
-
- static void
- add_m2_I_path (void)
- {
- for (auto np : Ipaths)
- {
-- if (np.lib_root)
-- append_option (OPT_fm2_pathname_rootI_, safe_strdup (np.name), 1);
-- else if (strcmp (np.name, "") == 0)
-+ if (strcmp (np.name, "") == 0)
- append_option (OPT_fm2_pathname_, safe_strdup ("-"), 1);
- else
- append_option (OPT_fm2_pathname_, safe_strdup (np.name), 1);
-@@ -596,10 +576,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
- args[i] |= SKIPOPT; /* We will add the option if it is needed. */
- m2_path_name = decoded_options[i].arg;
- break;
-- case OPT_fm2_pathname_root_:
-- args[i] |= SKIPOPT; /* We will add the option if it is needed. */
-- push_back_lib_root (decoded_options[i].arg);
-- break;
- case OPT__help:
- case OPT__help_:
- /* Let gcc.cc handle this, as it has a really
-@@ -763,6 +739,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
- "-fgen-module-list=", "-fuse-list=");
- }
-
-+
- /* There's no point adding -shared-libgcc if we don't have a shared
- libgcc. */
- #ifndef ENABLE_SHARED_LIBGCC
-diff --git a/gcc/m2/lang.opt b/gcc/m2/lang.opt
-index 2aea4ccb77eb..48c2380f565b 100644
---- a/gcc/m2/lang.opt
-+++ b/gcc/m2/lang.opt
-@@ -172,15 +172,7 @@ specify the module mangled prefix name for all modules in the following include
-
- fm2-pathnameI
- Modula-2 Joined
--; For internal use only: used by the driver to copy the user facing -I option in order
--
--fm2-pathname-root=
--Modula-2 Joined
--add include paths for all the library names in -flibs= to this directory root
--
--fm2-pathname-rootI=
--Modula-2 Joined
--; For internal use only: used by the driver to copy the user facing -I option in order
-+; For internal use only: used by the driver to copy the user facing -I option
-
- fm2-plugin
- Modula-2
-diff --git a/gcc/testsuite/gm2/switches/pathnameroot/pass/switches-pathnameroot-pass.exp b/gcc/testsuite/gm2/switches/pathnameroot/pass/switches-pathnameroot-pass.exp
-deleted file mode 100755
-index d2f4d87ae27b..000000000000
---- a/gcc/testsuite/gm2/switches/pathnameroot/pass/switches-pathnameroot-pass.exp
-+++ /dev/null
-@@ -1,48 +0,0 @@
--# Expect driver script for GCC Regression Tests
--# Copyright (C) 2025 Free Software Foundation, Inc.
--
--# This program is free software; you can redistribute it and/or modify
--# it under the terms of the GNU General Public License as published by
--# the Free Software Foundation; either version 3 of the License, or
--# (at your option) any later version.
--#
--# This program is distributed in the hope that it will be useful,
--# but WITHOUT ANY WARRANTY; without even the implied warranty of
--# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--# GNU General Public License for more details.
--#
--# You should have received a copy of the GNU General Public License
--# along with GCC; see the file COPYING3. If not see
--# <http://www.gnu.org/licenses/>.
--
--# This file was written by Gaius Mulley (gaius.mulley@southwales.ac.uk)
--# for GNU Modula-2.
--
--load_lib target-supports.exp
--
--global TESTING_IN_BUILD_TREE
--global ENABLE_PLUGIN
--
--# The plugin testcases currently only work when the build tree is available.
--# Also check whether the host supports plugins.
--if { ![info exists TESTING_IN_BUILD_TREE] || ![info exists ENABLE_PLUGIN] } {
-- return
--}
--
--if $tracelevel then {
-- strace $tracelevel
--}
--
--# load support procs
--load_lib gm2-torture.exp
--
--gm2_init_pim "${srcdir}/gm2/switches/pathnameroot/pass" -fm2-pathname-root="${srcdir}/gm2/switches/pathnameroot/pass/testlib"
--
--foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
-- # If we're only testing specific files and this isn't one of them, skip it.
-- if ![runtest_file_p $runtests $testcase] then {
-- continue
-- }
--
-- gm2-torture-fail $testcase
--}
-diff --git a/gcc/testsuite/gm2/switches/pathnameroot/pass/test.mod b/gcc/testsuite/gm2/switches/pathnameroot/pass/test.mod
-deleted file mode 100644
-index 0f9cd6fe38b2..000000000000
---- a/gcc/testsuite/gm2/switches/pathnameroot/pass/test.mod
-+++ /dev/null
-@@ -1,6 +0,0 @@
--MODULE test ;
--
--FROM foo IMPORT SomeValue ;
--
--BEGIN
--END test.
-diff --git a/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.def b/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.def
-deleted file mode 100644
-index 9fa4973b0de1..000000000000
---- a/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.def
-+++ /dev/null
-@@ -1,7 +0,0 @@
--DEFINITION MODULE foo ;
--
--CONST
-- SomeValue = 123 ;
--
--
--END foo.
-diff --git a/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.mod b/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.mod
-deleted file mode 100644
-index fcbcf1e9ce70..000000000000
---- a/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.mod
-+++ /dev/null
-@@ -1,3 +0,0 @@
--IMPLEMENTATION MODULE foo ;
--
--END foo.
-
-base-commit: 59db4ce2df1db33ad361eca06a7aec99b24d0d2f
---
-2.51.0
-
diff --git a/16.0.0/gentoo/89_all_PR121709-fix-build.patch b/16.0.0/gentoo/89_all_PR121709-fix-build.patch
new file mode 100644
index 0000000..0d185a5
--- /dev/null
+++ b/16.0.0/gentoo/89_all_PR121709-fix-build.patch
@@ -0,0 +1,142 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121709#c8
+diff --git a/gcc/m2/gm2-lang.cc b/gcc/m2/gm2-lang.cc
+index d378d1bc212..1b1b94a1f1d 100644
+--- a/gcc/m2/gm2-lang.cc
++++ b/gcc/m2/gm2-lang.cc
+@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see
+ #include "m2-tree.h"
+ #include "convert.h"
+ #include "rtegraph.h"
++#include "cppdefault.h"
+
+ static void write_globals (void);
+
+@@ -60,6 +61,7 @@ static bool allow_libraries = true;
+ static const char *flibs = nullptr;
+ static const char *iprefix = nullptr;
+ static const char *imultilib = nullptr;
++static const char *target_system_root = nullptr;
+ static std::vector<named_path>Ipaths;
+ static std::vector<const char*>isystem;
+ static std::vector<const char*>iquote;
+@@ -537,17 +539,80 @@ get_module_source_dir (void)
+ return lib;
+ }
+
++/* concat_component returns a string containing the path
++ left/right. */
++
++static char *
++concat_component (const char *left, const char *right)
++{
++ size_t len = strlen (left)
++ + strlen (right)
++ + get_dir_sep_size ()
++ + 1;
++ char *new_str = (char *) xmalloc (len);
++ strcpy (new_str, left);
++ add_path_component (new_str, right);
++ return new_str;
++}
++
++/* find_cpp_entry return the element of the cpp_include_defaults array
++ whose fname matches name. */
++
++static const struct default_include *
++find_cpp_entry (const char *name)
++{
++ const struct default_include *p;
++
++ for (p = cpp_include_defaults; p->fname; p++)
++ if (strcmp (p->fname, name) == 0)
++ return p;
++ return NULL;
++}
++
++/* lookup_cpp_default lookup the entry in cppdefault then add the directory to
++ the m2 search path. It also honours sysroot, imultilib and imultiarch. */
++
++static void
++lookup_cpp_default (const char *sysroot, const char *flibs, const char *name)
++{
++ const struct default_include *p = find_cpp_entry (name);
++
++ if (p != NULL)
++ {
++ char *full_str = xstrdup (p->fname);
++
++ /* Should this directory start with the sysroot? */
++ if (sysroot && p->add_sysroot)
++ full_str = concat_component (xstrdup (sysroot), full_str);
++ /* Should we append the imultilib component? */
++ if (p->multilib == 1 && imultilib)
++ full_str = concat_component (full_str, imultilib);
++ /* Or append the imultiarch component? */
++ else if (p->multilib == 2 && imultiarch)
++ full_str = concat_component (full_str, imultiarch);
++ foreach_lib_gen_import_path (flibs, full_str);
++ free (full_str);
++ }
++}
++
+ /* add_default_include_paths add include paths for site wide definition modules
+ and also gcc version specific definition modules. */
+
+ static void
+ add_default_include_paths (const char *flibs)
+ {
+- /* Add the site wide include path. */
+- foreach_lib_gen_import_path (flibs, PREFIX_INCLUDE_DIR);
++ /* Follow the order found in cppdefaults.cc. */
++#ifdef LOCAL_INCLUDE_DIR
++ lookup_cpp_default (target_system_root, flibs, LOCAL_INCLUDE_DIR);
++#endif
++#ifdef PREFIX_INCLUDE_DIR
++ lookup_cpp_default (target_system_root, flibs, PREFIX_INCLUDE_DIR);
++#endif
+ /* Add the gcc version specific include path. */
+- foreach_lib_gen_import_path (flibs,
+- get_module_source_dir ());
++ foreach_lib_gen_import_path (flibs, get_module_source_dir ());
++#ifdef NATIVE_SYSTEM_HEADER_DIR
++ lookup_cpp_default (target_system_root, flibs, NATIVE_SYSTEM_HEADER_DIR);
++#endif
+ }
+
+ /* assign_flibs assign flibs to a default providing that allow_libraries
+@@ -565,26 +630,6 @@ assign_flibs (void)
+ }
+ }
+
+-/* m2_pathname_root creates a new set of include paths for the
+- subdirectory m2 inside libroot. The ordering of the paths
+- follows the dialect library order. */
+-
+-static void
+-m2_pathname_root (const char *libroot)
+-{
+- const char *copy_flibs = flibs;
+-
+- if (copy_flibs == NULL)
+- {
+- if (iso)
+- copy_flibs = "m2iso,m2cor,m2pim,m2log";
+- else
+- copy_flibs = "m2pim,m2iso,m2cor,m2log";
+- }
+- foreach_lib_gen_import_path (copy_flibs, libroot);
+-}
+-
+-
+ /* Handle gm2 specific options. Return 0 if we didn't do anything. */
+
+ bool
+@@ -858,7 +903,7 @@ gm2_langhook_handle_option (
+ return 1;
+ break;
+ case OPT_isysroot:
+- /* Otherwise, ignored, at least for now. */
++ target_system_root = arg;
+ return 1;
+ break;
+ case OPT_fm2_whole_program:
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 63618fc..2ab24b0 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,8 +1,7 @@
13 ????
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
- + 88_all-x86-64-Improve-source-operand-check-for-TLS_CALL.patch
- + 89_all_PR121709-Revert-PR-modula2-121629-adding-third-party-modules.patchsam@mop
+ + 89_all_PR121709-fix-build.patch
12 24 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-29 12:15 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-29 12:15 UTC (permalink / raw
To: gentoo-commits
commit: c674e0a280a0a117ece1b7bcc07d61e796a6b033
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 29 12:15:10 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 29 12:15:10 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=c674e0a2
16.0.0: drop merged TLS patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
...Improve-source-operand-check-for-TLS_CALL.patch | 424 ---------------------
1 file changed, 424 deletions(-)
diff --git a/16.0.0/gentoo/88_all-x86-64-Improve-source-operand-check-for-TLS_CALL.patch b/16.0.0/gentoo/88_all-x86-64-Improve-source-operand-check-for-TLS_CALL.patch
deleted file mode 100644
index 7177603..0000000
--- a/16.0.0/gentoo/88_all-x86-64-Improve-source-operand-check-for-TLS_CALL.patch
+++ /dev/null
@@ -1,424 +0,0 @@
-From ec2e1fe2a6d5b004d5666e0a5f8dc00b8f0e2985 Mon Sep 17 00:00:00 2001
-Message-ID: <ec2e1fe2a6d5b004d5666e0a5f8dc00b8f0e2985.1756358733.git.sam@gentoo.org>
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Wed, 27 Aug 2025 19:14:13 -0700
-Subject: [PATCH] x86-64: Improve source operand check for TLS_CALL
-
-Source operands of 2 TLS_CALL patterns in
-
-(insn 10 9 11 3 (set (reg:DI 100)
- (unspec:DI [
- (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
- ] UNSPEC_TLSDESC)) "x.c":7:16 1674 {*tls_dynamic_gnu2_lea_64_di}
- (nil))
-(insn 11 10 12 3 (parallel [
- (set (reg:DI 99)
- (unspec:DI [
- (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
- (reg:DI 100)
- (reg/f:DI 7 sp)
- ] UNSPEC_TLSDESC))
- (clobber (reg:CC 17 flags))
- ]) "x.c":7:16 1676 {*tls_dynamic_gnu2_call_64_di}
- (expr_list:REG_DEAD (reg:DI 100)
- (expr_list:REG_UNUSED (reg:CC 17 flags)
- (nil))))
-
-and
-
-(insn 19 17 20 4 (set (reg:DI 104)
- (unspec:DI [
- (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
- ] UNSPEC_TLSDESC)) "x.c":6:10 discrim 1 1674 {*tls_dynamic_gnu2_lea_64_di}
- (nil))
-(insn 20 19 21 4 (parallel [
- (set (reg:DI 103)
- (unspec:DI [
- (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
- (reg:DI 104)
- (reg/f:DI 7 sp)
- ] UNSPEC_TLSDESC))
- (clobber (reg:CC 17 flags))
- ]) "x.c":6:10 discrim 1 1676 {*tls_dynamic_gnu2_call_64_di}
- (expr_list:REG_DEAD (reg:DI 104)
- (expr_list:REG_UNUSED (reg:CC 17 flags)
- (nil))))
-
-are the same even though rtx_equal_p returns false since (reg:DI 100)
-and (reg:DI 104) are set from the same symbol. Use the UNSPEC_TLSDESC
-symbol
-
-(unspec:DI [(symbol_ref:DI ("caml_state") [flags 0x10])] UNSPEC_TLSDESC))
-
-to check if 2 TLS_CALL patterns have the same source.
-
-For TLS64_COMBINE, use both UNSPEC_TLSDESC and UNSPEC_DTPOFF unspecs to
-check if 2 TLS64_COMBINE patterns have the same source.
-
-gcc/
-
- PR target/121694
- * config/i386/i386-features.cc (redundant_pattern): Add
- tlsdesc_val.
- (pass_x86_cse): Likewise.
- ((pass_x86_cse::tls_set_insn_from_symbol): New member function.
- (pass_x86_cse::candidate_gnu2_tls_p): Set tlsdesc_val. For
- TLS64_COMBINE, match both UNSPEC_TLSDESC and UNSPEC_DTPOFF
- symbols. For TLS64_CALL, match the UNSPEC_TLSDESC sumbol.
- (pass_x86_cse::x86_cse): Initialize the tlsdesc_val field in
- load. Pass the tlsdesc_val field to ix86_place_single_tls_call
- for X86_CSE_TLSDESC.
-
-gcc/testsuite/
-
- PR target/121694
- * gcc.target/i386/pr121668-1b.c: New test.
- * gcc.target/i386/pr121694-1a.c: Likewise.
- * gcc.target/i386/pr121694-1b.c: Likewise.
-
-Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
----
- gcc/config/i386/i386-features.cc | 201 ++++++++++++--------
- gcc/testsuite/gcc.target/i386/pr121668-1b.c | 6 +
- gcc/testsuite/gcc.target/i386/pr121694-1a.c | 19 ++
- gcc/testsuite/gcc.target/i386/pr121694-1b.c | 6 +
- 4 files changed, 154 insertions(+), 78 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121668-1b.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121694-1a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121694-1b.c
-
-diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index 93e20947edf3..5440a02c442b 100644
---- a/gcc/config/i386/i386-features.cc
-+++ b/gcc/config/i386/i386-features.cc
-@@ -3103,6 +3103,8 @@ struct redundant_pattern
- auto_bitmap insns;
- /* The broadcast inner scalar. */
- rtx val;
-+ /* The actual redundant source value for UNSPEC_TLSDESC. */
-+ rtx tlsdesc_val;
- /* The inner scalar mode. */
- machine_mode mode;
- /* The instruction which sets the inner scalar. Nullptr if the inner
-@@ -4155,6 +4157,8 @@ public:
- private:
- /* The redundant source value. */
- rtx val;
-+ /* The actual redundant source value for UNSPEC_TLSDESC. */
-+ rtx tlsdesc_val;
- /* The instruction which defines the redundant value. */
- rtx_insn *def_insn;
- /* Mode of the destination of the candidate redundant instruction. */
-@@ -4168,8 +4172,36 @@ private:
- bool candidate_gnu_tls_p (rtx_insn *, attr_tls64);
- bool candidate_gnu2_tls_p (rtx, attr_tls64);
- bool candidate_vector_p (rtx);
-+ rtx_insn *tls_set_insn_from_symbol (const_rtx, const_rtx);
- }; // class pass_x86_cse
-
-+/* Return the instruction which sets REG from TLS_SYMBOL. */
-+
-+rtx_insn *
-+pass_x86_cse::tls_set_insn_from_symbol (const_rtx reg,
-+ const_rtx tls_symbol)
-+{
-+ rtx_insn *set_insn = nullptr;
-+ for (df_ref ref = DF_REG_DEF_CHAIN (REGNO (reg));
-+ ref;
-+ ref = DF_REF_NEXT_REG (ref))
-+ {
-+ if (DF_REF_IS_ARTIFICIAL (ref))
-+ return nullptr;
-+
-+ set_insn = DF_REF_INSN (ref);
-+ if (get_attr_tls64 (set_insn) != TLS64_LEA)
-+ return nullptr;
-+
-+ rtx tls_set = PATTERN (set_insn);
-+ rtx tls_src = XVECEXP (SET_SRC (tls_set), 0, 0);
-+ if (!rtx_equal_p (tls_symbol, tls_src))
-+ return nullptr;
-+ }
-+
-+ return set_insn;
-+}
-+
- /* Return true and output def_insn, val, mode, scalar_mode and kind if
- INSN is UNSPEC_TLS_GD or UNSPEC_TLS_LD_BASE. */
-
-@@ -4226,29 +4258,71 @@ pass_x86_cse::candidate_gnu2_tls_p (rtx set, attr_tls64 tls64)
- if (!TARGET_64BIT || !cfun->machine->tls_descriptor_call_multiple_p)
- return false;
-
-- /* Record GNU2 TLS CALLs for 64-bit:
--
-- (set (reg/f:DI 104)
-- (plus:DI (unspec:DI [
-- (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
-- (reg:DI 114)
-- (reg/f:DI 7 sp)] UNSPEC_TLSDESC)
-- (const:DI (unspec:DI [
-- (symbol_ref:DI ("e") [flags 0x1a])
-- ] UNSPEC_DTPOFF))))
--
-- (set (reg/f:DI 104)
-- (plus:DI (unspec:DI [
-- (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
-- (unspec:DI [
-- (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
-- ] UNSPEC_TLSDESC)
-- (reg/f:DI 7 sp)] UNSPEC_TLSDESC)
-- (const:DI (unspec:DI [
-- (symbol_ref:DI ("e") [flags 0x1a])
-- ] UNSPEC_DTPOFF))))
-+ rtx tls_symbol;
-+ rtx_insn *set_insn;
-+ rtx src = SET_SRC (set);
-+ val = src;
-+ tlsdesc_val = src;
-+ kind = X86_CSE_TLSDESC;
-
-- and
-+ if (tls64 == TLS64_COMBINE)
-+ {
-+ /* Record 64-bit TLS64_COMBINE:
-+
-+ (set (reg/f:DI 104)
-+ (plus:DI (unspec:DI [
-+ (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
-+ (reg:DI 114)
-+ (reg/f:DI 7 sp)] UNSPEC_TLSDESC)
-+ (const:DI (unspec:DI [
-+ (symbol_ref:DI ("e") [flags 0x1a])
-+ ] UNSPEC_DTPOFF))))
-+
-+ (set (reg/f:DI 104)
-+ (plus:DI (unspec:DI [
-+ (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
-+ (unspec:DI [
-+ (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
-+ ] UNSPEC_TLSDESC)
-+ (reg/f:DI 7 sp)] UNSPEC_TLSDESC)
-+ (const:DI (unspec:DI [
-+ (symbol_ref:DI ("e") [flags 0x1a])
-+ ] UNSPEC_DTPOFF))))
-+ */
-+
-+ scalar_mode = mode = GET_MODE (src);
-+ rtx src0 = XEXP (src, 0);
-+ tls_symbol = XVECEXP (src0, 0, 0);
-+ rtx src1 = XVECEXP (src0, 0, 1);
-+ if (REG_P (src1))
-+ {
-+ set_insn = tls_set_insn_from_symbol (src1, tls_symbol);
-+ gcc_assert (set_insn);
-+ }
-+ else
-+ {
-+ set_insn = nullptr;
-+ gcc_assert (GET_CODE (src1) == UNSPEC
-+ && XINT (src1, 1) == UNSPEC_TLSDESC
-+ && SYMBOL_REF_P (XVECEXP (src1, 0, 0))
-+ && rtx_equal_p (XVECEXP (src1, 0, 0), tls_symbol));
-+ }
-+
-+ /* Use TLS_SYMBOL and
-+
-+ (const:DI (unspec:DI [
-+ (symbol_ref:DI ("e") [flags 0x1a])
-+ ] UNSPEC_DTPOFF))
-+
-+ as VAL to check if 2 patterns have the same source. */
-+
-+ rtvec vec = gen_rtvec (2, tls_symbol, XEXP (src, 1));
-+ val = gen_rtx_UNSPEC (mode, vec, UNSPEC_TLSDESC);
-+ def_insn = set_insn;
-+ return true;
-+ }
-+
-+ /* Record 64-bit TLS_CALL:
-
- (set (reg:DI 101)
- (unspec:DI [(symbol_ref:DI ("foo") [flags 0x50])
-@@ -4257,70 +4331,33 @@ pass_x86_cse::candidate_gnu2_tls_p (rtx set, attr_tls64 tls64)
-
- */
-
-- rtx src = SET_SRC (set);
-- val = src;
-- if (tls64 != TLS64_CALL)
-- src = XEXP (src, 0);
--
-- kind = X86_CSE_TLSDESC;
- gcc_assert (GET_CODE (src) == UNSPEC);
-- rtx tls_symbol = XVECEXP (src, 0, 0);
-+ tls_symbol = XVECEXP (src, 0, 0);
- src = XVECEXP (src, 0, 1);
- scalar_mode = mode = GET_MODE (src);
-- if (REG_P (src))
-- {
-- /* All definitions of reg:DI 129 in
--
-- (set (reg:DI 110)
-- (unspec:DI [(symbol_ref:DI ("foo"))
-- (reg:DI 129)
-- (reg/f:DI 7 sp)] UNSPEC_TLSDESC))
--
-- should have the same source as in
-+ gcc_assert (REG_P (src));
-
-- (set (reg:DI 129)
-- (unspec:DI [(symbol_ref:DI ("foo"))] UNSPEC_TLSDESC))
-+ /* All definitions of reg:DI 129 in
-
-- */
-+ (set (reg:DI 110)
-+ (unspec:DI [(symbol_ref:DI ("foo"))
-+ (reg:DI 129)
-+ (reg/f:DI 7 sp)] UNSPEC_TLSDESC))
-
-- df_ref ref;
-- rtx_insn *set_insn = nullptr;
-- for (ref = DF_REG_DEF_CHAIN (REGNO (src));
-- ref;
-- ref = DF_REF_NEXT_REG (ref))
-- {
-- if (DF_REF_IS_ARTIFICIAL (ref))
-- break;
-+ should have the same source as in
-
-- set_insn = DF_REF_INSN (ref);
-- tls64 = get_attr_tls64 (set_insn);
-- if (tls64 != TLS64_LEA)
-- {
-- set_insn = nullptr;
-- break;
-- }
-+ (set (reg:DI 129)
-+ (unspec:DI [(symbol_ref:DI ("foo"))] UNSPEC_TLSDESC))
-
-- rtx tls_set = PATTERN (set_insn);
-- rtx tls_src = XVECEXP (SET_SRC (tls_set), 0, 0);
-- if (!rtx_equal_p (tls_symbol, tls_src))
-- {
-- set_insn = nullptr;
-- break;
-- }
-- }
--
-- if (!set_insn)
-- return false;
-+ */
-
-- def_insn = set_insn;
-- }
-- else if (GET_CODE (src) == UNSPEC
-- && XINT (src, 1) == UNSPEC_TLSDESC
-- && SYMBOL_REF_P (XVECEXP (src, 0, 0)))
-- def_insn = nullptr;
-- else
-- gcc_unreachable ();
-+ set_insn = tls_set_insn_from_symbol (src, tls_symbol);
-+ if (!set_insn)
-+ return false;
-
-+ /* Use TLS_SYMBOL as VAL to check if 2 patterns have the same source. */
-+ val = tls_symbol;
-+ def_insn = set_insn;
- return true;
- }
-
-@@ -4395,6 +4432,8 @@ pass_x86_cse::x86_cse (void)
- if (!set && !CALL_P (insn))
- continue;
-
-+ tlsdesc_val = nullptr;
-+
- attr_tls64 tls64 = get_attr_tls64 (insn);
- switch (tls64)
- {
-@@ -4466,6 +4505,10 @@ pass_x86_cse::x86_cse (void)
- load = new redundant_pattern;
-
- load->val = copy_rtx (val);
-+ if (tlsdesc_val)
-+ load->tlsdesc_val = copy_rtx (tlsdesc_val);
-+ else
-+ load->tlsdesc_val = nullptr;
- load->mode = scalar_mode;
- load->size = GET_MODE_SIZE (mode);
- load->def_insn = def_insn;
-@@ -4560,7 +4603,7 @@ pass_x86_cse::x86_cse (void)
- {
- case X86_CSE_TLSDESC:
- ix86_place_single_tls_call (load->broadcast_reg,
-- load->val,
-+ load->tlsdesc_val,
- load->kind,
- load->bbs,
- updated_gnu_tls_insns,
-@@ -4606,7 +4649,9 @@ pass_x86_cse::x86_cse (void)
- case X86_CSE_TLS_LD_BASE:
- case X86_CSE_TLSDESC:
- ix86_place_single_tls_call (load->broadcast_reg,
-- load->val,
-+ (load->kind == X86_CSE_TLSDESC
-+ ? load->tlsdesc_val
-+ : load->val),
- load->kind,
- load->bbs,
- updated_gnu_tls_insns,
-diff --git a/gcc/testsuite/gcc.target/i386/pr121668-1b.c b/gcc/testsuite/gcc.target/i386/pr121668-1b.c
-new file mode 100644
-index 000000000000..54a277506f83
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121668-1b.c
-@@ -0,0 +1,6 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-Og -g -fpic -fplt -mtls-dialect=gnu2" } */
-+
-+#include "pr121668-1a.c"
-+
-+/* { dg-final { scan-assembler-times "call\[ \t\]\\*caml_state@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr121694-1a.c b/gcc/testsuite/gcc.target/i386/pr121694-1a.c
-new file mode 100644
-index 000000000000..af9c65701341
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121694-1a.c
-@@ -0,0 +1,19 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-Og -fpic -fplt -mtls-dialect=gnu" } */
-+
-+extern void func1 (long *);
-+extern int func2 (void);
-+extern void func3 (void);
-+static __thread long foo;
-+static __thread long bar;
-+long
-+func (void)
-+{
-+ func1 (&foo);
-+ func1 (&bar);
-+ if (func2 ())
-+ func3 ();
-+ return foo + bar;
-+}
-+
-+/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 1 { target { ! ia32 } } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr121694-1b.c b/gcc/testsuite/gcc.target/i386/pr121694-1b.c
-new file mode 100644
-index 000000000000..76ebbf7e90bd
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121694-1b.c
-@@ -0,0 +1,6 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-Og -fpic -fplt -mtls-dialect=gnu2" } */
-+
-+#include "pr121694-1a.c"
-+
-+/* { dg-final { scan-assembler-times "call\[ \t\]\\*_TLS_MODULE_BASE_@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */
-
-base-commit: 6aa1cbb140bba220439d839207a23f09222c99df
---
-2.51.0
-
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-28 17:57 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-28 17:57 UTC (permalink / raw
To: gentoo-commits
commit: 726224e5ec45e0d76552181d3d91e42f3dfc2f28
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 28 17:56:43 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Aug 28 17:56:43 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=726224e5
16.0.0: revert modula2 commit which breaks build
Bug: https://gcc.gnu.org/PR121709
Signed-off-by: Sam James <sam <AT> gentoo.org>
...modula2-121629-adding-third-party-modules.patch | 771 +++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 772 insertions(+)
diff --git a/16.0.0/gentoo/89_all_PR121709-Revert-PR-modula2-121629-adding-third-party-modules.patch b/16.0.0/gentoo/89_all_PR121709-Revert-PR-modula2-121629-adding-third-party-modules.patch
new file mode 100644
index 0000000..dccb31a
--- /dev/null
+++ b/16.0.0/gentoo/89_all_PR121709-Revert-PR-modula2-121629-adding-third-party-modules.patch
@@ -0,0 +1,771 @@
+From 3bbb5c9c356d34f3593d8beb512b13c2f9cae7fe Mon Sep 17 00:00:00 2001
+Message-ID: <3bbb5c9c356d34f3593d8beb512b13c2f9cae7fe.1756403767.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Thu, 28 Aug 2025 18:55:53 +0100
+Subject: [PATCH] Revert "PR modula2/121629: adding third party modules"
+
+This reverts commit 69faef01dff124cd2e657b7525ba6cc574626853.
+
+Bug: https://gcc.gnu.org/PR121709
+---
+ gcc/doc/gm2.texi | 69 +----
+ gcc/m2/gm2-compiler/PathName.mod | 21 --
+ gcc/m2/gm2-lang.cc | 283 +++++-------------
+ gcc/m2/gm2spec.cc | 31 +-
+ gcc/m2/lang.opt | 10 +-
+ .../pass/switches-pathnameroot-pass.exp | 48 ---
+ .../gm2/switches/pathnameroot/pass/test.mod | 6 -
+ .../pathnameroot/pass/testlib/m2/foo.def | 7 -
+ .../pathnameroot/pass/testlib/m2/foo.mod | 3 -
+ 9 files changed, 94 insertions(+), 384 deletions(-)
+ delete mode 100755 gcc/testsuite/gm2/switches/pathnameroot/pass/switches-pathnameroot-pass.exp
+ delete mode 100644 gcc/testsuite/gm2/switches/pathnameroot/pass/test.mod
+ delete mode 100644 gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.def
+ delete mode 100644 gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.mod
+
+diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi
+index 4147a287c45d..9bd0f0d22142 100644
+--- a/gcc/doc/gm2.texi
++++ b/gcc/doc/gm2.texi
+@@ -143,7 +143,11 @@ available and access to assembly programming is achieved using the
+ same syntax as that used by GCC.
+
+ The gm2 driver allows third party libraries to be installed alongside
+-gm2 libraries. @xref{Module Search Path}.
++gm2 libraries. For example if the user specifies library @code{foo}
++using @code{-flibs=foo} the driver will check the standard GCC install
++directory for a sub directory @code{foo} containing the library
++contents. The library module search path is altered accordingly
++for compile and link.
+
+ @node Development, Features, Why use GNU Modula-2, Overview
+ @section How to get source code using git
+@@ -225,7 +229,6 @@ such as the AVR and the ARM).
+ * Standard procedures:: Permanently accessible base procedures.
+ * High procedure function:: Behavior of the high procedure function.
+ * Dialect:: GNU Modula-2 supported dialects.
+-* Module Search Path:: How to add library modules.
+ * Exceptions:: Exception implementation
+ * Semantic checking:: How to detect run time problems at compile time.
+ * Extensions:: GNU Modula-2 language extensions.
+@@ -522,15 +525,6 @@ following include paths.
+ for internal use only: used by the driver to copy the user facing @samp{-I}
+ option.
+
+-@item -fm2-pathname-root=@file{pathroot}
+-add search paths derived from the specified @file{pathroot}.
+-@xref{Module Search Path} for examples.
+-
+-@item -fm2-pathname-rootI
+-for internal use only: used by the driver to copy every user
+-@samp{-fm2-pathname-root=} facing option in order with all other
+-@samp{-I} options.
+-
+ @item -fm2-plugin
+ insert plugin to identify run time errors at compile time (default on).
+
+@@ -1385,7 +1379,7 @@ Actual parameter | HIGH (a) | a[HIGH (a)] = nul
+ str3 | 3 | TRUE
+ @end example
+
+-@node Dialect, Module Search Path, High procedure function, Using
++@node Dialect, Exceptions, High procedure function, Using
+ @section GNU Modula-2 supported dialects
+
+ This section describes the dialects understood by GNU Modula-2.
+@@ -1450,39 +1444,6 @@ implemented as above, apart from the exception calling in the ISO
+ dialect. Instead of exception handling the results are the same as the
+ PIM4 dialect. This is a temporary implementation situation.
+
+-@node Module Search Path, Exceptions, Dialect, Using
+-@section Module Search Path
+-
+-This section describes the default module search path and how this
+-might be changed. By default the compiler will search the current
+-directory, site wide modules and lastly gcc version specific modules.
+-
+-The @samp{-I} option option can be used to introduce new directories
+-in the module search path and for convenience the options @samp{-flibs=}
+-and @samp{-fm2-pathname-root=} are also provided.
+-
+-The site wide modules are located at @var{prefix}@file{/include/m2}
+-whereas the version specific modules are located in
+-@var{libsubdir}@file{/m2}. Both of these @file{/m2} directories
+-are organized such that the non dialect specific modules are at the
+-top and dialect specific modules are in subdirectories.
+-
+-The @samp{-fm2-pathname-root=} option is equivalent to adding a
+-@samp{-I} path for every library dialect. For example if the library
+-dialect order is selected by @samp{-flibs=pim,iso,log} and
+-@samp{-fm2-pathname-root=foo} is supplied then this is equivalent to
+-the following pairs of options:
+-
+-@example
+--fm2-pathname=m2pim -I@file{foo/m2/m2pim}
+--fm2-pathname=m2iso -I@file{foo/m2/m2iso}
+--fm2-pathname=m2log -I@file{foo/m2/m2log}
+--fm2-pathname=- -I@file{foo/m2}
+-@end example
+-
+-The option @samp{-fsources} will show the source module, path and
+-pathname for each module parsed.
+-
+ @node Exceptions, Semantic checking, Dialect, Using
+ @section Exception implementation
+
+@@ -2062,7 +2023,7 @@ CONST
+
+ VAR
+ head: List ;
+-@end group
++@end group
+ @end example
+
+ @example
+@@ -2073,13 +2034,13 @@ VAR
+ BEGIN
+ p := head^.next ;
+ printf ("\nunique data\n");
+- printf ("===========\n");
++ printf ("===========\n");
+ WHILE p # NIL DO
+ printf ("%d\n", p^.value);
+ p := p^.next
+ END
+ END Display ;
+-@end group
++@end group
+ @end example
+
+ @example
+@@ -2092,7 +2053,7 @@ BEGIN
+ next := NIL
+ END
+ END Add ;
+-@end group
++@end group
+ @end example
+
+ @example
+@@ -2114,17 +2075,17 @@ EXCEPT
+ THEN
+ printf ("list was empty, add sentinal\n");
+ Add (head, -1) ;
+- RETRY (* Jump back to the begin statement. *)
++ RETRY (* Jump back to the begin statement. *)
+ ELSIF p^.next = NIL
+ THEN
+ printf ("growing the list\n");
+ Add (p^.next, val) ;
+ RETRY (* Jump back to the begin statement. *)
+ ELSE
+- printf ("should never reach here!\n");
++ printf ("should never reach here!\n");
+ END
+ END Unique ;
+-@end group
++@end group
+ @end example
+
+ @example
+@@ -2143,7 +2104,7 @@ BEGIN
+ head := NIL ;
+ unique
+ END lazyunique.
+-@end group
++@end group
+ @end example
+
+ @example
+@@ -2166,7 +2127,7 @@ unique data
+ 0
+ 2
+ 1
+-@end group
++@end group
+ @end example
+
+ @node Unbounded by reference, Building a shared library, Exception handling, Using
+diff --git a/gcc/m2/gm2-compiler/PathName.mod b/gcc/m2/gm2-compiler/PathName.mod
+index 0ba902408204..6fc7612d08f3 100644
+--- a/gcc/m2/gm2-compiler/PathName.mod
++++ b/gcc/m2/gm2-compiler/PathName.mod
+@@ -1,24 +1,3 @@
+-(* M2PathName.mod maintain a dictionary of named paths.
+-
+-Copyright (C) 2023-2025 Free Software Foundation, Inc.
+-Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
+-
+-This file is part of GNU Modula-2.
+-
+-GNU Modula-2 is free software; you can redistribute it and/or modify
+-it under the terms of the GNU General Public License as published by
+-the Free Software Foundation; either version 3, or (at your option)
+-any later version.
+-
+-GNU Modula-2 is distributed in the hope that it will be useful, but
+-WITHOUT ANY WARRANTY; without even the implied warranty of
+-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+-General Public License for more details.
+-
+-You should have received a copy of the GNU General Public License
+-along with GNU Modula-2; see the file COPYING3. If not see
+-<http://www.gnu.org/licenses/>. *)
+-
+ IMPLEMENTATION MODULE PathName ;
+
+ FROM Storage IMPORT ALLOCATE, DEALLOCATE ;
+diff --git a/gcc/m2/gm2-lang.cc b/gcc/m2/gm2-lang.cc
+index d378d1bc2122..31a2e46475dc 100644
+--- a/gcc/m2/gm2-lang.cc
++++ b/gcc/m2/gm2-lang.cc
+@@ -51,7 +51,6 @@ static bool iso = false;
+ typedef struct named_path_s {
+ std::vector<const char*>path;
+ const char *name;
+- bool lib_root;
+ } named_path;
+
+
+@@ -373,7 +372,6 @@ push_back_Ipath (const char *arg)
+ named_path np;
+ np.path.push_back (arg);
+ np.name = xstrdup (M2Options_GetM2PathName ());
+- np.lib_root = false;
+ Ipaths.push_back (np);
+ }
+ else
+@@ -386,205 +384,11 @@ push_back_Ipath (const char *arg)
+ named_path np;
+ np.path.push_back (arg);
+ np.name = xstrdup (M2Options_GetM2PathName ());
+- np.lib_root = false;
+ Ipaths.push_back (np);
+ }
+ }
+ }
+
+-/* push_back_lib_root pushes a lib_root onto the Ipaths vector.
+- The ordering of the -fm2_add_lib_root=, -I and named paths
+- must be preserved. */
+-
+-static void
+-push_back_lib_root (const char *arg)
+-{
+- named_path np;
+- np.name = arg;
+- np.lib_root = true;
+- Ipaths.push_back (np);
+-}
+-
+-/* get_dir_sep_size return the length of the DIR_SEPARATOR string. */
+-
+-static size_t
+-get_dir_sep_size (void)
+-{
+- const char dir_sep[] = {DIR_SEPARATOR, (char)0};
+- size_t dir_sep_size = strlen (dir_sep);
+- return dir_sep_size;
+-}
+-
+-/* add_path_component strcats src into dest and adds a directory seperator
+- if necessary. */
+-
+-static void
+-add_path_component (char *dest, const char *src)
+-{
+- size_t len = strlen (dest);
+- const char dir_sep[] = {DIR_SEPARATOR, (char)0};
+- size_t dir_sep_size = strlen (dir_sep);
+-
+- if (len > 0)
+- {
+- /* Only add a seperator if dest is not empty and does not end
+- with a seperator. */
+- if (len >= dir_sep_size
+- && (strcmp (&dest[len-dir_sep_size], dir_sep) != 0))
+- strcat (dest, dir_sep);
+- }
+- strcat (dest, src);
+-}
+-
+-/* This prefixes LIBNAME with the current compiler prefix (if it has been
+- relocated) or the LIBSUBDIR, if not. */
+-
+-static void
+-add_one_import_path (const char *libpath, const char *libname)
+-{
+- size_t dir_sep_size = get_dir_sep_size ();
+- size_t mlib_len = 0;
+-
+- if (imultilib)
+- {
+- mlib_len = strlen (imultilib);
+- mlib_len += dir_sep_size;
+- }
+-
+- char *lib = (char *)alloca (strlen (libpath) + dir_sep_size
+- + strlen ("m2") + dir_sep_size
+- + strlen (libname) + 1
+- + mlib_len + 1);
+- strcpy (lib, libpath);
+- if (imultilib)
+- add_path_component (lib, imultilib);
+- add_path_component (lib, "m2");
+- add_path_component (lib, libname);
+- M2Options_SetM2PathName (libname);
+- M2Options_SetSearchPath (lib);
+-}
+-
+-/* add_non_dialect_specific_path add non dialect specific includes
+- given a base libpath. */
+-
+-static void
+-add_non_dialect_specific_path (const char *libpath)
+-{
+- char *incpath = (char *)alloca (strlen (libpath)
+- + strlen ("m2")
+- + get_dir_sep_size ()
+- + 1);
+- strcpy (incpath, libpath);
+- add_path_component (incpath, "m2");
+- M2Options_SetM2PathName (""); /* No pathname for non dialect specific libs. */
+- M2Options_SetSearchPath (incpath);
+-}
+-
+-/* For each comma-separated standard library name in LIBLIST, add the
+- corresponding include path. */
+-
+-static void
+-foreach_lib_gen_import_path (const char *liblist, const char *libpath)
+-{
+- while (*liblist != 0 && *liblist != '-')
+- {
+- const char *comma = strstr (liblist, ",");
+- size_t len;
+- if (comma)
+- len = comma - liblist;
+- else
+- len = strlen (liblist);
+- char *libname = (char *) alloca (len+1);
+- strncpy (libname, liblist, len);
+- libname[len] = 0;
+- add_one_import_path (libpath, libname);
+- liblist += len;
+- if (*liblist == ',')
+- liblist++;
+- }
+- add_non_dialect_specific_path (libpath);
+-}
+-
+-/* get_module_source_dir return the libpath/{multilib/} as a malloc'd
+- string. */
+-
+-static const char *
+-get_module_source_dir (void)
+-{
+- const char *libpath = iprefix ? iprefix : LIBSUBDIR;
+- const char dir_sep[] = {DIR_SEPARATOR, (char)0};
+- size_t dir_sep_size = strlen (dir_sep);
+- unsigned int mlib_len = 0;
+-
+- if (imultilib)
+- {
+- mlib_len = strlen (imultilib);
+- mlib_len += strlen (dir_sep);
+- }
+- char *lib = (char *) xmalloc (strlen (libpath)
+- + dir_sep_size
+- + mlib_len + 1);
+- strcpy (lib, libpath);
+- /* iprefix has a trailing dir separator, LIBSUBDIR does not. */
+- if (!iprefix)
+- strcat (lib, dir_sep);
+-
+- if (imultilib)
+- {
+- strcat (lib, imultilib);
+- strcat (lib, dir_sep);
+- }
+- return lib;
+-}
+-
+-/* add_default_include_paths add include paths for site wide definition modules
+- and also gcc version specific definition modules. */
+-
+-static void
+-add_default_include_paths (const char *flibs)
+-{
+- /* Add the site wide include path. */
+- foreach_lib_gen_import_path (flibs, PREFIX_INCLUDE_DIR);
+- /* Add the gcc version specific include path. */
+- foreach_lib_gen_import_path (flibs,
+- get_module_source_dir ());
+-}
+-
+-/* assign_flibs assign flibs to a default providing that allow_libraries
+- is true and flibs has not been set. */
+-
+-static void
+-assign_flibs (void)
+-{
+- if (allow_libraries && (flibs == NULL))
+- {
+- if (iso)
+- flibs = "m2iso,m2cor,m2pim,m2log";
+- else
+- flibs = "m2pim,m2iso,m2cor,m2log";
+- }
+-}
+-
+-/* m2_pathname_root creates a new set of include paths for the
+- subdirectory m2 inside libroot. The ordering of the paths
+- follows the dialect library order. */
+-
+-static void
+-m2_pathname_root (const char *libroot)
+-{
+- const char *copy_flibs = flibs;
+-
+- if (copy_flibs == NULL)
+- {
+- if (iso)
+- copy_flibs = "m2iso,m2cor,m2pim,m2log";
+- else
+- copy_flibs = "m2pim,m2iso,m2cor,m2log";
+- }
+- foreach_lib_gen_import_path (copy_flibs, libroot);
+-}
+-
+-
+ /* Handle gm2 specific options. Return 0 if we didn't do anything. */
+
+ bool
+@@ -631,9 +435,6 @@ gm2_langhook_handle_option (
+ case OPT_fpositive_mod_floor_div:
+ M2Options_SetPositiveModFloor (value);
+ return 1;
+- case OPT_fm2_pathname_rootI_:
+- push_back_lib_root (arg);
+- return 1;
+ case OPT_flibs_:
+ allow_libraries = value;
+ flibs = arg;
+@@ -909,6 +710,66 @@ gm2_langhook_handle_option (
+ return 0;
+ }
+
++/* This prefixes LIBNAME with the current compiler prefix (if it has been
++ relocated) or the LIBSUBDIR, if not. */
++static void
++add_one_import_path (const char *libname)
++{
++ const char *libpath = iprefix ? iprefix : LIBSUBDIR;
++ const char dir_sep[] = {DIR_SEPARATOR, (char)0};
++ size_t dir_sep_size = strlen (dir_sep);
++ unsigned int mlib_len = 0;
++
++ if (imultilib)
++ {
++ mlib_len = strlen (imultilib);
++ mlib_len += strlen (dir_sep);
++ }
++
++ char *lib = (char *)alloca (strlen (libpath) + dir_sep_size
++ + strlen ("m2") + dir_sep_size
++ + strlen (libname) + 1
++ + mlib_len + 1);
++ strcpy (lib, libpath);
++ /* iprefix has a trailing dir separator, LIBSUBDIR does not. */
++ if (!iprefix)
++ strcat (lib, dir_sep);
++
++ if (imultilib)
++ {
++ strcat (lib, imultilib);
++ strcat (lib, dir_sep);
++ }
++ strcat (lib, "m2");
++ strcat (lib, dir_sep);
++ strcat (lib, libname);
++ M2Options_SetM2PathName (libname);
++ M2Options_SetSearchPath (lib);
++}
++
++/* For each comma-separated standard library name in LIBLIST, add the
++ corresponding include path. */
++static void
++add_m2_import_paths (const char *liblist)
++{
++ while (*liblist != 0 && *liblist != '-')
++ {
++ const char *comma = strstr (liblist, ",");
++ size_t len;
++ if (comma)
++ len = comma - liblist;
++ else
++ len = strlen (liblist);
++ char *libname = (char *) alloca (len+1);
++ strncpy (libname, liblist, len);
++ libname[len] = 0;
++ add_one_import_path (libname);
++ liblist += len;
++ if (*liblist == ',')
++ liblist++;
++ }
++}
++
+ /* Run after parsing options. */
+
+ static bool
+@@ -923,7 +784,16 @@ gm2_langhook_post_options (const char **pfilename)
+ /* Add the include paths as per the libraries specified.
+ NOTE: This assumes that the driver has validated the input and makes
+ no attempt to be defensive of nonsense input in flibs=. */
+- assign_flibs ();
++ if (allow_libraries)
++ {
++ if (!flibs)
++ {
++ if (iso)
++ flibs = "m2iso,m2cor,m2pim,m2log";
++ else
++ flibs = "m2pim,m2iso,m2cor,m2log";
++ }
++ }
+
+ /* Add search paths.
+ We are not handling all of the cases yet (e.g idirafter).
+@@ -937,14 +807,9 @@ gm2_langhook_post_options (const char **pfilename)
+ iquote.clear();
+ for (auto np : Ipaths)
+ {
+- if (np.lib_root)
+- foreach_lib_gen_import_path (flibs, np.name);
+- else
+- {
+- M2Options_SetM2PathName (np.name);
+- for (auto *s : np.path)
+- M2Options_SetSearchPath (s);
+- }
++ M2Options_SetM2PathName (np.name);
++ for (auto *s : np.path)
++ M2Options_SetSearchPath (s);
+ }
+ Ipaths.clear();
+ for (auto *s : isystem)
+@@ -953,7 +818,7 @@ gm2_langhook_post_options (const char **pfilename)
+ /* FIXME: this is not a good way to suppress the addition of the import
+ paths. */
+ if (allow_libraries)
+- add_default_include_paths (flibs);
++ add_m2_import_paths (flibs);
+
+ /* Returning false means that the backend should be used. */
+ return M2Options_GetPPOnly ();
+diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc
+index 18d9ce7a630b..868e5c5619ed 100644
+--- a/gcc/m2/gm2spec.cc
++++ b/gcc/m2/gm2spec.cc
+@@ -158,12 +158,10 @@ static const char *m2_path_name = "";
+ typedef struct named_path_s {
+ std::vector<const char*>path;
+ const char *name;
+- bool lib_root;
+ } named_path;
+
+ static std::vector<named_path>Ipaths;
+
+-/* push_back_Ipath pushes a named path to the Ipaths global variable. */
+
+ static void
+ push_back_Ipath (const char *arg)
+@@ -173,7 +171,6 @@ push_back_Ipath (const char *arg)
+ named_path np;
+ np.path.push_back (arg);
+ np.name = m2_path_name;
+- np.lib_root = false;
+ Ipaths.push_back (np);
+ }
+ else
+@@ -186,25 +183,11 @@ push_back_Ipath (const char *arg)
+ named_path np;
+ np.path.push_back (arg);
+ np.name = m2_path_name;
+- np.lib_root = false;
+ Ipaths.push_back (np);
+ }
+ }
+ }
+
+-/* push_back_lib_root pushes a lib_root onto the Ipaths vector.
+- The ordering of the -fm2_add_lib_root=, -I and named paths
+- must be preserved. */
+-
+-static void
+-push_back_lib_root (const char *arg)
+-{
+- named_path np;
+- np.name = arg;
+- np.lib_root = true;
+- Ipaths.push_back (np);
+-}
+-
+ /* Return whether strings S1 and S2 are both NULL or both the same
+ string. */
+
+@@ -396,18 +379,15 @@ convert_abbreviations (const char *libraries)
+ return full_libraries;
+ }
+
+-/* add_m2_I_path appends -fm2-pathname, -fm2-pathnameI and -fm2-add-lib-root
+- options to the command line which are contructed in the saved Ipaths.
+- The order of these options must be maintained. */
++/* add_m2_I_path appends -fm2-pathname and -fm2-pathnameI options to
++ the command line which are contructed in the saved Ipaths. */
+
+ static void
+ add_m2_I_path (void)
+ {
+ for (auto np : Ipaths)
+ {
+- if (np.lib_root)
+- append_option (OPT_fm2_pathname_rootI_, safe_strdup (np.name), 1);
+- else if (strcmp (np.name, "") == 0)
++ if (strcmp (np.name, "") == 0)
+ append_option (OPT_fm2_pathname_, safe_strdup ("-"), 1);
+ else
+ append_option (OPT_fm2_pathname_, safe_strdup (np.name), 1);
+@@ -596,10 +576,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
+ args[i] |= SKIPOPT; /* We will add the option if it is needed. */
+ m2_path_name = decoded_options[i].arg;
+ break;
+- case OPT_fm2_pathname_root_:
+- args[i] |= SKIPOPT; /* We will add the option if it is needed. */
+- push_back_lib_root (decoded_options[i].arg);
+- break;
+ case OPT__help:
+ case OPT__help_:
+ /* Let gcc.cc handle this, as it has a really
+@@ -763,6 +739,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
+ "-fgen-module-list=", "-fuse-list=");
+ }
+
++
+ /* There's no point adding -shared-libgcc if we don't have a shared
+ libgcc. */
+ #ifndef ENABLE_SHARED_LIBGCC
+diff --git a/gcc/m2/lang.opt b/gcc/m2/lang.opt
+index 2aea4ccb77eb..48c2380f565b 100644
+--- a/gcc/m2/lang.opt
++++ b/gcc/m2/lang.opt
+@@ -172,15 +172,7 @@ specify the module mangled prefix name for all modules in the following include
+
+ fm2-pathnameI
+ Modula-2 Joined
+-; For internal use only: used by the driver to copy the user facing -I option in order
+-
+-fm2-pathname-root=
+-Modula-2 Joined
+-add include paths for all the library names in -flibs= to this directory root
+-
+-fm2-pathname-rootI=
+-Modula-2 Joined
+-; For internal use only: used by the driver to copy the user facing -I option in order
++; For internal use only: used by the driver to copy the user facing -I option
+
+ fm2-plugin
+ Modula-2
+diff --git a/gcc/testsuite/gm2/switches/pathnameroot/pass/switches-pathnameroot-pass.exp b/gcc/testsuite/gm2/switches/pathnameroot/pass/switches-pathnameroot-pass.exp
+deleted file mode 100755
+index d2f4d87ae27b..000000000000
+--- a/gcc/testsuite/gm2/switches/pathnameroot/pass/switches-pathnameroot-pass.exp
++++ /dev/null
+@@ -1,48 +0,0 @@
+-# Expect driver script for GCC Regression Tests
+-# Copyright (C) 2025 Free Software Foundation, Inc.
+-
+-# This program is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation; either version 3 of the License, or
+-# (at your option) any later version.
+-#
+-# This program is distributed in the hope that it will be useful,
+-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-# GNU General Public License for more details.
+-#
+-# You should have received a copy of the GNU General Public License
+-# along with GCC; see the file COPYING3. If not see
+-# <http://www.gnu.org/licenses/>.
+-
+-# This file was written by Gaius Mulley (gaius.mulley@southwales.ac.uk)
+-# for GNU Modula-2.
+-
+-load_lib target-supports.exp
+-
+-global TESTING_IN_BUILD_TREE
+-global ENABLE_PLUGIN
+-
+-# The plugin testcases currently only work when the build tree is available.
+-# Also check whether the host supports plugins.
+-if { ![info exists TESTING_IN_BUILD_TREE] || ![info exists ENABLE_PLUGIN] } {
+- return
+-}
+-
+-if $tracelevel then {
+- strace $tracelevel
+-}
+-
+-# load support procs
+-load_lib gm2-torture.exp
+-
+-gm2_init_pim "${srcdir}/gm2/switches/pathnameroot/pass" -fm2-pathname-root="${srcdir}/gm2/switches/pathnameroot/pass/testlib"
+-
+-foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
+- # If we're only testing specific files and this isn't one of them, skip it.
+- if ![runtest_file_p $runtests $testcase] then {
+- continue
+- }
+-
+- gm2-torture-fail $testcase
+-}
+diff --git a/gcc/testsuite/gm2/switches/pathnameroot/pass/test.mod b/gcc/testsuite/gm2/switches/pathnameroot/pass/test.mod
+deleted file mode 100644
+index 0f9cd6fe38b2..000000000000
+--- a/gcc/testsuite/gm2/switches/pathnameroot/pass/test.mod
++++ /dev/null
+@@ -1,6 +0,0 @@
+-MODULE test ;
+-
+-FROM foo IMPORT SomeValue ;
+-
+-BEGIN
+-END test.
+diff --git a/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.def b/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.def
+deleted file mode 100644
+index 9fa4973b0de1..000000000000
+--- a/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.def
++++ /dev/null
+@@ -1,7 +0,0 @@
+-DEFINITION MODULE foo ;
+-
+-CONST
+- SomeValue = 123 ;
+-
+-
+-END foo.
+diff --git a/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.mod b/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.mod
+deleted file mode 100644
+index fcbcf1e9ce70..000000000000
+--- a/gcc/testsuite/gm2/switches/pathnameroot/pass/testlib/m2/foo.mod
++++ /dev/null
+@@ -1,3 +0,0 @@
+-IMPLEMENTATION MODULE foo ;
+-
+-END foo.
+
+base-commit: 59db4ce2df1db33ad361eca06a7aec99b24d0d2f
+--
+2.51.0
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index d0980b2..63618fc 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -2,6 +2,7 @@
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
+ 88_all-x86-64-Improve-source-operand-check-for-TLS_CALL.patch
+ + 89_all_PR121709-Revert-PR-modula2-121629-adding-third-party-modules.patchsam@mop
12 24 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-28 5:27 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-28 5:27 UTC (permalink / raw
To: gentoo-commits
commit: 3593100a40de80ef4b25dc04b016a8e75e46f6fc
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 28 05:26:30 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Aug 28 05:26:52 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=3593100a
16.0.0: update TLS patches
Signed-off-by: Sam James <sam <AT> gentoo.org>
...fault-to-mtls-dialect-gnu2-if-appropriate.patch | 41 +-
...er-compare-source-operands-of-tls_dynamic.patch | 234 ------------
...Improve-source-operand-check-for-TLS_CALL.patch | 424 +++++++++++++++++++++
16.0.0/gentoo/README.history | 2 +-
4 files changed, 442 insertions(+), 259 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch b/16.0.0/gentoo/86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
index cdcb655..dfd673c 100644
--- a/16.0.0/gentoo/86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
+++ b/16.0.0/gentoo/86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
@@ -1,5 +1,5 @@
-From 02616942358bd045b21a69c0c866687150080d12 Mon Sep 17 00:00:00 2001
-Message-ID: <02616942358bd045b21a69c0c866687150080d12.1756094106.git.sam@gentoo.org>
+From 06ade1197723d083766db2ea37af464492795b07 Mon Sep 17 00:00:00 2001
+Message-ID: <06ade1197723d083766db2ea37af464492795b07.1756358799.git.sam@gentoo.org>
From: Sam James <sam@gentoo.org>
Date: Sun, 24 Aug 2025 00:30:45 +0100
Subject: [PATCH] i386: default to -mtls-dialect=gnu2 if appropriate
@@ -45,9 +45,6 @@ Some implementation notes:
machinery is added to glibc and bfd. This makes the separate position of
the check (not with some of the others) a bit more palatable IMO.
-TODO: Handle -x32
-TODO: Test i686
-
gcc/ChangeLog:
PR target/120933
* configure: Regenerate.
@@ -57,12 +54,12 @@ gcc/ChangeLog:
(with_tls): Default to 'gnu2' if --with-tls is not passed and
gcc_cv_libc_x86_tlsdesc_call is 'yes'.
---
- gcc/configure | 219 +++++++++++++++++++++++++++++++----------------
- gcc/configure.ac | 114 ++++++++++++++++++------
- 2 files changed, 233 insertions(+), 100 deletions(-)
+ gcc/configure | 217 +++++++++++++++++++++++++++++++----------------
+ gcc/configure.ac | 112 ++++++++++++++++++------
+ 2 files changed, 229 insertions(+), 100 deletions(-)
diff --git a/gcc/configure b/gcc/configure
-index 4a751d969bab..067e95eeedd2 100755
+index 4a751d969bab..ba303469613c 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -737,7 +737,6 @@ libgcc_visibility
@@ -81,7 +78,7 @@ index 4a751d969bab..067e95eeedd2 100755
objext
manext
LIBICONV_DEP
-@@ -12927,6 +12927,147 @@ if test "x$enable_win32_utf8_manifest" != xno; then
+@@ -12927,6 +12927,145 @@ if test "x$enable_win32_utf8_manifest" != xno; then
host_extra_objs_mingw=utf8-mingw32.o
fi
@@ -168,15 +165,13 @@ index 4a751d969bab..067e95eeedd2 100755
+ # for this behavior and binaries will depend on GLIBC_ABI_GNU2_TLS and fixed
+ # glibc. Hence the presence of GLIBC_ABI_GNU2_TLS tells us if we can safely
+ # default to GNU2 TLS descriptors.
-+ #
-+ # TODO: x32
+ conftest_S='
+ .section .text.startup,"ax",@progbits
+ .p2align 4
+ .globl main
+ .type main, @function
+ main:
-+ #ifdef __x86_64__
++ #ifdef __x86_64__
+ leaq foo@TLSDESC(%rip), %rax
+ call *foo@TLSCALL(%rax)
+ movl %fs:(%rax), %eax
@@ -229,25 +224,25 @@ index 4a751d969bab..067e95eeedd2 100755
# --------------------------------------------------------
# Build, host, and target specific configuration fragments
# --------------------------------------------------------
-@@ -21484,7 +21625,7 @@ else
+@@ -21484,7 +21623,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 21487 "configure"
-+#line 21628 "configure"
++#line 21626 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
-@@ -21590,7 +21731,7 @@ else
+@@ -21590,7 +21729,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 21593 "configure"
-+#line 21734 "configure"
++#line 21732 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
-@@ -25419,78 +25560,6 @@ else
+@@ -25419,78 +25558,6 @@ else
$as_echo "$gcc_cv_objdump" >&6; }
fi
@@ -327,10 +322,10 @@ index 4a751d969bab..067e95eeedd2 100755
if ${gcc_cv_otool+:} false; then :
diff --git a/gcc/configure.ac b/gcc/configure.ac
-index 4532c5c22fe5..5c60c47d36be 100644
+index 4532c5c22fe5..4c268d565d72 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
-@@ -1886,6 +1886,95 @@ if test "x$enable_win32_utf8_manifest" != xno; then
+@@ -1886,6 +1886,93 @@ if test "x$enable_win32_utf8_manifest" != xno; then
host_extra_objs_mingw=utf8-mingw32.o
fi
@@ -372,15 +367,13 @@ index 4532c5c22fe5..5c60c47d36be 100644
+ # for this behavior and binaries will depend on GLIBC_ABI_GNU2_TLS and fixed
+ # glibc. Hence the presence of GLIBC_ABI_GNU2_TLS tells us if we can safely
+ # default to GNU2 TLS descriptors.
-+ #
-+ # TODO: x32
+ conftest_S='
+ .section .text.startup,"ax",@progbits
+ .p2align 4
+ .globl main
+ .type main, @function
+ main:
-+ #ifdef __x86_64__
++ #ifdef __x86_64__
+ leaq foo@TLSDESC(%rip), %rax
+ call *foo@TLSCALL(%rax)
+ movl %fs:(%rax), %eax
@@ -426,7 +419,7 @@ index 4532c5c22fe5..5c60c47d36be 100644
# --------------------------------------------------------
# Build, host, and target specific configuration fragments
# --------------------------------------------------------
-@@ -2934,31 +3023,6 @@ else
+@@ -2934,31 +3021,6 @@ else
AC_MSG_RESULT($gcc_cv_objdump)
fi
diff --git a/16.0.0/gentoo/88_all-x86-64-Better-compare-source-operands-of-tls_dynamic.patch b/16.0.0/gentoo/88_all-x86-64-Better-compare-source-operands-of-tls_dynamic.patch
deleted file mode 100644
index 44865e7..0000000
--- a/16.0.0/gentoo/88_all-x86-64-Better-compare-source-operands-of-tls_dynamic.patch
+++ /dev/null
@@ -1,234 +0,0 @@
-From ec4cc64262841e49967c2bf69dcd095985c2e304 Mon Sep 17 00:00:00 2001
-Message-ID: <ec4cc64262841e49967c2bf69dcd095985c2e304.1756251629.git.sam@gentoo.org>
-In-Reply-To: <ca5a4b3eea207904c64e638a4ecefd347f386abb.1756251629.git.sam@gentoo.org>
-References: <ca5a4b3eea207904c64e638a4ecefd347f386abb.1756251629.git.sam@gentoo.org>
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Tue, 26 Aug 2025 15:31:34 -0700
-Subject: [PATCH 2/2] x86-64: Better compare source operands of
- *tls_dynamic_gnu2_call_64_di
-
-Source operands of 2 *tls_dynamic_gnu2_call_64_di patterns in
-
-(insn 10 9 11 3 (set (reg:DI 100)
- (unspec:DI [
- (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
- ] UNSPEC_TLSDESC)) "x.c":7:16 1674 {*tls_dynamic_gnu2_lea_64_di}
- (nil))
-(insn 11 10 12 3 (parallel [
- (set (reg:DI 99)
- (unspec:DI [
- (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
- (reg:DI 100)
- (reg/f:DI 7 sp)
- ] UNSPEC_TLSDESC))
- (clobber (reg:CC 17 flags))
- ]) "x.c":7:16 1676 {*tls_dynamic_gnu2_call_64_di}
- (expr_list:REG_DEAD (reg:DI 100)
- (expr_list:REG_UNUSED (reg:CC 17 flags)
- (nil))))
-
-and
-
-(insn 19 17 20 4 (set (reg:DI 104)
- (unspec:DI [
- (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
- ] UNSPEC_TLSDESC)) "x.c":6:10 discrim 1 1674 {*tls_dynamic_gnu2_lea_64_di}
- (nil))
-(insn 20 19 21 4 (parallel [
- (set (reg:DI 103)
- (unspec:DI [
- (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
- (reg:DI 104)
- (reg/f:DI 7 sp)
- ] UNSPEC_TLSDESC))
- (clobber (reg:CC 17 flags))
- ]) "x.c":6:10 discrim 1 1676 {*tls_dynamic_gnu2_call_64_di}
- (expr_list:REG_DEAD (reg:DI 104)
- (expr_list:REG_UNUSED (reg:CC 17 flags)
- (nil))))
-
-are the same even though rtx_equal_p returns false since (reg:DI 100)
-and (reg:DI 104) are set from the same symbol. Add x86_cse_rtx_equal_p
-to compare source operands of *tls_dynamic_gnu2_call_64_di patterns and
-return true if only source operands differ and they are set from the
-same symbol.
-
-gcc/
-
- * config/i386/i386-features.cc
- (pass_x86_cse::x86_cse_rtx_equal_p): New.
- (pass_x86_cse::tls_set_insn_from_symbol): Likewise.
- (pass_x86_cse::candidate_gnu2_tls_p): Call
- tls_set_insn_from_symbol.
- (pass_x86_cse::x86_cse): Call x86_cse_rtx_equal_p, instead of
- rtx_equal_p, to compare 2 values.
-
-gcc/testsuite/
-
- * gcc.target/i386/pr121668-1b.c: New test.
-
-Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
----
- gcc/config/i386/i386-features.cc | 116 +++++++++++++++-----
- gcc/testsuite/gcc.target/i386/pr121668-1b.c | 6 +
- 2 files changed, 95 insertions(+), 27 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121668-1b.c
-
-diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index 93e20947edf3..ce77e91c1203 100644
---- a/gcc/config/i386/i386-features.cc
-+++ b/gcc/config/i386/i386-features.cc
-@@ -4168,8 +4168,95 @@ private:
- bool candidate_gnu_tls_p (rtx_insn *, attr_tls64);
- bool candidate_gnu2_tls_p (rtx, attr_tls64);
- bool candidate_vector_p (rtx);
-+ bool x86_cse_rtx_equal_p (const_rtx, const_rtx);
-+ rtx_insn *tls_set_insn_from_symbol (const_rtx, rtx *);
- }; // class pass_x86_cse
-
-+/* Return true if X and Y are equal. */
-+
-+bool
-+pass_x86_cse::x86_cse_rtx_equal_p (const_rtx x, const_rtx y)
-+{
-+ if (kind == X86_CSE_TLSDESC
-+ && GET_CODE (x) == UNSPEC
-+ && XINT (x, 1) == UNSPEC_TLSDESC
-+ && SYMBOL_REF_P (XVECEXP (x, 0, 0)))
-+ {
-+ /* Compare
-+
-+ (unspec:DI [
-+ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fffe99d9e40 caml_state>)
-+ (reg:DI 100)
-+ (reg/f:DI 7 sp)
-+ ] UNSPEC_TLSDESC)
-+
-+ against
-+
-+ (unspec:DI [
-+ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fffe99d9e40 caml_state>)
-+ (reg:DI 104)
-+ (reg/f:DI 7 sp)
-+ ] UNSPEC_TLSDESC)
-+
-+ If (reg:DI 100) and (reg:DI 104) are defined from the same source,
-+ they are equal. */
-+
-+ if (GET_CODE (y) != UNSPEC
-+ || XINT (y, 1) != UNSPEC_TLSDESC
-+ || !SYMBOL_REF_P (XVECEXP (y, 0, 0))
-+ || !rtx_equal_p (XVECEXP (x, 0, 0), XVECEXP (y, 0, 0)))
-+ return false;
-+
-+ x = XVECEXP (x, 0, 1);
-+ y = XVECEXP (y, 0, 1);
-+ if (rtx_equal_p (x, y))
-+ return true;
-+
-+ rtx tls_symbol = nullptr;
-+ return (tls_set_insn_from_symbol (x, &tls_symbol)
-+ && tls_symbol
-+ && tls_set_insn_from_symbol (y, &tls_symbol));
-+ }
-+
-+ return rtx_equal_p (x, y);
-+}
-+
-+/* Return the instruction which sets REG from one symbol and store the
-+ symbol in *TLS_SYMBOL_P if *TLS_SYMBOL_P is nullptr. */
-+
-+rtx_insn *
-+pass_x86_cse::tls_set_insn_from_symbol (const_rtx reg, rtx *tls_symol_p)
-+{
-+ rtx_insn *set_insn = nullptr;
-+ rtx tls_symbol = *tls_symol_p;
-+ for (df_ref ref = DF_REG_DEF_CHAIN (REGNO (reg));
-+ ref;
-+ ref = DF_REF_NEXT_REG (ref))
-+ {
-+ if (DF_REF_IS_ARTIFICIAL (ref))
-+ return nullptr;
-+
-+ set_insn = DF_REF_INSN (ref);
-+ if (get_attr_tls64 (set_insn) != TLS64_LEA)
-+ return nullptr;
-+
-+ rtx tls_set = PATTERN (set_insn);
-+ rtx tls_src = XVECEXP (SET_SRC (tls_set), 0, 0);
-+ if (tls_symbol == nullptr)
-+ {
-+ if (!SYMBOL_REF_P (tls_src))
-+ return nullptr;
-+
-+ tls_symbol = tls_src;
-+ *tls_symol_p = tls_src;
-+ }
-+ else if (!rtx_equal_p (tls_symbol, tls_src))
-+ return nullptr;
-+ }
-+
-+ return set_insn;
-+}
-+
- /* Return true and output def_insn, val, mode, scalar_mode and kind if
- INSN is UNSPEC_TLS_GD or UNSPEC_TLS_LD_BASE. */
-
-@@ -4283,32 +4370,7 @@ pass_x86_cse::candidate_gnu2_tls_p (rtx set, attr_tls64 tls64)
-
- */
-
-- df_ref ref;
-- rtx_insn *set_insn = nullptr;
-- for (ref = DF_REG_DEF_CHAIN (REGNO (src));
-- ref;
-- ref = DF_REF_NEXT_REG (ref))
-- {
-- if (DF_REF_IS_ARTIFICIAL (ref))
-- break;
--
-- set_insn = DF_REF_INSN (ref);
-- tls64 = get_attr_tls64 (set_insn);
-- if (tls64 != TLS64_LEA)
-- {
-- set_insn = nullptr;
-- break;
-- }
--
-- rtx tls_set = PATTERN (set_insn);
-- rtx tls_src = XVECEXP (SET_SRC (tls_set), 0, 0);
-- if (!rtx_equal_p (tls_symbol, tls_src))
-- {
-- set_insn = nullptr;
-- break;
-- }
-- }
--
-+ rtx_insn *set_insn = tls_set_insn_from_symbol (src, &tls_symbol);
- if (!set_insn)
- return false;
-
-@@ -4436,7 +4498,7 @@ pass_x86_cse::x86_cse (void)
- /* Non all 0s/1s vector load must be in the same
- basic block if it is in a recursive call. */
- || !recursive_call_p)
-- && rtx_equal_p (load->val, val))
-+ && x86_cse_rtx_equal_p (load->val, val))
- {
- /* Record instruction. */
- bitmap_set_bit (load->insns, INSN_UID (insn));
-diff --git a/gcc/testsuite/gcc.target/i386/pr121668-1b.c b/gcc/testsuite/gcc.target/i386/pr121668-1b.c
-new file mode 100644
-index 000000000000..54a277506f83
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121668-1b.c
-@@ -0,0 +1,6 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-Og -g -fpic -fplt -mtls-dialect=gnu2" } */
-+
-+#include "pr121668-1a.c"
-+
-+/* { dg-final { scan-assembler-times "call\[ \t\]\\*caml_state@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */
---
-2.51.0
-
diff --git a/16.0.0/gentoo/88_all-x86-64-Improve-source-operand-check-for-TLS_CALL.patch b/16.0.0/gentoo/88_all-x86-64-Improve-source-operand-check-for-TLS_CALL.patch
new file mode 100644
index 0000000..7177603
--- /dev/null
+++ b/16.0.0/gentoo/88_all-x86-64-Improve-source-operand-check-for-TLS_CALL.patch
@@ -0,0 +1,424 @@
+From ec2e1fe2a6d5b004d5666e0a5f8dc00b8f0e2985 Mon Sep 17 00:00:00 2001
+Message-ID: <ec2e1fe2a6d5b004d5666e0a5f8dc00b8f0e2985.1756358733.git.sam@gentoo.org>
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Wed, 27 Aug 2025 19:14:13 -0700
+Subject: [PATCH] x86-64: Improve source operand check for TLS_CALL
+
+Source operands of 2 TLS_CALL patterns in
+
+(insn 10 9 11 3 (set (reg:DI 100)
+ (unspec:DI [
+ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
+ ] UNSPEC_TLSDESC)) "x.c":7:16 1674 {*tls_dynamic_gnu2_lea_64_di}
+ (nil))
+(insn 11 10 12 3 (parallel [
+ (set (reg:DI 99)
+ (unspec:DI [
+ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
+ (reg:DI 100)
+ (reg/f:DI 7 sp)
+ ] UNSPEC_TLSDESC))
+ (clobber (reg:CC 17 flags))
+ ]) "x.c":7:16 1676 {*tls_dynamic_gnu2_call_64_di}
+ (expr_list:REG_DEAD (reg:DI 100)
+ (expr_list:REG_UNUSED (reg:CC 17 flags)
+ (nil))))
+
+and
+
+(insn 19 17 20 4 (set (reg:DI 104)
+ (unspec:DI [
+ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
+ ] UNSPEC_TLSDESC)) "x.c":6:10 discrim 1 1674 {*tls_dynamic_gnu2_lea_64_di}
+ (nil))
+(insn 20 19 21 4 (parallel [
+ (set (reg:DI 103)
+ (unspec:DI [
+ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
+ (reg:DI 104)
+ (reg/f:DI 7 sp)
+ ] UNSPEC_TLSDESC))
+ (clobber (reg:CC 17 flags))
+ ]) "x.c":6:10 discrim 1 1676 {*tls_dynamic_gnu2_call_64_di}
+ (expr_list:REG_DEAD (reg:DI 104)
+ (expr_list:REG_UNUSED (reg:CC 17 flags)
+ (nil))))
+
+are the same even though rtx_equal_p returns false since (reg:DI 100)
+and (reg:DI 104) are set from the same symbol. Use the UNSPEC_TLSDESC
+symbol
+
+(unspec:DI [(symbol_ref:DI ("caml_state") [flags 0x10])] UNSPEC_TLSDESC))
+
+to check if 2 TLS_CALL patterns have the same source.
+
+For TLS64_COMBINE, use both UNSPEC_TLSDESC and UNSPEC_DTPOFF unspecs to
+check if 2 TLS64_COMBINE patterns have the same source.
+
+gcc/
+
+ PR target/121694
+ * config/i386/i386-features.cc (redundant_pattern): Add
+ tlsdesc_val.
+ (pass_x86_cse): Likewise.
+ ((pass_x86_cse::tls_set_insn_from_symbol): New member function.
+ (pass_x86_cse::candidate_gnu2_tls_p): Set tlsdesc_val. For
+ TLS64_COMBINE, match both UNSPEC_TLSDESC and UNSPEC_DTPOFF
+ symbols. For TLS64_CALL, match the UNSPEC_TLSDESC sumbol.
+ (pass_x86_cse::x86_cse): Initialize the tlsdesc_val field in
+ load. Pass the tlsdesc_val field to ix86_place_single_tls_call
+ for X86_CSE_TLSDESC.
+
+gcc/testsuite/
+
+ PR target/121694
+ * gcc.target/i386/pr121668-1b.c: New test.
+ * gcc.target/i386/pr121694-1a.c: Likewise.
+ * gcc.target/i386/pr121694-1b.c: Likewise.
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+---
+ gcc/config/i386/i386-features.cc | 201 ++++++++++++--------
+ gcc/testsuite/gcc.target/i386/pr121668-1b.c | 6 +
+ gcc/testsuite/gcc.target/i386/pr121694-1a.c | 19 ++
+ gcc/testsuite/gcc.target/i386/pr121694-1b.c | 6 +
+ 4 files changed, 154 insertions(+), 78 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121668-1b.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121694-1a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121694-1b.c
+
+diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
+index 93e20947edf3..5440a02c442b 100644
+--- a/gcc/config/i386/i386-features.cc
++++ b/gcc/config/i386/i386-features.cc
+@@ -3103,6 +3103,8 @@ struct redundant_pattern
+ auto_bitmap insns;
+ /* The broadcast inner scalar. */
+ rtx val;
++ /* The actual redundant source value for UNSPEC_TLSDESC. */
++ rtx tlsdesc_val;
+ /* The inner scalar mode. */
+ machine_mode mode;
+ /* The instruction which sets the inner scalar. Nullptr if the inner
+@@ -4155,6 +4157,8 @@ public:
+ private:
+ /* The redundant source value. */
+ rtx val;
++ /* The actual redundant source value for UNSPEC_TLSDESC. */
++ rtx tlsdesc_val;
+ /* The instruction which defines the redundant value. */
+ rtx_insn *def_insn;
+ /* Mode of the destination of the candidate redundant instruction. */
+@@ -4168,8 +4172,36 @@ private:
+ bool candidate_gnu_tls_p (rtx_insn *, attr_tls64);
+ bool candidate_gnu2_tls_p (rtx, attr_tls64);
+ bool candidate_vector_p (rtx);
++ rtx_insn *tls_set_insn_from_symbol (const_rtx, const_rtx);
+ }; // class pass_x86_cse
+
++/* Return the instruction which sets REG from TLS_SYMBOL. */
++
++rtx_insn *
++pass_x86_cse::tls_set_insn_from_symbol (const_rtx reg,
++ const_rtx tls_symbol)
++{
++ rtx_insn *set_insn = nullptr;
++ for (df_ref ref = DF_REG_DEF_CHAIN (REGNO (reg));
++ ref;
++ ref = DF_REF_NEXT_REG (ref))
++ {
++ if (DF_REF_IS_ARTIFICIAL (ref))
++ return nullptr;
++
++ set_insn = DF_REF_INSN (ref);
++ if (get_attr_tls64 (set_insn) != TLS64_LEA)
++ return nullptr;
++
++ rtx tls_set = PATTERN (set_insn);
++ rtx tls_src = XVECEXP (SET_SRC (tls_set), 0, 0);
++ if (!rtx_equal_p (tls_symbol, tls_src))
++ return nullptr;
++ }
++
++ return set_insn;
++}
++
+ /* Return true and output def_insn, val, mode, scalar_mode and kind if
+ INSN is UNSPEC_TLS_GD or UNSPEC_TLS_LD_BASE. */
+
+@@ -4226,29 +4258,71 @@ pass_x86_cse::candidate_gnu2_tls_p (rtx set, attr_tls64 tls64)
+ if (!TARGET_64BIT || !cfun->machine->tls_descriptor_call_multiple_p)
+ return false;
+
+- /* Record GNU2 TLS CALLs for 64-bit:
+-
+- (set (reg/f:DI 104)
+- (plus:DI (unspec:DI [
+- (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
+- (reg:DI 114)
+- (reg/f:DI 7 sp)] UNSPEC_TLSDESC)
+- (const:DI (unspec:DI [
+- (symbol_ref:DI ("e") [flags 0x1a])
+- ] UNSPEC_DTPOFF))))
+-
+- (set (reg/f:DI 104)
+- (plus:DI (unspec:DI [
+- (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
+- (unspec:DI [
+- (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
+- ] UNSPEC_TLSDESC)
+- (reg/f:DI 7 sp)] UNSPEC_TLSDESC)
+- (const:DI (unspec:DI [
+- (symbol_ref:DI ("e") [flags 0x1a])
+- ] UNSPEC_DTPOFF))))
++ rtx tls_symbol;
++ rtx_insn *set_insn;
++ rtx src = SET_SRC (set);
++ val = src;
++ tlsdesc_val = src;
++ kind = X86_CSE_TLSDESC;
+
+- and
++ if (tls64 == TLS64_COMBINE)
++ {
++ /* Record 64-bit TLS64_COMBINE:
++
++ (set (reg/f:DI 104)
++ (plus:DI (unspec:DI [
++ (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
++ (reg:DI 114)
++ (reg/f:DI 7 sp)] UNSPEC_TLSDESC)
++ (const:DI (unspec:DI [
++ (symbol_ref:DI ("e") [flags 0x1a])
++ ] UNSPEC_DTPOFF))))
++
++ (set (reg/f:DI 104)
++ (plus:DI (unspec:DI [
++ (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
++ (unspec:DI [
++ (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
++ ] UNSPEC_TLSDESC)
++ (reg/f:DI 7 sp)] UNSPEC_TLSDESC)
++ (const:DI (unspec:DI [
++ (symbol_ref:DI ("e") [flags 0x1a])
++ ] UNSPEC_DTPOFF))))
++ */
++
++ scalar_mode = mode = GET_MODE (src);
++ rtx src0 = XEXP (src, 0);
++ tls_symbol = XVECEXP (src0, 0, 0);
++ rtx src1 = XVECEXP (src0, 0, 1);
++ if (REG_P (src1))
++ {
++ set_insn = tls_set_insn_from_symbol (src1, tls_symbol);
++ gcc_assert (set_insn);
++ }
++ else
++ {
++ set_insn = nullptr;
++ gcc_assert (GET_CODE (src1) == UNSPEC
++ && XINT (src1, 1) == UNSPEC_TLSDESC
++ && SYMBOL_REF_P (XVECEXP (src1, 0, 0))
++ && rtx_equal_p (XVECEXP (src1, 0, 0), tls_symbol));
++ }
++
++ /* Use TLS_SYMBOL and
++
++ (const:DI (unspec:DI [
++ (symbol_ref:DI ("e") [flags 0x1a])
++ ] UNSPEC_DTPOFF))
++
++ as VAL to check if 2 patterns have the same source. */
++
++ rtvec vec = gen_rtvec (2, tls_symbol, XEXP (src, 1));
++ val = gen_rtx_UNSPEC (mode, vec, UNSPEC_TLSDESC);
++ def_insn = set_insn;
++ return true;
++ }
++
++ /* Record 64-bit TLS_CALL:
+
+ (set (reg:DI 101)
+ (unspec:DI [(symbol_ref:DI ("foo") [flags 0x50])
+@@ -4257,70 +4331,33 @@ pass_x86_cse::candidate_gnu2_tls_p (rtx set, attr_tls64 tls64)
+
+ */
+
+- rtx src = SET_SRC (set);
+- val = src;
+- if (tls64 != TLS64_CALL)
+- src = XEXP (src, 0);
+-
+- kind = X86_CSE_TLSDESC;
+ gcc_assert (GET_CODE (src) == UNSPEC);
+- rtx tls_symbol = XVECEXP (src, 0, 0);
++ tls_symbol = XVECEXP (src, 0, 0);
+ src = XVECEXP (src, 0, 1);
+ scalar_mode = mode = GET_MODE (src);
+- if (REG_P (src))
+- {
+- /* All definitions of reg:DI 129 in
+-
+- (set (reg:DI 110)
+- (unspec:DI [(symbol_ref:DI ("foo"))
+- (reg:DI 129)
+- (reg/f:DI 7 sp)] UNSPEC_TLSDESC))
+-
+- should have the same source as in
++ gcc_assert (REG_P (src));
+
+- (set (reg:DI 129)
+- (unspec:DI [(symbol_ref:DI ("foo"))] UNSPEC_TLSDESC))
++ /* All definitions of reg:DI 129 in
+
+- */
++ (set (reg:DI 110)
++ (unspec:DI [(symbol_ref:DI ("foo"))
++ (reg:DI 129)
++ (reg/f:DI 7 sp)] UNSPEC_TLSDESC))
+
+- df_ref ref;
+- rtx_insn *set_insn = nullptr;
+- for (ref = DF_REG_DEF_CHAIN (REGNO (src));
+- ref;
+- ref = DF_REF_NEXT_REG (ref))
+- {
+- if (DF_REF_IS_ARTIFICIAL (ref))
+- break;
++ should have the same source as in
+
+- set_insn = DF_REF_INSN (ref);
+- tls64 = get_attr_tls64 (set_insn);
+- if (tls64 != TLS64_LEA)
+- {
+- set_insn = nullptr;
+- break;
+- }
++ (set (reg:DI 129)
++ (unspec:DI [(symbol_ref:DI ("foo"))] UNSPEC_TLSDESC))
+
+- rtx tls_set = PATTERN (set_insn);
+- rtx tls_src = XVECEXP (SET_SRC (tls_set), 0, 0);
+- if (!rtx_equal_p (tls_symbol, tls_src))
+- {
+- set_insn = nullptr;
+- break;
+- }
+- }
+-
+- if (!set_insn)
+- return false;
++ */
+
+- def_insn = set_insn;
+- }
+- else if (GET_CODE (src) == UNSPEC
+- && XINT (src, 1) == UNSPEC_TLSDESC
+- && SYMBOL_REF_P (XVECEXP (src, 0, 0)))
+- def_insn = nullptr;
+- else
+- gcc_unreachable ();
++ set_insn = tls_set_insn_from_symbol (src, tls_symbol);
++ if (!set_insn)
++ return false;
+
++ /* Use TLS_SYMBOL as VAL to check if 2 patterns have the same source. */
++ val = tls_symbol;
++ def_insn = set_insn;
+ return true;
+ }
+
+@@ -4395,6 +4432,8 @@ pass_x86_cse::x86_cse (void)
+ if (!set && !CALL_P (insn))
+ continue;
+
++ tlsdesc_val = nullptr;
++
+ attr_tls64 tls64 = get_attr_tls64 (insn);
+ switch (tls64)
+ {
+@@ -4466,6 +4505,10 @@ pass_x86_cse::x86_cse (void)
+ load = new redundant_pattern;
+
+ load->val = copy_rtx (val);
++ if (tlsdesc_val)
++ load->tlsdesc_val = copy_rtx (tlsdesc_val);
++ else
++ load->tlsdesc_val = nullptr;
+ load->mode = scalar_mode;
+ load->size = GET_MODE_SIZE (mode);
+ load->def_insn = def_insn;
+@@ -4560,7 +4603,7 @@ pass_x86_cse::x86_cse (void)
+ {
+ case X86_CSE_TLSDESC:
+ ix86_place_single_tls_call (load->broadcast_reg,
+- load->val,
++ load->tlsdesc_val,
+ load->kind,
+ load->bbs,
+ updated_gnu_tls_insns,
+@@ -4606,7 +4649,9 @@ pass_x86_cse::x86_cse (void)
+ case X86_CSE_TLS_LD_BASE:
+ case X86_CSE_TLSDESC:
+ ix86_place_single_tls_call (load->broadcast_reg,
+- load->val,
++ (load->kind == X86_CSE_TLSDESC
++ ? load->tlsdesc_val
++ : load->val),
+ load->kind,
+ load->bbs,
+ updated_gnu_tls_insns,
+diff --git a/gcc/testsuite/gcc.target/i386/pr121668-1b.c b/gcc/testsuite/gcc.target/i386/pr121668-1b.c
+new file mode 100644
+index 000000000000..54a277506f83
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121668-1b.c
+@@ -0,0 +1,6 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-Og -g -fpic -fplt -mtls-dialect=gnu2" } */
++
++#include "pr121668-1a.c"
++
++/* { dg-final { scan-assembler-times "call\[ \t\]\\*caml_state@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr121694-1a.c b/gcc/testsuite/gcc.target/i386/pr121694-1a.c
+new file mode 100644
+index 000000000000..af9c65701341
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121694-1a.c
+@@ -0,0 +1,19 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-Og -fpic -fplt -mtls-dialect=gnu" } */
++
++extern void func1 (long *);
++extern int func2 (void);
++extern void func3 (void);
++static __thread long foo;
++static __thread long bar;
++long
++func (void)
++{
++ func1 (&foo);
++ func1 (&bar);
++ if (func2 ())
++ func3 ();
++ return foo + bar;
++}
++
++/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 1 { target { ! ia32 } } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr121694-1b.c b/gcc/testsuite/gcc.target/i386/pr121694-1b.c
+new file mode 100644
+index 000000000000..76ebbf7e90bd
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121694-1b.c
+@@ -0,0 +1,6 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-Og -fpic -fplt -mtls-dialect=gnu2" } */
++
++#include "pr121694-1a.c"
++
++/* { dg-final { scan-assembler-times "call\[ \t\]\\*_TLS_MODULE_BASE_@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */
+
+base-commit: 6aa1cbb140bba220439d839207a23f09222c99df
+--
+2.51.0
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index a98dbcb..d0980b2 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,7 +1,7 @@
13 ????
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
- + 88_all-x86-64-Better-compare-source-operands-of-tls_dynamic.patch
+ + 88_all-x86-64-Improve-source-operand-check-for-TLS_CALL.patch
12 24 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-27 4:19 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-27 4:19 UTC (permalink / raw
To: gentoo-commits
commit: 0aa44894bc4eebe0069a1355bfb600b150f776b8
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 27 04:19:49 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Aug 27 04:19:49 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=0aa44894
16.0.0: drop 1 TLS patch merged upstream
Signed-off-by: Sam James <sam <AT> gentoo.org>
...6-64-Emit-the-TLS-call-after-debug-marker.patch | 105 ---------------------
16.0.0/gentoo/README.history | 1 -
2 files changed, 106 deletions(-)
diff --git a/16.0.0/gentoo/87_all_PR121668-x86-64-Emit-the-TLS-call-after-debug-marker.patch b/16.0.0/gentoo/87_all_PR121668-x86-64-Emit-the-TLS-call-after-debug-marker.patch
deleted file mode 100644
index ace990f..0000000
--- a/16.0.0/gentoo/87_all_PR121668-x86-64-Emit-the-TLS-call-after-debug-marker.patch
+++ /dev/null
@@ -1,105 +0,0 @@
-From ca5a4b3eea207904c64e638a4ecefd347f386abb Mon Sep 17 00:00:00 2001
-Message-ID: <ca5a4b3eea207904c64e638a4ecefd347f386abb.1756251629.git.sam@gentoo.org>
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Tue, 26 Aug 2025 15:29:25 -0700
-Subject: [PATCH 1/2] x86-64: Emit the TLS call after debug marker
-
-For a basic block with only a debug marker:
-
-(note 3 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
-(note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
-(debug_insn 5 2 16 2 (debug_marker) "x.c":6:3 -1 (nil))
-
-emit the TLS call after debug marker.
-
-gcc/
-
- PR target/121668
- * config/i386/i386-features.cc (ix86_emit_tls_call): Emit the
- TLS call after debug marker.
-
-gcc/testsuite/
-
- PR target/121668
- * gcc.target/i386/pr121668-1a.c: New test.
-
-Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
----
- gcc/config/i386/i386-features.cc | 26 +++++++++++++++++----
- gcc/testsuite/gcc.target/i386/pr121668-1a.c | 13 +++++++++++
- 2 files changed, 34 insertions(+), 5 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121668-1a.c
-
-diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index cdb2a0b34b27..93e20947edf3 100644
---- a/gcc/config/i386/i386-features.cc
-+++ b/gcc/config/i386/i386-features.cc
-@@ -3806,10 +3806,19 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
- (code_label 78 11 77 3 14 (nil) [1 uses])
- (note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
-
-+ or a basic block with only a debug marker:
-+
-+ (note 3 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
-+ (note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
-+ (debug_insn 5 2 16 2 (debug_marker) "x.c":6:3 -1 (nil))
-+
- */
-- gcc_assert (NOTE_P (insn)
-- && (NOTE_KIND (insn) == NOTE_INSN_FUNCTION_BEG
-- || NOTE_KIND (insn) == NOTE_INSN_BASIC_BLOCK));
-+ gcc_assert (DEBUG_INSN_P (insn)
-+ || (NOTE_P (insn)
-+ && ((NOTE_KIND (insn)
-+ == NOTE_INSN_FUNCTION_BEG)
-+ || (NOTE_KIND (insn)
-+ == NOTE_INSN_BASIC_BLOCK))));
- insn = NULL;
- break;
- }
-@@ -3854,12 +3863,19 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
- (note 4 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
- (note 2 4 26 2 NOTE_INSN_FUNCTION_BEG)
-
-- or after NOTE_INSN_BASIC_BLOCK a basic block with only
-- a label:
-+ or after NOTE_INSN_BASIC_BLOCK in a basic block with
-+ only a label:
-
- (code_label 78 11 77 3 14 (nil) [1 uses])
- (note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
-
-+ or after debug marker in a basic block with only a
-+ debug marker:
-+
-+ (note 3 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
-+ (note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
-+ (debug_insn 5 2 16 2 (debug_marker) "x.c":6:3 -1 (nil))
-+
- */
- insn = insn ? PREV_INSN (insn) : BB_END (bb);
- *after_p = insn;
-diff --git a/gcc/testsuite/gcc.target/i386/pr121668-1a.c b/gcc/testsuite/gcc.target/i386/pr121668-1a.c
-new file mode 100644
-index 000000000000..eb553081eb31
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121668-1a.c
-@@ -0,0 +1,13 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-Og -g -fpic -fplt -mtls-dialect=gnu" } */
-+
-+typedef int caml_domain_state;
-+thread_local caml_domain_state caml_state;
-+void
-+caml_empty_mark_stack ()
-+{
-+ while (caml_state)
-+ caml_state = 0;
-+}
-+
-+/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 1 { target { ! ia32 } } } } */
-
-base-commit: a43c30cb6f451d60b7e19be09da075ab0ff5830f
---
-2.51.0
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 3ea56ff..a98dbcb 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,7 +1,6 @@
13 ????
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
- + 87_all_PR121668-x86-64-Emit-the-TLS-call-after-debug-marker.patch
+ 88_all-x86-64-Better-compare-source-operands-of-tls_dynamic.patch
12 24 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-26 23:42 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-26 23:42 UTC (permalink / raw
To: gentoo-commits
commit: 716d0a7b2b116dc499a01370f879e6aa35a113eb
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 26 23:41:56 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Aug 26 23:42:49 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=716d0a7b
16.0.0: add two more TLS patches
One is for the OCaml ICE and one is an optimisation improvement.
Bug: https://bugs.gentoo.org/961977
Signed-off-by: Sam James <sam <AT> gentoo.org>
...6-64-Emit-the-TLS-call-after-debug-marker.patch | 105 +++++++++
...er-compare-source-operands-of-tls_dynamic.patch | 234 +++++++++++++++++++++
16.0.0/gentoo/README.history | 2 +
3 files changed, 341 insertions(+)
diff --git a/16.0.0/gentoo/87_all_PR121668-x86-64-Emit-the-TLS-call-after-debug-marker.patch b/16.0.0/gentoo/87_all_PR121668-x86-64-Emit-the-TLS-call-after-debug-marker.patch
new file mode 100644
index 0000000..ace990f
--- /dev/null
+++ b/16.0.0/gentoo/87_all_PR121668-x86-64-Emit-the-TLS-call-after-debug-marker.patch
@@ -0,0 +1,105 @@
+From ca5a4b3eea207904c64e638a4ecefd347f386abb Mon Sep 17 00:00:00 2001
+Message-ID: <ca5a4b3eea207904c64e638a4ecefd347f386abb.1756251629.git.sam@gentoo.org>
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Tue, 26 Aug 2025 15:29:25 -0700
+Subject: [PATCH 1/2] x86-64: Emit the TLS call after debug marker
+
+For a basic block with only a debug marker:
+
+(note 3 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
+(note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
+(debug_insn 5 2 16 2 (debug_marker) "x.c":6:3 -1 (nil))
+
+emit the TLS call after debug marker.
+
+gcc/
+
+ PR target/121668
+ * config/i386/i386-features.cc (ix86_emit_tls_call): Emit the
+ TLS call after debug marker.
+
+gcc/testsuite/
+
+ PR target/121668
+ * gcc.target/i386/pr121668-1a.c: New test.
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+---
+ gcc/config/i386/i386-features.cc | 26 +++++++++++++++++----
+ gcc/testsuite/gcc.target/i386/pr121668-1a.c | 13 +++++++++++
+ 2 files changed, 34 insertions(+), 5 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121668-1a.c
+
+diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
+index cdb2a0b34b27..93e20947edf3 100644
+--- a/gcc/config/i386/i386-features.cc
++++ b/gcc/config/i386/i386-features.cc
+@@ -3806,10 +3806,19 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
+ (code_label 78 11 77 3 14 (nil) [1 uses])
+ (note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
+
++ or a basic block with only a debug marker:
++
++ (note 3 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
++ (note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
++ (debug_insn 5 2 16 2 (debug_marker) "x.c":6:3 -1 (nil))
++
+ */
+- gcc_assert (NOTE_P (insn)
+- && (NOTE_KIND (insn) == NOTE_INSN_FUNCTION_BEG
+- || NOTE_KIND (insn) == NOTE_INSN_BASIC_BLOCK));
++ gcc_assert (DEBUG_INSN_P (insn)
++ || (NOTE_P (insn)
++ && ((NOTE_KIND (insn)
++ == NOTE_INSN_FUNCTION_BEG)
++ || (NOTE_KIND (insn)
++ == NOTE_INSN_BASIC_BLOCK))));
+ insn = NULL;
+ break;
+ }
+@@ -3854,12 +3863,19 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
+ (note 4 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
+ (note 2 4 26 2 NOTE_INSN_FUNCTION_BEG)
+
+- or after NOTE_INSN_BASIC_BLOCK a basic block with only
+- a label:
++ or after NOTE_INSN_BASIC_BLOCK in a basic block with
++ only a label:
+
+ (code_label 78 11 77 3 14 (nil) [1 uses])
+ (note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
+
++ or after debug marker in a basic block with only a
++ debug marker:
++
++ (note 3 0 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
++ (note 2 3 5 2 NOTE_INSN_FUNCTION_BEG)
++ (debug_insn 5 2 16 2 (debug_marker) "x.c":6:3 -1 (nil))
++
+ */
+ insn = insn ? PREV_INSN (insn) : BB_END (bb);
+ *after_p = insn;
+diff --git a/gcc/testsuite/gcc.target/i386/pr121668-1a.c b/gcc/testsuite/gcc.target/i386/pr121668-1a.c
+new file mode 100644
+index 000000000000..eb553081eb31
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121668-1a.c
+@@ -0,0 +1,13 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-Og -g -fpic -fplt -mtls-dialect=gnu" } */
++
++typedef int caml_domain_state;
++thread_local caml_domain_state caml_state;
++void
++caml_empty_mark_stack ()
++{
++ while (caml_state)
++ caml_state = 0;
++}
++
++/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 1 { target { ! ia32 } } } } */
+
+base-commit: a43c30cb6f451d60b7e19be09da075ab0ff5830f
+--
+2.51.0
+
diff --git a/16.0.0/gentoo/88_all-x86-64-Better-compare-source-operands-of-tls_dynamic.patch b/16.0.0/gentoo/88_all-x86-64-Better-compare-source-operands-of-tls_dynamic.patch
new file mode 100644
index 0000000..44865e7
--- /dev/null
+++ b/16.0.0/gentoo/88_all-x86-64-Better-compare-source-operands-of-tls_dynamic.patch
@@ -0,0 +1,234 @@
+From ec4cc64262841e49967c2bf69dcd095985c2e304 Mon Sep 17 00:00:00 2001
+Message-ID: <ec4cc64262841e49967c2bf69dcd095985c2e304.1756251629.git.sam@gentoo.org>
+In-Reply-To: <ca5a4b3eea207904c64e638a4ecefd347f386abb.1756251629.git.sam@gentoo.org>
+References: <ca5a4b3eea207904c64e638a4ecefd347f386abb.1756251629.git.sam@gentoo.org>
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Tue, 26 Aug 2025 15:31:34 -0700
+Subject: [PATCH 2/2] x86-64: Better compare source operands of
+ *tls_dynamic_gnu2_call_64_di
+
+Source operands of 2 *tls_dynamic_gnu2_call_64_di patterns in
+
+(insn 10 9 11 3 (set (reg:DI 100)
+ (unspec:DI [
+ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
+ ] UNSPEC_TLSDESC)) "x.c":7:16 1674 {*tls_dynamic_gnu2_lea_64_di}
+ (nil))
+(insn 11 10 12 3 (parallel [
+ (set (reg:DI 99)
+ (unspec:DI [
+ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
+ (reg:DI 100)
+ (reg/f:DI 7 sp)
+ ] UNSPEC_TLSDESC))
+ (clobber (reg:CC 17 flags))
+ ]) "x.c":7:16 1676 {*tls_dynamic_gnu2_call_64_di}
+ (expr_list:REG_DEAD (reg:DI 100)
+ (expr_list:REG_UNUSED (reg:CC 17 flags)
+ (nil))))
+
+and
+
+(insn 19 17 20 4 (set (reg:DI 104)
+ (unspec:DI [
+ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
+ ] UNSPEC_TLSDESC)) "x.c":6:10 discrim 1 1674 {*tls_dynamic_gnu2_lea_64_di}
+ (nil))
+(insn 20 19 21 4 (parallel [
+ (set (reg:DI 103)
+ (unspec:DI [
+ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fe10e1d9e40 caml_state>)
+ (reg:DI 104)
+ (reg/f:DI 7 sp)
+ ] UNSPEC_TLSDESC))
+ (clobber (reg:CC 17 flags))
+ ]) "x.c":6:10 discrim 1 1676 {*tls_dynamic_gnu2_call_64_di}
+ (expr_list:REG_DEAD (reg:DI 104)
+ (expr_list:REG_UNUSED (reg:CC 17 flags)
+ (nil))))
+
+are the same even though rtx_equal_p returns false since (reg:DI 100)
+and (reg:DI 104) are set from the same symbol. Add x86_cse_rtx_equal_p
+to compare source operands of *tls_dynamic_gnu2_call_64_di patterns and
+return true if only source operands differ and they are set from the
+same symbol.
+
+gcc/
+
+ * config/i386/i386-features.cc
+ (pass_x86_cse::x86_cse_rtx_equal_p): New.
+ (pass_x86_cse::tls_set_insn_from_symbol): Likewise.
+ (pass_x86_cse::candidate_gnu2_tls_p): Call
+ tls_set_insn_from_symbol.
+ (pass_x86_cse::x86_cse): Call x86_cse_rtx_equal_p, instead of
+ rtx_equal_p, to compare 2 values.
+
+gcc/testsuite/
+
+ * gcc.target/i386/pr121668-1b.c: New test.
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+---
+ gcc/config/i386/i386-features.cc | 116 +++++++++++++++-----
+ gcc/testsuite/gcc.target/i386/pr121668-1b.c | 6 +
+ 2 files changed, 95 insertions(+), 27 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121668-1b.c
+
+diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
+index 93e20947edf3..ce77e91c1203 100644
+--- a/gcc/config/i386/i386-features.cc
++++ b/gcc/config/i386/i386-features.cc
+@@ -4168,8 +4168,95 @@ private:
+ bool candidate_gnu_tls_p (rtx_insn *, attr_tls64);
+ bool candidate_gnu2_tls_p (rtx, attr_tls64);
+ bool candidate_vector_p (rtx);
++ bool x86_cse_rtx_equal_p (const_rtx, const_rtx);
++ rtx_insn *tls_set_insn_from_symbol (const_rtx, rtx *);
+ }; // class pass_x86_cse
+
++/* Return true if X and Y are equal. */
++
++bool
++pass_x86_cse::x86_cse_rtx_equal_p (const_rtx x, const_rtx y)
++{
++ if (kind == X86_CSE_TLSDESC
++ && GET_CODE (x) == UNSPEC
++ && XINT (x, 1) == UNSPEC_TLSDESC
++ && SYMBOL_REF_P (XVECEXP (x, 0, 0)))
++ {
++ /* Compare
++
++ (unspec:DI [
++ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fffe99d9e40 caml_state>)
++ (reg:DI 100)
++ (reg/f:DI 7 sp)
++ ] UNSPEC_TLSDESC)
++
++ against
++
++ (unspec:DI [
++ (symbol_ref:DI ("caml_state") [flags 0x10] <var_decl 0x7fffe99d9e40 caml_state>)
++ (reg:DI 104)
++ (reg/f:DI 7 sp)
++ ] UNSPEC_TLSDESC)
++
++ If (reg:DI 100) and (reg:DI 104) are defined from the same source,
++ they are equal. */
++
++ if (GET_CODE (y) != UNSPEC
++ || XINT (y, 1) != UNSPEC_TLSDESC
++ || !SYMBOL_REF_P (XVECEXP (y, 0, 0))
++ || !rtx_equal_p (XVECEXP (x, 0, 0), XVECEXP (y, 0, 0)))
++ return false;
++
++ x = XVECEXP (x, 0, 1);
++ y = XVECEXP (y, 0, 1);
++ if (rtx_equal_p (x, y))
++ return true;
++
++ rtx tls_symbol = nullptr;
++ return (tls_set_insn_from_symbol (x, &tls_symbol)
++ && tls_symbol
++ && tls_set_insn_from_symbol (y, &tls_symbol));
++ }
++
++ return rtx_equal_p (x, y);
++}
++
++/* Return the instruction which sets REG from one symbol and store the
++ symbol in *TLS_SYMBOL_P if *TLS_SYMBOL_P is nullptr. */
++
++rtx_insn *
++pass_x86_cse::tls_set_insn_from_symbol (const_rtx reg, rtx *tls_symol_p)
++{
++ rtx_insn *set_insn = nullptr;
++ rtx tls_symbol = *tls_symol_p;
++ for (df_ref ref = DF_REG_DEF_CHAIN (REGNO (reg));
++ ref;
++ ref = DF_REF_NEXT_REG (ref))
++ {
++ if (DF_REF_IS_ARTIFICIAL (ref))
++ return nullptr;
++
++ set_insn = DF_REF_INSN (ref);
++ if (get_attr_tls64 (set_insn) != TLS64_LEA)
++ return nullptr;
++
++ rtx tls_set = PATTERN (set_insn);
++ rtx tls_src = XVECEXP (SET_SRC (tls_set), 0, 0);
++ if (tls_symbol == nullptr)
++ {
++ if (!SYMBOL_REF_P (tls_src))
++ return nullptr;
++
++ tls_symbol = tls_src;
++ *tls_symol_p = tls_src;
++ }
++ else if (!rtx_equal_p (tls_symbol, tls_src))
++ return nullptr;
++ }
++
++ return set_insn;
++}
++
+ /* Return true and output def_insn, val, mode, scalar_mode and kind if
+ INSN is UNSPEC_TLS_GD or UNSPEC_TLS_LD_BASE. */
+
+@@ -4283,32 +4370,7 @@ pass_x86_cse::candidate_gnu2_tls_p (rtx set, attr_tls64 tls64)
+
+ */
+
+- df_ref ref;
+- rtx_insn *set_insn = nullptr;
+- for (ref = DF_REG_DEF_CHAIN (REGNO (src));
+- ref;
+- ref = DF_REF_NEXT_REG (ref))
+- {
+- if (DF_REF_IS_ARTIFICIAL (ref))
+- break;
+-
+- set_insn = DF_REF_INSN (ref);
+- tls64 = get_attr_tls64 (set_insn);
+- if (tls64 != TLS64_LEA)
+- {
+- set_insn = nullptr;
+- break;
+- }
+-
+- rtx tls_set = PATTERN (set_insn);
+- rtx tls_src = XVECEXP (SET_SRC (tls_set), 0, 0);
+- if (!rtx_equal_p (tls_symbol, tls_src))
+- {
+- set_insn = nullptr;
+- break;
+- }
+- }
+-
++ rtx_insn *set_insn = tls_set_insn_from_symbol (src, &tls_symbol);
+ if (!set_insn)
+ return false;
+
+@@ -4436,7 +4498,7 @@ pass_x86_cse::x86_cse (void)
+ /* Non all 0s/1s vector load must be in the same
+ basic block if it is in a recursive call. */
+ || !recursive_call_p)
+- && rtx_equal_p (load->val, val))
++ && x86_cse_rtx_equal_p (load->val, val))
+ {
+ /* Record instruction. */
+ bitmap_set_bit (load->insns, INSN_UID (insn));
+diff --git a/gcc/testsuite/gcc.target/i386/pr121668-1b.c b/gcc/testsuite/gcc.target/i386/pr121668-1b.c
+new file mode 100644
+index 000000000000..54a277506f83
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121668-1b.c
+@@ -0,0 +1,6 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-Og -g -fpic -fplt -mtls-dialect=gnu2" } */
++
++#include "pr121668-1a.c"
++
++/* { dg-final { scan-assembler-times "call\[ \t\]\\*caml_state@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */
+--
+2.51.0
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 44873fe..3ea56ff 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,8 @@
13 ????
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
+ + 87_all_PR121668-x86-64-Emit-the-TLS-call-after-debug-marker.patch
+ + 88_all-x86-64-Better-compare-source-operands-of-tls_dynamic.patch
12 24 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-26 4:48 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-26 4:48 UTC (permalink / raw
To: gentoo-commits
commit: 69b8462a17b9685df1c1fa79ac667a96a22435ce
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 26 04:48:33 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Aug 26 04:48:33 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=69b8462a
16.0.0: drop patch merged upstream
Signed-off-by: Sam James <sam <AT> gentoo.org>
...-recent-changes-to-use-GFNI-for-rotates-s.patch | 134 ---------------------
16.0.0/gentoo/README.history | 1 -
2 files changed, 135 deletions(-)
diff --git a/16.0.0/gentoo/87_all_PR121658-i386-Fix-up-recent-changes-to-use-GFNI-for-rotates-s.patch b/16.0.0/gentoo/87_all_PR121658-i386-Fix-up-recent-changes-to-use-GFNI-for-rotates-s.patch
deleted file mode 100644
index c5bd764..0000000
--- a/16.0.0/gentoo/87_all_PR121658-i386-Fix-up-recent-changes-to-use-GFNI-for-rotates-s.patch
+++ /dev/null
@@ -1,134 +0,0 @@
-From 830dea69de876322ec39823073163f1957bfec9a Mon Sep 17 00:00:00 2001
-Message-ID: <830dea69de876322ec39823073163f1957bfec9a.1756169719.git.sam@gentoo.org>
-From: Jakub Jelinek <jakub@redhat.com>
-Date: Tue, 26 Aug 2025 00:39:47 +0200
-Subject: [PATCH] i386: Fix up recent changes to use GFNI for rotates/shifts
- [PR121658]
-
-Hi!
-
-The vgf2p8affineqb_<mode><mask_name> pattern uses "register_operand"
-predicate for the first input operand, so using "general_operand"
-for the rotate operand passed to it leads to ICEs, and so does
-the "nonimmediate_operand" in the <insn>v16qi3 define_expand.
-The following patch fixes it by using "register_operand" in the former
-case (that pattern is TARGET_GFNI only) and using force_reg in
-the latter case (the pattern is TARGET_XOP || TARGET_GFNI and for XOP
-we can handle MEM operand).
-
-The rest of the changes are small formatting tweaks or use of const0_rtx
-instead of GEN_INT (0).
-
-Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
-
-2025-08-25 Jakub Jelinek <jakub@redhat.com>
-
- PR target/121658
- * config/i386/sse.md (<insn><mode>3 any_shift): Use const0_rtx
- instead of GEN_INT (0).
- (cond_<insn><mode> any_shift): Likewise. Formatting fix.
- (<insn><mode>3 any_rotate): Use register_operand predicate instead of
- general_operand for match_operand 1. Use const0_rtx instead of
- GEN_INT (0).
- (<insn>v16qi3 any_rotate): Use force_reg on operands[1]. Formatting
- fix.
- * config/i386/i386.cc (ix86_shift_rotate_cost): Comment formatting
- fixes.
-
- * gcc.target/i386/pr121658.c: New test.
----
- gcc/config/i386/i386.cc | 6 +++---
- gcc/config/i386/sse.md | 14 ++++++++------
- gcc/testsuite/gcc.target/i386/pr121658.c | 11 +++++++++++
- 3 files changed, 22 insertions(+), 9 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121658.c
-
-diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
-index 9093f2077346..b2c1acd12dac 100644
---- a/gcc/config/i386/i386.cc
-+++ b/gcc/config/i386/i386.cc
-@@ -22104,9 +22104,9 @@ ix86_shift_rotate_cost (const struct processor_costs *cost,
- case V32QImode:
- if (TARGET_GFNI && constant_op1)
- {
-- /* Use vgf2p8affine. One extra load for the mask, but in a loop
-- with enough registers it will be moved out. So for now don't
-- account the constant mask load. This is not quite right
-+ /* Use vgf2p8affine. One extra load for the mask, but in a loop
-+ with enough registers it will be moved out. So for now don't
-+ account the constant mask load. This is not quite right
- for non loop vectorization. */
- extra = 0;
- return ix86_vec_cost (mode, cost->sse_op) + extra;
-diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
-index 951ee54589f3..505095040f75 100644
---- a/gcc/config/i386/sse.md
-+++ b/gcc/config/i386/sse.md
-@@ -26994,7 +26994,7 @@ (define_expand "<insn><mode>3"
- rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], operands[2],
- <CODE>);
- emit_insn (gen_vgf2p8affineqb_<mode> (operands[0], operands[1], matrix,
-- GEN_INT (0)));
-+ const0_rtx));
- }
- else
- ix86_expand_vecop_qihi (<CODE>, operands[0], operands[1], operands[2]);
-@@ -27014,20 +27014,21 @@ (define_expand "cond_<insn><mode>"
- {
- rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], operands[2], <CODE>);
- emit_insn (gen_vgf2p8affineqb_<mode>_mask (operands[0], operands[1], matrix,
-- GEN_INT (0), operands[4], operands[1]));
-+ const0_rtx, operands[4],
-+ operands[1]));
- DONE;
- })
-
- (define_expand "<insn><mode>3"
- [(set (match_operand:VI1_AVX512_3264 0 "register_operand")
- (any_rotate:VI1_AVX512_3264
-- (match_operand:VI1_AVX512_3264 1 "general_operand")
-+ (match_operand:VI1_AVX512_3264 1 "register_operand")
- (match_operand:SI 2 "const_int_operand")))]
- "TARGET_GFNI"
- {
- rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], operands[2], <CODE>);
- emit_insn (gen_vgf2p8affineqb_<mode> (operands[0], operands[1], matrix,
-- GEN_INT (0)));
-+ const0_rtx));
- DONE;
- })
-
-@@ -27073,8 +27074,9 @@ (define_expand "<insn>v16qi3"
- else if (TARGET_GFNI && CONST_INT_P (operands[2]))
- {
- rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], operands[2], <CODE>);
-- emit_insn (gen_vgf2p8affineqb_v16qi (operands[0], operands[1], matrix,
-- GEN_INT (0)));
-+ emit_insn (gen_vgf2p8affineqb_v16qi (operands[0],
-+ force_reg (V16QImode, operands[1]),
-+ matrix, const0_rtx));
- DONE;
- }
- else
-diff --git a/gcc/testsuite/gcc.target/i386/pr121658.c b/gcc/testsuite/gcc.target/i386/pr121658.c
-new file mode 100644
-index 000000000000..04373161e688
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121658.c
-@@ -0,0 +1,11 @@
-+/* PR target/121658 */
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -mavx512f -mgfni" } */
-+
-+__attribute__((__vector_size__(64))) unsigned char v;
-+
-+void
-+foo (void)
-+{
-+ v = (v << 7) | (v >> 1);
-+}
-
-base-commit: 2dfd2779e373dffaae9532d45267497a6246f661
---
-2.51.0
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 2caadb6..44873fe 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,7 +1,6 @@
13 ????
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
- + 87_all_PR121658-i386-Fix-up-recent-changes-to-use-GFNI-for-rotates-s.patch
12 24 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-26 0:56 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-26 0:56 UTC (permalink / raw
To: gentoo-commits
commit: 490956af07fb29586060d60f6fe9a3eeeb12e9b5
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 26 00:55:51 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Aug 26 00:56:17 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=490956af
16.0.0: fix GFNI changes
The change is approved already but I'm about to do a rebuild so
may as well have this in.
Signed-off-by: Sam James <sam <AT> gentoo.org>
...-recent-changes-to-use-GFNI-for-rotates-s.patch | 134 +++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 135 insertions(+)
diff --git a/16.0.0/gentoo/87_all_PR121658-i386-Fix-up-recent-changes-to-use-GFNI-for-rotates-s.patch b/16.0.0/gentoo/87_all_PR121658-i386-Fix-up-recent-changes-to-use-GFNI-for-rotates-s.patch
new file mode 100644
index 0000000..c5bd764
--- /dev/null
+++ b/16.0.0/gentoo/87_all_PR121658-i386-Fix-up-recent-changes-to-use-GFNI-for-rotates-s.patch
@@ -0,0 +1,134 @@
+From 830dea69de876322ec39823073163f1957bfec9a Mon Sep 17 00:00:00 2001
+Message-ID: <830dea69de876322ec39823073163f1957bfec9a.1756169719.git.sam@gentoo.org>
+From: Jakub Jelinek <jakub@redhat.com>
+Date: Tue, 26 Aug 2025 00:39:47 +0200
+Subject: [PATCH] i386: Fix up recent changes to use GFNI for rotates/shifts
+ [PR121658]
+
+Hi!
+
+The vgf2p8affineqb_<mode><mask_name> pattern uses "register_operand"
+predicate for the first input operand, so using "general_operand"
+for the rotate operand passed to it leads to ICEs, and so does
+the "nonimmediate_operand" in the <insn>v16qi3 define_expand.
+The following patch fixes it by using "register_operand" in the former
+case (that pattern is TARGET_GFNI only) and using force_reg in
+the latter case (the pattern is TARGET_XOP || TARGET_GFNI and for XOP
+we can handle MEM operand).
+
+The rest of the changes are small formatting tweaks or use of const0_rtx
+instead of GEN_INT (0).
+
+Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
+
+2025-08-25 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/121658
+ * config/i386/sse.md (<insn><mode>3 any_shift): Use const0_rtx
+ instead of GEN_INT (0).
+ (cond_<insn><mode> any_shift): Likewise. Formatting fix.
+ (<insn><mode>3 any_rotate): Use register_operand predicate instead of
+ general_operand for match_operand 1. Use const0_rtx instead of
+ GEN_INT (0).
+ (<insn>v16qi3 any_rotate): Use force_reg on operands[1]. Formatting
+ fix.
+ * config/i386/i386.cc (ix86_shift_rotate_cost): Comment formatting
+ fixes.
+
+ * gcc.target/i386/pr121658.c: New test.
+---
+ gcc/config/i386/i386.cc | 6 +++---
+ gcc/config/i386/sse.md | 14 ++++++++------
+ gcc/testsuite/gcc.target/i386/pr121658.c | 11 +++++++++++
+ 3 files changed, 22 insertions(+), 9 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121658.c
+
+diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
+index 9093f2077346..b2c1acd12dac 100644
+--- a/gcc/config/i386/i386.cc
++++ b/gcc/config/i386/i386.cc
+@@ -22104,9 +22104,9 @@ ix86_shift_rotate_cost (const struct processor_costs *cost,
+ case V32QImode:
+ if (TARGET_GFNI && constant_op1)
+ {
+- /* Use vgf2p8affine. One extra load for the mask, but in a loop
+- with enough registers it will be moved out. So for now don't
+- account the constant mask load. This is not quite right
++ /* Use vgf2p8affine. One extra load for the mask, but in a loop
++ with enough registers it will be moved out. So for now don't
++ account the constant mask load. This is not quite right
+ for non loop vectorization. */
+ extra = 0;
+ return ix86_vec_cost (mode, cost->sse_op) + extra;
+diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
+index 951ee54589f3..505095040f75 100644
+--- a/gcc/config/i386/sse.md
++++ b/gcc/config/i386/sse.md
+@@ -26994,7 +26994,7 @@ (define_expand "<insn><mode>3"
+ rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], operands[2],
+ <CODE>);
+ emit_insn (gen_vgf2p8affineqb_<mode> (operands[0], operands[1], matrix,
+- GEN_INT (0)));
++ const0_rtx));
+ }
+ else
+ ix86_expand_vecop_qihi (<CODE>, operands[0], operands[1], operands[2]);
+@@ -27014,20 +27014,21 @@ (define_expand "cond_<insn><mode>"
+ {
+ rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], operands[2], <CODE>);
+ emit_insn (gen_vgf2p8affineqb_<mode>_mask (operands[0], operands[1], matrix,
+- GEN_INT (0), operands[4], operands[1]));
++ const0_rtx, operands[4],
++ operands[1]));
+ DONE;
+ })
+
+ (define_expand "<insn><mode>3"
+ [(set (match_operand:VI1_AVX512_3264 0 "register_operand")
+ (any_rotate:VI1_AVX512_3264
+- (match_operand:VI1_AVX512_3264 1 "general_operand")
++ (match_operand:VI1_AVX512_3264 1 "register_operand")
+ (match_operand:SI 2 "const_int_operand")))]
+ "TARGET_GFNI"
+ {
+ rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], operands[2], <CODE>);
+ emit_insn (gen_vgf2p8affineqb_<mode> (operands[0], operands[1], matrix,
+- GEN_INT (0)));
++ const0_rtx));
+ DONE;
+ })
+
+@@ -27073,8 +27074,9 @@ (define_expand "<insn>v16qi3"
+ else if (TARGET_GFNI && CONST_INT_P (operands[2]))
+ {
+ rtx matrix = ix86_vgf2p8affine_shift_matrix (operands[0], operands[2], <CODE>);
+- emit_insn (gen_vgf2p8affineqb_v16qi (operands[0], operands[1], matrix,
+- GEN_INT (0)));
++ emit_insn (gen_vgf2p8affineqb_v16qi (operands[0],
++ force_reg (V16QImode, operands[1]),
++ matrix, const0_rtx));
+ DONE;
+ }
+ else
+diff --git a/gcc/testsuite/gcc.target/i386/pr121658.c b/gcc/testsuite/gcc.target/i386/pr121658.c
+new file mode 100644
+index 000000000000..04373161e688
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121658.c
+@@ -0,0 +1,11 @@
++/* PR target/121658 */
++/* { dg-do compile } */
++/* { dg-options "-O2 -mavx512f -mgfni" } */
++
++__attribute__((__vector_size__(64))) unsigned char v;
++
++void
++foo (void)
++{
++ v = (v << 7) | (v >> 1);
++}
+
+base-commit: 2dfd2779e373dffaae9532d45267497a6246f661
+--
+2.51.0
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 44873fe..2caadb6 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,7 @@
13 ????
U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
+ + 87_all_PR121658-i386-Fix-up-recent-changes-to-use-GFNI-for-rotates-s.patch
12 24 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-25 3:55 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-25 3:55 UTC (permalink / raw
To: gentoo-commits
commit: ad74f78cff1addde72f636ea978f955d51387a79
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 25 03:55:39 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Aug 25 03:55:39 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=ad74f78c
16.0.0: update -mtls-dialect=gnu2 default patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
...fault-to-mtls-dialect-gnu2-if-appropriate.patch | 208 ++++++++-------------
16.0.0/gentoo/README.history | 4 +
2 files changed, 84 insertions(+), 128 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch b/16.0.0/gentoo/86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
index 11cbfdf..cdcb655 100644
--- a/16.0.0/gentoo/86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
+++ b/16.0.0/gentoo/86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
@@ -1,20 +1,32 @@
-From 49dee4e109d23a7a2f9644a84909c9dec7896fa5 Mon Sep 17 00:00:00 2001
-Message-ID: <49dee4e109d23a7a2f9644a84909c9dec7896fa5.1756009689.git.sam@gentoo.org>
+From 02616942358bd045b21a69c0c866687150080d12 Mon Sep 17 00:00:00 2001
+Message-ID: <02616942358bd045b21a69c0c866687150080d12.1756094106.git.sam@gentoo.org>
From: Sam James <sam@gentoo.org>
Date: Sun, 24 Aug 2025 00:30:45 +0100
Subject: [PATCH] i386: default to -mtls-dialect=gnu2 if appropriate
-For GNU/Linux IA-32/X86-64 targets, check if ld emits GLIBC_ABI_GNU2_TLS and
-use it to decide if we can default to -mtls-dialect=gnu2.
+GNU2 TLS descriptors were introduced in 2006 (r0-73091-g5bf5a10b1ccacf)
+but were only opt-in with -mtls-dialect=gnu2. They are more efficient
+and it's time to enable them by default.
+
+Builds on the --with-tls= machinery from r16-3355-g96a291c4bb0b8a.
+
+We achieve this for GNU/Linux IA-32/X86-64 targets by checking if ld emits
+GLIBC_ABI_GNU2_TLS, using its presence to decide if we can default to
+-mtls-dialect=gnu2.
For PR ld/33130, newer ld will add GLIBC_ABI_GNU2_TLS if either unconfigured
(auto mode) or if configured with --enable-gnu2-tls-tag. In auto mode,
GLIBC_ABI_GNU2_TLS is only added if glibc provides it. In explicit mode, the
user has asked for this behavior and binaries will depend on GLIBC_ABI_GNU2_TLS
and fixed glibc. Hence the presence of GLIBC_ABI_GNU2_TLS tells us if we can
-safely default to GNU2 TLS descriptors.
+safely default to GNU2 TLS descriptors. We added GLIBC_ABI_GNU2_TLS in glibc
+to indicate that PR dynamic-link/33129 is fixed.
-Builds on the --with-tls= machinery from r16-3355-g96a291c4bb0b8a.
+If distributions wish to opt-out of this for systems which meet the above
+conditions, they can either configure GCC using --with-tls=gnu, or configure
+binutils with --disable-gnu2-tls-tag: if this is necessary, it is recommended
+to use --with-tls=gnu instead, to avoid affecting the ecosystem negatively by
+having unmarked binaries.
Some implementation notes:
* The readelf check had to be moved earlier because we want
@@ -26,6 +38,9 @@ Some implementation notes:
fails, it falls back to --with-tls=DIALECT if passed, and failing that,
the previous and safe default of 'gnu'.
+* The change is only made for glibc systems at this time. Enablement and testing
+ can be done for other libcs as future work.
+
* In future, we may do the same thing for ARM if/when appropriate equivalent
machinery is added to glibc and bfd. This makes the separate position of
the check (not with some of the others) a bit more palatable IMO.
@@ -42,12 +57,12 @@ gcc/ChangeLog:
(with_tls): Default to 'gnu2' if --with-tls is not passed and
gcc_cv_libc_x86_tlsdesc_call is 'yes'.
---
- gcc/configure | 254 +++++++++++++++++++++++++++++++++--------------
- gcc/configure.ac | 142 +++++++++++++++++++++-----
- 2 files changed, 296 insertions(+), 100 deletions(-)
+ gcc/configure | 219 +++++++++++++++++++++++++++++++----------------
+ gcc/configure.ac | 114 ++++++++++++++++++------
+ 2 files changed, 233 insertions(+), 100 deletions(-)
diff --git a/gcc/configure b/gcc/configure
-index 4a751d969bab..54b67908e701 100755
+index 4a751d969bab..067e95eeedd2 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -737,7 +737,6 @@ libgcc_visibility
@@ -66,7 +81,7 @@ index 4a751d969bab..54b67908e701 100755
objext
manext
LIBICONV_DEP
-@@ -12927,6 +12927,182 @@ if test "x$enable_win32_utf8_manifest" != xno; then
+@@ -12927,6 +12927,147 @@ if test "x$enable_win32_utf8_manifest" != xno; then
host_extra_objs_mingw=utf8-mingw32.o
fi
@@ -144,66 +159,32 @@ index 4a751d969bab..54b67908e701 100755
+fi
+
+case $target in
-+ i[34567]86-*-* | x86_64-*-*)
-+ # PR target/120933
-+ # For GNU/Linux targets, check if ld emits GLIBC_ABI_GNU2_TLS. For PR ld/33130,
-+ # newer ld will add GLIBC_ABI_GNU2_TLS if either unconfigured (auto mode) or if
-+ # configured with --enable-gnu2-tls-tag. In auto mode, GLIBC_ABI_GNU2_TLS
-+ # is only added if glibc provides it. In explicit mode, the user has asked
-+ # for this behavior and binaries will depend on GLIBC_ABI_GNU2_TLS and fixed
-+ # glibc. Hence the presence of GLIBC_ABI_GNU2_TLS tells us if we can safely
-+ # default to GNU2 TLS descriptors.
-+ case $target in
-+ # TODO: x32
-+ i?86-*-linux*gnu* )
-+ conftest_s='
-+ .section .text.startup,"ax",@progbits
-+ .p2align 4
-+ .globl main
-+ .type main, @function
-+ main:
-+ leal ld@TLSDESC(%ebx), %eax
-+ call *ld@TLSCALL(%eax)
-+ addl %gs:0, %eax
-+ ret
-+ .size main, .-main
-+ .section .note.GNU-stack,"",@progbits
-+ '
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking libc has GLIBC_ABI_GNU2_TLS symbol dep and ld emits it" >&5
-+$as_echo_n "checking libc has GLIBC_ABI_GNU2_TLS symbol dep and ld emits it... " >&6; }
-+if ${gcc_cv_libc_x86_tlsdesc_call+:} false; then :
-+ $as_echo_n "(cached) " >&6
-+else
-+
-+ gcc_cv_libc_x86_tlsdesc_call=no
-+ echo "$conftest_s" > conftest.s
-+ if $CC $CFLAGS conftest.s -o conftest -shared > /dev/null 2>&1; then
-+ if test x$gcc_cv_readelf != x; then
-+ if $gcc_cv_readelf --version-info conftest 2>&1 \
-+ | grep "GLIBC_ABI_GNU2_TLS" > /dev/null 2>&1; then
-+ gcc_cv_libc_x86_tlsdesc_call=yes
-+ else
-+ gcc_cv_libc_x86_tlsdesc_call=no
-+ fi
-+ fi
-+ fi
-+ rm -f conftest.*
-+
-+fi
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_libc_x86_tlsdesc_call" >&5
-+$as_echo "$gcc_cv_libc_x86_tlsdesc_call" >&6; }
-+ ;;
-+ x86_64-*-linux*gnu* )
-+ conftest_s='
++ i[34567]86-*-gnu* | x86_64-*-gnu* )
++ # PR target/120933
++ # For GNU/Linux targets, check if ld emits GLIBC_ABI_GNU2_TLS. For PR ld/33130,
++ # newer ld will add GLIBC_ABI_GNU2_TLS if either unconfigured (auto mode) or if
++ # configured with --enable-gnu2-tls-tag. In auto mode, GLIBC_ABI_GNU2_TLS
++ # is only added if glibc provides it. In explicit mode, the user has asked
++ # for this behavior and binaries will depend on GLIBC_ABI_GNU2_TLS and fixed
++ # glibc. Hence the presence of GLIBC_ABI_GNU2_TLS tells us if we can safely
++ # default to GNU2 TLS descriptors.
++ #
++ # TODO: x32
++ conftest_S='
+ .section .text.startup,"ax",@progbits
+ .p2align 4
+ .globl main
+ .type main, @function
+ main:
++ #ifdef __x86_64__
+ leaq foo@TLSDESC(%rip), %rax
+ call *foo@TLSCALL(%rax)
+ movl %fs:(%rax), %eax
++ #else
++ leal ld@TLSDESC(%ebx), %eax
++ call *ld@TLSCALL(%eax)
++ addl %gs:0, %eax
++ #endif
+ ret
+ .size main, .-main
+ .section .note.GNU-stack,"",@progbits
@@ -216,8 +197,8 @@ index 4a751d969bab..54b67908e701 100755
+else
+
+ gcc_cv_libc_x86_tlsdesc_call=no
-+ echo "$conftest_s" > conftest.s
-+ if $CC $CFLAGS conftest.s -o conftest -shared > /dev/null 2>&1; then
++ echo "$conftest_S" > conftest.S
++ if $CC $CFLAGS conftest.S -o conftest -shared > /dev/null 2>&1; then
+ if test x$gcc_cv_readelf != x; then
+ if $gcc_cv_readelf --version-info conftest 2>&1 \
+ | grep "GLIBC_ABI_GNU2_TLS" > /dev/null 2>&1; then
@@ -232,42 +213,41 @@ index 4a751d969bab..54b67908e701 100755
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_libc_x86_tlsdesc_call" >&5
+$as_echo "$gcc_cv_libc_x86_tlsdesc_call" >&6; }
-+ ;;
-+ esac
+
-+ case "$gcc_cv_libc_x86_tlsdesc_call" in
++ # Set with_tls only if it's not already set via --with-tls=DIALECT
++ case "$gcc_cv_libc_x86_tlsdesc_call" in
+ yes)
+ with_tls=${with_tls:-gnu2}
+ ;;
+ *)
+ with_tls=${with_tls:-gnu}
+ ;;
-+ esac
++ esac
+ ;;
+esac
+
# --------------------------------------------------------
# Build, host, and target specific configuration fragments
# --------------------------------------------------------
-@@ -21484,7 +21660,7 @@ else
+@@ -21484,7 +21625,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 21487 "configure"
-+#line 21663 "configure"
++#line 21628 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
-@@ -21590,7 +21766,7 @@ else
+@@ -21590,7 +21731,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 21593 "configure"
-+#line 21769 "configure"
++#line 21734 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
-@@ -25419,78 +25595,6 @@ else
+@@ -25419,78 +25560,6 @@ else
$as_echo "$gcc_cv_objdump" >&6; }
fi
@@ -347,10 +327,10 @@ index 4a751d969bab..54b67908e701 100755
if ${gcc_cv_otool+:} false; then :
diff --git a/gcc/configure.ac b/gcc/configure.ac
-index 4532c5c22fe5..b62cb747ee50 100644
+index 4532c5c22fe5..5c60c47d36be 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
-@@ -1886,6 +1886,123 @@ if test "x$enable_win32_utf8_manifest" != xno; then
+@@ -1886,6 +1886,95 @@ if test "x$enable_win32_utf8_manifest" != xno; then
host_extra_objs_mingw=utf8-mingw32.o
fi
@@ -382,60 +362,33 @@ index 4532c5c22fe5..b62cb747ee50 100644
+
+case $target in
+changequote(,)dnl
-+ i[34567]86-*-* | x86_64-*-*)
++ i[34567]86-*-gnu* | x86_64-*-gnu* )
+changequote([,])dnl
-+ # PR target/120933
-+ # For GNU/Linux targets, check if ld emits GLIBC_ABI_GNU2_TLS. For PR ld/33130,
-+ # newer ld will add GLIBC_ABI_GNU2_TLS if either unconfigured (auto mode) or if
-+ # configured with --enable-gnu2-tls-tag. In auto mode, GLIBC_ABI_GNU2_TLS
-+ # is only added if glibc provides it. In explicit mode, the user has asked
-+ # for this behavior and binaries will depend on GLIBC_ABI_GNU2_TLS and fixed
-+ # glibc. Hence the presence of GLIBC_ABI_GNU2_TLS tells us if we can safely
-+ # default to GNU2 TLS descriptors.
-+ case $target in
-+ # TODO: x32
-+ i?86-*-linux*gnu* )
-+ conftest_s='
-+ .section .text.startup,"ax",@progbits
-+ .p2align 4
-+ .globl main
-+ .type main, @function
-+ main:
-+ leal ld@TLSDESC(%ebx), %eax
-+ call *ld@TLSCALL(%eax)
-+ addl %gs:0, %eax
-+ ret
-+ .size main, .-main
-+ .section .note.GNU-stack,"",@progbits
-+ '
-+
-+ AC_CACHE_CHECK([libc has GLIBC_ABI_GNU2_TLS symbol dep and ld emits it],
-+ gcc_cv_libc_x86_tlsdesc_call, [
-+ gcc_cv_libc_x86_tlsdesc_call=no
-+ echo "$conftest_s" > conftest.s
-+ if $CC $CFLAGS conftest.s -o conftest -shared > /dev/null 2>&1; then
-+ if test x$gcc_cv_readelf != x; then
-+ if $gcc_cv_readelf --version-info conftest 2>&1 \
-+ | grep "GLIBC_ABI_GNU2_TLS" > /dev/null 2>&1; then
-+ gcc_cv_libc_x86_tlsdesc_call=yes
-+ else
-+ gcc_cv_libc_x86_tlsdesc_call=no
-+ fi
-+ fi
-+ fi
-+ rm -f conftest.*
-+ ])
-+ ;;
-+ x86_64-*-linux*gnu* )
-+ conftest_s='
++ # PR target/120933
++ # For GNU/Linux targets, check if ld emits GLIBC_ABI_GNU2_TLS. For PR ld/33130,
++ # newer ld will add GLIBC_ABI_GNU2_TLS if either unconfigured (auto mode) or if
++ # configured with --enable-gnu2-tls-tag. In auto mode, GLIBC_ABI_GNU2_TLS
++ # is only added if glibc provides it. In explicit mode, the user has asked
++ # for this behavior and binaries will depend on GLIBC_ABI_GNU2_TLS and fixed
++ # glibc. Hence the presence of GLIBC_ABI_GNU2_TLS tells us if we can safely
++ # default to GNU2 TLS descriptors.
++ #
++ # TODO: x32
++ conftest_S='
+ .section .text.startup,"ax",@progbits
+ .p2align 4
+ .globl main
+ .type main, @function
+ main:
++ #ifdef __x86_64__
+ leaq foo@TLSDESC(%rip), %rax
+ call *foo@TLSCALL(%rax)
+ movl %fs:(%rax), %eax
++ #else
++ leal ld@TLSDESC(%ebx), %eax
++ call *ld@TLSCALL(%eax)
++ addl %gs:0, %eax
++ #endif
+ ret
+ .size main, .-main
+ .section .note.GNU-stack,"",@progbits
@@ -444,8 +397,8 @@ index 4532c5c22fe5..b62cb747ee50 100644
+ AC_CACHE_CHECK([libc has GLIBC_ABI_GNU2_TLS symbol dep and ld emits it],
+ gcc_cv_libc_x86_tlsdesc_call, [
+ gcc_cv_libc_x86_tlsdesc_call=no
-+ echo "$conftest_s" > conftest.s
-+ if $CC $CFLAGS conftest.s -o conftest -shared > /dev/null 2>&1; then
++ echo "$conftest_S" > conftest.S
++ if $CC $CFLAGS conftest.S -o conftest -shared > /dev/null 2>&1; then
+ if test x$gcc_cv_readelf != x; then
+ if $gcc_cv_readelf --version-info conftest 2>&1 \
+ | grep "GLIBC_ABI_GNU2_TLS" > /dev/null 2>&1; then
@@ -457,24 +410,23 @@ index 4532c5c22fe5..b62cb747ee50 100644
+ fi
+ rm -f conftest.*
+ ])
-+ ;;
-+ esac
+
-+ case "$gcc_cv_libc_x86_tlsdesc_call" in
++ # Set with_tls only if it's not already set via --with-tls=DIALECT
++ case "$gcc_cv_libc_x86_tlsdesc_call" in
+ yes)
+ with_tls=${with_tls:-gnu2}
+ ;;
+ *)
+ with_tls=${with_tls:-gnu}
+ ;;
-+ esac
++ esac
+ ;;
+esac
+
# --------------------------------------------------------
# Build, host, and target specific configuration fragments
# --------------------------------------------------------
-@@ -2934,31 +3051,6 @@ else
+@@ -2934,31 +3023,6 @@ else
AC_MSG_RESULT($gcc_cv_objdump)
fi
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 140c03f..44873fe 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+13 ????
+
+ U 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
+
12 24 August 2025
+ 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-24 23:42 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-24 23:42 UTC (permalink / raw
To: gentoo-commits
commit: 8c150c66bafa10ce66400f30b9e35700c7216fbf
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 24 23:37:44 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 24 23:37:44 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=8c150c66
16.0.0: cut patchset 12, add default -mtls-dialect=gnu2 patch
Note that the -mtls-dialect=gnu2 patch only takes effect with:
a) new enough glibc, AND
b) new enough (unreleased) binutils
Signed-off-by: Sam James <sam <AT> gentoo.org>
...fault-to-mtls-dialect-gnu2-if-appropriate.patch | 511 +++++++++++++++++++++
16.0.0/gentoo/README.history | 3 +-
2 files changed, 513 insertions(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch b/16.0.0/gentoo/86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
new file mode 100644
index 0000000..11cbfdf
--- /dev/null
+++ b/16.0.0/gentoo/86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
@@ -0,0 +1,511 @@
+From 49dee4e109d23a7a2f9644a84909c9dec7896fa5 Mon Sep 17 00:00:00 2001
+Message-ID: <49dee4e109d23a7a2f9644a84909c9dec7896fa5.1756009689.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Sun, 24 Aug 2025 00:30:45 +0100
+Subject: [PATCH] i386: default to -mtls-dialect=gnu2 if appropriate
+
+For GNU/Linux IA-32/X86-64 targets, check if ld emits GLIBC_ABI_GNU2_TLS and
+use it to decide if we can default to -mtls-dialect=gnu2.
+
+For PR ld/33130, newer ld will add GLIBC_ABI_GNU2_TLS if either unconfigured
+(auto mode) or if configured with --enable-gnu2-tls-tag. In auto mode,
+GLIBC_ABI_GNU2_TLS is only added if glibc provides it. In explicit mode, the
+user has asked for this behavior and binaries will depend on GLIBC_ABI_GNU2_TLS
+and fixed glibc. Hence the presence of GLIBC_ABI_GNU2_TLS tells us if we can
+safely default to GNU2 TLS descriptors.
+
+Builds on the --with-tls= machinery from r16-3355-g96a291c4bb0b8a.
+
+Some implementation notes:
+* The readelf check had to be moved earlier because we want
+ to set `with_tls` before `config.gcc` is processed (which has default
+ machinery for TLS).
+
+* The check doesn't really handle cross, but I don't see
+ this as a huge problem. The check is already opportunistic and if it
+ fails, it falls back to --with-tls=DIALECT if passed, and failing that,
+ the previous and safe default of 'gnu'.
+
+* In future, we may do the same thing for ARM if/when appropriate equivalent
+ machinery is added to glibc and bfd. This makes the separate position of
+ the check (not with some of the others) a bit more palatable IMO.
+
+TODO: Handle -x32
+TODO: Test i686
+
+gcc/ChangeLog:
+ PR target/120933
+ * configure: Regenerate.
+ * configure.ac (gcc_cv_readelf): Move check earlier.
+ (gcc_cv_libc_x86_tlsdesc_call): Define to 'yes' if
+ glibc has the GLIBC_ABI_GNU2_TLS version tag and ld emits it.
+ (with_tls): Default to 'gnu2' if --with-tls is not passed and
+ gcc_cv_libc_x86_tlsdesc_call is 'yes'.
+---
+ gcc/configure | 254 +++++++++++++++++++++++++++++++++--------------
+ gcc/configure.ac | 142 +++++++++++++++++++++-----
+ 2 files changed, 296 insertions(+), 100 deletions(-)
+
+diff --git a/gcc/configure b/gcc/configure
+index 4a751d969bab..54b67908e701 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -737,7 +737,6 @@ libgcc_visibility
+ ORIGINAL_DSYMUTIL_FOR_TARGET
+ gcc_cv_dsymutil
+ gcc_cv_otool
+-gcc_cv_readelf
+ gcc_cv_objdump
+ ORIGINAL_NM_FOR_TARGET
+ gcc_cv_nm
+@@ -801,6 +800,7 @@ HAVE_AUTO_BUILD
+ extra_opt_files
+ extra_modes_file
+ NATIVE_SYSTEM_HEADER_DIR
++gcc_cv_readelf
+ objext
+ manext
+ LIBICONV_DEP
+@@ -12927,6 +12927,182 @@ if test "x$enable_win32_utf8_manifest" != xno; then
+ host_extra_objs_mingw=utf8-mingw32.o
+ fi
+
++
++# Figure out what readelf we will be using.
++if ${gcc_cv_readelf+:} false; then :
++
++else
++
++if test -f $gcc_cv_binutils_srcdir/configure.ac \
++ && test -f ../binutils/Makefile \
++ && test x$build = x$host; then
++ # Single tree build which includes binutils.
++ gcc_cv_readelf=../binutils/readelf$build_exeext
++elif test -x readelf$build_exeext; then
++ gcc_cv_readelf=./readelf$build_exeext
++elif ( set dummy $READELF_FOR_TARGET; test -x $2 ); then
++ gcc_cv_readelf="$READELF_FOR_TARGET"
++else
++ # Extract the first word of "$READELF_FOR_TARGET", so it can be a program name with args.
++set dummy $READELF_FOR_TARGET; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if ${ac_cv_path_gcc_cv_readelf+:} false; then :
++ $as_echo_n "(cached) " >&6
++else
++ case $gcc_cv_readelf in
++ [\\/]* | ?:[\\/]*)
++ ac_cv_path_gcc_cv_readelf="$gcc_cv_readelf" # Let the user override the test with a path.
++ ;;
++ *)
++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
++ ac_cv_path_gcc_cv_readelf="$as_dir/$ac_word$ac_exec_ext"
++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++ done
++IFS=$as_save_IFS
++
++ ;;
++esac
++fi
++gcc_cv_readelf=$ac_cv_path_gcc_cv_readelf
++if test -n "$gcc_cv_readelf"; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_readelf" >&5
++$as_echo "$gcc_cv_readelf" >&6; }
++else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
++
++
++fi
++fi
++
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking what readelf to use" >&5
++$as_echo_n "checking what readelf to use... " >&6; }
++if test "$gcc_cv_readelf" = ../binutils/readelf$build_exeext; then
++ # Single tree build which includes binutils.
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: newly built readelf" >&5
++$as_echo "newly built readelf" >&6; }
++elif test x$gcc_cv_readelf = x; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
++$as_echo "not found" >&6; }
++else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_readelf" >&5
++$as_echo "$gcc_cv_readelf" >&6; }
++fi
++
++case $target in
++ i[34567]86-*-* | x86_64-*-*)
++ # PR target/120933
++ # For GNU/Linux targets, check if ld emits GLIBC_ABI_GNU2_TLS. For PR ld/33130,
++ # newer ld will add GLIBC_ABI_GNU2_TLS if either unconfigured (auto mode) or if
++ # configured with --enable-gnu2-tls-tag. In auto mode, GLIBC_ABI_GNU2_TLS
++ # is only added if glibc provides it. In explicit mode, the user has asked
++ # for this behavior and binaries will depend on GLIBC_ABI_GNU2_TLS and fixed
++ # glibc. Hence the presence of GLIBC_ABI_GNU2_TLS tells us if we can safely
++ # default to GNU2 TLS descriptors.
++ case $target in
++ # TODO: x32
++ i?86-*-linux*gnu* )
++ conftest_s='
++ .section .text.startup,"ax",@progbits
++ .p2align 4
++ .globl main
++ .type main, @function
++ main:
++ leal ld@TLSDESC(%ebx), %eax
++ call *ld@TLSCALL(%eax)
++ addl %gs:0, %eax
++ ret
++ .size main, .-main
++ .section .note.GNU-stack,"",@progbits
++ '
++
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking libc has GLIBC_ABI_GNU2_TLS symbol dep and ld emits it" >&5
++$as_echo_n "checking libc has GLIBC_ABI_GNU2_TLS symbol dep and ld emits it... " >&6; }
++if ${gcc_cv_libc_x86_tlsdesc_call+:} false; then :
++ $as_echo_n "(cached) " >&6
++else
++
++ gcc_cv_libc_x86_tlsdesc_call=no
++ echo "$conftest_s" > conftest.s
++ if $CC $CFLAGS conftest.s -o conftest -shared > /dev/null 2>&1; then
++ if test x$gcc_cv_readelf != x; then
++ if $gcc_cv_readelf --version-info conftest 2>&1 \
++ | grep "GLIBC_ABI_GNU2_TLS" > /dev/null 2>&1; then
++ gcc_cv_libc_x86_tlsdesc_call=yes
++ else
++ gcc_cv_libc_x86_tlsdesc_call=no
++ fi
++ fi
++ fi
++ rm -f conftest.*
++
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_libc_x86_tlsdesc_call" >&5
++$as_echo "$gcc_cv_libc_x86_tlsdesc_call" >&6; }
++ ;;
++ x86_64-*-linux*gnu* )
++ conftest_s='
++ .section .text.startup,"ax",@progbits
++ .p2align 4
++ .globl main
++ .type main, @function
++ main:
++ leaq foo@TLSDESC(%rip), %rax
++ call *foo@TLSCALL(%rax)
++ movl %fs:(%rax), %eax
++ ret
++ .size main, .-main
++ .section .note.GNU-stack,"",@progbits
++ '
++
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking libc has GLIBC_ABI_GNU2_TLS symbol dep and ld emits it" >&5
++$as_echo_n "checking libc has GLIBC_ABI_GNU2_TLS symbol dep and ld emits it... " >&6; }
++if ${gcc_cv_libc_x86_tlsdesc_call+:} false; then :
++ $as_echo_n "(cached) " >&6
++else
++
++ gcc_cv_libc_x86_tlsdesc_call=no
++ echo "$conftest_s" > conftest.s
++ if $CC $CFLAGS conftest.s -o conftest -shared > /dev/null 2>&1; then
++ if test x$gcc_cv_readelf != x; then
++ if $gcc_cv_readelf --version-info conftest 2>&1 \
++ | grep "GLIBC_ABI_GNU2_TLS" > /dev/null 2>&1; then
++ gcc_cv_libc_x86_tlsdesc_call=yes
++ else
++ gcc_cv_libc_x86_tlsdesc_call=no
++ fi
++ fi
++ fi
++ rm -f conftest.*
++
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_libc_x86_tlsdesc_call" >&5
++$as_echo "$gcc_cv_libc_x86_tlsdesc_call" >&6; }
++ ;;
++ esac
++
++ case "$gcc_cv_libc_x86_tlsdesc_call" in
++ yes)
++ with_tls=${with_tls:-gnu2}
++ ;;
++ *)
++ with_tls=${with_tls:-gnu}
++ ;;
++ esac
++ ;;
++esac
++
+ # --------------------------------------------------------
+ # Build, host, and target specific configuration fragments
+ # --------------------------------------------------------
+@@ -21484,7 +21660,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 21487 "configure"
++#line 21663 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -21590,7 +21766,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 21593 "configure"
++#line 21769 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -25419,78 +25595,6 @@ else
+ $as_echo "$gcc_cv_objdump" >&6; }
+ fi
+
+-# Figure out what readelf we will be using.
+-if ${gcc_cv_readelf+:} false; then :
+-
+-else
+-
+-if test -f $gcc_cv_binutils_srcdir/configure.ac \
+- && test -f ../binutils/Makefile \
+- && test x$build = x$host; then
+- # Single tree build which includes binutils.
+- gcc_cv_readelf=../binutils/readelf$build_exeext
+-elif test -x readelf$build_exeext; then
+- gcc_cv_readelf=./readelf$build_exeext
+-elif ( set dummy $READELF_FOR_TARGET; test -x $2 ); then
+- gcc_cv_readelf="$READELF_FOR_TARGET"
+-else
+- # Extract the first word of "$READELF_FOR_TARGET", so it can be a program name with args.
+-set dummy $READELF_FOR_TARGET; ac_word=$2
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+-$as_echo_n "checking for $ac_word... " >&6; }
+-if ${ac_cv_path_gcc_cv_readelf+:} false; then :
+- $as_echo_n "(cached) " >&6
+-else
+- case $gcc_cv_readelf in
+- [\\/]* | ?:[\\/]*)
+- ac_cv_path_gcc_cv_readelf="$gcc_cv_readelf" # Let the user override the test with a path.
+- ;;
+- *)
+- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+-for as_dir in $PATH
+-do
+- IFS=$as_save_IFS
+- test -z "$as_dir" && as_dir=.
+- for ac_exec_ext in '' $ac_executable_extensions; do
+- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+- ac_cv_path_gcc_cv_readelf="$as_dir/$ac_word$ac_exec_ext"
+- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+- break 2
+- fi
+-done
+- done
+-IFS=$as_save_IFS
+-
+- ;;
+-esac
+-fi
+-gcc_cv_readelf=$ac_cv_path_gcc_cv_readelf
+-if test -n "$gcc_cv_readelf"; then
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_readelf" >&5
+-$as_echo "$gcc_cv_readelf" >&6; }
+-else
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+-$as_echo "no" >&6; }
+-fi
+-
+-
+-fi
+-fi
+-
+-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking what readelf to use" >&5
+-$as_echo_n "checking what readelf to use... " >&6; }
+-if test "$gcc_cv_readelf" = ../binutils/readelf$build_exeext; then
+- # Single tree build which includes binutils.
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: newly built readelf" >&5
+-$as_echo "newly built readelf" >&6; }
+-elif test x$gcc_cv_readelf = x; then
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+-$as_echo "not found" >&6; }
+-else
+- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_readelf" >&5
+-$as_echo "$gcc_cv_readelf" >&6; }
+-fi
+-
+ # Figure out what otool we will be using.
+ if ${gcc_cv_otool+:} false; then :
+
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 4532c5c22fe5..b62cb747ee50 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -1886,6 +1886,123 @@ if test "x$enable_win32_utf8_manifest" != xno; then
+ host_extra_objs_mingw=utf8-mingw32.o
+ fi
+
++
++# Figure out what readelf we will be using.
++AS_VAR_SET_IF(gcc_cv_readelf,, [
++if test -f $gcc_cv_binutils_srcdir/configure.ac \
++ && test -f ../binutils/Makefile \
++ && test x$build = x$host; then
++ # Single tree build which includes binutils.
++ gcc_cv_readelf=../binutils/readelf$build_exeext
++elif test -x readelf$build_exeext; then
++ gcc_cv_readelf=./readelf$build_exeext
++elif ( set dummy $READELF_FOR_TARGET; test -x $[2] ); then
++ gcc_cv_readelf="$READELF_FOR_TARGET"
++else
++ AC_PATH_PROG(gcc_cv_readelf, $READELF_FOR_TARGET)
++fi])
++
++AC_MSG_CHECKING(what readelf to use)
++if test "$gcc_cv_readelf" = ../binutils/readelf$build_exeext; then
++ # Single tree build which includes binutils.
++ AC_MSG_RESULT(newly built readelf)
++elif test x$gcc_cv_readelf = x; then
++ AC_MSG_RESULT(not found)
++else
++ AC_MSG_RESULT($gcc_cv_readelf)
++fi
++
++case $target in
++changequote(,)dnl
++ i[34567]86-*-* | x86_64-*-*)
++changequote([,])dnl
++ # PR target/120933
++ # For GNU/Linux targets, check if ld emits GLIBC_ABI_GNU2_TLS. For PR ld/33130,
++ # newer ld will add GLIBC_ABI_GNU2_TLS if either unconfigured (auto mode) or if
++ # configured with --enable-gnu2-tls-tag. In auto mode, GLIBC_ABI_GNU2_TLS
++ # is only added if glibc provides it. In explicit mode, the user has asked
++ # for this behavior and binaries will depend on GLIBC_ABI_GNU2_TLS and fixed
++ # glibc. Hence the presence of GLIBC_ABI_GNU2_TLS tells us if we can safely
++ # default to GNU2 TLS descriptors.
++ case $target in
++ # TODO: x32
++ i?86-*-linux*gnu* )
++ conftest_s='
++ .section .text.startup,"ax",@progbits
++ .p2align 4
++ .globl main
++ .type main, @function
++ main:
++ leal ld@TLSDESC(%ebx), %eax
++ call *ld@TLSCALL(%eax)
++ addl %gs:0, %eax
++ ret
++ .size main, .-main
++ .section .note.GNU-stack,"",@progbits
++ '
++
++ AC_CACHE_CHECK([libc has GLIBC_ABI_GNU2_TLS symbol dep and ld emits it],
++ gcc_cv_libc_x86_tlsdesc_call, [
++ gcc_cv_libc_x86_tlsdesc_call=no
++ echo "$conftest_s" > conftest.s
++ if $CC $CFLAGS conftest.s -o conftest -shared > /dev/null 2>&1; then
++ if test x$gcc_cv_readelf != x; then
++ if $gcc_cv_readelf --version-info conftest 2>&1 \
++ | grep "GLIBC_ABI_GNU2_TLS" > /dev/null 2>&1; then
++ gcc_cv_libc_x86_tlsdesc_call=yes
++ else
++ gcc_cv_libc_x86_tlsdesc_call=no
++ fi
++ fi
++ fi
++ rm -f conftest.*
++ ])
++ ;;
++ x86_64-*-linux*gnu* )
++ conftest_s='
++ .section .text.startup,"ax",@progbits
++ .p2align 4
++ .globl main
++ .type main, @function
++ main:
++ leaq foo@TLSDESC(%rip), %rax
++ call *foo@TLSCALL(%rax)
++ movl %fs:(%rax), %eax
++ ret
++ .size main, .-main
++ .section .note.GNU-stack,"",@progbits
++ '
++
++ AC_CACHE_CHECK([libc has GLIBC_ABI_GNU2_TLS symbol dep and ld emits it],
++ gcc_cv_libc_x86_tlsdesc_call, [
++ gcc_cv_libc_x86_tlsdesc_call=no
++ echo "$conftest_s" > conftest.s
++ if $CC $CFLAGS conftest.s -o conftest -shared > /dev/null 2>&1; then
++ if test x$gcc_cv_readelf != x; then
++ if $gcc_cv_readelf --version-info conftest 2>&1 \
++ | grep "GLIBC_ABI_GNU2_TLS" > /dev/null 2>&1; then
++ gcc_cv_libc_x86_tlsdesc_call=yes
++ else
++ gcc_cv_libc_x86_tlsdesc_call=no
++ fi
++ fi
++ fi
++ rm -f conftest.*
++ ])
++ ;;
++ esac
++
++ case "$gcc_cv_libc_x86_tlsdesc_call" in
++ yes)
++ with_tls=${with_tls:-gnu2}
++ ;;
++ *)
++ with_tls=${with_tls:-gnu}
++ ;;
++ esac
++ ;;
++esac
++
+ # --------------------------------------------------------
+ # Build, host, and target specific configuration fragments
+ # --------------------------------------------------------
+@@ -2934,31 +3051,6 @@ else
+ AC_MSG_RESULT($gcc_cv_objdump)
+ fi
+
+-# Figure out what readelf we will be using.
+-AS_VAR_SET_IF(gcc_cv_readelf,, [
+-if test -f $gcc_cv_binutils_srcdir/configure.ac \
+- && test -f ../binutils/Makefile \
+- && test x$build = x$host; then
+- # Single tree build which includes binutils.
+- gcc_cv_readelf=../binutils/readelf$build_exeext
+-elif test -x readelf$build_exeext; then
+- gcc_cv_readelf=./readelf$build_exeext
+-elif ( set dummy $READELF_FOR_TARGET; test -x $[2] ); then
+- gcc_cv_readelf="$READELF_FOR_TARGET"
+-else
+- AC_PATH_PROG(gcc_cv_readelf, $READELF_FOR_TARGET)
+-fi])
+-
+-AC_MSG_CHECKING(what readelf to use)
+-if test "$gcc_cv_readelf" = ../binutils/readelf$build_exeext; then
+- # Single tree build which includes binutils.
+- AC_MSG_RESULT(newly built readelf)
+-elif test x$gcc_cv_readelf = x; then
+- AC_MSG_RESULT(not found)
+-else
+- AC_MSG_RESULT($gcc_cv_readelf)
+-fi
+-
+ # Figure out what otool we will be using.
+ AS_VAR_SET_IF(gcc_cv_otool,, [
+ if test -x otool$build_exeext; then
+--
+2.51.0
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 53a4c78..140c03f 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,5 +1,6 @@
-12 ????
+12 24 August 2025
+ + 86_all_PR120933-i386-default-to-mtls-dialect-gnu2-if-appropriate.patch
- 86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
- 87_all_PR121553-Revert-c-P2036R3-Change-scope-of-lambda-trailing-ret.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-21 16:11 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-21 16:11 UTC (permalink / raw
To: gentoo-commits
commit: 2dd1daa1a22e7590ab905ce0e84dde60675bec1b
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 21 16:10:58 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Aug 21 16:11:28 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=2dd1daa1
16.0.0: drop upstreamed TLS ICE patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch | 173 ----------------------------
16.0.0/gentoo/README.history | 1 -
2 files changed, 174 deletions(-)
diff --git a/16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch b/16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch
deleted file mode 100644
index a156cb1..0000000
--- a/16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch
+++ /dev/null
@@ -1,173 +0,0 @@
-From e22c8a8cd7aef8938722e0ea6719dd1298d48812 Mon Sep 17 00:00:00 2001
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Wed, 20 Aug 2025 06:59:48 -0700
-Subject: [PATCH] x86-64: Emit the TLS call after NOTE_INSN_BASIC_BLOCK
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-For a basic block with only a label:
-
-(code_label 78 11 77 3 14 (nil) [1 uses])
-(note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
-
-emit the TLS call after NOTE_INSN_BASIC_BLOCK, instead of before
-NOTE_INSN_BASIC_BLOCK, to avoid
-
-x.c: In function ‘aout_16_write_syms’:
-x.c:54:1: error: NOTE_INSN_BASIC_BLOCK is missing for block 3
- 54 | }
- | ^
-x.c:54:1: error: NOTE_INSN_BASIC_BLOCK 77 in middle of basic block 3
-during RTL pass: x86_cse
-x.c:54:1: internal compiler error: verify_flow_info failed
-
-gcc/
-
- PR target/121607
- * config/i386/i386-features.cc (ix86_emit_tls_call): Emit the
- TLS call after NOTE_INSN_BASIC_BLOCK in a basic block with only
- a label.
-
-gcc/testsuite/
-
- PR target/121607
- * gcc.target/i386/pr121607-1a.c: New test.
- * gcc.target/i386/pr121607-1b.c: Likewise.
-
-Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
----
- gcc/config/i386/i386-features.cc | 24 +++++++--
- gcc/testsuite/gcc.target/i386/pr121607-1a.c | 59 +++++++++++++++++++++
- gcc/testsuite/gcc.target/i386/pr121607-1b.c | 6 +++
- 3 files changed, 86 insertions(+), 3 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121607-1a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121607-1b.c
-
-diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index 7869ee22b67..514d2a5d378 100644
---- a/gcc/config/i386/i386-features.cc
-+++ b/gcc/config/i386/i386-features.cc
-@@ -3795,7 +3795,18 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
- while (insn && !NONDEBUG_INSN_P (insn))
- {
- if (insn == BB_END (bb))
-- break;
-+ {
-+ /* This must be a basic block with only a label:
-+
-+ (code_label 78 11 77 3 14 (nil) [1 uses])
-+ (note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
-+
-+ */
-+ gcc_assert (NOTE_P (insn)
-+ && NOTE_KIND (insn) == NOTE_INSN_BASIC_BLOCK);
-+ insn = NULL;
-+ break;
-+ }
- insn = NEXT_INSN (insn);
- }
-
-@@ -3824,14 +3835,21 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
-
- if (bitmap_empty_p (live_caller_saved_regs))
- {
-- if (insn == BB_HEAD (bb) || insn == BB_END (bb))
-+ if (insn == BB_HEAD (bb))
- {
- *before_p = insn;
- tls_insn = emit_insn_before (tls_set, insn);
- }
- else
- {
-- insn = PREV_INSN (insn);
-+ /* Emit the TLS call after NOTE_INSN_BASIC_BLOCK in a
-+ basic block with only a label:
-+
-+ (code_label 78 11 77 3 14 (nil) [1 uses])
-+ (note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
-+
-+ */
-+ insn = insn ? PREV_INSN (insn) : BB_END (bb);
- *after_p = insn;
- tls_insn = emit_insn_after (tls_set, insn);
- }
-diff --git a/gcc/testsuite/gcc.target/i386/pr121607-1a.c b/gcc/testsuite/gcc.target/i386/pr121607-1a.c
-new file mode 100644
-index 00000000000..4c047068e3a
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121607-1a.c
-@@ -0,0 +1,59 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu -fno-semantic-interposition -fstack-protector" } */
-+
-+typedef enum
-+{
-+ bfd_error_invalid_error_code
-+} bfd_error_type;
-+thread_local bfd_error_type bfd_error;
-+int aout_16_write_syms___trans_tmp_1;
-+short aout_16_write_syms_g_0_0;
-+void xvec_0 (long, void *);
-+
-+typedef struct
-+{
-+ int output_section;
-+} asection;
-+
-+void bfd_asymbol_section ();
-+
-+struct pdp11_external_nlist
-+{
-+ char e_desc[2];
-+ char e_type[1];
-+ char e_ovly[10];
-+} translate_to_native_sym_flags (struct pdp11_external_nlist *sym_pointer)
-+{
-+ asection *sec;
-+ sym_pointer->e_type[0] &= 5;
-+ bfd_asymbol_section ();
-+ if (sec == 0)
-+ {
-+ bfd_error_type error_tag;
-+ bfd_error = error_tag;
-+ }
-+ if (sec->output_section)
-+ {
-+ bfd_error_type error_tag;
-+ bfd_error = error_tag;
-+ }
-+}
-+
-+bool
-+aout_16_write_syms (void *abfd)
-+{
-+ for (; aout_16_write_syms___trans_tmp_1;)
-+ {
-+ struct pdp11_external_nlist nsp;
-+ if (abfd)
-+ {
-+ xvec_0 (aout_16_write_syms_g_0_0, nsp.e_desc);
-+ nsp.e_ovly[0] = 0;
-+ }
-+ else
-+ nsp.e_type[0] = 0;
-+ translate_to_native_sym_flags (&nsp);
-+ }
-+}
-+
-+/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 2 { target { ! ia32 } } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr121607-1b.c b/gcc/testsuite/gcc.target/i386/pr121607-1b.c
-new file mode 100644
-index 00000000000..366306702c7
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121607-1b.c
-@@ -0,0 +1,6 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu2 -fno-semantic-interposition -fstack-protector" } */
-+
-+#include "pr121607-1a.c"
-+
-+/* { dg-final { scan-assembler-times "call\[ \t\]\\*bfd_error@TLSCALL\\(%(?:r|e)ax\\)" 2 { target { ! ia32 } } } } */
---
-2.50.1
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index a3bc300..53a4c78 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -2,7 +2,6 @@
- 86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
- 87_all_PR121553-Revert-c-P2036R3-Change-scope-of-lambda-trailing-ret.patch
- + 88_all_PR121607-TLS-ICE.patch
11 20 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-20 20:45 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-20 20:45 UTC (permalink / raw
To: gentoo-commits
commit: 07367a96580437b5de949e04a39b408fd673448e
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 20 20:45:01 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Aug 20 20:45:01 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=07367a96
16.0.0: drop obsolete C++ patch
It's been fixed upstream now.
Signed-off-by: Sam James <sam <AT> gentoo.org>
...036R3-Change-scope-of-lambda-trailing-ret.patch | 1186 --------------------
16.0.0/gentoo/README.history | 1 +
2 files changed, 1 insertion(+), 1186 deletions(-)
diff --git a/16.0.0/gentoo/87_all_PR121553-Revert-c-P2036R3-Change-scope-of-lambda-trailing-ret.patch b/16.0.0/gentoo/87_all_PR121553-Revert-c-P2036R3-Change-scope-of-lambda-trailing-ret.patch
deleted file mode 100644
index ad792d0..0000000
--- a/16.0.0/gentoo/87_all_PR121553-Revert-c-P2036R3-Change-scope-of-lambda-trailing-ret.patch
+++ /dev/null
@@ -1,1186 +0,0 @@
-From 358ad796de168eedb8bcf9509a7dc40861f057a0 Mon Sep 17 00:00:00 2001
-Message-ID: <358ad796de168eedb8bcf9509a7dc40861f057a0.1755561114.git.sam@gentoo.org>
-From: Sam James <sam@gentoo.org>
-Date: Tue, 19 Aug 2025 00:51:27 +0100
-Subject: [PATCH] Revert "c++: P2036R3 - Change scope of lambda
- trailing-return-type [PR102610]"
-
-This reverts commit d2dccd1bf79b862b9989c1b62ed8c074980cd457.
-
-Bug: https://gcc.gnu.org/PR121553
----
- gcc/cp/cp-tree.h | 11 -
- gcc/cp/lambda.cc | 40 +---
- gcc/cp/name-lookup.cc | 11 +-
- gcc/cp/name-lookup.h | 1 -
- gcc/cp/parser.cc | 94 --------
- gcc/cp/pt.cc | 21 --
- gcc/cp/semantics.cc | 64 ++----
- .../g++.dg/cpp0x/lambda/lambda-decltype3.C | 2 +-
- gcc/testsuite/g++.dg/cpp23/lambda-scope1.C | 85 -------
- gcc/testsuite/g++.dg/cpp23/lambda-scope2.C | 217 ------------------
- gcc/testsuite/g++.dg/cpp23/lambda-scope3.C | 44 ----
- gcc/testsuite/g++.dg/cpp23/lambda-scope4.C | 41 ----
- gcc/testsuite/g++.dg/cpp23/lambda-scope4b.C | 42 ----
- gcc/testsuite/g++.dg/cpp23/lambda-scope5.C | 22 --
- gcc/testsuite/g++.dg/cpp23/lambda-scope6.C | 20 --
- gcc/testsuite/g++.dg/cpp23/lambda-scope7.C | 20 --
- gcc/testsuite/g++.dg/cpp23/lambda-scope8.C | 25 --
- gcc/testsuite/g++.dg/cpp23/lambda-scope9.C | 15 --
- gcc/testsuite/g++.dg/warn/Wshadow-19.C | 4 +-
- gcc/testsuite/g++.dg/warn/Wshadow-6.C | 8 +-
- 20 files changed, 37 insertions(+), 750 deletions(-)
- delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope1.C
- delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope2.C
- delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope3.C
- delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope4.C
- delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope4b.C
- delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope5.C
- delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope6.C
- delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope7.C
- delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope8.C
- delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope9.C
-
-diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
-index 55e8e0736272..d29d996e55e5 100644
---- a/gcc/cp/cp-tree.h
-+++ b/gcc/cp/cp-tree.h
-@@ -476,7 +476,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
- ATOMIC_CONSTR_EXPR_FROM_CONCEPT_P (in ATOMIC_CONSTR)
- STATIC_INIT_DECOMP_BASE_P (in the TREE_LIST for {static,tls}_aggregates)
- MUST_NOT_THROW_THROW_P (in MUST_NOT_THROW_EXPR)
-- LAMBDA_EXPR_CONST_QUAL_P (in LAMBDA_EXPR)
- 2: IDENTIFIER_KIND_BIT_2 (in IDENTIFIER_NODE)
- ICS_THIS_FLAG (in _CONV)
- DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (in VAR_DECL)
-@@ -1558,13 +1557,6 @@ enum cp_lambda_default_capture_mode_type {
- #define LAMBDA_EXPR_CONSTEVAL_BLOCK_P(NODE) \
- TREE_LANG_FLAG_0 (LAMBDA_EXPR_CHECK (NODE))
-
--/* True if we should add "const" when figuring out the type of an entity
-- in a lambda. This is false in the parameter-declaration-clause of
-- a lambda; after that, it will remain false if the mutable keyword is
-- present. */
--#define LAMBDA_EXPR_CONST_QUAL_P(NODE) \
-- TREE_LANG_FLAG_1 (LAMBDA_EXPR_CHECK (NODE))
--
- /* True iff uses of a const variable capture were optimized away. */
- #define LAMBDA_EXPR_CAPTURE_OPTIMIZED(NODE) \
- TREE_LANG_FLAG_2 (LAMBDA_EXPR_CHECK (NODE))
-@@ -7807,8 +7799,6 @@ extern location_t defparse_location (tree);
- extern void maybe_show_extern_c_location (void);
- extern bool literal_integer_zerop (const_tree);
- extern tree attr_chainon (tree, tree);
--extern tree maybe_add_dummy_lambda_op (tree);
--extern void remove_dummy_lambda_op (tree, tree);
-
- /* in pt.cc */
- extern tree canonical_type_parameter (tree);
-@@ -8339,7 +8329,6 @@ extern void record_lambda_scope (tree lambda);
- extern void record_lambda_scope_discriminator (tree lambda);
- extern void record_lambda_scope_sig_discriminator (tree lambda, tree fn);
- extern tree start_lambda_function (tree fn, tree lambda_expr);
--extern void push_capture_proxies (tree, bool = false);
- extern void finish_lambda_function (tree body);
- extern bool regenerated_lambda_fn_p (tree);
- extern tree lambda_regenerating_args (tree);
-diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc
-index 711e3b7a18e4..c798967f8e1c 100644
---- a/gcc/cp/lambda.cc
-+++ b/gcc/cp/lambda.cc
-@@ -409,11 +409,10 @@ lambda_proxy_type (tree ref)
-
- /* MEMBER is a capture field in a lambda closure class. Now that we're
- inside the operator(), build a placeholder var for future lookups and
-- debugging. But if EARLY_P is true, we do not have the real operator()
-- yet and we have to proceed differently. */
-+ debugging. */
-
--tree
--build_capture_proxy (tree member, tree init, bool early_p)
-+static tree
-+build_capture_proxy (tree member, tree init)
- {
- tree var, object, fn, closure, name, lam, type;
-
-@@ -504,19 +503,11 @@ build_capture_proxy (tree member, tree init, bool early_p)
-
- if (name == this_identifier)
- {
-- if (early_p)
-- return var;
- gcc_assert (LAMBDA_EXPR_THIS_CAPTURE (lam) == member);
- LAMBDA_EXPR_THIS_CAPTURE (lam) = var;
- }
-
-- if (early_p)
-- {
-- gcc_checking_assert (current_binding_level->kind == sk_lambda);
-- /* insert_capture_proxy below wouldn't push into the lambda scope. */
-- pushdecl (var);
-- }
-- else if (fn == current_function_decl)
-+ if (fn == current_function_decl)
- insert_capture_proxy (var);
- else
- vec_safe_push (LAMBDA_EXPR_PENDING_PROXIES (lam), var);
-@@ -736,7 +727,7 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
- = tree_cons (listmem, initializer, LAMBDA_EXPR_CAPTURE_LIST (lambda));
-
- if (LAMBDA_EXPR_CLOSURE (lambda))
-- return build_capture_proxy (member, initializer, /*early_p=*/false);
-+ return build_capture_proxy (member, initializer);
- /* For explicit captures we haven't started the function yet, so we wait
- and build the proxy from cp_parser_lambda_body. */
- LAMBDA_CAPTURE_EXPLICIT_P (LAMBDA_EXPR_CAPTURE_LIST (lambda)) = true;
-@@ -989,14 +980,10 @@ resolvable_dummy_lambda (tree object)
- tree type = TYPE_MAIN_VARIANT (TREE_TYPE (object));
- gcc_assert (!TYPE_PTR_P (type));
-
-- tree fn;
- if (type != current_class_type
- && current_class_type
- && LAMBDA_TYPE_P (current_class_type)
-- && (fn = lambda_function (current_class_type))
-- /* Even dummy lambdas have an operator() since P2036, but the
-- dummy operator() doesn't have this set. */
-- && DECL_LAMBDA_FUNCTION_P (fn)
-+ && lambda_function (current_class_type)
- && DERIVED_FROM_P (type, nonlambda_method_basetype()))
- return CLASSTYPE_LAMBDA_EXPR (current_class_type);
-
-@@ -1797,17 +1784,6 @@ record_lambda_scope_sig_discriminator (tree lambda, tree fn)
- LAMBDA_EXPR_SCOPE_SIG_DISCRIMINATOR (lambda) = sig->count++;
- }
-
--/* Push the proxies for any explicit captures in LAMBDA_EXPR.
-- If EARLY_P, we do not have the real operator() yet. */
--
--void
--push_capture_proxies (tree lambda_expr, bool early_p)
--{
-- for (tree cap = LAMBDA_EXPR_CAPTURE_LIST (lambda_expr); cap;
-- cap = TREE_CHAIN (cap))
-- build_capture_proxy (TREE_PURPOSE (cap), TREE_VALUE (cap), early_p);
--}
--
- tree
- start_lambda_function (tree fco, tree lambda_expr)
- {
-@@ -1820,7 +1796,9 @@ start_lambda_function (tree fco, tree lambda_expr)
- tree body = begin_function_body ();
-
- /* Push the proxies for any explicit captures. */
-- push_capture_proxies (lambda_expr);
-+ for (tree cap = LAMBDA_EXPR_CAPTURE_LIST (lambda_expr); cap;
-+ cap = TREE_CHAIN (cap))
-+ build_capture_proxy (TREE_PURPOSE (cap), TREE_VALUE (cap));
-
- return body;
- }
-diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
-index fa367214507e..a805f42f6668 100644
---- a/gcc/cp/name-lookup.cc
-+++ b/gcc/cp/name-lookup.cc
-@@ -3351,11 +3351,8 @@ check_local_shadow (tree decl)
- }
- /* Don't complain if it's from an enclosing function. */
- else if (DECL_CONTEXT (old) == current_function_decl
-- && ((TREE_CODE (decl) != PARM_DECL
-- && TREE_CODE (old) == PARM_DECL)
-- /* We should also give an error for
-- [x=1]{ int x; } */
-- || is_capture_proxy (old)))
-+ && TREE_CODE (decl) != PARM_DECL
-+ && TREE_CODE (old) == PARM_DECL)
- {
- /* Go to where the parms should be and see if we find
- them there. */
-@@ -4641,8 +4638,7 @@ cp_binding_level_descriptor (cp_binding_level *scope)
- "template-parameter-scope",
- "template-explicit-spec-scope",
- "transaction-scope",
-- "openmp-scope",
-- "lambda-scope"
-+ "openmp-scope"
- };
- static_assert (ARRAY_SIZE (scope_kind_names) == sk_count,
- "must keep names aligned with scope_kind enum");
-@@ -4734,7 +4730,6 @@ begin_scope (scope_kind kind, tree entity)
- case sk_transaction:
- case sk_omp:
- case sk_stmt_expr:
-- case sk_lambda:
- scope->keep = keep_next_level_flag;
- break;
-
-diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
-index 5b142e748999..6a3c0df47007 100644
---- a/gcc/cp/name-lookup.h
-+++ b/gcc/cp/name-lookup.h
-@@ -215,7 +215,6 @@ enum scope_kind {
- "template <>", this scope is always empty. */
- sk_transaction, /* A synchronized or atomic statement. */
- sk_omp, /* An OpenMP structured block. */
-- sk_lambda, /* A lambda scope. */
- sk_count /* Number of scope_kind enumerations. */
- };
-
-diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
-index d66b658b748f..9dbd254dc61b 100644
---- a/gcc/cp/parser.cc
-+++ b/gcc/cp/parser.cc
-@@ -11887,10 +11887,6 @@ cp_parser_lambda_expression (cp_parser* parser,
- if (cp_parser_start_tentative_firewall (parser))
- start = token;
-
-- /* A lambda scope starts immediately after the lambda-introducer of E
-- and extends to the end of the compound-statement of E. */
-- begin_scope (sk_lambda, NULL_TREE);
--
- ok &= cp_parser_lambda_declarator_opt (parser, lambda_expr,
- consteval_block_p);
-
-@@ -11912,8 +11908,6 @@ cp_parser_lambda_expression (cp_parser* parser,
- if (ok)
- maybe_add_lambda_conv_op (type);
-
-- /* Leave the lambda scope. */
-- pop_bindings_and_leave_scope ();
- finish_struct (type, /*attributes=*/NULL_TREE);
-
- in_expansion_stmt = save_in_expansion_stmt;
-@@ -12305,13 +12299,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr,
- clear_decl_specs (&lambda_specs);
- /* A lambda op() is const unless explicitly 'mutable'. */
- cp_cv_quals quals = TYPE_QUAL_CONST;
-- /* Don't add "const" to entities in the parameter-declaration-clause. */
-- LAMBDA_EXPR_CONST_QUAL_P (lambda_expr) = false;
--
-- /* Inject the captures into the lambda scope as they may be used in the
-- declarator and we have to be able to look them up. */
-- tree dummy_fco = maybe_add_dummy_lambda_op (lambda_expr);
-- push_capture_proxies (lambda_expr, /*early_p=*/true);
-
- /* The template-parameter-list is optional, but must begin with
- an opening angle if present. */
-@@ -12502,10 +12489,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr,
- }
- }
-
-- /* Now we're done with the parameter-declaration-clause, and should
-- assume "const" unless "mutable" was present. */
-- LAMBDA_EXPR_CONST_QUAL_P (lambda_expr) = quals == TYPE_QUAL_CONST;
--
- tx_qual = cp_parser_tx_qualifier_opt (parser);
- if (omitted_parms_loc && tx_qual)
- {
-@@ -12563,10 +12546,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr,
- pop_bindings_and_leave_scope ();
- }
-
-- /* We are about to create the real operator(), so get rid of the old one. */
-- if (dummy_fco)
-- remove_dummy_lambda_op (dummy_fco, lambda_expr);
--
- /* Create the function call operator.
-
- Messing with declarators like this is no uglier than building up the
-@@ -12646,79 +12625,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr,
- }
- }
-
--/* Create a fake operator() for a lambda. We do this so that we can
-- build_capture_proxy even before start_lambda_function. */
--
--static tree
--make_dummy_lambda_op ()
--{
-- cp_decl_specifier_seq return_type_specs;
-- cp_cv_quals quals = TYPE_UNQUALIFIED;
--
-- clear_decl_specs (&return_type_specs);
-- return_type_specs.type = make_auto ();
--
-- void *p = obstack_alloc (&declarator_obstack, 0);
--
-- cp_declarator *declarator = make_id_declarator (NULL_TREE,
-- call_op_identifier,
-- sfk_none,
-- input_location);
--
-- declarator = make_call_declarator (declarator, void_list_node, quals,
-- VIRT_SPEC_UNSPECIFIED,
-- REF_QUAL_NONE, NULL_TREE,
-- NULL_TREE, NULL_TREE, NULL_TREE,
-- NULL_TREE, UNKNOWN_LOCATION);
--
-- tree fco = grokmethod (&return_type_specs, declarator, NULL_TREE);
-- obstack_free (&declarator_obstack, p);
--
-- return fco;
--}
--
--/* We need to push early capture proxies (for parsing the lambda-declarator),
-- and we may need a dummy operator() to be able to build the proxies.
-- LAMBDA_EXPR is the lambda we are building the captures for. */
--
--tree
--maybe_add_dummy_lambda_op (tree lambda_expr)
--{
-- /* If there are no captures, we don't need this. */
-- if (!LAMBDA_EXPR_CAPTURE_LIST (lambda_expr))
-- return NULL_TREE;
--
-- tree fco = make_dummy_lambda_op ();
-- if (fco != error_mark_node)
-- finish_member_declaration (fco);
--
-- return fco;
--}
--
--/* Remove the dummy operator() DUMMY_FCO we built for parsing the
-- lambda-declarator of LAMBDA_EXPR. */
--
--void
--remove_dummy_lambda_op (tree dummy_fco, tree lambda_expr)
--{
-- tree type = TREE_TYPE (lambda_expr);
-- if (TYPE_FIELDS (type) == dummy_fco)
-- {
-- /* Stitch out the dummy operator(). */
-- TYPE_FIELDS (type) = DECL_CHAIN (TYPE_FIELDS (type));
-- /* And clear the member vector as well. */
-- auto *member_vec = CLASSTYPE_MEMBER_VEC (type);
-- gcc_assert (member_vec->length () == 1);
-- member_vec->truncate (0);
-- }
-- /* Class templates will have the dummy operator() stashed here too. */
-- tree &list = CLASSTYPE_DECL_LIST (type);
-- if (list && TREE_VALUE (list) == dummy_fco)
-- list = TREE_CHAIN (list);
-- /* ??? We can't ggc_free dummy_fco yet. There's still a binding in the
-- closure to it, and the captures have it as their DECL_CONTEXT. */
--}
--
- /* Parse the body of a lambda expression, which is simply
-
- compound-statement
-diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
-index bb2d0b48fd42..b72f285d86d6 100644
---- a/gcc/cp/pt.cc
-+++ b/gcc/cp/pt.cc
-@@ -20590,18 +20590,6 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
-
- tree fntype = static_fn_type (oldfn);
-
-- begin_scope (sk_lambda, NULL_TREE);
--
-- /* Like in cp_parser_lambda_expression, we need to bring the captures
-- into the lambda scope. */
-- tree ns = decl_namespace_context (type);
-- push_nested_namespace (ns);
-- push_nested_class (type);
-- tree dummy_fco = maybe_add_dummy_lambda_op (r);
-- pop_nested_class ();
-- pop_nested_namespace (ns);
-- push_capture_proxies (r, /*early_p=*/true);
--
- tree saved_ctp = current_template_parms;
- if (oldtmpl)
- {
-@@ -20615,10 +20603,6 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
- --processing_template_decl;
- }
-
-- /* We are about to create the real operator(), so get rid of the old one. */
-- if (dummy_fco)
-- remove_dummy_lambda_op (dummy_fco, r);
--
- if (fntype == error_mark_node)
- r = error_mark_node;
- else
-@@ -20652,10 +20636,6 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
- enclosing expression. */
- cp_evaluated ev;
-
-- /* Now we're done with the parameter-declaration-clause, and should
-- assume "const" unless "mutable" was present. */
-- LAMBDA_EXPR_CONST_QUAL_P (r) = LAMBDA_EXPR_CONST_QUAL_P (t);
--
- bool nested = cfun;
- if (nested)
- push_function_context ();
-@@ -20724,7 +20704,6 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
- }
-
- out:
-- pop_bindings_and_leave_scope ();
- finish_struct (type, /*attr*/NULL_TREE);
-
- insert_pending_capture_proxies ();
-diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
-index 26709c7a33bf..ef331f64f8da 100644
---- a/gcc/cp/semantics.cc
-+++ b/gcc/cp/semantics.cc
-@@ -4511,17 +4511,6 @@ baselink_for_fns (tree fns)
- return build_baselink (conv_path, access_path, fns, /*optype=*/NULL_TREE);
- }
-
--/* Returns true iff we are currently parsing a lambda-declarator. */
--
--static bool
--parsing_lambda_declarator ()
--{
-- cp_binding_level *b = current_binding_level;
-- while (b->kind == sk_template_parms || b->kind == sk_function_parms)
-- b = b->level_chain;
-- return b->kind == sk_lambda;
--}
--
- /* Returns true iff DECL is a variable from a function outside
- the current one. */
-
-@@ -4536,15 +4525,7 @@ outer_var_p (tree decl)
- /* Don't get confused by temporaries. */
- && DECL_NAME (decl)
- && (DECL_CONTEXT (decl) != current_function_decl
-- || parsing_nsdmi ()
-- /* Also consider captures as outer vars if we are in
-- decltype in a lambda declarator as in:
-- auto l = [j=0]() -> decltype((j)) { ... }
-- for the sake of finish_decltype_type.
--
-- (Similar issue also affects non-lambdas, but vexing parse
-- makes it more difficult to handle than lambdas.) */
-- || parsing_lambda_declarator ()));
-+ || parsing_nsdmi ()));
- }
-
- /* As above, but also checks that DECL is automatic. */
-@@ -4590,7 +4571,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use)
- if (!mark_used (decl, complain))
- return error_mark_node;
-
-- if (parsing_nsdmi () || parsing_lambda_declarator ())
-+ if (parsing_nsdmi ())
- containing_function = NULL_TREE;
-
- if (containing_function && LAMBDA_FUNCTION_P (containing_function))
-@@ -12960,9 +12941,9 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
- }
- else
- {
-- tree decl = STRIP_REFERENCE_REF (expr);
-- tree lam = current_lambda_expr ();
-- if (lam && outer_automatic_var_p (decl))
-+ if (outer_automatic_var_p (STRIP_REFERENCE_REF (expr))
-+ && current_function_decl
-+ && LAMBDA_FUNCTION_P (current_function_decl))
- {
- /* [expr.prim.id.unqual]/3: If naming the entity from outside of an
- unevaluated operand within S would refer to an entity captured by
-@@ -12979,6 +12960,8 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
- local variable inside decltype, not just decltype((x)) (PR83167).
- And we don't handle nested lambdas properly, where we need to
- consider the outer lambdas as well (PR112926). */
-+ tree decl = STRIP_REFERENCE_REF (expr);
-+ tree lam = CLASSTYPE_LAMBDA_EXPR (DECL_CONTEXT (current_function_decl));
- tree cap = lookup_name (DECL_NAME (decl), LOOK_where::BLOCK,
- LOOK_want::HIDDEN_LAMBDA);
-
-@@ -12994,28 +12977,17 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
-
- if (type && !TYPE_REF_P (type))
- {
-- int quals;
-- if (current_function_decl
-- && LAMBDA_FUNCTION_P (current_function_decl)
-- && DECL_XOBJ_MEMBER_FUNCTION_P (current_function_decl))
-- {
-- tree obtype = TREE_TYPE (DECL_ARGUMENTS (current_function_decl));
-- if (WILDCARD_TYPE_P (non_reference (obtype)))
-- /* We don't know what the eventual obtype quals will be. */
-- goto dependent;
-- auto direct_type = [](tree t){
-- if (INDIRECT_TYPE_P (t))
-- return TREE_TYPE (t);
-- return t;
-- };
-- quals = (cp_type_quals (type)
-- | cp_type_quals (direct_type (obtype)));
-- }
-- else
-- /* We are in the parameter clause, trailing return type, or
-- the requires clause and have no relevant c_f_decl yet. */
-- quals = (LAMBDA_EXPR_CONST_QUAL_P (lam)
-- ? TYPE_QUAL_CONST : TYPE_UNQUALIFIED);
-+ tree obtype = TREE_TYPE (DECL_ARGUMENTS (current_function_decl));
-+ if (WILDCARD_TYPE_P (non_reference (obtype)))
-+ /* We don't know what the eventual obtype quals will be. */
-+ goto dependent;
-+ auto direct_type = [](tree t){
-+ if (INDIRECT_TYPE_P (t))
-+ return TREE_TYPE (t);
-+ return t;
-+ };
-+ int const quals = cp_type_quals (type)
-+ | cp_type_quals (direct_type (obtype));
- type = cp_build_qualified_type (type, quals);
- type = build_reference_type (type);
- }
-diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype3.C
-index 6ba0dabc37d5..2e06e4961408 100644
---- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype3.C
-+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype3.C
-@@ -11,7 +11,7 @@ void f() {
- decltype((x)) y2 = y1; // y2 has type float const&
- decltype(r) r1 = y1; // r1 has type float&
- decltype((r)) r2 = y2; // r2 has type float const&
-- return y2; // { dg-bogus "'float&' to 'const float'" }
-+ return y2; // { dg-bogus "'float&' to 'const float'" "" { xfail *-*-* } }
- };
-
- [=](decltype((x)) y) {
-diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope1.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope1.C
-deleted file mode 100644
-index 000979e30778..000000000000
---- a/gcc/testsuite/g++.dg/cpp23/lambda-scope1.C
-+++ /dev/null
-@@ -1,85 +0,0 @@
--// P2036R3 - Change scope of lambda trailing-return-type
--// PR c++/102610
--// { dg-do compile { target c++23 } }
--
--template <typename T, typename U>
--constexpr bool is_same = false;
--
--template <typename T>
--constexpr bool is_same<T, T> = true;
--
--struct S {
-- void foo () {
-- auto counter1 = [j=0]() mutable -> decltype(j) {
-- return j++;
-- };
-- auto counter2 = [j=0, o=0, k=0, e=0]() mutable -> decltype(j) {
-- return j + o + k + e;
-- };
-- }
--};
--
--// [expr.prim.id.unqual]/3.2
--void
--f ()
--{
-- float x, &r = x;
--
-- [=]() -> decltype((x)) { // lambda returns float const& because this lambda is not mutable and
-- // x is an lvalue
-- decltype(x) y1; // y1 has type float
-- decltype((x)) y2 = y1; // y2 has type float const&
-- decltype(r) r1 = y1; // r1 has type float&
-- decltype((r)) r2 = y2; // r2 has type float const&
-- return y2;
-- };
--
-- [=](decltype((x)) y) {
-- decltype((x)) z = x; // OK, y has type float&, z has type float const&
-- static_assert(is_same<float&, decltype((y))>);
-- static_assert(is_same<const float&, decltype((z))>);
-- };
--
-- [=] {
-- [](decltype((x)) y) { // OK, lambda takes a parameter of type float const&
-- };
--
-- [x=1](decltype((x)) y) {
-- decltype((x)) z = x; // OK, y has type int&, z has type int const&
-- // FIXME We don't handle nested lambdas yet?
-- //static_assert(is_same<int&, decltype((y))>);
-- static_assert(is_same<const int&, decltype((z))>);
-- };
-- };
--
-- [x=1](decltype((x)) y) {
-- decltype((x)) z = x;
-- static_assert(is_same<int&, decltype((y))>);
-- static_assert(is_same<const int&, decltype((z))>);
-- };
--}
--
--void
--ok ()
--{
-- auto counter1 = [j=0]() mutable -> decltype(j) {
-- static_assert(is_same<int&, decltype((j))>);
-- return j++;
-- };
--
-- auto l = [j=0]() -> decltype(j) {
-- static_assert(is_same<const int&, decltype((j))>);
-- return j;
-- };
--
-- int y;
-- [=] -> decltype((y)) {
-- return y;
-- };
--}
--
--void
--foo ()
--{
-- int x = [x](int y[sizeof x]){return sizeof x;}(0);
--}
-diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope2.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope2.C
-deleted file mode 100644
-index 6b55e5fe5134..000000000000
---- a/gcc/testsuite/g++.dg/cpp23/lambda-scope2.C
-+++ /dev/null
-@@ -1,217 +0,0 @@
--// P2036R3 - Change scope of lambda trailing-return-type
--// PR c++/102610
--// { dg-do compile { target c++23 } }
--// From LLVM's test/SemaCXX/lambda-capture-type-deduction.cpp
--
--template <typename T, typename U>
--constexpr bool is_same = false;
--
--template <typename T>
--constexpr bool is_same<T, T> = true;
--
--void
--f ()
--{
-- int y;
--
-- static_assert(is_same<const int &,
-- decltype([x = 1] -> decltype((x)) { return x; }())>);
--
-- static_assert(is_same<int &,
-- decltype([x = 1] mutable -> decltype((x)) { return x; }())>);
--
-- static_assert(is_same<const int &,
-- decltype([=] -> decltype((y)) { return y; }())>);
--
-- static_assert(is_same<int &,
-- decltype([=] mutable -> decltype((y)) { return y; }())>);
--
-- // Clang++ rejects this one, though the only difference is the extra (),
-- // and without the () the result is correct, as demonstrated above.
-- static_assert(is_same<const int &,
-- decltype([=]() -> decltype((y)) { return y; }())>);
--
-- static_assert(is_same<int &,
-- decltype([=]() mutable -> decltype((y)) { return y; }())>);
--
-- static_assert(is_same<const int &,
-- decltype([y] -> decltype((y)) { return y; }())>);
--
-- static_assert(is_same<int &,
-- decltype([y] mutable -> decltype((y)) { return y; }())>);
--
--
-- auto ref = [&x = y](
-- decltype([&](decltype(x)) { return 0; }) y) {
-- return x;
-- };
--}
--
--void
--nested ()
--{
-- int x, y, z;
-- (void)[&](
-- decltype([&](
-- decltype([=](
-- decltype([&](
-- decltype([&](decltype(x)) {})) {})) {})) {})){};
--
-- (void)[&](
-- decltype([&](
-- decltype([&](
-- decltype([&](
-- decltype([&](decltype(y)) {})) {})) {})) {})){};
--
-- (void)[=](
-- decltype([=](
-- decltype([=](
-- decltype([=](
-- decltype([&]<decltype(z)> {})) {})) {})) {})){};
--}
--
--void
--test_noexcept ()
--{
-- int y;
--
-- static_assert(noexcept([x = 1] noexcept(is_same<const int &, decltype((x))>) {}()));
-- static_assert(noexcept([x = 1] mutable noexcept(is_same<int &, decltype((x))>) {}()));
-- static_assert(noexcept([y] noexcept(is_same<const int &, decltype((y))>) {}()));
-- static_assert(noexcept([y] mutable noexcept(is_same<int &, decltype((y))>) {}()));
-- static_assert(noexcept([=] noexcept(is_same<const int &, decltype((y))>) {}()));
-- static_assert(noexcept([=] mutable noexcept(is_same<int &, decltype((y))>) {}()));
-- static_assert(noexcept([&] noexcept(is_same<int &, decltype((y))>) {}()));
-- static_assert(noexcept([&] mutable noexcept(is_same<int &, decltype((y))>) {}()));
--}
--
--void
--check_params ()
--{
-- int i = 0;
-- int &j = i;
--
-- [=](decltype((j)) jp, decltype((i)) ip) {
-- static_assert(is_same<const int&, decltype((j))>);
-- static_assert(is_same<const int &, decltype((i))>);
-- static_assert(is_same<int &, decltype((jp))>);
-- static_assert(is_same<int &, decltype((ip))>);
-- };
--
-- [=](decltype((j)) jp, decltype((i)) ip) mutable {
-- static_assert(is_same<int &, decltype((j))>);
-- static_assert(is_same<int &, decltype((i))>);
-- static_assert(is_same<int &, decltype((jp))>);
-- static_assert(is_same<int &, decltype((ip))>);
-- static_assert(is_same<int &, decltype(jp)>);
-- static_assert(is_same<int &, decltype(ip)>);
-- };
--
-- [a = 0](decltype((a)) ap) mutable {
-- static_assert(is_same<int &, decltype((a))>);
-- static_assert(is_same<int, decltype(a)>);
-- static_assert(is_same<int &, decltype(ap)>);
-- decltype(a) x;
-- decltype((a)) y = x;
-- static_assert(is_same<int &, decltype(y)>);
-- };
--
-- [a = 0](decltype((a)) ap) {
-- static_assert(is_same<const int &, decltype((a))>);
-- static_assert(is_same<int, decltype(a)>);
-- static_assert(is_same<int&, decltype((ap))>);
-- decltype(a) x;
-- decltype((a)) y = x;
-- static_assert(is_same<const int &, decltype(y)>);
-- };
--
-- int a;
-- [a](decltype((a)) ap) mutable {
-- static_assert(is_same<int &, decltype((a))>);
-- static_assert(is_same<int, decltype(a)>);
-- static_assert(is_same<int &, decltype(ap)>);
-- decltype(a) x;
-- decltype((a)) y = x;
-- static_assert(is_same<int &, decltype(y)>);
-- };
--
-- [a](decltype((a)) ap) {
-- static_assert(is_same<const int &, decltype((a))>);
-- static_assert(is_same<int, decltype(a)>);
-- static_assert(is_same<int&, decltype((ap))>);
-- decltype(a) x;
-- decltype((a)) y = x;
-- static_assert(is_same<const int &, decltype(y)>);
-- };
--}
--
--template <typename T>
--void
--check_params_tpl ()
--{
-- T i = 0;
-- T &j = i;
-- (void)[=](decltype((j)) jp, decltype((i)) ip) {
-- static_assert(is_same<const int&, decltype((j))>);
-- static_assert(is_same<const int &, decltype((i))>);
-- // In these two, clang++ produces 'const int&'. Why, when it's
-- // the same as in check_params, just not a template?
-- static_assert(is_same<int &, decltype((jp))>);
-- static_assert(is_same<int &, decltype((ip))>);
-- };
--
-- (void)[=](decltype((j)) jp, decltype((i)) ip) mutable {
-- static_assert(is_same<int &, decltype((j))>);
-- static_assert(is_same<int &, decltype((i))>);
-- static_assert(is_same<int &, decltype((jp))>);
-- static_assert(is_same<int &, decltype((ip))>);
-- static_assert(is_same<int &, decltype(jp)>);
-- static_assert(is_same<int &, decltype(ip)>);
-- };
--
-- (void)[a = 0](decltype((a)) ap) mutable {
-- static_assert(is_same<int &, decltype((a))>);
-- static_assert(is_same<int, decltype(a)>);
-- static_assert(is_same<int &, decltype(ap)>);
-- };
-- (void)[a = 0](decltype((a)) ap) {
-- static_assert(is_same<const int &, decltype((a))>);
-- static_assert(is_same<int, decltype(a)>);
-- static_assert(is_same<int&, decltype((ap))>);
-- };
--}
--
--template<typename T>
--void
--test_requires ()
--{
-- int x;
--
-- [x = 1]() requires is_same<const int &, decltype((x))> {} ();
-- [x = 1]() mutable requires is_same<int &, decltype((x))> {}
-- ();
-- [x]() requires is_same<const int &, decltype((x))> {} ();
-- [x]() mutable requires is_same<int &, decltype((x))> {}
-- ();
-- [=]() requires is_same<const int &, decltype((x))> {} ();
-- [=]() mutable requires is_same<int &, decltype((x))> {}
-- ();
-- [&]() requires is_same<int &, decltype((x))> {}
-- ();
-- [&]() mutable requires is_same<int &, decltype((x))> {}
-- ();
-- [&x]() requires is_same<int &, decltype((x))> {}
-- ();
-- [&x]() mutable requires is_same<int &, decltype((x))> {}
-- ();
--
-- [x = 1]() requires is_same<const int &, decltype((x))> {} ();
-- [x = 1]() mutable requires is_same<int &, decltype((x))> {} ();
--}
--
--void
--use ()
--{
-- test_requires<int>();
-- check_params_tpl<int>();
--}
-diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope3.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope3.C
-deleted file mode 100644
-index 697fdaae0955..000000000000
---- a/gcc/testsuite/g++.dg/cpp23/lambda-scope3.C
-+++ /dev/null
-@@ -1,44 +0,0 @@
--// P2036R3 - Change scope of lambda trailing-return-type
--// PR c++/102610
--// { dg-do compile { target c++17 } }
--
--template <typename T>
--inline constexpr auto
--equal1 (T &&t)
--{
-- return [t = 3](const auto& obj) -> decltype(obj == t)
-- {
-- return obj == t;
-- };
--}
--
--template <typename T>
--inline constexpr auto
--equal2 (T &&t)
--{
-- return [t = t](const auto& obj) -> decltype(obj == t)
-- {
-- return obj == t;
-- };
--}
--
--template <typename T>
--inline constexpr auto
--equal3 (T &&t)
--{
-- return [t = 4](const auto& obj) -> decltype(obj == t)
-- {
-- return obj == t;
-- };
--}
--
--void
--g ()
--{
-- constexpr auto l1 = equal1 (5);
-- static_assert (l1 (3));
-- constexpr auto l2 = equal2 (3);
-- static_assert (l2 (3));
-- constexpr auto l3 = equal3 (2);
-- static_assert (l3 (4));
--}
-diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope4.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope4.C
-deleted file mode 100644
-index 9442db3f9567..000000000000
---- a/gcc/testsuite/g++.dg/cpp23/lambda-scope4.C
-+++ /dev/null
-@@ -1,41 +0,0 @@
--// P2036R3 - Change scope of lambda trailing-return-type
--// PR c++/102610
--// { dg-do compile { target c++17 } }
--
--struct integral_constant {
-- using type = integral_constant;
--};
--template <bool> using __bool_constant = integral_constant;
--template <typename _Fn, typename>
--struct is_invocable : __bool_constant<true> {};
--int forward() { return 42; }
--template <typename...> class tuple;
--struct plus {
-- template <typename _Tp, typename _Up>
-- constexpr auto operator()(_Tp __t, _Up __u) {
-- return __t > __u;
-- }
--};
--constexpr auto equal() {
-- int t = 0;
-- return [t = 3](auto obj) -> decltype(obj == t) { return t; };
--}
--template <typename> struct is_tuple_invocable;
--template <typename... Ts> struct is_tuple_invocable<tuple<Ts...>> {
-- using type = typename is_invocable<Ts...>::type;
--};
--namespace detail {
--template <typename F, typename Tail, typename... T>
--constexpr auto compose(__bool_constant<true>, F f, Tail tail, T... objs) {
-- return f(tail(objs...));
--}
--} // namespace detail
--template <typename F, typename... Fs> constexpr auto compose(F f, Fs... fs) {
-- return [f, tail(fs...)](auto... objs) {
-- auto unitail =
-- typename is_tuple_invocable<tuple<decltype(objs)...>>::type{};
-- return detail::compose(unitail, f, tail, objs...);
-- };
--}
--template <auto> constexpr auto eq = equal();
--static_assert(compose(eq<3>, plus{})(1, 2));
-diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope4b.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope4b.C
-deleted file mode 100644
-index 6a9e6ec5e9d7..000000000000
---- a/gcc/testsuite/g++.dg/cpp23/lambda-scope4b.C
-+++ /dev/null
-@@ -1,42 +0,0 @@
--// P2036R3 - Change scope of lambda trailing-return-type
--// PR c++/102610
--// { dg-do compile { target c++17 } }
--
--struct integral_constant {
-- using type = integral_constant;
--};
--template <bool> using __bool_constant = integral_constant;
--template <typename _Fn, typename>
--struct is_invocable : __bool_constant<true> {};
--int forward() { return 42; }
--template <typename...> class tuple;
--struct plus {
-- template <typename _Tp, typename _Up>
-- constexpr auto operator()(_Tp __t, _Up __u) {
-- return __t > __u;
-- }
--};
--constexpr auto equal() {
-- int t = 0;
-- return [t = 3](auto obj) -> decltype(obj == t) { return t; };
--}
--template <typename> struct is_tuple_invocable;
--template <typename... Ts> struct is_tuple_invocable<tuple<Ts...>> {
-- using type = typename is_invocable<Ts...>::type;
--};
--namespace detail {
--template <typename F, typename Tail, typename... T>
--constexpr auto compose(__bool_constant<true>, F f, Tail tail, T... objs) {
-- return f(tail(objs...));
--}
--} // namespace detail
--template <typename F, typename... Fs>
--constexpr auto compose(F f, Fs... fs) {
-- return [f, tail(fs...)](auto... objs) -> decltype (detail::compose(typename is_tuple_invocable<tuple<decltype(objs)...>>::type{}, f, tail, objs...)) {
-- auto unitail =
-- typename is_tuple_invocable<tuple<decltype(objs)...>>::type{};
-- return detail::compose(unitail, f, tail, objs...);
-- };
--}
--template <auto> constexpr auto eq = equal();
--static_assert(compose(eq<3>, plus{})(1, 2));
-diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope5.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope5.C
-deleted file mode 100644
-index 48b5ef34c9e9..000000000000
---- a/gcc/testsuite/g++.dg/cpp23/lambda-scope5.C
-+++ /dev/null
-@@ -1,22 +0,0 @@
--// P2036R3 - Change scope of lambda trailing-return-type
--// PR c++/102610
--// { dg-do compile { target c++17 } }
--
--constexpr auto equal() {
-- int t = 0;
-- return [t](auto obj) { return obj; };
--}
--template <typename F>
--constexpr int bar (F) {
-- return 42;
--}
--
--template <typename F>
--constexpr auto compose(F f)
--{
-- return [f=f](int i) -> decltype(bar (f)) {
-- return 42;
-- };
--}
--template <auto> constexpr auto eq = equal();
--static_assert(compose(eq<3>)(1));
-diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope6.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope6.C
-deleted file mode 100644
-index 720c1ec6cba2..000000000000
---- a/gcc/testsuite/g++.dg/cpp23/lambda-scope6.C
-+++ /dev/null
-@@ -1,20 +0,0 @@
--// P2036R3 - Change scope of lambda trailing-return-type
--// PR c++/102610
--// { dg-do compile { target c++23 } }
--
--void
--g ()
--{
-- /* It looks like this shouldn't work but [expr.prim.lambda.closure]/6
-- says "Otherwise, it is a non-static member function or member function
-- template that is declared const if and only if the lambda-expression's
-- parameter-declaration-clause is not followed by mutable and the
-- lambda-declarator does not contain an explicit object parameter." */
-- auto counter = [j=0](this auto const& self) -> decltype(j) {
-- return j++;
-- };
--
-- auto counter2 = [j=0](this auto& self) -> decltype(j) {
-- return j++;
-- };
--}
-diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope7.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope7.C
-deleted file mode 100644
-index 6db39bd8692c..000000000000
---- a/gcc/testsuite/g++.dg/cpp23/lambda-scope7.C
-+++ /dev/null
-@@ -1,20 +0,0 @@
--// P2036R3 - Change scope of lambda trailing-return-type
--// PR c++/102610
--// { dg-do compile { target c++14_only } }
--
--template <typename T>
--inline constexpr auto
--equal1 (T &&t)
--{
-- return [t = 3](const auto& obj) -> decltype(obj == t)
-- {
-- return obj == t;
-- };
--}
--
--void
--g ()
--{
-- constexpr auto l1 = equal1 (5); // { dg-error "not literal" }
-- static_assert (l1 (3), ""); // { dg-error "non-constant|non-.constexpr." }
--}
-diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope8.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope8.C
-deleted file mode 100644
-index 87ad47323809..000000000000
---- a/gcc/testsuite/g++.dg/cpp23/lambda-scope8.C
-+++ /dev/null
-@@ -1,25 +0,0 @@
--// P2036R3 - Change scope of lambda trailing-return-type
--// PR c++/102610
--// { dg-do compile { target c++23 } }
--// { dg-options "-Wshadow" }
--
--void
--bad ()
--{
-- [x=1](int x){}; // { dg-error "declared as a capture" }
-- // { dg-warning "shadows a lambda capture" "" { target *-*-* } .-1 }
-- [x=1]{ int x; }; // { dg-error "shadows a parameter" }
--
-- auto f = [i = 5] () { int i; return 0; }; // { dg-error "shadows a parameter" }
-- auto f2 = [i = 5] <int N> () { int i; return 0; }; // { dg-error "shadows a parameter" }
--
-- // [expr.prim.lambda.capture]/5
-- int x = 0;
-- auto g = [x](int x) { return 0; }; // { dg-error "declared as a capture" }
-- // { dg-warning "shadows a lambda capture" "" { target *-*-* } .-1 }
-- auto h = [y = 0]<typename y>(y) { return 0; }; // { dg-error "shadows template parameter" }
--
-- auto l2 = [i = 0, j = i]() -> decltype(i) { // { dg-error "not declared in this scope" }
-- return i;
-- };
--}
-diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope9.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope9.C
-deleted file mode 100644
-index b75e97cb89d7..000000000000
---- a/gcc/testsuite/g++.dg/cpp23/lambda-scope9.C
-+++ /dev/null
-@@ -1,15 +0,0 @@
--// P2036R3 - Change scope of lambda trailing-return-type
--// PR c++/102610
--// { dg-do compile { target c++23 } }
--// { dg-options "" }
--
--constexpr char f(auto a) { return 'a'; }
--
--namespace A {
-- int i = 42;
-- template<char X = f([i]{})> void g() { } // { dg-warning "capture of variable .A::i. with non-automatic storage duration" }
--}
--
--namespace B {
-- void call() { A::g(); }
--}
-diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-19.C b/gcc/testsuite/g++.dg/warn/Wshadow-19.C
-index d0b8dba8549f..030aefd153d8 100644
---- a/gcc/testsuite/g++.dg/warn/Wshadow-19.C
-+++ b/gcc/testsuite/g++.dg/warn/Wshadow-19.C
-@@ -1,5 +1,5 @@
- // { dg-do compile }
--// { dg-options "-Wshadow -Wpedantic" }
-+// { dg-options "-Wshadow" }
-
- void
- foo (int x)
-@@ -10,7 +10,7 @@ foo (int x)
- extern int y; // { dg-warning "declaration of 'y' shadows a previous local" }
- }
- #if __cplusplus >= 201102L
-- auto fn = [x] () { extern int x; return 0; }; // { dg-warning "declaration of 'int x' shadows a parameter" "" { target c++11 } }
-+ auto fn = [x] () { extern int x; return 0; }; // { dg-warning "declaration of 'x' shadows a lambda capture" "" { target c++11 } }
- #endif
- }
-
-diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-6.C b/gcc/testsuite/g++.dg/warn/Wshadow-6.C
-index 7b44d52781aa..1d8d21b9b6f1 100644
---- a/gcc/testsuite/g++.dg/warn/Wshadow-6.C
-+++ b/gcc/testsuite/g++.dg/warn/Wshadow-6.C
-@@ -33,8 +33,8 @@ void f2(struct S i, int j) {
-
- void f3(int i) {
- [=]{
-- int j = i; // { dg-message "previously declared here" }
-- int i; // { dg-error "shadows a parameter" }
-+ int j = i; // { dg-message "shadowed declaration" }
-+ int i; // { dg-warning "shadows a lambda capture" }
- i = 1;
- };
- }
-@@ -42,8 +42,8 @@ void f3(int i) {
- template <class T>
- void f4(int i) {
- [=]{
-- int j = i; // { dg-message "previously declared here" }
-- int i; // { dg-error "shadows a parameter" }
-+ int j = i; // { dg-message "shadowed declaration" }
-+ int i; // { dg-warning "shadows a " }
- i = 1;
- };
- }
-
-base-commit: 2be801a805c6cca08aaa33fd387dcc7bd4fe8aac
---
-2.51.0
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index ff3cbb8..a3bc300 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,7 @@
12 ????
- 86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+ - 87_all_PR121553-Revert-c-P2036R3-Change-scope-of-lambda-trailing-ret.patch
+ 88_all_PR121607-TLS-ICE.patch
11 20 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-20 14:10 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-20 14:10 UTC (permalink / raw
To: gentoo-commits
commit: 7839f4bfafb5241ffa4dac16d088572965626173
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 20 14:10:04 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Aug 20 14:10:04 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=7839f4bf
16.0.0: fix TLS ICE
Bug: https://gcc.gnu.org/PR121607
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch | 173 ++++++++++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 174 insertions(+)
diff --git a/16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch b/16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch
new file mode 100644
index 0000000..a156cb1
--- /dev/null
+++ b/16.0.0/gentoo/88_all_PR121607-TLS-ICE.patch
@@ -0,0 +1,173 @@
+From e22c8a8cd7aef8938722e0ea6719dd1298d48812 Mon Sep 17 00:00:00 2001
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Wed, 20 Aug 2025 06:59:48 -0700
+Subject: [PATCH] x86-64: Emit the TLS call after NOTE_INSN_BASIC_BLOCK
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+For a basic block with only a label:
+
+(code_label 78 11 77 3 14 (nil) [1 uses])
+(note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
+
+emit the TLS call after NOTE_INSN_BASIC_BLOCK, instead of before
+NOTE_INSN_BASIC_BLOCK, to avoid
+
+x.c: In function ‘aout_16_write_syms’:
+x.c:54:1: error: NOTE_INSN_BASIC_BLOCK is missing for block 3
+ 54 | }
+ | ^
+x.c:54:1: error: NOTE_INSN_BASIC_BLOCK 77 in middle of basic block 3
+during RTL pass: x86_cse
+x.c:54:1: internal compiler error: verify_flow_info failed
+
+gcc/
+
+ PR target/121607
+ * config/i386/i386-features.cc (ix86_emit_tls_call): Emit the
+ TLS call after NOTE_INSN_BASIC_BLOCK in a basic block with only
+ a label.
+
+gcc/testsuite/
+
+ PR target/121607
+ * gcc.target/i386/pr121607-1a.c: New test.
+ * gcc.target/i386/pr121607-1b.c: Likewise.
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+---
+ gcc/config/i386/i386-features.cc | 24 +++++++--
+ gcc/testsuite/gcc.target/i386/pr121607-1a.c | 59 +++++++++++++++++++++
+ gcc/testsuite/gcc.target/i386/pr121607-1b.c | 6 +++
+ 3 files changed, 86 insertions(+), 3 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121607-1a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121607-1b.c
+
+diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
+index 7869ee22b67..514d2a5d378 100644
+--- a/gcc/config/i386/i386-features.cc
++++ b/gcc/config/i386/i386-features.cc
+@@ -3795,7 +3795,18 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
+ while (insn && !NONDEBUG_INSN_P (insn))
+ {
+ if (insn == BB_END (bb))
+- break;
++ {
++ /* This must be a basic block with only a label:
++
++ (code_label 78 11 77 3 14 (nil) [1 uses])
++ (note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
++
++ */
++ gcc_assert (NOTE_P (insn)
++ && NOTE_KIND (insn) == NOTE_INSN_BASIC_BLOCK);
++ insn = NULL;
++ break;
++ }
+ insn = NEXT_INSN (insn);
+ }
+
+@@ -3824,14 +3835,21 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
+
+ if (bitmap_empty_p (live_caller_saved_regs))
+ {
+- if (insn == BB_HEAD (bb) || insn == BB_END (bb))
++ if (insn == BB_HEAD (bb))
+ {
+ *before_p = insn;
+ tls_insn = emit_insn_before (tls_set, insn);
+ }
+ else
+ {
+- insn = PREV_INSN (insn);
++ /* Emit the TLS call after NOTE_INSN_BASIC_BLOCK in a
++ basic block with only a label:
++
++ (code_label 78 11 77 3 14 (nil) [1 uses])
++ (note 77 78 54 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
++
++ */
++ insn = insn ? PREV_INSN (insn) : BB_END (bb);
+ *after_p = insn;
+ tls_insn = emit_insn_after (tls_set, insn);
+ }
+diff --git a/gcc/testsuite/gcc.target/i386/pr121607-1a.c b/gcc/testsuite/gcc.target/i386/pr121607-1a.c
+new file mode 100644
+index 00000000000..4c047068e3a
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121607-1a.c
+@@ -0,0 +1,59 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu -fno-semantic-interposition -fstack-protector" } */
++
++typedef enum
++{
++ bfd_error_invalid_error_code
++} bfd_error_type;
++thread_local bfd_error_type bfd_error;
++int aout_16_write_syms___trans_tmp_1;
++short aout_16_write_syms_g_0_0;
++void xvec_0 (long, void *);
++
++typedef struct
++{
++ int output_section;
++} asection;
++
++void bfd_asymbol_section ();
++
++struct pdp11_external_nlist
++{
++ char e_desc[2];
++ char e_type[1];
++ char e_ovly[10];
++} translate_to_native_sym_flags (struct pdp11_external_nlist *sym_pointer)
++{
++ asection *sec;
++ sym_pointer->e_type[0] &= 5;
++ bfd_asymbol_section ();
++ if (sec == 0)
++ {
++ bfd_error_type error_tag;
++ bfd_error = error_tag;
++ }
++ if (sec->output_section)
++ {
++ bfd_error_type error_tag;
++ bfd_error = error_tag;
++ }
++}
++
++bool
++aout_16_write_syms (void *abfd)
++{
++ for (; aout_16_write_syms___trans_tmp_1;)
++ {
++ struct pdp11_external_nlist nsp;
++ if (abfd)
++ {
++ xvec_0 (aout_16_write_syms_g_0_0, nsp.e_desc);
++ nsp.e_ovly[0] = 0;
++ }
++ else
++ nsp.e_type[0] = 0;
++ translate_to_native_sym_flags (&nsp);
++ }
++}
++
++/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 2 { target { ! ia32 } } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr121607-1b.c b/gcc/testsuite/gcc.target/i386/pr121607-1b.c
+new file mode 100644
+index 00000000000..366306702c7
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121607-1b.c
+@@ -0,0 +1,6 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu2 -fno-semantic-interposition -fstack-protector" } */
++
++#include "pr121607-1a.c"
++
++/* { dg-final { scan-assembler-times "call\[ \t\]\\*bfd_error@TLSCALL\\(%(?:r|e)ax\\)" 2 { target { ! ia32 } } } } */
+--
+2.50.1
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 45143c9..ff3cbb8 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,7 @@
12 ????
- 86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+ + 88_all_PR121607-TLS-ICE.patch
11 20 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-20 1:16 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-20 1:16 UTC (permalink / raw
To: gentoo-commits
commit: f65bd49e153e44a12a1462ec76be031e71bfa0c3
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 20 01:16:33 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Aug 20 01:16:33 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=f65bd49e
16.0.0: drop patch merged upstream
Signed-off-by: Sam James <sam <AT> gentoo.org>
...he-TLS-call-before-all-FLAGS_REG-setting-.patch | 620 ---------------------
16.0.0/gentoo/README.history | 4 +
2 files changed, 4 insertions(+), 620 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
deleted file mode 100644
index 9f7908a..0000000
--- a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+++ /dev/null
@@ -1,620 +0,0 @@
-From 43a0428a61f17969c8e0bf4ede1935b5655100c2 Mon Sep 17 00:00:00 2001
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Sat, 16 Aug 2025 14:04:33 -0700
-Subject: [PATCH v4] x86: Place the TLS call before all register setting BBs
-
-We can't place a TLS call before a conditional jump in a basic block like
-
-(code_label 13 11 14 4 2 (nil) [1 uses])
-(note 14 13 16 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
-(jump_insn 16 14 17 4 (set (pc)
- (if_then_else (le (reg:CCNO 17 flags)
- (const_int 0 [0]))
- (label_ref 27)
- (pc))) "x.c":10:21 discrim 1 1462 {*jcc}
- (expr_list:REG_DEAD (reg:CCNO 17 flags)
- (int_list:REG_BR_PROB 628353713 (nil)))
- -> 27)
-
-since the TLS call will clobber flags register nor place a TLS call in a
-basic block if any live caller-saved registers aren't dead at the end of
-the basic block:
-
-;; live in 6 [bp] 7 [sp] 16 [argp] 17 [flags] 19 [frame] 104
-;; live gen 0 [ax] 102 106 108 116 117 118 120
-;; live kill 5 [di]
-
-Instead, we should place such call before all register setting basic
-blocks which dominate the current basic block.
-
-Keep track the replaced GNU and GNU2 TLS instructions. Use these info to
-place the __tls_get_addr call and mark FLAGS register as dead.
-
-gcc/
-
- PR target/121572
- * config/i386/i386-features.cc (replace_tls_call): Add a bitmap
- argument and put the updated TLS instruction in the bitmap.
- (ix86_get_dominator_for_reg): New.
- (ix86_check_flags_reg): Likewise.
- (ix86_emit_tls_call): Likewise.
- (ix86_place_single_tls_call): Add 2 bitmap arguments for updated
- GNU and GNU2 TLS instructions. Call ix86_emit_tls_call to emit
- TLS instruction. Correct debug dump for before instruction.
-
-gcc/testsuite/
-
- PR target/121572
- * gcc.target/i386/pr121572-1a.c: New test.
- * gcc.target/i386/pr121572-1b.c: Likewise.
- * gcc.target/i386/pr121572-2a.c: Likewise.
- * gcc.target/i386/pr121572-2b.c: Likewise.
-
-Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
----
- gcc/config/i386/i386-features.cc | 334 +++++++++++++-------
- gcc/testsuite/gcc.target/i386/pr121572-1a.c | 41 +++
- gcc/testsuite/gcc.target/i386/pr121572-1b.c | 18 ++
- gcc/testsuite/gcc.target/i386/pr121572-2a.c | 39 +++
- gcc/testsuite/gcc.target/i386/pr121572-2b.c | 6 +
- 5 files changed, 332 insertions(+), 106 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1b.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2b.c
-
-diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index f0bdc5c1880..7869ee22b67 100644
---- a/gcc/config/i386/i386-features.cc
-+++ b/gcc/config/i386/i386-features.cc
-@@ -3684,10 +3684,12 @@ ix86_broadcast_inner (rtx op, machine_mode mode,
- return op;
- }
-
--/* Replace CALL instruction in TLS_CALL_INSNS with SET from SRC. */
-+/* Replace CALL instruction in TLS_CALL_INSNS with SET from SRC and
-+ put the updated instruction in UPDATED_TLS_INSNS. */
-
- static void
--replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
-+replace_tls_call (rtx src, auto_bitmap &tls_call_insns,
-+ auto_bitmap &updated_tls_insns)
- {
- bitmap_iterator bi;
- unsigned int id;
-@@ -3716,6 +3718,9 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
- if (recog_memoized (set_insn) < 0)
- gcc_unreachable ();
-
-+ /* Put SET_INSN in UPDATED_TLS_INSNS. */
-+ bitmap_set_bit (updated_tls_insns, INSN_UID (set_insn));
-+
- if (dump_file)
- {
- fprintf (dump_file, "\nReplace:\n\n");
-@@ -3732,15 +3737,216 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
- }
- }
-
-+/* Return the basic block which dominates all basic blocks which set
-+ hard register REGNO used in basic block BB. */
-+
-+static basic_block
-+ix86_get_dominator_for_reg (unsigned int regno, basic_block bb)
-+{
-+ basic_block set_bb;
-+ auto_bitmap set_bbs;
-+
-+ /* Get all BBs which set REGNO and dominate the current BB from all
-+ DEFs of REGNO. */
-+ for (df_ref def = DF_REG_DEF_CHAIN (regno);
-+ def;
-+ def = DF_REF_NEXT_REG (def))
-+ if (!DF_REF_IS_ARTIFICIAL (def)
-+ && !DF_REF_FLAGS_IS_SET (def, DF_REF_MAY_CLOBBER)
-+ && !DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER))
-+ {
-+ set_bb = DF_REF_BB (def);
-+ if (dominated_by_p (CDI_DOMINATORS, bb, set_bb))
-+ bitmap_set_bit (set_bbs, set_bb->index);
-+ }
-+
-+ bb = nearest_common_dominator_for_set (CDI_DOMINATORS, set_bbs);
-+ return bb;
-+}
-+
-+/* Mark FLAGS register as live in DATA, a bitmap of live caller-saved
-+ registers, if DEST is FLAGS register. */
-+
-+static void
-+ix86_check_flags_reg (rtx dest, const_rtx, void *data)
-+{
-+ auto_bitmap *live_caller_saved_regs = (auto_bitmap *) data;
-+ if (REG_P (dest) && REGNO (dest) == FLAGS_REG)
-+ bitmap_set_bit (*live_caller_saved_regs, FLAGS_REG);
-+}
-+
-+/* Emit a TLS_SET instruction of KIND in basic block BB. Store the
-+ insertion point in *BEFORE_P for emit_insn_before or in *AFTER_P
-+ for emit_insn_after. UPDATED_GNU_TLS_INSNS contains instructions
-+ which replace the GNU TLS instructions. UPDATED_GNU2_TLS_INSNS
-+ contains instructions which replace the GNU2 TLS instructions. */
-+
-+static rtx_insn *
-+ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
-+ rtx_insn **before_p, rtx_insn **after_p,
-+ auto_bitmap &updated_gnu_tls_insns,
-+ auto_bitmap &updated_gnu2_tls_insns)
-+{
-+ rtx_insn *tls_insn;
-+
-+ do
-+ {
-+ rtx_insn *insn = BB_HEAD (bb);
-+ while (insn && !NONDEBUG_INSN_P (insn))
-+ {
-+ if (insn == BB_END (bb))
-+ break;
-+ insn = NEXT_INSN (insn);
-+ }
-+
-+ /* TLS_GD and TLS_LD_BASE instructions are normal functions which
-+ clobber caller-saved registers. TLSDESC instructions only
-+ clobber FLAGS. If any registers clobbered by TLS instructions
-+ are live in this basic block, we must insert TLS instructions
-+ after all live registers clobbered are dead. */
-+
-+ auto_bitmap live_caller_saved_regs;
-+ bitmap in = df_live ? DF_LIVE_IN (bb) : DF_LR_IN (bb);
-+
-+ if (bitmap_bit_p (in, FLAGS_REG))
-+ bitmap_set_bit (live_caller_saved_regs, FLAGS_REG);
-+
-+ unsigned int i;
-+
-+ /* Get all live caller-saved registers for TLS_GD and TLS_LD_BASE
-+ instructions. */
-+ if (kind != X86_CSE_TLSDESC)
-+ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-+ if (call_used_regs[i]
-+ && !fixed_regs[i]
-+ && bitmap_bit_p (in, i))
-+ bitmap_set_bit (live_caller_saved_regs, i);
-+
-+ if (bitmap_empty_p (live_caller_saved_regs))
-+ {
-+ if (insn == BB_HEAD (bb) || insn == BB_END (bb))
-+ {
-+ *before_p = insn;
-+ tls_insn = emit_insn_before (tls_set, insn);
-+ }
-+ else
-+ {
-+ insn = PREV_INSN (insn);
-+ *after_p = insn;
-+ tls_insn = emit_insn_after (tls_set, insn);
-+ }
-+ return tls_insn;
-+ }
-+
-+ bool repeat = false;
-+
-+ /* Search for REG_DEAD notes in this basic block. */
-+ FOR_BB_INSNS (bb, insn)
-+ {
-+ if (!NONDEBUG_INSN_P (insn))
-+ continue;
-+
-+ /* NB: Conditional jump is the only instruction which reads
-+ flags register and changes control flow. We can never
-+ place the TLS call after unconditional jump. */
-+ if (JUMP_P (insn))
-+ {
-+ /* This must be a conditional jump. */
-+ rtx label = JUMP_LABEL (insn);
-+ if (label == nullptr
-+ || ANY_RETURN_P (label)
-+ || !(LABEL_P (label) || SYMBOL_REF_P (label)))
-+ gcc_unreachable ();
-+
-+ /* Place the call before all FLAGS_REG setting BBs since
-+ we can't place a call before nor after a conditional
-+ jump. */
-+ bb = ix86_get_dominator_for_reg (FLAGS_REG, bb);
-+
-+ /* Start over again. */
-+ repeat = true;
-+ break;
-+ }
-+
-+ if (bitmap_bit_p (updated_gnu_tls_insns, INSN_UID (insn)))
-+ {
-+ /* Insert the __tls_get_addr call before INSN which
-+ replaces a __tls_get_addr call. */
-+ *before_p = insn;
-+ tls_insn = emit_insn_before (tls_set, insn);
-+ return tls_insn;
-+ }
-+
-+ if (bitmap_bit_p (updated_gnu2_tls_insns, INSN_UID (insn)))
-+ {
-+ /* Mark FLAGS register as dead since FLAGS register
-+ would be clobbered by the GNU2 TLS instruction. */
-+ bitmap_clear_bit (live_caller_saved_regs, FLAGS_REG);
-+ continue;
-+ }
-+
-+ /* Check if FLAGS register is live. */
-+ note_stores (insn, ix86_check_flags_reg,
-+ &live_caller_saved_regs);
-+
-+ rtx link;
-+ for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
-+ if (REG_NOTE_KIND (link) == REG_DEAD
-+ && REG_P (XEXP (link, 0)))
-+ {
-+ /* Mark the live caller-saved register as dead. */
-+ for (i = REGNO (XEXP (link, 0));
-+ i < END_REGNO (XEXP (link, 0));
-+ i++)
-+ if (i < FIRST_PSEUDO_REGISTER)
-+ bitmap_clear_bit (live_caller_saved_regs, i);
-+
-+ if (bitmap_empty_p (live_caller_saved_regs))
-+ {
-+ *after_p = insn;
-+ tls_insn = emit_insn_after (tls_set, insn);
-+ return tls_insn;
-+ }
-+ }
-+ }
-+
-+ /* NB: Start over again for conditional jump. */
-+ if (repeat)
-+ continue;
-+
-+ gcc_assert (!bitmap_empty_p (live_caller_saved_regs));
-+
-+ /* If any live caller-saved registers aren't dead at the end of
-+ this basic block, get the basic block which dominates all
-+ basic blocks which set the remaining live registers. */
-+ auto_bitmap set_bbs;
-+ bitmap_iterator bi;
-+ unsigned int id;
-+ EXECUTE_IF_SET_IN_BITMAP (live_caller_saved_regs, 0, id, bi)
-+ {
-+ basic_block set_bb = ix86_get_dominator_for_reg (id, bb);
-+ bitmap_set_bit (set_bbs, set_bb->index);
-+ }
-+ bb = nearest_common_dominator_for_set (CDI_DOMINATORS, set_bbs);
-+ }
-+ while (true);
-+}
-+
- /* Generate a TLS call of KIND with VAL and copy the call result to DEST,
- at entry of the nearest dominator for basic block map BBS, which is in
- the fake loop that contains the whole function, so that there is only
-- a single TLS CALL of KIND with VAL in the whole function. If
-- TLSDESC_SET isn't nullptr, insert it before the TLS call. */
-+ a single TLS CALL of KIND with VAL in the whole function.
-+ UPDATED_GNU_TLS_INSNS contains instructions which replace the GNU TLS
-+ instructions. UPDATED_GNU2_TLS_INSNS contains instructions which
-+ replace the GNU2 TLS instructions. If TLSDESC_SET isn't nullptr,
-+ insert it before the TLS call. */
-
- static void
- ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
-- bitmap bbs, rtx tlsdesc_set = nullptr)
-+ auto_bitmap &bbs,
-+ auto_bitmap &updated_gnu_tls_insns,
-+ auto_bitmap &updated_gnu2_tls_insns,
-+ rtx tlsdesc_set = nullptr)
- {
- basic_block bb = nearest_common_dominator_for_set (CDI_DOMINATORS, bbs);
- while (bb->loop_father->latch
-@@ -3748,17 +3954,6 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
- bb = get_immediate_dominator (CDI_DOMINATORS,
- bb->loop_father->header);
-
-- rtx_insn *insn = BB_HEAD (bb);
-- while (insn && !NONDEBUG_INSN_P (insn))
-- {
-- if (insn == BB_END (bb))
-- {
-- insn = NULL;
-- break;
-- }
-- insn = NEXT_INSN (insn);
-- }
--
- rtx rax = nullptr, rdi;
- rtx eqv = nullptr;
- rtx caddr;
-@@ -3766,7 +3961,6 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
- rtx clob;
- rtx symbol;
- rtx tls;
-- rtx_insn *tls_insn;
-
- switch (kind)
- {
-@@ -3808,94 +4002,13 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
- gcc_unreachable ();
- }
-
-+ /* Emit the TLS CALL insn. */
- rtx_insn *before = nullptr;
- rtx_insn *after = nullptr;
-- if (insn == BB_HEAD (bb))
-- before = insn;
-- else
-- after = insn ? PREV_INSN (insn) : BB_END (bb);
--
-- /* TLS_GD and TLS_LD_BASE instructions are normal functions which
-- clobber caller-saved registers. TLSDESC instructions only clobber
-- FLAGS. If any registers clobbered by TLS instructions are live
-- in this basic block, we must insert TLS instructions after all live
-- registers clobbered are dead. */
--
-- auto_bitmap live_caller_saved_regs;
-- bitmap in = df_live ? DF_LIVE_IN (bb) : DF_LR_IN (bb);
--
-- bool flags_live_p = bitmap_bit_p (in, FLAGS_REG);
--
-- unsigned int i;
--
-- /* Get all live caller-saved registers for TLS_GD and TLS_LD_BASE
-- instructions. */
-- if (kind != X86_CSE_TLSDESC)
-- for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-- if (call_used_regs[i]
-- && !fixed_regs[i]
-- && bitmap_bit_p (in, i))
-- bitmap_set_bit (live_caller_saved_regs, i);
--
-- if (!bitmap_empty_p (live_caller_saved_regs))
-- {
-- /* Search for REG_DEAD notes in this basic block. */
-- FOR_BB_INSNS (bb, insn)
-- {
-- if (!NONDEBUG_INSN_P (insn))
-- continue;
--
-- /* Check if FLAGS register is live. */
-- set = single_set (insn);
-- if (set)
-- {
-- rtx dest = SET_DEST (set);
-- if (REG_P (dest) && REGNO (dest) == FLAGS_REG)
-- flags_live_p = true;
-- }
--
-- rtx link;
-- for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
-- if (REG_NOTE_KIND (link) == REG_DEAD
-- && REG_P (XEXP (link, 0)))
-- {
-- /* Mark the live caller-saved register as dead. */
-- for (i = REGNO (XEXP (link, 0));
-- i < END_REGNO (XEXP (link, 0));
-- i++)
-- bitmap_clear_bit (live_caller_saved_regs, i);
--
-- /* Check if FLAGS register is dead. */
-- if (REGNO (XEXP (link, 0)) == FLAGS_REG)
-- flags_live_p = false;
--
-- if (bitmap_empty_p (live_caller_saved_regs))
-- {
-- /* All live caller-saved registers are dead after
-- this instruction. Since TLS instructions
-- clobber FLAGS register, it must be dead where
-- the TLS will be inserted after. */
-- if (flags_live_p)
-- gcc_unreachable ();
-- after = insn;
-- goto insert_after;
-- }
-- }
-- }
--
-- /* All live caller-saved registers should be dead at the end
-- of this basic block. */
-- gcc_unreachable ();
-- }
--
-- /* Emit the TLS CALL insn. */
-- if (after)
-- {
--insert_after:
-- tls_insn = emit_insn_after (tls, after);
-- }
-- else
-- tls_insn = emit_insn_before (tls, before);
-+ rtx_insn *tls_insn = ix86_emit_tls_call (tls, kind, bb, &before,
-+ &after,
-+ updated_gnu_tls_insns,
-+ updated_gnu2_tls_insns);
-
- rtx_insn *tlsdesc_insn = nullptr;
- if (tlsdesc_set)
-@@ -3936,7 +4049,7 @@ insert_after:
- print_rtl_single (dump_file, tlsdesc_insn);
- print_rtl_single (dump_file, tls_insn);
- fprintf (dump_file, "\nbefore:\n\n");
-- print_rtl_single (dump_file, insn);
-+ print_rtl_single (dump_file, before);
- fprintf (dump_file, "\n");
- }
- }
-@@ -4213,6 +4326,8 @@ pass_x86_cse::x86_cse (void)
- basic_block bb;
- rtx_insn *insn;
- unsigned int i;
-+ auto_bitmap updated_gnu_tls_insns;
-+ auto_bitmap updated_gnu2_tls_insns;
-
- df_set_flags (DF_DEFER_INSN_RESCAN);
-
-@@ -4333,7 +4448,10 @@ pass_x86_cse::x86_cse (void)
- case X86_CSE_TLS_LD_BASE:
- case X86_CSE_TLSDESC:
- broadcast_reg = gen_reg_rtx (load->mode);
-- replace_tls_call (broadcast_reg, load->insns);
-+ replace_tls_call (broadcast_reg, load->insns,
-+ (load->kind == X86_CSE_TLSDESC
-+ ? updated_gnu2_tls_insns
-+ : updated_gnu_tls_insns));
- load->broadcast_reg = broadcast_reg;
- break;
-
-@@ -4399,6 +4517,8 @@ pass_x86_cse::x86_cse (void)
- load->val,
- load->kind,
- load->bbs,
-+ updated_gnu_tls_insns,
-+ updated_gnu2_tls_insns,
- PATTERN (load->def_insn));
- break;
- case X86_CSE_VEC_DUP:
-@@ -4442,7 +4562,9 @@ pass_x86_cse::x86_cse (void)
- ix86_place_single_tls_call (load->broadcast_reg,
- load->val,
- load->kind,
-- load->bbs);
-+ load->bbs,
-+ updated_gnu_tls_insns,
-+ updated_gnu2_tls_insns);
- break;
- case X86_CSE_CONST0_VECTOR:
- case X86_CSE_CONSTM1_VECTOR:
-diff --git a/gcc/testsuite/gcc.target/i386/pr121572-1a.c b/gcc/testsuite/gcc.target/i386/pr121572-1a.c
-new file mode 100644
-index 00000000000..270d8ff5cb6
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121572-1a.c
-@@ -0,0 +1,41 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-O0 -fpic -fplt -mtls-dialect=gnu" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
-+
-+/*
-+**bug:
-+**.LFB[0-9]+:
-+**...
-+** leaq tv_cache@tlsld\(%rip\), %rdi
-+** call __tls_get_addr@PLT
-+** movl \$-1, %edi
-+** mov[l|q] %[e|r]ax, %[e|r]bx
-+** call val@PLT
-+**...
-+*/
-+
-+extern __thread int tv_cache __attribute__ ((visibility ("hidden")));
-+extern void use_cache (int);
-+extern int val (int v);
-+
-+__attribute__ ((optimize (2)))
-+void
-+bug (void)
-+{
-+ int compared = val (-1);
-+
-+ if (compared == 0 || (compared > 0 && val (2) == 0))
-+ {
-+ __builtin_trap ();
-+ }
-+
-+ if (compared < 0)
-+ {
-+ use_cache (tv_cache);
-+ return;
-+ }
-+
-+ use_cache (tv_cache);
-+ __builtin_trap ();
-+}
-diff --git a/gcc/testsuite/gcc.target/i386/pr121572-1b.c b/gcc/testsuite/gcc.target/i386/pr121572-1b.c
-new file mode 100644
-index 00000000000..8a6089109f5
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121572-1b.c
-@@ -0,0 +1,18 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-O0 -fpic -fplt -mtls-dialect=gnu2" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
-+
-+/*
-+**bug:
-+**.LFB[0-9]+:
-+**...
-+** lea[l|q] tv_cache@TLSDESC\(%rip\), %[e|r]ax
-+** movl \$-1, %edi
-+** call \*tv_cache@TLSCALL\(%[e|r]ax\)
-+** mov[l|q] %[e|r]ax, %[e|r]bx
-+** call val@PLT
-+**...
-+*/
-+
-+#include "pr121572-1a.c"
-diff --git a/gcc/testsuite/gcc.target/i386/pr121572-2a.c b/gcc/testsuite/gcc.target/i386/pr121572-2a.c
-new file mode 100644
-index 00000000000..38b254657d3
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121572-2a.c
-@@ -0,0 +1,39 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu" } */
-+
-+typedef enum
-+{
-+ MPFR_RNDN
-+} mpfr_rnd_t;
-+typedef int mpfr_t[1];
-+long __gmpfr_emin, mpfr_agm_expo_0;
-+_Thread_local long __gmpfr_emax;
-+int mpfr_agm_compare, mpfr_agm___trans_tmp_1;
-+mpfr_t mpfr_agm_u;
-+void mpfr_mul (int *, int, int, mpfr_rnd_t);
-+int
-+mpfr_agm (int op1)
-+{
-+ int op2 = 0;
-+ if (__builtin_expect (mpfr_agm_compare == 0, 0))
-+ return 0;
-+ if (mpfr_agm_compare > 0)
-+ {
-+ int t = op1;
-+ op2 = t;
-+ }
-+ mpfr_agm_expo_0 = __gmpfr_emax;
-+ for (;;)
-+ {
-+ retry:
-+ mpfr_mul (mpfr_agm_u, op1, op2, MPFR_RNDN);
-+ if (0)
-+ goto retry;
-+ if (__builtin_expect (mpfr_agm___trans_tmp_1, 1))
-+ break;
-+ }
-+ __gmpfr_emin = __gmpfr_emax;
-+ return 0;
-+}
-+
-+/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 1 { target { ! ia32 } } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr121572-2b.c b/gcc/testsuite/gcc.target/i386/pr121572-2b.c
-new file mode 100644
-index 00000000000..33d70024324
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121572-2b.c
-@@ -0,0 +1,6 @@
-+/* { dg-do compile { target *-*-linux* } } */
-+/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu2" } */
-+
-+#include "pr121572-2a.c"
-+
-+/* { dg-final { scan-assembler-times "call\[ \t\]\\*__gmpfr_emax@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */
---
-2.50.1
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index a64c662..45143c9 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+12 ????
+
+ - 86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+
11 20 August 2025
U 86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-20 1:10 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-20 1:10 UTC (permalink / raw
To: gentoo-commits
commit: 5059c246b5f9b832808db3dee77947c33cacc235
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 20 01:10:24 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Aug 20 01:10:24 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=5059c246
16.0.0: cut patchset 11
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/README.history | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index b2fcc91..a64c662 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,5 +1,6 @@
-11 ????
+11 20 August 2025
+ U 86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+ 87_all_PR121553-Revert-c-P2036R3-Change-scope-of-lambda-trailing-ret.patch
10 17 August 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-19 16:30 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-19 16:30 UTC (permalink / raw
To: gentoo-commits
commit: d7e4a6ed7dbaa9482ef38b686c1f886f8a1289a0
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 19 16:30:15 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Aug 19 16:30:15 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=d7e4a6ed
16.0.0: update TLS patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
...he-TLS-call-before-all-FLAGS_REG-setting-.patch | 96 ++++++++++++----------
1 file changed, 51 insertions(+), 45 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
index d998713..9f7908a 100644
--- a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+++ b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
@@ -1,7 +1,7 @@
-From 93b90830524746278635ddac3a5841caa7139baf Mon Sep 17 00:00:00 2001
+From 43a0428a61f17969c8e0bf4ede1935b5655100c2 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 16 Aug 2025 14:04:33 -0700
-Subject: [PATCH v3] x86: Place the TLS call before all register setting BBs
+Subject: [PATCH v4] x86: Place the TLS call before all register setting BBs
We can't place a TLS call before a conditional jump in a basic block like
@@ -36,6 +36,7 @@ gcc/
* config/i386/i386-features.cc (replace_tls_call): Add a bitmap
argument and put the updated TLS instruction in the bitmap.
(ix86_get_dominator_for_reg): New.
+ (ix86_check_flags_reg): Likewise.
(ix86_emit_tls_call): Likewise.
(ix86_place_single_tls_call): Add 2 bitmap arguments for updated
GNU and GNU2 TLS instructions. Call ix86_emit_tls_call to emit
@@ -51,19 +52,19 @@ gcc/testsuite/
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
- gcc/config/i386/i386-features.cc | 329 +++++++++++++-------
+ gcc/config/i386/i386-features.cc | 334 +++++++++++++-------
gcc/testsuite/gcc.target/i386/pr121572-1a.c | 41 +++
gcc/testsuite/gcc.target/i386/pr121572-1b.c | 18 ++
gcc/testsuite/gcc.target/i386/pr121572-2a.c | 39 +++
gcc/testsuite/gcc.target/i386/pr121572-2b.c | 6 +
- 5 files changed, 327 insertions(+), 106 deletions(-)
+ 5 files changed, 332 insertions(+), 106 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1a.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1b.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2a.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2b.c
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index f0bdc5c1880..b1211ca916a 100644
+index f0bdc5c1880..7869ee22b67 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -3684,10 +3684,12 @@ ix86_broadcast_inner (rtx op, machine_mode mode,
@@ -91,7 +92,7 @@ index f0bdc5c1880..b1211ca916a 100644
if (dump_file)
{
fprintf (dump_file, "\nReplace:\n\n");
-@@ -3732,15 +3737,211 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
+@@ -3732,15 +3737,216 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
}
}
@@ -122,6 +123,17 @@ index f0bdc5c1880..b1211ca916a 100644
+ return bb;
+}
+
++/* Mark FLAGS register as live in DATA, a bitmap of live caller-saved
++ registers, if DEST is FLAGS register. */
++
++static void
++ix86_check_flags_reg (rtx dest, const_rtx, void *data)
++{
++ auto_bitmap *live_caller_saved_regs = (auto_bitmap *) data;
++ if (REG_P (dest) && REGNO (dest) == FLAGS_REG)
++ bitmap_set_bit (*live_caller_saved_regs, FLAGS_REG);
++}
++
+/* Emit a TLS_SET instruction of KIND in basic block BB. Store the
+ insertion point in *BEFORE_P for emit_insn_before or in *AFTER_P
+ for emit_insn_after. UPDATED_GNU_TLS_INSNS contains instructions
@@ -142,10 +154,7 @@ index f0bdc5c1880..b1211ca916a 100644
+ while (insn && !NONDEBUG_INSN_P (insn))
+ {
+ if (insn == BB_END (bb))
-+ {
-+ insn = NULL;
-+ break;
-+ }
++ break;
+ insn = NEXT_INSN (insn);
+ }
+
@@ -174,14 +183,14 @@ index f0bdc5c1880..b1211ca916a 100644
+
+ if (bitmap_empty_p (live_caller_saved_regs))
+ {
-+ if (insn == BB_HEAD (bb))
++ if (insn == BB_HEAD (bb) || insn == BB_END (bb))
+ {
+ *before_p = insn;
+ tls_insn = emit_insn_before (tls_set, insn);
+ }
+ else
+ {
-+ insn = insn ? PREV_INSN (insn) : BB_END (bb);
++ insn = PREV_INSN (insn);
+ *after_p = insn;
+ tls_insn = emit_insn_after (tls_set, insn);
+ }
@@ -197,7 +206,8 @@ index f0bdc5c1880..b1211ca916a 100644
+ continue;
+
+ /* NB: Conditional jump is the only instruction which reads
-+ flags register and changes control flow. */
++ flags register and changes control flow. We can never
++ place the TLS call after unconditional jump. */
+ if (JUMP_P (insn))
+ {
+ /* This must be a conditional jump. */
@@ -217,33 +227,27 @@ index f0bdc5c1880..b1211ca916a 100644
+ break;
+ }
+
-+ /* Check if FLAGS register is live. */
-+ rtx set = single_set (insn);
-+ if (set)
++ if (bitmap_bit_p (updated_gnu_tls_insns, INSN_UID (insn)))
+ {
-+ rtx dest = SET_DEST (set);
-+ if (REG_P (dest))
-+ {
-+ if (bitmap_bit_p (updated_gnu_tls_insns,
-+ INSN_UID (insn)))
-+ {
-+ /* Insert the __tls_get_addr call before INSN
-+ which replaces a __tls_get_addr call. */
-+ *before_p = insn;
-+ tls_insn = emit_insn_before (tls_set, insn);
-+ return tls_insn;
-+ }
-+ if (bitmap_bit_p (updated_gnu2_tls_insns,
-+ INSN_UID (insn)))
-+ /* Mark FLAGS register as dead since FLAGS register
-+ would be clobbered by the GNU2 TLS instruction. */
-+ bitmap_clear_bit (live_caller_saved_regs,
-+ FLAGS_REG);
-+ else if (REGNO (dest) == FLAGS_REG)
-+ bitmap_set_bit (live_caller_saved_regs, FLAGS_REG);
-+ }
++ /* Insert the __tls_get_addr call before INSN which
++ replaces a __tls_get_addr call. */
++ *before_p = insn;
++ tls_insn = emit_insn_before (tls_set, insn);
++ return tls_insn;
++ }
++
++ if (bitmap_bit_p (updated_gnu2_tls_insns, INSN_UID (insn)))
++ {
++ /* Mark FLAGS register as dead since FLAGS register
++ would be clobbered by the GNU2 TLS instruction. */
++ bitmap_clear_bit (live_caller_saved_regs, FLAGS_REG);
++ continue;
+ }
+
++ /* Check if FLAGS register is live. */
++ note_stores (insn, ix86_check_flags_reg,
++ &live_caller_saved_regs);
++
+ rtx link;
+ for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
+ if (REG_NOTE_KIND (link) == REG_DEAD
@@ -269,6 +273,8 @@ index f0bdc5c1880..b1211ca916a 100644
+ if (repeat)
+ continue;
+
++ gcc_assert (!bitmap_empty_p (live_caller_saved_regs));
++
+ /* If any live caller-saved registers aren't dead at the end of
+ this basic block, get the basic block which dominates all
+ basic blocks which set the remaining live registers. */
@@ -306,7 +312,7 @@ index f0bdc5c1880..b1211ca916a 100644
{
basic_block bb = nearest_common_dominator_for_set (CDI_DOMINATORS, bbs);
while (bb->loop_father->latch
-@@ -3748,17 +3949,6 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+@@ -3748,17 +3954,6 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
bb = get_immediate_dominator (CDI_DOMINATORS,
bb->loop_father->header);
@@ -324,7 +330,7 @@ index f0bdc5c1880..b1211ca916a 100644
rtx rax = nullptr, rdi;
rtx eqv = nullptr;
rtx caddr;
-@@ -3766,7 +3956,6 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+@@ -3766,7 +3961,6 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
rtx clob;
rtx symbol;
rtx tls;
@@ -332,7 +338,7 @@ index f0bdc5c1880..b1211ca916a 100644
switch (kind)
{
-@@ -3808,94 +3997,13 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+@@ -3808,94 +4002,13 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
gcc_unreachable ();
}
@@ -432,7 +438,7 @@ index f0bdc5c1880..b1211ca916a 100644
rtx_insn *tlsdesc_insn = nullptr;
if (tlsdesc_set)
-@@ -3936,7 +4044,7 @@ insert_after:
+@@ -3936,7 +4049,7 @@ insert_after:
print_rtl_single (dump_file, tlsdesc_insn);
print_rtl_single (dump_file, tls_insn);
fprintf (dump_file, "\nbefore:\n\n");
@@ -441,7 +447,7 @@ index f0bdc5c1880..b1211ca916a 100644
fprintf (dump_file, "\n");
}
}
-@@ -4213,6 +4321,8 @@ pass_x86_cse::x86_cse (void)
+@@ -4213,6 +4326,8 @@ pass_x86_cse::x86_cse (void)
basic_block bb;
rtx_insn *insn;
unsigned int i;
@@ -450,7 +456,7 @@ index f0bdc5c1880..b1211ca916a 100644
df_set_flags (DF_DEFER_INSN_RESCAN);
-@@ -4333,7 +4443,10 @@ pass_x86_cse::x86_cse (void)
+@@ -4333,7 +4448,10 @@ pass_x86_cse::x86_cse (void)
case X86_CSE_TLS_LD_BASE:
case X86_CSE_TLSDESC:
broadcast_reg = gen_reg_rtx (load->mode);
@@ -462,7 +468,7 @@ index f0bdc5c1880..b1211ca916a 100644
load->broadcast_reg = broadcast_reg;
break;
-@@ -4399,6 +4512,8 @@ pass_x86_cse::x86_cse (void)
+@@ -4399,6 +4517,8 @@ pass_x86_cse::x86_cse (void)
load->val,
load->kind,
load->bbs,
@@ -471,7 +477,7 @@ index f0bdc5c1880..b1211ca916a 100644
PATTERN (load->def_insn));
break;
case X86_CSE_VEC_DUP:
-@@ -4442,7 +4557,9 @@ pass_x86_cse::x86_cse (void)
+@@ -4442,7 +4562,9 @@ pass_x86_cse::x86_cse (void)
ix86_place_single_tls_call (load->broadcast_reg,
load->val,
load->kind,
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-18 23:52 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-18 23:52 UTC (permalink / raw
To: gentoo-commits
commit: b5d57636befce566cec78c6cd26f400558d024e9
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 18 23:52:24 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Aug 18 23:52:24 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=b5d57636
16.0.0: revert C++ lambda change
It breaks building Dolphin, FF, ...
Bug: https://gcc.gnu.org/PR121553
Signed-off-by: Sam James <sam <AT> gentoo.org>
...036R3-Change-scope-of-lambda-trailing-ret.patch | 1186 ++++++++++++++++++++
16.0.0/gentoo/README.history | 4 +
2 files changed, 1190 insertions(+)
diff --git a/16.0.0/gentoo/87_all_PR121553-Revert-c-P2036R3-Change-scope-of-lambda-trailing-ret.patch b/16.0.0/gentoo/87_all_PR121553-Revert-c-P2036R3-Change-scope-of-lambda-trailing-ret.patch
new file mode 100644
index 0000000..ad792d0
--- /dev/null
+++ b/16.0.0/gentoo/87_all_PR121553-Revert-c-P2036R3-Change-scope-of-lambda-trailing-ret.patch
@@ -0,0 +1,1186 @@
+From 358ad796de168eedb8bcf9509a7dc40861f057a0 Mon Sep 17 00:00:00 2001
+Message-ID: <358ad796de168eedb8bcf9509a7dc40861f057a0.1755561114.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Tue, 19 Aug 2025 00:51:27 +0100
+Subject: [PATCH] Revert "c++: P2036R3 - Change scope of lambda
+ trailing-return-type [PR102610]"
+
+This reverts commit d2dccd1bf79b862b9989c1b62ed8c074980cd457.
+
+Bug: https://gcc.gnu.org/PR121553
+---
+ gcc/cp/cp-tree.h | 11 -
+ gcc/cp/lambda.cc | 40 +---
+ gcc/cp/name-lookup.cc | 11 +-
+ gcc/cp/name-lookup.h | 1 -
+ gcc/cp/parser.cc | 94 --------
+ gcc/cp/pt.cc | 21 --
+ gcc/cp/semantics.cc | 64 ++----
+ .../g++.dg/cpp0x/lambda/lambda-decltype3.C | 2 +-
+ gcc/testsuite/g++.dg/cpp23/lambda-scope1.C | 85 -------
+ gcc/testsuite/g++.dg/cpp23/lambda-scope2.C | 217 ------------------
+ gcc/testsuite/g++.dg/cpp23/lambda-scope3.C | 44 ----
+ gcc/testsuite/g++.dg/cpp23/lambda-scope4.C | 41 ----
+ gcc/testsuite/g++.dg/cpp23/lambda-scope4b.C | 42 ----
+ gcc/testsuite/g++.dg/cpp23/lambda-scope5.C | 22 --
+ gcc/testsuite/g++.dg/cpp23/lambda-scope6.C | 20 --
+ gcc/testsuite/g++.dg/cpp23/lambda-scope7.C | 20 --
+ gcc/testsuite/g++.dg/cpp23/lambda-scope8.C | 25 --
+ gcc/testsuite/g++.dg/cpp23/lambda-scope9.C | 15 --
+ gcc/testsuite/g++.dg/warn/Wshadow-19.C | 4 +-
+ gcc/testsuite/g++.dg/warn/Wshadow-6.C | 8 +-
+ 20 files changed, 37 insertions(+), 750 deletions(-)
+ delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope1.C
+ delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope2.C
+ delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope3.C
+ delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope4.C
+ delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope4b.C
+ delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope5.C
+ delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope6.C
+ delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope7.C
+ delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope8.C
+ delete mode 100644 gcc/testsuite/g++.dg/cpp23/lambda-scope9.C
+
+diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
+index 55e8e0736272..d29d996e55e5 100644
+--- a/gcc/cp/cp-tree.h
++++ b/gcc/cp/cp-tree.h
+@@ -476,7 +476,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
+ ATOMIC_CONSTR_EXPR_FROM_CONCEPT_P (in ATOMIC_CONSTR)
+ STATIC_INIT_DECOMP_BASE_P (in the TREE_LIST for {static,tls}_aggregates)
+ MUST_NOT_THROW_THROW_P (in MUST_NOT_THROW_EXPR)
+- LAMBDA_EXPR_CONST_QUAL_P (in LAMBDA_EXPR)
+ 2: IDENTIFIER_KIND_BIT_2 (in IDENTIFIER_NODE)
+ ICS_THIS_FLAG (in _CONV)
+ DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (in VAR_DECL)
+@@ -1558,13 +1557,6 @@ enum cp_lambda_default_capture_mode_type {
+ #define LAMBDA_EXPR_CONSTEVAL_BLOCK_P(NODE) \
+ TREE_LANG_FLAG_0 (LAMBDA_EXPR_CHECK (NODE))
+
+-/* True if we should add "const" when figuring out the type of an entity
+- in a lambda. This is false in the parameter-declaration-clause of
+- a lambda; after that, it will remain false if the mutable keyword is
+- present. */
+-#define LAMBDA_EXPR_CONST_QUAL_P(NODE) \
+- TREE_LANG_FLAG_1 (LAMBDA_EXPR_CHECK (NODE))
+-
+ /* True iff uses of a const variable capture were optimized away. */
+ #define LAMBDA_EXPR_CAPTURE_OPTIMIZED(NODE) \
+ TREE_LANG_FLAG_2 (LAMBDA_EXPR_CHECK (NODE))
+@@ -7807,8 +7799,6 @@ extern location_t defparse_location (tree);
+ extern void maybe_show_extern_c_location (void);
+ extern bool literal_integer_zerop (const_tree);
+ extern tree attr_chainon (tree, tree);
+-extern tree maybe_add_dummy_lambda_op (tree);
+-extern void remove_dummy_lambda_op (tree, tree);
+
+ /* in pt.cc */
+ extern tree canonical_type_parameter (tree);
+@@ -8339,7 +8329,6 @@ extern void record_lambda_scope (tree lambda);
+ extern void record_lambda_scope_discriminator (tree lambda);
+ extern void record_lambda_scope_sig_discriminator (tree lambda, tree fn);
+ extern tree start_lambda_function (tree fn, tree lambda_expr);
+-extern void push_capture_proxies (tree, bool = false);
+ extern void finish_lambda_function (tree body);
+ extern bool regenerated_lambda_fn_p (tree);
+ extern tree lambda_regenerating_args (tree);
+diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc
+index 711e3b7a18e4..c798967f8e1c 100644
+--- a/gcc/cp/lambda.cc
++++ b/gcc/cp/lambda.cc
+@@ -409,11 +409,10 @@ lambda_proxy_type (tree ref)
+
+ /* MEMBER is a capture field in a lambda closure class. Now that we're
+ inside the operator(), build a placeholder var for future lookups and
+- debugging. But if EARLY_P is true, we do not have the real operator()
+- yet and we have to proceed differently. */
++ debugging. */
+
+-tree
+-build_capture_proxy (tree member, tree init, bool early_p)
++static tree
++build_capture_proxy (tree member, tree init)
+ {
+ tree var, object, fn, closure, name, lam, type;
+
+@@ -504,19 +503,11 @@ build_capture_proxy (tree member, tree init, bool early_p)
+
+ if (name == this_identifier)
+ {
+- if (early_p)
+- return var;
+ gcc_assert (LAMBDA_EXPR_THIS_CAPTURE (lam) == member);
+ LAMBDA_EXPR_THIS_CAPTURE (lam) = var;
+ }
+
+- if (early_p)
+- {
+- gcc_checking_assert (current_binding_level->kind == sk_lambda);
+- /* insert_capture_proxy below wouldn't push into the lambda scope. */
+- pushdecl (var);
+- }
+- else if (fn == current_function_decl)
++ if (fn == current_function_decl)
+ insert_capture_proxy (var);
+ else
+ vec_safe_push (LAMBDA_EXPR_PENDING_PROXIES (lam), var);
+@@ -736,7 +727,7 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
+ = tree_cons (listmem, initializer, LAMBDA_EXPR_CAPTURE_LIST (lambda));
+
+ if (LAMBDA_EXPR_CLOSURE (lambda))
+- return build_capture_proxy (member, initializer, /*early_p=*/false);
++ return build_capture_proxy (member, initializer);
+ /* For explicit captures we haven't started the function yet, so we wait
+ and build the proxy from cp_parser_lambda_body. */
+ LAMBDA_CAPTURE_EXPLICIT_P (LAMBDA_EXPR_CAPTURE_LIST (lambda)) = true;
+@@ -989,14 +980,10 @@ resolvable_dummy_lambda (tree object)
+ tree type = TYPE_MAIN_VARIANT (TREE_TYPE (object));
+ gcc_assert (!TYPE_PTR_P (type));
+
+- tree fn;
+ if (type != current_class_type
+ && current_class_type
+ && LAMBDA_TYPE_P (current_class_type)
+- && (fn = lambda_function (current_class_type))
+- /* Even dummy lambdas have an operator() since P2036, but the
+- dummy operator() doesn't have this set. */
+- && DECL_LAMBDA_FUNCTION_P (fn)
++ && lambda_function (current_class_type)
+ && DERIVED_FROM_P (type, nonlambda_method_basetype()))
+ return CLASSTYPE_LAMBDA_EXPR (current_class_type);
+
+@@ -1797,17 +1784,6 @@ record_lambda_scope_sig_discriminator (tree lambda, tree fn)
+ LAMBDA_EXPR_SCOPE_SIG_DISCRIMINATOR (lambda) = sig->count++;
+ }
+
+-/* Push the proxies for any explicit captures in LAMBDA_EXPR.
+- If EARLY_P, we do not have the real operator() yet. */
+-
+-void
+-push_capture_proxies (tree lambda_expr, bool early_p)
+-{
+- for (tree cap = LAMBDA_EXPR_CAPTURE_LIST (lambda_expr); cap;
+- cap = TREE_CHAIN (cap))
+- build_capture_proxy (TREE_PURPOSE (cap), TREE_VALUE (cap), early_p);
+-}
+-
+ tree
+ start_lambda_function (tree fco, tree lambda_expr)
+ {
+@@ -1820,7 +1796,9 @@ start_lambda_function (tree fco, tree lambda_expr)
+ tree body = begin_function_body ();
+
+ /* Push the proxies for any explicit captures. */
+- push_capture_proxies (lambda_expr);
++ for (tree cap = LAMBDA_EXPR_CAPTURE_LIST (lambda_expr); cap;
++ cap = TREE_CHAIN (cap))
++ build_capture_proxy (TREE_PURPOSE (cap), TREE_VALUE (cap));
+
+ return body;
+ }
+diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
+index fa367214507e..a805f42f6668 100644
+--- a/gcc/cp/name-lookup.cc
++++ b/gcc/cp/name-lookup.cc
+@@ -3351,11 +3351,8 @@ check_local_shadow (tree decl)
+ }
+ /* Don't complain if it's from an enclosing function. */
+ else if (DECL_CONTEXT (old) == current_function_decl
+- && ((TREE_CODE (decl) != PARM_DECL
+- && TREE_CODE (old) == PARM_DECL)
+- /* We should also give an error for
+- [x=1]{ int x; } */
+- || is_capture_proxy (old)))
++ && TREE_CODE (decl) != PARM_DECL
++ && TREE_CODE (old) == PARM_DECL)
+ {
+ /* Go to where the parms should be and see if we find
+ them there. */
+@@ -4641,8 +4638,7 @@ cp_binding_level_descriptor (cp_binding_level *scope)
+ "template-parameter-scope",
+ "template-explicit-spec-scope",
+ "transaction-scope",
+- "openmp-scope",
+- "lambda-scope"
++ "openmp-scope"
+ };
+ static_assert (ARRAY_SIZE (scope_kind_names) == sk_count,
+ "must keep names aligned with scope_kind enum");
+@@ -4734,7 +4730,6 @@ begin_scope (scope_kind kind, tree entity)
+ case sk_transaction:
+ case sk_omp:
+ case sk_stmt_expr:
+- case sk_lambda:
+ scope->keep = keep_next_level_flag;
+ break;
+
+diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
+index 5b142e748999..6a3c0df47007 100644
+--- a/gcc/cp/name-lookup.h
++++ b/gcc/cp/name-lookup.h
+@@ -215,7 +215,6 @@ enum scope_kind {
+ "template <>", this scope is always empty. */
+ sk_transaction, /* A synchronized or atomic statement. */
+ sk_omp, /* An OpenMP structured block. */
+- sk_lambda, /* A lambda scope. */
+ sk_count /* Number of scope_kind enumerations. */
+ };
+
+diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
+index d66b658b748f..9dbd254dc61b 100644
+--- a/gcc/cp/parser.cc
++++ b/gcc/cp/parser.cc
+@@ -11887,10 +11887,6 @@ cp_parser_lambda_expression (cp_parser* parser,
+ if (cp_parser_start_tentative_firewall (parser))
+ start = token;
+
+- /* A lambda scope starts immediately after the lambda-introducer of E
+- and extends to the end of the compound-statement of E. */
+- begin_scope (sk_lambda, NULL_TREE);
+-
+ ok &= cp_parser_lambda_declarator_opt (parser, lambda_expr,
+ consteval_block_p);
+
+@@ -11912,8 +11908,6 @@ cp_parser_lambda_expression (cp_parser* parser,
+ if (ok)
+ maybe_add_lambda_conv_op (type);
+
+- /* Leave the lambda scope. */
+- pop_bindings_and_leave_scope ();
+ finish_struct (type, /*attributes=*/NULL_TREE);
+
+ in_expansion_stmt = save_in_expansion_stmt;
+@@ -12305,13 +12299,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr,
+ clear_decl_specs (&lambda_specs);
+ /* A lambda op() is const unless explicitly 'mutable'. */
+ cp_cv_quals quals = TYPE_QUAL_CONST;
+- /* Don't add "const" to entities in the parameter-declaration-clause. */
+- LAMBDA_EXPR_CONST_QUAL_P (lambda_expr) = false;
+-
+- /* Inject the captures into the lambda scope as they may be used in the
+- declarator and we have to be able to look them up. */
+- tree dummy_fco = maybe_add_dummy_lambda_op (lambda_expr);
+- push_capture_proxies (lambda_expr, /*early_p=*/true);
+
+ /* The template-parameter-list is optional, but must begin with
+ an opening angle if present. */
+@@ -12502,10 +12489,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr,
+ }
+ }
+
+- /* Now we're done with the parameter-declaration-clause, and should
+- assume "const" unless "mutable" was present. */
+- LAMBDA_EXPR_CONST_QUAL_P (lambda_expr) = quals == TYPE_QUAL_CONST;
+-
+ tx_qual = cp_parser_tx_qualifier_opt (parser);
+ if (omitted_parms_loc && tx_qual)
+ {
+@@ -12563,10 +12546,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr,
+ pop_bindings_and_leave_scope ();
+ }
+
+- /* We are about to create the real operator(), so get rid of the old one. */
+- if (dummy_fco)
+- remove_dummy_lambda_op (dummy_fco, lambda_expr);
+-
+ /* Create the function call operator.
+
+ Messing with declarators like this is no uglier than building up the
+@@ -12646,79 +12625,6 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr,
+ }
+ }
+
+-/* Create a fake operator() for a lambda. We do this so that we can
+- build_capture_proxy even before start_lambda_function. */
+-
+-static tree
+-make_dummy_lambda_op ()
+-{
+- cp_decl_specifier_seq return_type_specs;
+- cp_cv_quals quals = TYPE_UNQUALIFIED;
+-
+- clear_decl_specs (&return_type_specs);
+- return_type_specs.type = make_auto ();
+-
+- void *p = obstack_alloc (&declarator_obstack, 0);
+-
+- cp_declarator *declarator = make_id_declarator (NULL_TREE,
+- call_op_identifier,
+- sfk_none,
+- input_location);
+-
+- declarator = make_call_declarator (declarator, void_list_node, quals,
+- VIRT_SPEC_UNSPECIFIED,
+- REF_QUAL_NONE, NULL_TREE,
+- NULL_TREE, NULL_TREE, NULL_TREE,
+- NULL_TREE, UNKNOWN_LOCATION);
+-
+- tree fco = grokmethod (&return_type_specs, declarator, NULL_TREE);
+- obstack_free (&declarator_obstack, p);
+-
+- return fco;
+-}
+-
+-/* We need to push early capture proxies (for parsing the lambda-declarator),
+- and we may need a dummy operator() to be able to build the proxies.
+- LAMBDA_EXPR is the lambda we are building the captures for. */
+-
+-tree
+-maybe_add_dummy_lambda_op (tree lambda_expr)
+-{
+- /* If there are no captures, we don't need this. */
+- if (!LAMBDA_EXPR_CAPTURE_LIST (lambda_expr))
+- return NULL_TREE;
+-
+- tree fco = make_dummy_lambda_op ();
+- if (fco != error_mark_node)
+- finish_member_declaration (fco);
+-
+- return fco;
+-}
+-
+-/* Remove the dummy operator() DUMMY_FCO we built for parsing the
+- lambda-declarator of LAMBDA_EXPR. */
+-
+-void
+-remove_dummy_lambda_op (tree dummy_fco, tree lambda_expr)
+-{
+- tree type = TREE_TYPE (lambda_expr);
+- if (TYPE_FIELDS (type) == dummy_fco)
+- {
+- /* Stitch out the dummy operator(). */
+- TYPE_FIELDS (type) = DECL_CHAIN (TYPE_FIELDS (type));
+- /* And clear the member vector as well. */
+- auto *member_vec = CLASSTYPE_MEMBER_VEC (type);
+- gcc_assert (member_vec->length () == 1);
+- member_vec->truncate (0);
+- }
+- /* Class templates will have the dummy operator() stashed here too. */
+- tree &list = CLASSTYPE_DECL_LIST (type);
+- if (list && TREE_VALUE (list) == dummy_fco)
+- list = TREE_CHAIN (list);
+- /* ??? We can't ggc_free dummy_fco yet. There's still a binding in the
+- closure to it, and the captures have it as their DECL_CONTEXT. */
+-}
+-
+ /* Parse the body of a lambda expression, which is simply
+
+ compound-statement
+diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
+index bb2d0b48fd42..b72f285d86d6 100644
+--- a/gcc/cp/pt.cc
++++ b/gcc/cp/pt.cc
+@@ -20590,18 +20590,6 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
+
+ tree fntype = static_fn_type (oldfn);
+
+- begin_scope (sk_lambda, NULL_TREE);
+-
+- /* Like in cp_parser_lambda_expression, we need to bring the captures
+- into the lambda scope. */
+- tree ns = decl_namespace_context (type);
+- push_nested_namespace (ns);
+- push_nested_class (type);
+- tree dummy_fco = maybe_add_dummy_lambda_op (r);
+- pop_nested_class ();
+- pop_nested_namespace (ns);
+- push_capture_proxies (r, /*early_p=*/true);
+-
+ tree saved_ctp = current_template_parms;
+ if (oldtmpl)
+ {
+@@ -20615,10 +20603,6 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
+ --processing_template_decl;
+ }
+
+- /* We are about to create the real operator(), so get rid of the old one. */
+- if (dummy_fco)
+- remove_dummy_lambda_op (dummy_fco, r);
+-
+ if (fntype == error_mark_node)
+ r = error_mark_node;
+ else
+@@ -20652,10 +20636,6 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
+ enclosing expression. */
+ cp_evaluated ev;
+
+- /* Now we're done with the parameter-declaration-clause, and should
+- assume "const" unless "mutable" was present. */
+- LAMBDA_EXPR_CONST_QUAL_P (r) = LAMBDA_EXPR_CONST_QUAL_P (t);
+-
+ bool nested = cfun;
+ if (nested)
+ push_function_context ();
+@@ -20724,7 +20704,6 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
+ }
+
+ out:
+- pop_bindings_and_leave_scope ();
+ finish_struct (type, /*attr*/NULL_TREE);
+
+ insert_pending_capture_proxies ();
+diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
+index 26709c7a33bf..ef331f64f8da 100644
+--- a/gcc/cp/semantics.cc
++++ b/gcc/cp/semantics.cc
+@@ -4511,17 +4511,6 @@ baselink_for_fns (tree fns)
+ return build_baselink (conv_path, access_path, fns, /*optype=*/NULL_TREE);
+ }
+
+-/* Returns true iff we are currently parsing a lambda-declarator. */
+-
+-static bool
+-parsing_lambda_declarator ()
+-{
+- cp_binding_level *b = current_binding_level;
+- while (b->kind == sk_template_parms || b->kind == sk_function_parms)
+- b = b->level_chain;
+- return b->kind == sk_lambda;
+-}
+-
+ /* Returns true iff DECL is a variable from a function outside
+ the current one. */
+
+@@ -4536,15 +4525,7 @@ outer_var_p (tree decl)
+ /* Don't get confused by temporaries. */
+ && DECL_NAME (decl)
+ && (DECL_CONTEXT (decl) != current_function_decl
+- || parsing_nsdmi ()
+- /* Also consider captures as outer vars if we are in
+- decltype in a lambda declarator as in:
+- auto l = [j=0]() -> decltype((j)) { ... }
+- for the sake of finish_decltype_type.
+-
+- (Similar issue also affects non-lambdas, but vexing parse
+- makes it more difficult to handle than lambdas.) */
+- || parsing_lambda_declarator ()));
++ || parsing_nsdmi ()));
+ }
+
+ /* As above, but also checks that DECL is automatic. */
+@@ -4590,7 +4571,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use)
+ if (!mark_used (decl, complain))
+ return error_mark_node;
+
+- if (parsing_nsdmi () || parsing_lambda_declarator ())
++ if (parsing_nsdmi ())
+ containing_function = NULL_TREE;
+
+ if (containing_function && LAMBDA_FUNCTION_P (containing_function))
+@@ -12960,9 +12941,9 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
+ }
+ else
+ {
+- tree decl = STRIP_REFERENCE_REF (expr);
+- tree lam = current_lambda_expr ();
+- if (lam && outer_automatic_var_p (decl))
++ if (outer_automatic_var_p (STRIP_REFERENCE_REF (expr))
++ && current_function_decl
++ && LAMBDA_FUNCTION_P (current_function_decl))
+ {
+ /* [expr.prim.id.unqual]/3: If naming the entity from outside of an
+ unevaluated operand within S would refer to an entity captured by
+@@ -12979,6 +12960,8 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
+ local variable inside decltype, not just decltype((x)) (PR83167).
+ And we don't handle nested lambdas properly, where we need to
+ consider the outer lambdas as well (PR112926). */
++ tree decl = STRIP_REFERENCE_REF (expr);
++ tree lam = CLASSTYPE_LAMBDA_EXPR (DECL_CONTEXT (current_function_decl));
+ tree cap = lookup_name (DECL_NAME (decl), LOOK_where::BLOCK,
+ LOOK_want::HIDDEN_LAMBDA);
+
+@@ -12994,28 +12977,17 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
+
+ if (type && !TYPE_REF_P (type))
+ {
+- int quals;
+- if (current_function_decl
+- && LAMBDA_FUNCTION_P (current_function_decl)
+- && DECL_XOBJ_MEMBER_FUNCTION_P (current_function_decl))
+- {
+- tree obtype = TREE_TYPE (DECL_ARGUMENTS (current_function_decl));
+- if (WILDCARD_TYPE_P (non_reference (obtype)))
+- /* We don't know what the eventual obtype quals will be. */
+- goto dependent;
+- auto direct_type = [](tree t){
+- if (INDIRECT_TYPE_P (t))
+- return TREE_TYPE (t);
+- return t;
+- };
+- quals = (cp_type_quals (type)
+- | cp_type_quals (direct_type (obtype)));
+- }
+- else
+- /* We are in the parameter clause, trailing return type, or
+- the requires clause and have no relevant c_f_decl yet. */
+- quals = (LAMBDA_EXPR_CONST_QUAL_P (lam)
+- ? TYPE_QUAL_CONST : TYPE_UNQUALIFIED);
++ tree obtype = TREE_TYPE (DECL_ARGUMENTS (current_function_decl));
++ if (WILDCARD_TYPE_P (non_reference (obtype)))
++ /* We don't know what the eventual obtype quals will be. */
++ goto dependent;
++ auto direct_type = [](tree t){
++ if (INDIRECT_TYPE_P (t))
++ return TREE_TYPE (t);
++ return t;
++ };
++ int const quals = cp_type_quals (type)
++ | cp_type_quals (direct_type (obtype));
+ type = cp_build_qualified_type (type, quals);
+ type = build_reference_type (type);
+ }
+diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype3.C
+index 6ba0dabc37d5..2e06e4961408 100644
+--- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype3.C
++++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype3.C
+@@ -11,7 +11,7 @@ void f() {
+ decltype((x)) y2 = y1; // y2 has type float const&
+ decltype(r) r1 = y1; // r1 has type float&
+ decltype((r)) r2 = y2; // r2 has type float const&
+- return y2; // { dg-bogus "'float&' to 'const float'" }
++ return y2; // { dg-bogus "'float&' to 'const float'" "" { xfail *-*-* } }
+ };
+
+ [=](decltype((x)) y) {
+diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope1.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope1.C
+deleted file mode 100644
+index 000979e30778..000000000000
+--- a/gcc/testsuite/g++.dg/cpp23/lambda-scope1.C
++++ /dev/null
+@@ -1,85 +0,0 @@
+-// P2036R3 - Change scope of lambda trailing-return-type
+-// PR c++/102610
+-// { dg-do compile { target c++23 } }
+-
+-template <typename T, typename U>
+-constexpr bool is_same = false;
+-
+-template <typename T>
+-constexpr bool is_same<T, T> = true;
+-
+-struct S {
+- void foo () {
+- auto counter1 = [j=0]() mutable -> decltype(j) {
+- return j++;
+- };
+- auto counter2 = [j=0, o=0, k=0, e=0]() mutable -> decltype(j) {
+- return j + o + k + e;
+- };
+- }
+-};
+-
+-// [expr.prim.id.unqual]/3.2
+-void
+-f ()
+-{
+- float x, &r = x;
+-
+- [=]() -> decltype((x)) { // lambda returns float const& because this lambda is not mutable and
+- // x is an lvalue
+- decltype(x) y1; // y1 has type float
+- decltype((x)) y2 = y1; // y2 has type float const&
+- decltype(r) r1 = y1; // r1 has type float&
+- decltype((r)) r2 = y2; // r2 has type float const&
+- return y2;
+- };
+-
+- [=](decltype((x)) y) {
+- decltype((x)) z = x; // OK, y has type float&, z has type float const&
+- static_assert(is_same<float&, decltype((y))>);
+- static_assert(is_same<const float&, decltype((z))>);
+- };
+-
+- [=] {
+- [](decltype((x)) y) { // OK, lambda takes a parameter of type float const&
+- };
+-
+- [x=1](decltype((x)) y) {
+- decltype((x)) z = x; // OK, y has type int&, z has type int const&
+- // FIXME We don't handle nested lambdas yet?
+- //static_assert(is_same<int&, decltype((y))>);
+- static_assert(is_same<const int&, decltype((z))>);
+- };
+- };
+-
+- [x=1](decltype((x)) y) {
+- decltype((x)) z = x;
+- static_assert(is_same<int&, decltype((y))>);
+- static_assert(is_same<const int&, decltype((z))>);
+- };
+-}
+-
+-void
+-ok ()
+-{
+- auto counter1 = [j=0]() mutable -> decltype(j) {
+- static_assert(is_same<int&, decltype((j))>);
+- return j++;
+- };
+-
+- auto l = [j=0]() -> decltype(j) {
+- static_assert(is_same<const int&, decltype((j))>);
+- return j;
+- };
+-
+- int y;
+- [=] -> decltype((y)) {
+- return y;
+- };
+-}
+-
+-void
+-foo ()
+-{
+- int x = [x](int y[sizeof x]){return sizeof x;}(0);
+-}
+diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope2.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope2.C
+deleted file mode 100644
+index 6b55e5fe5134..000000000000
+--- a/gcc/testsuite/g++.dg/cpp23/lambda-scope2.C
++++ /dev/null
+@@ -1,217 +0,0 @@
+-// P2036R3 - Change scope of lambda trailing-return-type
+-// PR c++/102610
+-// { dg-do compile { target c++23 } }
+-// From LLVM's test/SemaCXX/lambda-capture-type-deduction.cpp
+-
+-template <typename T, typename U>
+-constexpr bool is_same = false;
+-
+-template <typename T>
+-constexpr bool is_same<T, T> = true;
+-
+-void
+-f ()
+-{
+- int y;
+-
+- static_assert(is_same<const int &,
+- decltype([x = 1] -> decltype((x)) { return x; }())>);
+-
+- static_assert(is_same<int &,
+- decltype([x = 1] mutable -> decltype((x)) { return x; }())>);
+-
+- static_assert(is_same<const int &,
+- decltype([=] -> decltype((y)) { return y; }())>);
+-
+- static_assert(is_same<int &,
+- decltype([=] mutable -> decltype((y)) { return y; }())>);
+-
+- // Clang++ rejects this one, though the only difference is the extra (),
+- // and without the () the result is correct, as demonstrated above.
+- static_assert(is_same<const int &,
+- decltype([=]() -> decltype((y)) { return y; }())>);
+-
+- static_assert(is_same<int &,
+- decltype([=]() mutable -> decltype((y)) { return y; }())>);
+-
+- static_assert(is_same<const int &,
+- decltype([y] -> decltype((y)) { return y; }())>);
+-
+- static_assert(is_same<int &,
+- decltype([y] mutable -> decltype((y)) { return y; }())>);
+-
+-
+- auto ref = [&x = y](
+- decltype([&](decltype(x)) { return 0; }) y) {
+- return x;
+- };
+-}
+-
+-void
+-nested ()
+-{
+- int x, y, z;
+- (void)[&](
+- decltype([&](
+- decltype([=](
+- decltype([&](
+- decltype([&](decltype(x)) {})) {})) {})) {})){};
+-
+- (void)[&](
+- decltype([&](
+- decltype([&](
+- decltype([&](
+- decltype([&](decltype(y)) {})) {})) {})) {})){};
+-
+- (void)[=](
+- decltype([=](
+- decltype([=](
+- decltype([=](
+- decltype([&]<decltype(z)> {})) {})) {})) {})){};
+-}
+-
+-void
+-test_noexcept ()
+-{
+- int y;
+-
+- static_assert(noexcept([x = 1] noexcept(is_same<const int &, decltype((x))>) {}()));
+- static_assert(noexcept([x = 1] mutable noexcept(is_same<int &, decltype((x))>) {}()));
+- static_assert(noexcept([y] noexcept(is_same<const int &, decltype((y))>) {}()));
+- static_assert(noexcept([y] mutable noexcept(is_same<int &, decltype((y))>) {}()));
+- static_assert(noexcept([=] noexcept(is_same<const int &, decltype((y))>) {}()));
+- static_assert(noexcept([=] mutable noexcept(is_same<int &, decltype((y))>) {}()));
+- static_assert(noexcept([&] noexcept(is_same<int &, decltype((y))>) {}()));
+- static_assert(noexcept([&] mutable noexcept(is_same<int &, decltype((y))>) {}()));
+-}
+-
+-void
+-check_params ()
+-{
+- int i = 0;
+- int &j = i;
+-
+- [=](decltype((j)) jp, decltype((i)) ip) {
+- static_assert(is_same<const int&, decltype((j))>);
+- static_assert(is_same<const int &, decltype((i))>);
+- static_assert(is_same<int &, decltype((jp))>);
+- static_assert(is_same<int &, decltype((ip))>);
+- };
+-
+- [=](decltype((j)) jp, decltype((i)) ip) mutable {
+- static_assert(is_same<int &, decltype((j))>);
+- static_assert(is_same<int &, decltype((i))>);
+- static_assert(is_same<int &, decltype((jp))>);
+- static_assert(is_same<int &, decltype((ip))>);
+- static_assert(is_same<int &, decltype(jp)>);
+- static_assert(is_same<int &, decltype(ip)>);
+- };
+-
+- [a = 0](decltype((a)) ap) mutable {
+- static_assert(is_same<int &, decltype((a))>);
+- static_assert(is_same<int, decltype(a)>);
+- static_assert(is_same<int &, decltype(ap)>);
+- decltype(a) x;
+- decltype((a)) y = x;
+- static_assert(is_same<int &, decltype(y)>);
+- };
+-
+- [a = 0](decltype((a)) ap) {
+- static_assert(is_same<const int &, decltype((a))>);
+- static_assert(is_same<int, decltype(a)>);
+- static_assert(is_same<int&, decltype((ap))>);
+- decltype(a) x;
+- decltype((a)) y = x;
+- static_assert(is_same<const int &, decltype(y)>);
+- };
+-
+- int a;
+- [a](decltype((a)) ap) mutable {
+- static_assert(is_same<int &, decltype((a))>);
+- static_assert(is_same<int, decltype(a)>);
+- static_assert(is_same<int &, decltype(ap)>);
+- decltype(a) x;
+- decltype((a)) y = x;
+- static_assert(is_same<int &, decltype(y)>);
+- };
+-
+- [a](decltype((a)) ap) {
+- static_assert(is_same<const int &, decltype((a))>);
+- static_assert(is_same<int, decltype(a)>);
+- static_assert(is_same<int&, decltype((ap))>);
+- decltype(a) x;
+- decltype((a)) y = x;
+- static_assert(is_same<const int &, decltype(y)>);
+- };
+-}
+-
+-template <typename T>
+-void
+-check_params_tpl ()
+-{
+- T i = 0;
+- T &j = i;
+- (void)[=](decltype((j)) jp, decltype((i)) ip) {
+- static_assert(is_same<const int&, decltype((j))>);
+- static_assert(is_same<const int &, decltype((i))>);
+- // In these two, clang++ produces 'const int&'. Why, when it's
+- // the same as in check_params, just not a template?
+- static_assert(is_same<int &, decltype((jp))>);
+- static_assert(is_same<int &, decltype((ip))>);
+- };
+-
+- (void)[=](decltype((j)) jp, decltype((i)) ip) mutable {
+- static_assert(is_same<int &, decltype((j))>);
+- static_assert(is_same<int &, decltype((i))>);
+- static_assert(is_same<int &, decltype((jp))>);
+- static_assert(is_same<int &, decltype((ip))>);
+- static_assert(is_same<int &, decltype(jp)>);
+- static_assert(is_same<int &, decltype(ip)>);
+- };
+-
+- (void)[a = 0](decltype((a)) ap) mutable {
+- static_assert(is_same<int &, decltype((a))>);
+- static_assert(is_same<int, decltype(a)>);
+- static_assert(is_same<int &, decltype(ap)>);
+- };
+- (void)[a = 0](decltype((a)) ap) {
+- static_assert(is_same<const int &, decltype((a))>);
+- static_assert(is_same<int, decltype(a)>);
+- static_assert(is_same<int&, decltype((ap))>);
+- };
+-}
+-
+-template<typename T>
+-void
+-test_requires ()
+-{
+- int x;
+-
+- [x = 1]() requires is_same<const int &, decltype((x))> {} ();
+- [x = 1]() mutable requires is_same<int &, decltype((x))> {}
+- ();
+- [x]() requires is_same<const int &, decltype((x))> {} ();
+- [x]() mutable requires is_same<int &, decltype((x))> {}
+- ();
+- [=]() requires is_same<const int &, decltype((x))> {} ();
+- [=]() mutable requires is_same<int &, decltype((x))> {}
+- ();
+- [&]() requires is_same<int &, decltype((x))> {}
+- ();
+- [&]() mutable requires is_same<int &, decltype((x))> {}
+- ();
+- [&x]() requires is_same<int &, decltype((x))> {}
+- ();
+- [&x]() mutable requires is_same<int &, decltype((x))> {}
+- ();
+-
+- [x = 1]() requires is_same<const int &, decltype((x))> {} ();
+- [x = 1]() mutable requires is_same<int &, decltype((x))> {} ();
+-}
+-
+-void
+-use ()
+-{
+- test_requires<int>();
+- check_params_tpl<int>();
+-}
+diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope3.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope3.C
+deleted file mode 100644
+index 697fdaae0955..000000000000
+--- a/gcc/testsuite/g++.dg/cpp23/lambda-scope3.C
++++ /dev/null
+@@ -1,44 +0,0 @@
+-// P2036R3 - Change scope of lambda trailing-return-type
+-// PR c++/102610
+-// { dg-do compile { target c++17 } }
+-
+-template <typename T>
+-inline constexpr auto
+-equal1 (T &&t)
+-{
+- return [t = 3](const auto& obj) -> decltype(obj == t)
+- {
+- return obj == t;
+- };
+-}
+-
+-template <typename T>
+-inline constexpr auto
+-equal2 (T &&t)
+-{
+- return [t = t](const auto& obj) -> decltype(obj == t)
+- {
+- return obj == t;
+- };
+-}
+-
+-template <typename T>
+-inline constexpr auto
+-equal3 (T &&t)
+-{
+- return [t = 4](const auto& obj) -> decltype(obj == t)
+- {
+- return obj == t;
+- };
+-}
+-
+-void
+-g ()
+-{
+- constexpr auto l1 = equal1 (5);
+- static_assert (l1 (3));
+- constexpr auto l2 = equal2 (3);
+- static_assert (l2 (3));
+- constexpr auto l3 = equal3 (2);
+- static_assert (l3 (4));
+-}
+diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope4.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope4.C
+deleted file mode 100644
+index 9442db3f9567..000000000000
+--- a/gcc/testsuite/g++.dg/cpp23/lambda-scope4.C
++++ /dev/null
+@@ -1,41 +0,0 @@
+-// P2036R3 - Change scope of lambda trailing-return-type
+-// PR c++/102610
+-// { dg-do compile { target c++17 } }
+-
+-struct integral_constant {
+- using type = integral_constant;
+-};
+-template <bool> using __bool_constant = integral_constant;
+-template <typename _Fn, typename>
+-struct is_invocable : __bool_constant<true> {};
+-int forward() { return 42; }
+-template <typename...> class tuple;
+-struct plus {
+- template <typename _Tp, typename _Up>
+- constexpr auto operator()(_Tp __t, _Up __u) {
+- return __t > __u;
+- }
+-};
+-constexpr auto equal() {
+- int t = 0;
+- return [t = 3](auto obj) -> decltype(obj == t) { return t; };
+-}
+-template <typename> struct is_tuple_invocable;
+-template <typename... Ts> struct is_tuple_invocable<tuple<Ts...>> {
+- using type = typename is_invocable<Ts...>::type;
+-};
+-namespace detail {
+-template <typename F, typename Tail, typename... T>
+-constexpr auto compose(__bool_constant<true>, F f, Tail tail, T... objs) {
+- return f(tail(objs...));
+-}
+-} // namespace detail
+-template <typename F, typename... Fs> constexpr auto compose(F f, Fs... fs) {
+- return [f, tail(fs...)](auto... objs) {
+- auto unitail =
+- typename is_tuple_invocable<tuple<decltype(objs)...>>::type{};
+- return detail::compose(unitail, f, tail, objs...);
+- };
+-}
+-template <auto> constexpr auto eq = equal();
+-static_assert(compose(eq<3>, plus{})(1, 2));
+diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope4b.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope4b.C
+deleted file mode 100644
+index 6a9e6ec5e9d7..000000000000
+--- a/gcc/testsuite/g++.dg/cpp23/lambda-scope4b.C
++++ /dev/null
+@@ -1,42 +0,0 @@
+-// P2036R3 - Change scope of lambda trailing-return-type
+-// PR c++/102610
+-// { dg-do compile { target c++17 } }
+-
+-struct integral_constant {
+- using type = integral_constant;
+-};
+-template <bool> using __bool_constant = integral_constant;
+-template <typename _Fn, typename>
+-struct is_invocable : __bool_constant<true> {};
+-int forward() { return 42; }
+-template <typename...> class tuple;
+-struct plus {
+- template <typename _Tp, typename _Up>
+- constexpr auto operator()(_Tp __t, _Up __u) {
+- return __t > __u;
+- }
+-};
+-constexpr auto equal() {
+- int t = 0;
+- return [t = 3](auto obj) -> decltype(obj == t) { return t; };
+-}
+-template <typename> struct is_tuple_invocable;
+-template <typename... Ts> struct is_tuple_invocable<tuple<Ts...>> {
+- using type = typename is_invocable<Ts...>::type;
+-};
+-namespace detail {
+-template <typename F, typename Tail, typename... T>
+-constexpr auto compose(__bool_constant<true>, F f, Tail tail, T... objs) {
+- return f(tail(objs...));
+-}
+-} // namespace detail
+-template <typename F, typename... Fs>
+-constexpr auto compose(F f, Fs... fs) {
+- return [f, tail(fs...)](auto... objs) -> decltype (detail::compose(typename is_tuple_invocable<tuple<decltype(objs)...>>::type{}, f, tail, objs...)) {
+- auto unitail =
+- typename is_tuple_invocable<tuple<decltype(objs)...>>::type{};
+- return detail::compose(unitail, f, tail, objs...);
+- };
+-}
+-template <auto> constexpr auto eq = equal();
+-static_assert(compose(eq<3>, plus{})(1, 2));
+diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope5.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope5.C
+deleted file mode 100644
+index 48b5ef34c9e9..000000000000
+--- a/gcc/testsuite/g++.dg/cpp23/lambda-scope5.C
++++ /dev/null
+@@ -1,22 +0,0 @@
+-// P2036R3 - Change scope of lambda trailing-return-type
+-// PR c++/102610
+-// { dg-do compile { target c++17 } }
+-
+-constexpr auto equal() {
+- int t = 0;
+- return [t](auto obj) { return obj; };
+-}
+-template <typename F>
+-constexpr int bar (F) {
+- return 42;
+-}
+-
+-template <typename F>
+-constexpr auto compose(F f)
+-{
+- return [f=f](int i) -> decltype(bar (f)) {
+- return 42;
+- };
+-}
+-template <auto> constexpr auto eq = equal();
+-static_assert(compose(eq<3>)(1));
+diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope6.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope6.C
+deleted file mode 100644
+index 720c1ec6cba2..000000000000
+--- a/gcc/testsuite/g++.dg/cpp23/lambda-scope6.C
++++ /dev/null
+@@ -1,20 +0,0 @@
+-// P2036R3 - Change scope of lambda trailing-return-type
+-// PR c++/102610
+-// { dg-do compile { target c++23 } }
+-
+-void
+-g ()
+-{
+- /* It looks like this shouldn't work but [expr.prim.lambda.closure]/6
+- says "Otherwise, it is a non-static member function or member function
+- template that is declared const if and only if the lambda-expression's
+- parameter-declaration-clause is not followed by mutable and the
+- lambda-declarator does not contain an explicit object parameter." */
+- auto counter = [j=0](this auto const& self) -> decltype(j) {
+- return j++;
+- };
+-
+- auto counter2 = [j=0](this auto& self) -> decltype(j) {
+- return j++;
+- };
+-}
+diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope7.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope7.C
+deleted file mode 100644
+index 6db39bd8692c..000000000000
+--- a/gcc/testsuite/g++.dg/cpp23/lambda-scope7.C
++++ /dev/null
+@@ -1,20 +0,0 @@
+-// P2036R3 - Change scope of lambda trailing-return-type
+-// PR c++/102610
+-// { dg-do compile { target c++14_only } }
+-
+-template <typename T>
+-inline constexpr auto
+-equal1 (T &&t)
+-{
+- return [t = 3](const auto& obj) -> decltype(obj == t)
+- {
+- return obj == t;
+- };
+-}
+-
+-void
+-g ()
+-{
+- constexpr auto l1 = equal1 (5); // { dg-error "not literal" }
+- static_assert (l1 (3), ""); // { dg-error "non-constant|non-.constexpr." }
+-}
+diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope8.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope8.C
+deleted file mode 100644
+index 87ad47323809..000000000000
+--- a/gcc/testsuite/g++.dg/cpp23/lambda-scope8.C
++++ /dev/null
+@@ -1,25 +0,0 @@
+-// P2036R3 - Change scope of lambda trailing-return-type
+-// PR c++/102610
+-// { dg-do compile { target c++23 } }
+-// { dg-options "-Wshadow" }
+-
+-void
+-bad ()
+-{
+- [x=1](int x){}; // { dg-error "declared as a capture" }
+- // { dg-warning "shadows a lambda capture" "" { target *-*-* } .-1 }
+- [x=1]{ int x; }; // { dg-error "shadows a parameter" }
+-
+- auto f = [i = 5] () { int i; return 0; }; // { dg-error "shadows a parameter" }
+- auto f2 = [i = 5] <int N> () { int i; return 0; }; // { dg-error "shadows a parameter" }
+-
+- // [expr.prim.lambda.capture]/5
+- int x = 0;
+- auto g = [x](int x) { return 0; }; // { dg-error "declared as a capture" }
+- // { dg-warning "shadows a lambda capture" "" { target *-*-* } .-1 }
+- auto h = [y = 0]<typename y>(y) { return 0; }; // { dg-error "shadows template parameter" }
+-
+- auto l2 = [i = 0, j = i]() -> decltype(i) { // { dg-error "not declared in this scope" }
+- return i;
+- };
+-}
+diff --git a/gcc/testsuite/g++.dg/cpp23/lambda-scope9.C b/gcc/testsuite/g++.dg/cpp23/lambda-scope9.C
+deleted file mode 100644
+index b75e97cb89d7..000000000000
+--- a/gcc/testsuite/g++.dg/cpp23/lambda-scope9.C
++++ /dev/null
+@@ -1,15 +0,0 @@
+-// P2036R3 - Change scope of lambda trailing-return-type
+-// PR c++/102610
+-// { dg-do compile { target c++23 } }
+-// { dg-options "" }
+-
+-constexpr char f(auto a) { return 'a'; }
+-
+-namespace A {
+- int i = 42;
+- template<char X = f([i]{})> void g() { } // { dg-warning "capture of variable .A::i. with non-automatic storage duration" }
+-}
+-
+-namespace B {
+- void call() { A::g(); }
+-}
+diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-19.C b/gcc/testsuite/g++.dg/warn/Wshadow-19.C
+index d0b8dba8549f..030aefd153d8 100644
+--- a/gcc/testsuite/g++.dg/warn/Wshadow-19.C
++++ b/gcc/testsuite/g++.dg/warn/Wshadow-19.C
+@@ -1,5 +1,5 @@
+ // { dg-do compile }
+-// { dg-options "-Wshadow -Wpedantic" }
++// { dg-options "-Wshadow" }
+
+ void
+ foo (int x)
+@@ -10,7 +10,7 @@ foo (int x)
+ extern int y; // { dg-warning "declaration of 'y' shadows a previous local" }
+ }
+ #if __cplusplus >= 201102L
+- auto fn = [x] () { extern int x; return 0; }; // { dg-warning "declaration of 'int x' shadows a parameter" "" { target c++11 } }
++ auto fn = [x] () { extern int x; return 0; }; // { dg-warning "declaration of 'x' shadows a lambda capture" "" { target c++11 } }
+ #endif
+ }
+
+diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-6.C b/gcc/testsuite/g++.dg/warn/Wshadow-6.C
+index 7b44d52781aa..1d8d21b9b6f1 100644
+--- a/gcc/testsuite/g++.dg/warn/Wshadow-6.C
++++ b/gcc/testsuite/g++.dg/warn/Wshadow-6.C
+@@ -33,8 +33,8 @@ void f2(struct S i, int j) {
+
+ void f3(int i) {
+ [=]{
+- int j = i; // { dg-message "previously declared here" }
+- int i; // { dg-error "shadows a parameter" }
++ int j = i; // { dg-message "shadowed declaration" }
++ int i; // { dg-warning "shadows a lambda capture" }
+ i = 1;
+ };
+ }
+@@ -42,8 +42,8 @@ void f3(int i) {
+ template <class T>
+ void f4(int i) {
+ [=]{
+- int j = i; // { dg-message "previously declared here" }
+- int i; // { dg-error "shadows a parameter" }
++ int j = i; // { dg-message "shadowed declaration" }
++ int i; // { dg-warning "shadows a " }
+ i = 1;
+ };
+ }
+
+base-commit: 2be801a805c6cca08aaa33fd387dcc7bd4fe8aac
+--
+2.51.0
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index dcb6159..b2fcc91 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+11 ????
+
+ + 87_all_PR121553-Revert-c-P2036R3-Change-scope-of-lambda-trailing-ret.patch
+
10 17 August 2025
+ 86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-18 23:08 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-18 23:08 UTC (permalink / raw
To: gentoo-commits
commit: fc24904e190e6c785f7c4640ab00d214e397d49e
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 18 23:08:29 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Aug 18 23:08:29 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=fc24904e
16.0.0: update TLS patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
...he-TLS-call-before-all-FLAGS_REG-setting-.patch | 417 ++++++++++++++-------
1 file changed, 291 insertions(+), 126 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
index 497ee1c..d998713 100644
--- a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+++ b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
@@ -1,8 +1,7 @@
-From 81d358d3e24e18744e1c000672c5317d606c91ee Mon Sep 17 00:00:00 2001
-Message-ID: <81d358d3e24e18744e1c000672c5317d606c91ee.1755464442.git.sam@gentoo.org>
+From 93b90830524746278635ddac3a5841caa7139baf Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Sun, 17 Aug 2025 13:50:05 -0700
-Subject: [PATCH] x86: Place the TLS call before all register setting BBs
+Date: Sat, 16 Aug 2025 14:04:33 -0700
+Subject: [PATCH v3] x86: Place the TLS call before all register setting BBs
We can't place a TLS call before a conditional jump in a basic block like
@@ -37,15 +36,10 @@ gcc/
* config/i386/i386-features.cc (replace_tls_call): Add a bitmap
argument and put the updated TLS instruction in the bitmap.
(ix86_get_dominator_for_reg): New.
+ (ix86_emit_tls_call): Likewise.
(ix86_place_single_tls_call): Add 2 bitmap arguments for updated
- GNU and GNU2 TLS instructions. Add the live flag register to the
- bitmap. Insert the __tls_get_addr call before INSN if it replaces
- a __tls_get_addr call. Mark FLAGS register as dead if INSN
- replaced the GNU2 TLS instruction. Clear the live register bitmap
- only for hard register. If there is a conditional jump in the
- basic block or any live caller-saved registers aren't dead at the
- end of the basic block, get the basic block which dominates all
- basic blocks which set the live registers.
+ GNU and GNU2 TLS instructions. Call ix86_emit_tls_call to emit
+ TLS instruction. Correct debug dump for before instruction.
gcc/testsuite/
@@ -57,19 +51,19 @@ gcc/testsuite/
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
- gcc/config/i386/i386-features.cc | 136 ++++++++++++++++----
- gcc/testsuite/gcc.target/i386/pr121572-1a.c | 41 ++++++
- gcc/testsuite/gcc.target/i386/pr121572-1b.c | 18 +++
- gcc/testsuite/gcc.target/i386/pr121572-2a.c | 39 ++++++
+ gcc/config/i386/i386-features.cc | 329 +++++++++++++-------
+ gcc/testsuite/gcc.target/i386/pr121572-1a.c | 41 +++
+ gcc/testsuite/gcc.target/i386/pr121572-1b.c | 18 ++
+ gcc/testsuite/gcc.target/i386/pr121572-2a.c | 39 +++
gcc/testsuite/gcc.target/i386/pr121572-2b.c | 6 +
- 5 files changed, 215 insertions(+), 25 deletions(-)
+ 5 files changed, 327 insertions(+), 106 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1a.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1b.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2a.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2b.c
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index f0bdc5c1880b..903f2b0b4789 100644
+index f0bdc5c1880..b1211ca916a 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -3684,10 +3684,12 @@ ix86_broadcast_inner (rtx op, machine_mode mode,
@@ -97,7 +91,7 @@ index f0bdc5c1880b..903f2b0b4789 100644
if (dump_file)
{
fprintf (dump_file, "\nReplace:\n\n");
-@@ -3732,15 +3737,48 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
+@@ -3732,15 +3737,211 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
}
}
@@ -128,49 +122,82 @@ index f0bdc5c1880b..903f2b0b4789 100644
+ return bb;
+}
+
- /* Generate a TLS call of KIND with VAL and copy the call result to DEST,
- at entry of the nearest dominator for basic block map BBS, which is in
- the fake loop that contains the whole function, so that there is only
-- a single TLS CALL of KIND with VAL in the whole function. If
-- TLSDESC_SET isn't nullptr, insert it before the TLS call. */
-+ a single TLS CALL of KIND with VAL in the whole function.
-+ UPDATED_GNU_TLS_INSNS contains instructions which replace the GNU TLS
-+ instructions. UPDATED_GNU2_TLS_INSNS contains instructions which
-+ replace the GNU2 TLS instructions. If TLSDESC_SET isn't nullptr,
-+ insert it before the TLS call. */
-
- static void
- ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
-- bitmap bbs, rtx tlsdesc_set = nullptr)
-+ auto_bitmap &bbs,
-+ auto_bitmap &updated_gnu_tls_insns,
-+ auto_bitmap &updated_gnu2_tls_insns,
-+ rtx tlsdesc_set = nullptr)
- {
- basic_block bb = nearest_common_dominator_for_set (CDI_DOMINATORS, bbs);
- while (bb->loop_father->latch
-@@ -3748,6 +3786,7 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
- bb = get_immediate_dominator (CDI_DOMINATORS,
- bb->loop_father->header);
-
-+place_tls_call:
- rtx_insn *insn = BB_HEAD (bb);
- while (insn && !NONDEBUG_INSN_P (insn))
- {
-@@ -3824,7 +3863,8 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
- auto_bitmap live_caller_saved_regs;
- bitmap in = df_live ? DF_LIVE_IN (bb) : DF_LR_IN (bb);
-
-- bool flags_live_p = bitmap_bit_p (in, FLAGS_REG);
-+ if (bitmap_bit_p (in, FLAGS_REG))
-+ bitmap_set_bit (live_caller_saved_regs, FLAGS_REG);
-
- unsigned int i;
-
-@@ -3845,13 +3885,46 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
- if (!NONDEBUG_INSN_P (insn))
- continue;
-
++/* Emit a TLS_SET instruction of KIND in basic block BB. Store the
++ insertion point in *BEFORE_P for emit_insn_before or in *AFTER_P
++ for emit_insn_after. UPDATED_GNU_TLS_INSNS contains instructions
++ which replace the GNU TLS instructions. UPDATED_GNU2_TLS_INSNS
++ contains instructions which replace the GNU2 TLS instructions. */
++
++static rtx_insn *
++ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, basic_block bb,
++ rtx_insn **before_p, rtx_insn **after_p,
++ auto_bitmap &updated_gnu_tls_insns,
++ auto_bitmap &updated_gnu2_tls_insns)
++{
++ rtx_insn *tls_insn;
++
++ do
++ {
++ rtx_insn *insn = BB_HEAD (bb);
++ while (insn && !NONDEBUG_INSN_P (insn))
++ {
++ if (insn == BB_END (bb))
++ {
++ insn = NULL;
++ break;
++ }
++ insn = NEXT_INSN (insn);
++ }
++
++ /* TLS_GD and TLS_LD_BASE instructions are normal functions which
++ clobber caller-saved registers. TLSDESC instructions only
++ clobber FLAGS. If any registers clobbered by TLS instructions
++ are live in this basic block, we must insert TLS instructions
++ after all live registers clobbered are dead. */
++
++ auto_bitmap live_caller_saved_regs;
++ bitmap in = df_live ? DF_LIVE_IN (bb) : DF_LR_IN (bb);
++
++ if (bitmap_bit_p (in, FLAGS_REG))
++ bitmap_set_bit (live_caller_saved_regs, FLAGS_REG);
++
++ unsigned int i;
++
++ /* Get all live caller-saved registers for TLS_GD and TLS_LD_BASE
++ instructions. */
++ if (kind != X86_CSE_TLSDESC)
++ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
++ if (call_used_regs[i]
++ && !fixed_regs[i]
++ && bitmap_bit_p (in, i))
++ bitmap_set_bit (live_caller_saved_regs, i);
++
++ if (bitmap_empty_p (live_caller_saved_regs))
++ {
++ if (insn == BB_HEAD (bb))
++ {
++ *before_p = insn;
++ tls_insn = emit_insn_before (tls_set, insn);
++ }
++ else
++ {
++ insn = insn ? PREV_INSN (insn) : BB_END (bb);
++ *after_p = insn;
++ tls_insn = emit_insn_after (tls_set, insn);
++ }
++ return tls_insn;
++ }
++
++ bool repeat = false;
++
++ /* Search for REG_DEAD notes in this basic block. */
++ FOR_BB_INSNS (bb, insn)
++ {
++ if (!NONDEBUG_INSN_P (insn))
++ continue;
++
++ /* NB: Conditional jump is the only instruction which reads
++ flags register and changes control flow. */
+ if (JUMP_P (insn))
+ {
+ /* This must be a conditional jump. */
@@ -184,25 +211,27 @@ index f0bdc5c1880b..903f2b0b4789 100644
+ we can't place a call before nor after a conditional
+ jump. */
+ bb = ix86_get_dominator_for_reg (FLAGS_REG, bb);
-+ goto place_tls_call;
++
++ /* Start over again. */
++ repeat = true;
++ break;
+ }
+
- /* Check if FLAGS register is live. */
- set = single_set (insn);
- if (set)
- {
- rtx dest = SET_DEST (set);
-- if (REG_P (dest) && REGNO (dest) == FLAGS_REG)
-- flags_live_p = true;
++ /* Check if FLAGS register is live. */
++ rtx set = single_set (insn);
++ if (set)
++ {
++ rtx dest = SET_DEST (set);
+ if (REG_P (dest))
+ {
+ if (bitmap_bit_p (updated_gnu_tls_insns,
+ INSN_UID (insn)))
+ {
-+ /* Insert the __tls_get_addr call before INSN which
-+ replaces a __tls_get_addr call. */
-+ before = insn;
-+ goto insert_before;
++ /* Insert the __tls_get_addr call before INSN
++ which replaces a __tls_get_addr call. */
++ *before_p = insn;
++ tls_insn = emit_insn_before (tls_set, insn);
++ return tls_insn;
+ }
+ if (bitmap_bit_p (updated_gnu2_tls_insns,
+ INSN_UID (insn)))
@@ -213,67 +242,206 @@ index f0bdc5c1880b..903f2b0b4789 100644
+ else if (REGNO (dest) == FLAGS_REG)
+ bitmap_set_bit (live_caller_saved_regs, FLAGS_REG);
+ }
- }
++ }
++
++ rtx link;
++ for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
++ if (REG_NOTE_KIND (link) == REG_DEAD
++ && REG_P (XEXP (link, 0)))
++ {
++ /* Mark the live caller-saved register as dead. */
++ for (i = REGNO (XEXP (link, 0));
++ i < END_REGNO (XEXP (link, 0));
++ i++)
++ if (i < FIRST_PSEUDO_REGISTER)
++ bitmap_clear_bit (live_caller_saved_regs, i);
++
++ if (bitmap_empty_p (live_caller_saved_regs))
++ {
++ *after_p = insn;
++ tls_insn = emit_insn_after (tls_set, insn);
++ return tls_insn;
++ }
++ }
++ }
++
++ /* NB: Start over again for conditional jump. */
++ if (repeat)
++ continue;
++
++ /* If any live caller-saved registers aren't dead at the end of
++ this basic block, get the basic block which dominates all
++ basic blocks which set the remaining live registers. */
++ auto_bitmap set_bbs;
++ bitmap_iterator bi;
++ unsigned int id;
++ EXECUTE_IF_SET_IN_BITMAP (live_caller_saved_regs, 0, id, bi)
++ {
++ basic_block set_bb = ix86_get_dominator_for_reg (id, bb);
++ bitmap_set_bit (set_bbs, set_bb->index);
++ }
++ bb = nearest_common_dominator_for_set (CDI_DOMINATORS, set_bbs);
++ }
++ while (true);
++}
++
+ /* Generate a TLS call of KIND with VAL and copy the call result to DEST,
+ at entry of the nearest dominator for basic block map BBS, which is in
+ the fake loop that contains the whole function, so that there is only
+- a single TLS CALL of KIND with VAL in the whole function. If
+- TLSDESC_SET isn't nullptr, insert it before the TLS call. */
++ a single TLS CALL of KIND with VAL in the whole function.
++ UPDATED_GNU_TLS_INSNS contains instructions which replace the GNU TLS
++ instructions. UPDATED_GNU2_TLS_INSNS contains instructions which
++ replace the GNU2 TLS instructions. If TLSDESC_SET isn't nullptr,
++ insert it before the TLS call. */
- rtx link;
-@@ -3863,29 +3936,30 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
- for (i = REGNO (XEXP (link, 0));
- i < END_REGNO (XEXP (link, 0));
- i++)
+ static void
+ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+- bitmap bbs, rtx tlsdesc_set = nullptr)
++ auto_bitmap &bbs,
++ auto_bitmap &updated_gnu_tls_insns,
++ auto_bitmap &updated_gnu2_tls_insns,
++ rtx tlsdesc_set = nullptr)
+ {
+ basic_block bb = nearest_common_dominator_for_set (CDI_DOMINATORS, bbs);
+ while (bb->loop_father->latch
+@@ -3748,17 +3949,6 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+ bb = get_immediate_dominator (CDI_DOMINATORS,
+ bb->loop_father->header);
+
+- rtx_insn *insn = BB_HEAD (bb);
+- while (insn && !NONDEBUG_INSN_P (insn))
+- {
+- if (insn == BB_END (bb))
+- {
+- insn = NULL;
+- break;
+- }
+- insn = NEXT_INSN (insn);
+- }
+-
+ rtx rax = nullptr, rdi;
+ rtx eqv = nullptr;
+ rtx caddr;
+@@ -3766,7 +3956,6 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+ rtx clob;
+ rtx symbol;
+ rtx tls;
+- rtx_insn *tls_insn;
+
+ switch (kind)
+ {
+@@ -3808,94 +3997,13 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+ gcc_unreachable ();
+ }
+
++ /* Emit the TLS CALL insn. */
+ rtx_insn *before = nullptr;
+ rtx_insn *after = nullptr;
+- if (insn == BB_HEAD (bb))
+- before = insn;
+- else
+- after = insn ? PREV_INSN (insn) : BB_END (bb);
+-
+- /* TLS_GD and TLS_LD_BASE instructions are normal functions which
+- clobber caller-saved registers. TLSDESC instructions only clobber
+- FLAGS. If any registers clobbered by TLS instructions are live
+- in this basic block, we must insert TLS instructions after all live
+- registers clobbered are dead. */
+-
+- auto_bitmap live_caller_saved_regs;
+- bitmap in = df_live ? DF_LIVE_IN (bb) : DF_LR_IN (bb);
+-
+- bool flags_live_p = bitmap_bit_p (in, FLAGS_REG);
+-
+- unsigned int i;
+-
+- /* Get all live caller-saved registers for TLS_GD and TLS_LD_BASE
+- instructions. */
+- if (kind != X86_CSE_TLSDESC)
+- for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+- if (call_used_regs[i]
+- && !fixed_regs[i]
+- && bitmap_bit_p (in, i))
+- bitmap_set_bit (live_caller_saved_regs, i);
+-
+- if (!bitmap_empty_p (live_caller_saved_regs))
+- {
+- /* Search for REG_DEAD notes in this basic block. */
+- FOR_BB_INSNS (bb, insn)
+- {
+- if (!NONDEBUG_INSN_P (insn))
+- continue;
+-
+- /* Check if FLAGS register is live. */
+- set = single_set (insn);
+- if (set)
+- {
+- rtx dest = SET_DEST (set);
+- if (REG_P (dest) && REGNO (dest) == FLAGS_REG)
+- flags_live_p = true;
+- }
+-
+- rtx link;
+- for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
+- if (REG_NOTE_KIND (link) == REG_DEAD
+- && REG_P (XEXP (link, 0)))
+- {
+- /* Mark the live caller-saved register as dead. */
+- for (i = REGNO (XEXP (link, 0));
+- i < END_REGNO (XEXP (link, 0));
+- i++)
- bitmap_clear_bit (live_caller_saved_regs, i);
-
- /* Check if FLAGS register is dead. */
- if (REGNO (XEXP (link, 0)) == FLAGS_REG)
- flags_live_p = false;
-+ if (i < FIRST_PSEUDO_REGISTER)
-+ bitmap_clear_bit (live_caller_saved_regs, i);
-
- if (bitmap_empty_p (live_caller_saved_regs))
- {
+-
+- if (bitmap_empty_p (live_caller_saved_regs))
+- {
- /* All live caller-saved registers are dead after
- this instruction. Since TLS instructions
- clobber FLAGS register, it must be dead where
- the TLS will be inserted after. */
- if (flags_live_p)
- gcc_unreachable ();
- after = insn;
- goto insert_after;
- }
- }
- }
-
+- after = insn;
+- goto insert_after;
+- }
+- }
+- }
+-
- /* All live caller-saved registers should be dead at the end
- of this basic block. */
- gcc_unreachable ();
-+ /* If any live caller-saved registers aren't dead at the end
-+ of this basic block, get the basic block which dominates all
-+ basic blocks which set the remaining live registers. */
-+ auto_bitmap set_bbs;
-+ bitmap_iterator bi;
-+ unsigned int id;
-+ EXECUTE_IF_SET_IN_BITMAP (live_caller_saved_regs, 0, id, bi)
-+ {
-+ basic_block set_bb = ix86_get_dominator_for_reg (id, bb);
-+ bitmap_set_bit (set_bbs, set_bb->index);
-+ }
-+ bb = nearest_common_dominator_for_set (CDI_DOMINATORS, set_bbs);
-+ goto place_tls_call;
- }
-
- /* Emit the TLS CALL insn. */
-@@ -3895,7 +3969,10 @@ insert_after:
- tls_insn = emit_insn_after (tls, after);
- }
- else
+- }
+-
+- /* Emit the TLS CALL insn. */
+- if (after)
+- {
+-insert_after:
+- tls_insn = emit_insn_after (tls, after);
+- }
+- else
- tls_insn = emit_insn_before (tls, before);
-+ {
-+insert_before:
-+ tls_insn = emit_insn_before (tls, before);
-+ }
++ rtx_insn *tls_insn = ix86_emit_tls_call (tls, kind, bb, &before,
++ &after,
++ updated_gnu_tls_insns,
++ updated_gnu2_tls_insns);
rtx_insn *tlsdesc_insn = nullptr;
if (tlsdesc_set)
-@@ -4213,6 +4290,8 @@ pass_x86_cse::x86_cse (void)
+@@ -3936,7 +4044,7 @@ insert_after:
+ print_rtl_single (dump_file, tlsdesc_insn);
+ print_rtl_single (dump_file, tls_insn);
+ fprintf (dump_file, "\nbefore:\n\n");
+- print_rtl_single (dump_file, insn);
++ print_rtl_single (dump_file, before);
+ fprintf (dump_file, "\n");
+ }
+ }
+@@ -4213,6 +4321,8 @@ pass_x86_cse::x86_cse (void)
basic_block bb;
rtx_insn *insn;
unsigned int i;
@@ -282,7 +450,7 @@ index f0bdc5c1880b..903f2b0b4789 100644
df_set_flags (DF_DEFER_INSN_RESCAN);
-@@ -4333,7 +4412,10 @@ pass_x86_cse::x86_cse (void)
+@@ -4333,7 +4443,10 @@ pass_x86_cse::x86_cse (void)
case X86_CSE_TLS_LD_BASE:
case X86_CSE_TLSDESC:
broadcast_reg = gen_reg_rtx (load->mode);
@@ -294,7 +462,7 @@ index f0bdc5c1880b..903f2b0b4789 100644
load->broadcast_reg = broadcast_reg;
break;
-@@ -4399,6 +4481,8 @@ pass_x86_cse::x86_cse (void)
+@@ -4399,6 +4512,8 @@ pass_x86_cse::x86_cse (void)
load->val,
load->kind,
load->bbs,
@@ -303,7 +471,7 @@ index f0bdc5c1880b..903f2b0b4789 100644
PATTERN (load->def_insn));
break;
case X86_CSE_VEC_DUP:
-@@ -4442,7 +4526,9 @@ pass_x86_cse::x86_cse (void)
+@@ -4442,7 +4557,9 @@ pass_x86_cse::x86_cse (void)
ix86_place_single_tls_call (load->broadcast_reg,
load->val,
load->kind,
@@ -316,7 +484,7 @@ index f0bdc5c1880b..903f2b0b4789 100644
case X86_CSE_CONSTM1_VECTOR:
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-1a.c b/gcc/testsuite/gcc.target/i386/pr121572-1a.c
new file mode 100644
-index 000000000000..270d8ff5cb6d
+index 00000000000..270d8ff5cb6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121572-1a.c
@@ -0,0 +1,41 @@
@@ -363,7 +531,7 @@ index 000000000000..270d8ff5cb6d
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-1b.c b/gcc/testsuite/gcc.target/i386/pr121572-1b.c
new file mode 100644
-index 000000000000..8a6089109f50
+index 00000000000..8a6089109f5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121572-1b.c
@@ -0,0 +1,18 @@
@@ -387,7 +555,7 @@ index 000000000000..8a6089109f50
+#include "pr121572-1a.c"
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-2a.c b/gcc/testsuite/gcc.target/i386/pr121572-2a.c
new file mode 100644
-index 000000000000..38b254657d35
+index 00000000000..38b254657d3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121572-2a.c
@@ -0,0 +1,39 @@
@@ -432,7 +600,7 @@ index 000000000000..38b254657d35
+/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 1 { target { ! ia32 } } } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-2b.c b/gcc/testsuite/gcc.target/i386/pr121572-2b.c
new file mode 100644
-index 000000000000..33d700243249
+index 00000000000..33d70024324
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121572-2b.c
@@ -0,0 +1,6 @@
@@ -442,8 +610,5 @@ index 000000000000..33d700243249
+#include "pr121572-2a.c"
+
+/* { dg-final { scan-assembler-times "call\[ \t\]\\*__gmpfr_emax@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */
-
-base-commit: 6f63044a7ae63a276a4f6d3108849e093c690bc6
--
2.50.1
-
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-17 22:45 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-17 22:45 UTC (permalink / raw
To: gentoo-commits
commit: 5a9b5a057d7fd45bee241cfe10cfe6354aa352cb
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 22:45:01 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 17 22:45:01 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=5a9b5a05
16.0.0: cut patchset 10
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/README.history | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 64aa256..dcb6159 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,4 +1,4 @@
-10 ???
+10 17 August 2025
+ 86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-17 21:01 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-17 21:01 UTC (permalink / raw
To: gentoo-commits
commit: 3f589e338f62031dbb5efb7f966c0025a154654c
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 21:01:18 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 17 21:01:18 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=3f589e33
16.0.0: tweak patch header
Signed-off-by: Sam James <sam <AT> gentoo.org>
...he-TLS-call-before-all-FLAGS_REG-setting-.patch | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
index 35401c6..497ee1c 100644
--- a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+++ b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
@@ -1,9 +1,8 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121572#c9
-
-From ef27987069ba929157eb43f3b734534dd636f7f4 Mon Sep 17 00:00:00 2001
+From 81d358d3e24e18744e1c000672c5317d606c91ee Mon Sep 17 00:00:00 2001
+Message-ID: <81d358d3e24e18744e1c000672c5317d606c91ee.1755464442.git.sam@gentoo.org>
From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Sat, 16 Aug 2025 14:04:33 -0700
-Subject: [PATCH v2] x86: Place the TLS call before all register setting BBs
+Date: Sun, 17 Aug 2025 13:50:05 -0700
+Subject: [PATCH] x86: Place the TLS call before all register setting BBs
We can't place a TLS call before a conditional jump in a basic block like
@@ -70,7 +69,7 @@ Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2b.c
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index f0bdc5c1880..903f2b0b478 100644
+index f0bdc5c1880b..903f2b0b4789 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -3684,10 +3684,12 @@ ix86_broadcast_inner (rtx op, machine_mode mode,
@@ -317,7 +316,7 @@ index f0bdc5c1880..903f2b0b478 100644
case X86_CSE_CONSTM1_VECTOR:
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-1a.c b/gcc/testsuite/gcc.target/i386/pr121572-1a.c
new file mode 100644
-index 00000000000..270d8ff5cb6
+index 000000000000..270d8ff5cb6d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121572-1a.c
@@ -0,0 +1,41 @@
@@ -364,7 +363,7 @@ index 00000000000..270d8ff5cb6
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-1b.c b/gcc/testsuite/gcc.target/i386/pr121572-1b.c
new file mode 100644
-index 00000000000..8a6089109f5
+index 000000000000..8a6089109f50
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121572-1b.c
@@ -0,0 +1,18 @@
@@ -388,7 +387,7 @@ index 00000000000..8a6089109f5
+#include "pr121572-1a.c"
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-2a.c b/gcc/testsuite/gcc.target/i386/pr121572-2a.c
new file mode 100644
-index 00000000000..38b254657d3
+index 000000000000..38b254657d35
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121572-2a.c
@@ -0,0 +1,39 @@
@@ -433,7 +432,7 @@ index 00000000000..38b254657d3
+/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 1 { target { ! ia32 } } } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-2b.c b/gcc/testsuite/gcc.target/i386/pr121572-2b.c
new file mode 100644
-index 00000000000..33d70024324
+index 000000000000..33d700243249
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121572-2b.c
@@ -0,0 +1,6 @@
@@ -443,5 +442,8 @@ index 00000000000..33d70024324
+#include "pr121572-2a.c"
+
+/* { dg-final { scan-assembler-times "call\[ \t\]\\*__gmpfr_emax@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */
+
+base-commit: 6f63044a7ae63a276a4f6d3108849e093c690bc6
--
2.50.1
+
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-17 16:30 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-17 16:30 UTC (permalink / raw
To: gentoo-commits
commit: 87b21b5805818ff1dfe4940104d8640f1746d0a4
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 16:30:42 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 17 16:30:42 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=87b21b58
16.0.0: update TLS patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
...he-TLS-call-before-all-FLAGS_REG-setting-.patch | 124 +++++++++++----------
1 file changed, 68 insertions(+), 56 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
index ad929ae..35401c6 100644
--- a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+++ b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
@@ -1,6 +1,6 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121572#c8
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121572#c9
-From db980f943e547d786c2a33798b0e217b658058c4 Mon Sep 17 00:00:00 2001
+From ef27987069ba929157eb43f3b734534dd636f7f4 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 16 Aug 2025 14:04:33 -0700
Subject: [PATCH v2] x86: Place the TLS call before all register setting BBs
@@ -29,23 +29,8 @@ the basic block:
Instead, we should place such call before all register setting basic
blocks which dominate the current basic block.
-NB: GNU2 TLS:
-
-(insn 66 2 5 2 (parallel [
- (set (reg:DI 116)
- (plus:DI (unspec:DI [
- (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
- (unspec:DI [
- (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
- ] UNSPEC_TLSDESC)
- (reg/f:DI 7 sp)] UNSPEC_TLSDESC)
- (const:DI (unspec:DI [
- (symbol_ref:DI ("tv_cache") [flags 0x5a])
- ] UNSPEC_DTPOFF))))
- (clobber (reg:CC 17 flags))]) 1678 {*tls_dynamic_gnu2_combine_64_di}
- (nil))
-
-only clobbers flags register.
+Keep track the replaced GNU and GNU2 TLS instructions. Use these info to
+place the __tls_get_addr call and mark FLAGS register as dead.
gcc/
@@ -53,14 +38,15 @@ gcc/
* config/i386/i386-features.cc (replace_tls_call): Add a bitmap
argument and put the updated TLS instruction in the bitmap.
(ix86_get_dominator_for_reg): New.
- (ix86_place_single_tls_call): Add a bitmap argument for updated
- TLS instructions. Add the live flag register to the bitmap.
- Mark FLAGS register as dead if INSN replaced the TLS instruction.
- Clear the live register bitmap only for hard register. If there
- is a conditional jump in the basic block or any live caller-saved
- registers aren't dead at the end of the basic block, get the basic
- block which dominates all basic blocks which set the live
- registers.
+ (ix86_place_single_tls_call): Add 2 bitmap arguments for updated
+ GNU and GNU2 TLS instructions. Add the live flag register to the
+ bitmap. Insert the __tls_get_addr call before INSN if it replaces
+ a __tls_get_addr call. Mark FLAGS register as dead if INSN
+ replaced the GNU2 TLS instruction. Clear the live register bitmap
+ only for hard register. If there is a conditional jump in the
+ basic block or any live caller-saved registers aren't dead at the
+ end of the basic block, get the basic block which dominates all
+ basic blocks which set the live registers.
gcc/testsuite/
@@ -72,19 +58,19 @@ gcc/testsuite/
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
- gcc/config/i386/i386-features.cc | 117 ++++++++++++++++----
- gcc/testsuite/gcc.target/i386/pr121572-1a.c | 41 +++++++
+ gcc/config/i386/i386-features.cc | 136 ++++++++++++++++----
+ gcc/testsuite/gcc.target/i386/pr121572-1a.c | 41 ++++++
gcc/testsuite/gcc.target/i386/pr121572-1b.c | 18 +++
- gcc/testsuite/gcc.target/i386/pr121572-2a.c | 39 +++++++
+ gcc/testsuite/gcc.target/i386/pr121572-2a.c | 39 ++++++
gcc/testsuite/gcc.target/i386/pr121572-2b.c | 6 +
- 5 files changed, 197 insertions(+), 24 deletions(-)
+ 5 files changed, 215 insertions(+), 25 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1a.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1b.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2a.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2b.c
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index f0bdc5c1880..e7285c639dd 100644
+index f0bdc5c1880..903f2b0b478 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -3684,10 +3684,12 @@ ix86_broadcast_inner (rtx op, machine_mode mode,
@@ -112,7 +98,7 @@ index f0bdc5c1880..e7285c639dd 100644
if (dump_file)
{
fprintf (dump_file, "\nReplace:\n\n");
-@@ -3732,15 +3737,46 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
+@@ -3732,15 +3737,48 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
}
}
@@ -149,20 +135,22 @@ index f0bdc5c1880..e7285c639dd 100644
- a single TLS CALL of KIND with VAL in the whole function. If
- TLSDESC_SET isn't nullptr, insert it before the TLS call. */
+ a single TLS CALL of KIND with VAL in the whole function.
-+ UPDATED_TLS_INSNS contains instructions which replace the original TLS
-+ instructions. If TLSDESC_SET isn't nullptr, insert it before the TLS
-+ call. */
++ UPDATED_GNU_TLS_INSNS contains instructions which replace the GNU TLS
++ instructions. UPDATED_GNU2_TLS_INSNS contains instructions which
++ replace the GNU2 TLS instructions. If TLSDESC_SET isn't nullptr,
++ insert it before the TLS call. */
static void
ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
- bitmap bbs, rtx tlsdesc_set = nullptr)
+ auto_bitmap &bbs,
-+ auto_bitmap &updated_tls_insns,
++ auto_bitmap &updated_gnu_tls_insns,
++ auto_bitmap &updated_gnu2_tls_insns,
+ rtx tlsdesc_set = nullptr)
{
basic_block bb = nearest_common_dominator_for_set (CDI_DOMINATORS, bbs);
while (bb->loop_father->latch
-@@ -3748,6 +3784,7 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+@@ -3748,6 +3786,7 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
bb = get_immediate_dominator (CDI_DOMINATORS,
bb->loop_father->header);
@@ -170,7 +158,7 @@ index f0bdc5c1880..e7285c639dd 100644
rtx_insn *insn = BB_HEAD (bb);
while (insn && !NONDEBUG_INSN_P (insn))
{
-@@ -3824,7 +3861,8 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+@@ -3824,7 +3863,8 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
auto_bitmap live_caller_saved_regs;
bitmap in = df_live ? DF_LIVE_IN (bb) : DF_LR_IN (bb);
@@ -180,7 +168,7 @@ index f0bdc5c1880..e7285c639dd 100644
unsigned int i;
-@@ -3845,13 +3883,39 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+@@ -3845,13 +3885,46 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
if (!NONDEBUG_INSN_P (insn))
continue;
@@ -209,20 +197,27 @@ index f0bdc5c1880..e7285c639dd 100644
- flags_live_p = true;
+ if (REG_P (dest))
+ {
-+ if (REGNO (dest) == FLAGS_REG)
-+ bitmap_set_bit (live_caller_saved_regs, FLAGS_REG);
-+ /* NB: Mark FLAGS register as dead if INSN replaced
-+ the TLS instruction since FLAGS register would be
-+ clobbered by the TLS instruction. */
-+ else if (bitmap_bit_p (updated_tls_insns,
-+ INSN_UID (insn)))
++ if (bitmap_bit_p (updated_gnu_tls_insns,
++ INSN_UID (insn)))
++ {
++ /* Insert the __tls_get_addr call before INSN which
++ replaces a __tls_get_addr call. */
++ before = insn;
++ goto insert_before;
++ }
++ if (bitmap_bit_p (updated_gnu2_tls_insns,
++ INSN_UID (insn)))
++ /* Mark FLAGS register as dead since FLAGS register
++ would be clobbered by the GNU2 TLS instruction. */
+ bitmap_clear_bit (live_caller_saved_regs,
+ FLAGS_REG);
++ else if (REGNO (dest) == FLAGS_REG)
++ bitmap_set_bit (live_caller_saved_regs, FLAGS_REG);
+ }
}
rtx link;
-@@ -3863,29 +3927,30 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+@@ -3863,29 +3936,30 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
for (i = REGNO (XEXP (link, 0));
i < END_REGNO (XEXP (link, 0));
i++)
@@ -267,39 +262,56 @@ index f0bdc5c1880..e7285c639dd 100644
}
/* Emit the TLS CALL insn. */
-@@ -4213,6 +4278,7 @@ pass_x86_cse::x86_cse (void)
+@@ -3895,7 +3969,10 @@ insert_after:
+ tls_insn = emit_insn_after (tls, after);
+ }
+ else
+- tls_insn = emit_insn_before (tls, before);
++ {
++insert_before:
++ tls_insn = emit_insn_before (tls, before);
++ }
+
+ rtx_insn *tlsdesc_insn = nullptr;
+ if (tlsdesc_set)
+@@ -4213,6 +4290,8 @@ pass_x86_cse::x86_cse (void)
basic_block bb;
rtx_insn *insn;
unsigned int i;
-+ auto_bitmap updated_tls_insns;
++ auto_bitmap updated_gnu_tls_insns;
++ auto_bitmap updated_gnu2_tls_insns;
df_set_flags (DF_DEFER_INSN_RESCAN);
-@@ -4333,7 +4399,8 @@ pass_x86_cse::x86_cse (void)
+@@ -4333,7 +4412,10 @@ pass_x86_cse::x86_cse (void)
case X86_CSE_TLS_LD_BASE:
case X86_CSE_TLSDESC:
broadcast_reg = gen_reg_rtx (load->mode);
- replace_tls_call (broadcast_reg, load->insns);
+ replace_tls_call (broadcast_reg, load->insns,
-+ updated_tls_insns);
++ (load->kind == X86_CSE_TLSDESC
++ ? updated_gnu2_tls_insns
++ : updated_gnu_tls_insns));
load->broadcast_reg = broadcast_reg;
break;
-@@ -4399,6 +4466,7 @@ pass_x86_cse::x86_cse (void)
+@@ -4399,6 +4481,8 @@ pass_x86_cse::x86_cse (void)
load->val,
load->kind,
load->bbs,
-+ updated_tls_insns,
++ updated_gnu_tls_insns,
++ updated_gnu2_tls_insns,
PATTERN (load->def_insn));
break;
case X86_CSE_VEC_DUP:
-@@ -4442,7 +4510,8 @@ pass_x86_cse::x86_cse (void)
+@@ -4442,7 +4526,9 @@ pass_x86_cse::x86_cse (void)
ix86_place_single_tls_call (load->broadcast_reg,
load->val,
load->kind,
- load->bbs);
+ load->bbs,
-+ updated_tls_insns);
++ updated_gnu_tls_insns,
++ updated_gnu2_tls_insns);
break;
case X86_CSE_CONST0_VECTOR:
case X86_CSE_CONSTM1_VECTOR:
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-17 15:44 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-17 15:44 UTC (permalink / raw
To: gentoo-commits
commit: 09f392c758f706895861300d59557e185aac0697
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 15:44:10 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 17 15:44:10 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=09f392c7
16.0.0: update TLS patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
...he-TLS-call-before-all-FLAGS_REG-setting-.patch | 186 ++++++++++++++-------
1 file changed, 126 insertions(+), 60 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
index a01b5bc..ad929ae 100644
--- a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+++ b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
@@ -1,9 +1,9 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121572#c6
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121572#c8
-From 27d463bd32623918d641a4f5168811ae86939e9b Mon Sep 17 00:00:00 2001
+From db980f943e547d786c2a33798b0e217b658058c4 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 16 Aug 2025 14:04:33 -0700
-Subject: [PATCH] x86: Place the TLS call before all register setting BBs
+Subject: [PATCH v2] x86: Place the TLS call before all register setting BBs
We can't place a TLS call before a conditional jump in a basic block like
@@ -50,13 +50,17 @@ only clobbers flags register.
gcc/
PR target/121572
- * config/i386/i386-features.cc (ix86_get_dominator_for_reg): New.
- (ix86_place_single_tls_call): Add the live flag register to the
- bitmap. Clear the live register bitmap only for hard register.
- If there is a conditional jump in the basic block or any live
- caller-saved registers aren't dead at the end of the basic block,
- get the basic block which dominates all basic blocks which set
- the live registers.
+ * config/i386/i386-features.cc (replace_tls_call): Add a bitmap
+ argument and put the updated TLS instruction in the bitmap.
+ (ix86_get_dominator_for_reg): New.
+ (ix86_place_single_tls_call): Add a bitmap argument for updated
+ TLS instructions. Add the live flag register to the bitmap.
+ Mark FLAGS register as dead if INSN replaced the TLS instruction.
+ Clear the live register bitmap only for hard register. If there
+ is a conditional jump in the basic block or any live caller-saved
+ registers aren't dead at the end of the basic block, get the basic
+ block which dominates all basic blocks which set the live
+ registers.
gcc/testsuite/
@@ -68,22 +72,47 @@ gcc/testsuite/
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
- gcc/config/i386/i386-features.cc | 77 ++++++++++++++++-----
- gcc/testsuite/gcc.target/i386/pr121572-1a.c | 41 +++++++++++
- gcc/testsuite/gcc.target/i386/pr121572-1b.c | 18 +++++
- gcc/testsuite/gcc.target/i386/pr121572-2a.c | 55 +++++++++++++++
- gcc/testsuite/gcc.target/i386/pr121572-2b.c | 17 +++++
- 5 files changed, 192 insertions(+), 16 deletions(-)
+ gcc/config/i386/i386-features.cc | 117 ++++++++++++++++----
+ gcc/testsuite/gcc.target/i386/pr121572-1a.c | 41 +++++++
+ gcc/testsuite/gcc.target/i386/pr121572-1b.c | 18 +++
+ gcc/testsuite/gcc.target/i386/pr121572-2a.c | 39 +++++++
+ gcc/testsuite/gcc.target/i386/pr121572-2b.c | 6 +
+ 5 files changed, 197 insertions(+), 24 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1a.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1b.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2a.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2b.c
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index f0bdc5c1880..235c255232a 100644
+index f0bdc5c1880..e7285c639dd 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
-@@ -3732,6 +3732,33 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
+@@ -3684,10 +3684,12 @@ ix86_broadcast_inner (rtx op, machine_mode mode,
+ return op;
+ }
+
+-/* Replace CALL instruction in TLS_CALL_INSNS with SET from SRC. */
++/* Replace CALL instruction in TLS_CALL_INSNS with SET from SRC and
++ put the updated instruction in UPDATED_TLS_INSNS. */
+
+ static void
+-replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
++replace_tls_call (rtx src, auto_bitmap &tls_call_insns,
++ auto_bitmap &updated_tls_insns)
+ {
+ bitmap_iterator bi;
+ unsigned int id;
+@@ -3716,6 +3718,9 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
+ if (recog_memoized (set_insn) < 0)
+ gcc_unreachable ();
+
++ /* Put SET_INSN in UPDATED_TLS_INSNS. */
++ bitmap_set_bit (updated_tls_insns, INSN_UID (set_insn));
++
+ if (dump_file)
+ {
+ fprintf (dump_file, "\nReplace:\n\n");
+@@ -3732,15 +3737,46 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
}
}
@@ -117,7 +146,23 @@ index f0bdc5c1880..235c255232a 100644
/* Generate a TLS call of KIND with VAL and copy the call result to DEST,
at entry of the nearest dominator for basic block map BBS, which is in
the fake loop that contains the whole function, so that there is only
-@@ -3748,6 +3775,7 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+- a single TLS CALL of KIND with VAL in the whole function. If
+- TLSDESC_SET isn't nullptr, insert it before the TLS call. */
++ a single TLS CALL of KIND with VAL in the whole function.
++ UPDATED_TLS_INSNS contains instructions which replace the original TLS
++ instructions. If TLSDESC_SET isn't nullptr, insert it before the TLS
++ call. */
+
+ static void
+ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+- bitmap bbs, rtx tlsdesc_set = nullptr)
++ auto_bitmap &bbs,
++ auto_bitmap &updated_tls_insns,
++ rtx tlsdesc_set = nullptr)
+ {
+ basic_block bb = nearest_common_dominator_for_set (CDI_DOMINATORS, bbs);
+ while (bb->loop_father->latch
+@@ -3748,6 +3784,7 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
bb = get_immediate_dominator (CDI_DOMINATORS,
bb->loop_father->header);
@@ -125,7 +170,7 @@ index f0bdc5c1880..235c255232a 100644
rtx_insn *insn = BB_HEAD (bb);
while (insn && !NONDEBUG_INSN_P (insn))
{
-@@ -3824,7 +3852,8 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+@@ -3824,7 +3861,8 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
auto_bitmap live_caller_saved_regs;
bitmap in = df_live ? DF_LIVE_IN (bb) : DF_LR_IN (bb);
@@ -135,7 +180,7 @@ index f0bdc5c1880..235c255232a 100644
unsigned int i;
-@@ -3845,13 +3874,28 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+@@ -3845,13 +3883,39 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
if (!NONDEBUG_INSN_P (insn))
continue;
@@ -151,7 +196,8 @@ index f0bdc5c1880..235c255232a 100644
+ /* Place the call before all FLAGS_REG setting BBs since
+ we can't place a call before nor after a conditional
+ jump. */
-+ break;
++ bb = ix86_get_dominator_for_reg (FLAGS_REG, bb);
++ goto place_tls_call;
+ }
+
/* Check if FLAGS register is live. */
@@ -159,13 +205,24 @@ index f0bdc5c1880..235c255232a 100644
if (set)
{
rtx dest = SET_DEST (set);
- if (REG_P (dest) && REGNO (dest) == FLAGS_REG)
+- if (REG_P (dest) && REGNO (dest) == FLAGS_REG)
- flags_live_p = true;
-+ bitmap_set_bit (live_caller_saved_regs, FLAGS_REG);
++ if (REG_P (dest))
++ {
++ if (REGNO (dest) == FLAGS_REG)
++ bitmap_set_bit (live_caller_saved_regs, FLAGS_REG);
++ /* NB: Mark FLAGS register as dead if INSN replaced
++ the TLS instruction since FLAGS register would be
++ clobbered by the TLS instruction. */
++ else if (bitmap_bit_p (updated_tls_insns,
++ INSN_UID (insn)))
++ bitmap_clear_bit (live_caller_saved_regs,
++ FLAGS_REG);
++ }
}
rtx link;
-@@ -3863,29 +3907,30 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+@@ -3863,29 +3927,30 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
for (i = REGNO (XEXP (link, 0));
i < END_REGNO (XEXP (link, 0));
i++)
@@ -210,6 +267,42 @@ index f0bdc5c1880..235c255232a 100644
}
/* Emit the TLS CALL insn. */
+@@ -4213,6 +4278,7 @@ pass_x86_cse::x86_cse (void)
+ basic_block bb;
+ rtx_insn *insn;
+ unsigned int i;
++ auto_bitmap updated_tls_insns;
+
+ df_set_flags (DF_DEFER_INSN_RESCAN);
+
+@@ -4333,7 +4399,8 @@ pass_x86_cse::x86_cse (void)
+ case X86_CSE_TLS_LD_BASE:
+ case X86_CSE_TLSDESC:
+ broadcast_reg = gen_reg_rtx (load->mode);
+- replace_tls_call (broadcast_reg, load->insns);
++ replace_tls_call (broadcast_reg, load->insns,
++ updated_tls_insns);
+ load->broadcast_reg = broadcast_reg;
+ break;
+
+@@ -4399,6 +4466,7 @@ pass_x86_cse::x86_cse (void)
+ load->val,
+ load->kind,
+ load->bbs,
++ updated_tls_insns,
+ PATTERN (load->def_insn));
+ break;
+ case X86_CSE_VEC_DUP:
+@@ -4442,7 +4510,8 @@ pass_x86_cse::x86_cse (void)
+ ix86_place_single_tls_call (load->broadcast_reg,
+ load->val,
+ load->kind,
+- load->bbs);
++ load->bbs,
++ updated_tls_insns);
+ break;
+ case X86_CSE_CONST0_VECTOR:
+ case X86_CSE_CONSTM1_VECTOR:
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-1a.c b/gcc/testsuite/gcc.target/i386/pr121572-1a.c
new file mode 100644
index 00000000000..270d8ff5cb6
@@ -283,30 +376,12 @@ index 00000000000..8a6089109f5
+#include "pr121572-1a.c"
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-2a.c b/gcc/testsuite/gcc.target/i386/pr121572-2a.c
new file mode 100644
-index 00000000000..3f2230f8885
+index 00000000000..38b254657d3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121572-2a.c
-@@ -0,0 +1,55 @@
+@@ -0,0 +1,39 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
-+
-+/*
-+**mpfr_agm:
-+**.LFB[0-9]+:
-+**...
-+** movl %edi, %ebp
-+** data16 leaq __gmpfr_emax@tlsgd\(%rip\), %rdi
-+** .value 0x6666
-+** rex64
-+** call __tls_get_addr@PLT
-+** mov[l|q] mpfr_agm_compare@GOTPCREL\(%rip\), %[e|r]dx
-+** movl \(%[e|r]dx\), %edx
-+** testl %edx, %edx
-+** je .L2
-+**...
-+*/
+
+typedef enum
+{
@@ -342,28 +417,19 @@ index 00000000000..3f2230f8885
+ __gmpfr_emin = __gmpfr_emax;
+ return 0;
+}
++
++/* { dg-final { scan-assembler-times "call\[ \t\]__tls_get_addr@PLT" 1 { target { ! ia32 } } } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-2b.c b/gcc/testsuite/gcc.target/i386/pr121572-2b.c
new file mode 100644
-index 00000000000..d81e2edc6f2
+index 00000000000..33d70024324
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121572-2b.c
-@@ -0,0 +1,17 @@
+@@ -0,0 +1,6 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu2" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
-+
-+/*
-+**mpfr_agm:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+** sub[l|q] \$[0-9]+, %[e|r]sp
-+** .cfi_def_cfa_offset [0-9]+
-+** lea[l|q] __gmpfr_emax@TLSDESC\(%rip\), %[e|r]ax
-+** call \*__gmpfr_emax@TLSCALL\(%[e|r]ax\)
-+**...
-+*/
+
+#include "pr121572-2a.c"
++
++/* { dg-final { scan-assembler-times "call\[ \t\]\\*__gmpfr_emax@TLSCALL\\(%(?:r|e)ax\\)" 1 { target { ! ia32 } } } } */
--
2.50.1
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-17 15:10 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-17 15:10 UTC (permalink / raw
To: gentoo-commits
commit: 80713478a329eba635f17209a3e1ed0549062060
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 15:10:50 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug 17 15:10:50 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=80713478
16.0.0: update TLS patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
...he-TLS-call-before-all-FLAGS_REG-setting-.patch | 287 ++++++++++++++++-----
1 file changed, 227 insertions(+), 60 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
index 62ccbe9..a01b5bc 100644
--- a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+++ b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
@@ -1,9 +1,9 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121572#c4
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121572#c6
-From caceadf47fe1b278311c73d5cbd062dca62298ac Mon Sep 17 00:00:00 2001
+From 27d463bd32623918d641a4f5168811ae86939e9b Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 16 Aug 2025 14:04:33 -0700
-Subject: [PATCH] x86: Place the TLS call before all FLAGS_REG setting BBs
+Subject: [PATCH] x86: Place the TLS call before all register setting BBs
We can't place a TLS call before a conditional jump in a basic block like
@@ -18,9 +18,16 @@ We can't place a TLS call before a conditional jump in a basic block like
(int_list:REG_BR_PROB 628353713 (nil)))
-> 27)
-since the TLS call will clobber flags register. Instead, we should place
-such call before all register setting basic blocks which dominate the
-current basic block.
+since the TLS call will clobber flags register nor place a TLS call in a
+basic block if any live caller-saved registers aren't dead at the end of
+the basic block:
+
+;; live in 6 [bp] 7 [sp] 16 [argp] 17 [flags] 19 [frame] 104
+;; live gen 0 [ax] 102 106 108 116 117 118 120
+;; live kill 5 [di]
+
+Instead, we should place such call before all register setting basic
+blocks which dominate the current basic block.
NB: GNU2 TLS:
@@ -43,30 +50,74 @@ only clobbers flags register.
gcc/
PR target/121572
- * config/i386/i386-features.cc (ix86_place_single_tls_call): Also
- search for REG_DEAD notes if flag register is alive. Place the
- TLS call before all FLAGS_REG setting BBs for conditional jump.
+ * config/i386/i386-features.cc (ix86_get_dominator_for_reg): New.
+ (ix86_place_single_tls_call): Add the live flag register to the
+ bitmap. Clear the live register bitmap only for hard register.
+ If there is a conditional jump in the basic block or any live
+ caller-saved registers aren't dead at the end of the basic block,
+ get the basic block which dominates all basic blocks which set
+ the live registers.
gcc/testsuite/
PR target/121572
* gcc.target/i386/pr121572-1a.c: New test.
* gcc.target/i386/pr121572-1b.c: Likewise.
+ * gcc.target/i386/pr121572-2a.c: Likewise.
+ * gcc.target/i386/pr121572-2b.c: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
- gcc/config/i386/i386-features.cc | 41 ++++++++++++++++++++-
- gcc/testsuite/gcc.target/i386/pr121572-1a.c | 40 ++++++++++++++++++++
- gcc/testsuite/gcc.target/i386/pr121572-1b.c | 18 +++++++++
- 3 files changed, 98 insertions(+), 1 deletion(-)
+ gcc/config/i386/i386-features.cc | 77 ++++++++++++++++-----
+ gcc/testsuite/gcc.target/i386/pr121572-1a.c | 41 +++++++++++
+ gcc/testsuite/gcc.target/i386/pr121572-1b.c | 18 +++++
+ gcc/testsuite/gcc.target/i386/pr121572-2a.c | 55 +++++++++++++++
+ gcc/testsuite/gcc.target/i386/pr121572-2b.c | 17 +++++
+ 5 files changed, 192 insertions(+), 16 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1a.c
create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1b.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-2b.c
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index f0bdc5c1880..7cdf98c5778 100644
+index f0bdc5c1880..235c255232a 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
-@@ -3748,6 +3748,7 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+@@ -3732,6 +3732,33 @@ replace_tls_call (rtx src, auto_bitmap &tls_call_insns)
+ }
+ }
+
++/* Return the basic block which dominates all basic blocks which set
++ hard register REGNO used in basic block BB. */
++
++static basic_block
++ix86_get_dominator_for_reg (unsigned int regno, basic_block bb)
++{
++ basic_block set_bb;
++ auto_bitmap set_bbs;
++
++ /* Get all BBs which set REGNO and dominate the current BB from all
++ DEFs of REGNO. */
++ for (df_ref def = DF_REG_DEF_CHAIN (regno);
++ def;
++ def = DF_REF_NEXT_REG (def))
++ if (!DF_REF_IS_ARTIFICIAL (def)
++ && !DF_REF_FLAGS_IS_SET (def, DF_REF_MAY_CLOBBER)
++ && !DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER))
++ {
++ set_bb = DF_REF_BB (def);
++ if (dominated_by_p (CDI_DOMINATORS, bb, set_bb))
++ bitmap_set_bit (set_bbs, set_bb->index);
++ }
++
++ bb = nearest_common_dominator_for_set (CDI_DOMINATORS, set_bbs);
++ return bb;
++}
++
+ /* Generate a TLS call of KIND with VAL and copy the call result to DEST,
+ at entry of the nearest dominator for basic block map BBS, which is in
+ the fake loop that contains the whole function, so that there is only
+@@ -3748,6 +3775,7 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
bb = get_immediate_dominator (CDI_DOMINATORS,
bb->loop_father->header);
@@ -74,16 +125,17 @@ index f0bdc5c1880..7cdf98c5778 100644
rtx_insn *insn = BB_HEAD (bb);
while (insn && !NONDEBUG_INSN_P (insn))
{
-@@ -3837,7 +3838,7 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
- && bitmap_bit_p (in, i))
- bitmap_set_bit (live_caller_saved_regs, i);
+@@ -3824,7 +3852,8 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+ auto_bitmap live_caller_saved_regs;
+ bitmap in = df_live ? DF_LIVE_IN (bb) : DF_LR_IN (bb);
-- if (!bitmap_empty_p (live_caller_saved_regs))
-+ if (flags_live_p || !bitmap_empty_p (live_caller_saved_regs))
- {
- /* Search for REG_DEAD notes in this basic block. */
- FOR_BB_INSNS (bb, insn)
-@@ -3845,6 +3846,44 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+- bool flags_live_p = bitmap_bit_p (in, FLAGS_REG);
++ if (bitmap_bit_p (in, FLAGS_REG))
++ bitmap_set_bit (live_caller_saved_regs, FLAGS_REG);
+
+ unsigned int i;
+
+@@ -3845,13 +3874,28 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
if (!NONDEBUG_INSN_P (insn))
continue;
@@ -96,44 +148,74 @@ index f0bdc5c1880..7cdf98c5778 100644
+ || !(LABEL_P (label) || SYMBOL_REF_P (label)))
+ gcc_unreachable ();
+
-+ rtx_insn *set_insn;
-+ basic_block set_bb;
-+ auto_bitmap set_bbs;
-+
-+ /* Get all BBs which define FLAGS_REG and dominate the
-+ current BB from all DEFs of FLAGS_REG. */
-+ for (df_ref def = DF_REG_DEF_CHAIN (FLAGS_REG);
-+ def;
-+ def = DF_REF_NEXT_REG (def))
-+ if (!DF_REF_IS_ARTIFICIAL (def)
-+ && !DF_REF_FLAGS_IS_SET (def, DF_REF_MAY_CLOBBER)
-+ && !DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER))
-+ {
-+ set_insn = DF_REF_INSN (def);
-+ set = single_set (set_insn);
-+ gcc_assert (set);
-+ set_bb = DF_REF_BB (def);
-+ if (dominated_by_p (CDI_DOMINATORS, bb, set_bb))
-+ bitmap_set_bit (set_bbs, set_bb->index);
-+ }
-+
+ /* Place the call before all FLAGS_REG setting BBs since
+ we can't place a call before nor after a conditional
+ jump. */
-+ bb = nearest_common_dominator_for_set (CDI_DOMINATORS,
-+ set_bbs);
-+ goto place_tls_call;
++ break;
+ }
+
/* Check if FLAGS register is live. */
set = single_set (insn);
if (set)
+ {
+ rtx dest = SET_DEST (set);
+ if (REG_P (dest) && REGNO (dest) == FLAGS_REG)
+- flags_live_p = true;
++ bitmap_set_bit (live_caller_saved_regs, FLAGS_REG);
+ }
+
+ rtx link;
+@@ -3863,29 +3907,30 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+ for (i = REGNO (XEXP (link, 0));
+ i < END_REGNO (XEXP (link, 0));
+ i++)
+- bitmap_clear_bit (live_caller_saved_regs, i);
+-
+- /* Check if FLAGS register is dead. */
+- if (REGNO (XEXP (link, 0)) == FLAGS_REG)
+- flags_live_p = false;
++ if (i < FIRST_PSEUDO_REGISTER)
++ bitmap_clear_bit (live_caller_saved_regs, i);
+
+ if (bitmap_empty_p (live_caller_saved_regs))
+ {
+- /* All live caller-saved registers are dead after
+- this instruction. Since TLS instructions
+- clobber FLAGS register, it must be dead where
+- the TLS will be inserted after. */
+- if (flags_live_p)
+- gcc_unreachable ();
+ after = insn;
+ goto insert_after;
+ }
+ }
+ }
+
+- /* All live caller-saved registers should be dead at the end
+- of this basic block. */
+- gcc_unreachable ();
++ /* If any live caller-saved registers aren't dead at the end
++ of this basic block, get the basic block which dominates all
++ basic blocks which set the remaining live registers. */
++ auto_bitmap set_bbs;
++ bitmap_iterator bi;
++ unsigned int id;
++ EXECUTE_IF_SET_IN_BITMAP (live_caller_saved_regs, 0, id, bi)
++ {
++ basic_block set_bb = ix86_get_dominator_for_reg (id, bb);
++ bitmap_set_bit (set_bbs, set_bb->index);
++ }
++ bb = nearest_common_dominator_for_set (CDI_DOMINATORS, set_bbs);
++ goto place_tls_call;
+ }
+
+ /* Emit the TLS CALL insn. */
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-1a.c b/gcc/testsuite/gcc.target/i386/pr121572-1a.c
new file mode 100644
-index 00000000000..179a1a9e66c
+index 00000000000..270d8ff5cb6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121572-1a.c
-@@ -0,0 +1,40 @@
+@@ -0,0 +1,41 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O0 -fpic -fplt -mtls-dialect=gnu" } */
+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
@@ -151,28 +233,29 @@ index 00000000000..179a1a9e66c
+**...
+*/
+
-+extern __thread int tv_cache __attribute__ ((visibility("hidden")));
++extern __thread int tv_cache __attribute__ ((visibility ("hidden")));
+extern void use_cache (int);
+extern int val (int v);
+
-+__attribute__((optimize(2)))
++__attribute__ ((optimize (2)))
+void
+bug (void)
+{
-+ int compared = val(-1);
++ int compared = val (-1);
+
-+ if (compared == 0 || (compared > 0 && val(2) == 0))
++ if (compared == 0 || (compared > 0 && val (2) == 0))
+ {
-+ __builtin_trap();
++ __builtin_trap ();
+ }
+
-+ if (compared < 0) {
-+ use_cache(tv_cache);
++ if (compared < 0)
++ {
++ use_cache (tv_cache);
+ return;
-+ }
++ }
+
-+ use_cache(tv_cache);
-+ __builtin_trap();
++ use_cache (tv_cache);
++ __builtin_trap ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr121572-1b.c b/gcc/testsuite/gcc.target/i386/pr121572-1b.c
new file mode 100644
@@ -198,5 +281,89 @@ index 00000000000..8a6089109f5
+*/
+
+#include "pr121572-1a.c"
+diff --git a/gcc/testsuite/gcc.target/i386/pr121572-2a.c b/gcc/testsuite/gcc.target/i386/pr121572-2a.c
+new file mode 100644
+index 00000000000..3f2230f8885
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121572-2a.c
+@@ -0,0 +1,55 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
++
++/*
++**mpfr_agm:
++**.LFB[0-9]+:
++**...
++** movl %edi, %ebp
++** data16 leaq __gmpfr_emax@tlsgd\(%rip\), %rdi
++** .value 0x6666
++** rex64
++** call __tls_get_addr@PLT
++** mov[l|q] mpfr_agm_compare@GOTPCREL\(%rip\), %[e|r]dx
++** movl \(%[e|r]dx\), %edx
++** testl %edx, %edx
++** je .L2
++**...
++*/
++
++typedef enum
++{
++ MPFR_RNDN
++} mpfr_rnd_t;
++typedef int mpfr_t[1];
++long __gmpfr_emin, mpfr_agm_expo_0;
++_Thread_local long __gmpfr_emax;
++int mpfr_agm_compare, mpfr_agm___trans_tmp_1;
++mpfr_t mpfr_agm_u;
++void mpfr_mul (int *, int, int, mpfr_rnd_t);
++int
++mpfr_agm (int op1)
++{
++ int op2 = 0;
++ if (__builtin_expect (mpfr_agm_compare == 0, 0))
++ return 0;
++ if (mpfr_agm_compare > 0)
++ {
++ int t = op1;
++ op2 = t;
++ }
++ mpfr_agm_expo_0 = __gmpfr_emax;
++ for (;;)
++ {
++ retry:
++ mpfr_mul (mpfr_agm_u, op1, op2, MPFR_RNDN);
++ if (0)
++ goto retry;
++ if (__builtin_expect (mpfr_agm___trans_tmp_1, 1))
++ break;
++ }
++ __gmpfr_emin = __gmpfr_emax;
++ return 0;
++}
+diff --git a/gcc/testsuite/gcc.target/i386/pr121572-2b.c b/gcc/testsuite/gcc.target/i386/pr121572-2b.c
+new file mode 100644
+index 00000000000..d81e2edc6f2
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121572-2b.c
+@@ -0,0 +1,17 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O2 -fpic -fplt -mtls-dialect=gnu2" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
++
++/*
++**mpfr_agm:
++**.LFB[0-9]+:
++** .cfi_startproc
++** sub[l|q] \$[0-9]+, %[e|r]sp
++** .cfi_def_cfa_offset [0-9]+
++** lea[l|q] __gmpfr_emax@TLSDESC\(%rip\), %[e|r]ax
++** call \*__gmpfr_emax@TLSCALL\(%[e|r]ax\)
++**...
++*/
++
++#include "pr121572-2a.c"
--
2.50.1
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-16 23:06 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-16 23:06 UTC (permalink / raw
To: gentoo-commits
commit: 9d05dcbe0d03e364397647c8e06d4d3827ec65b7
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 16 23:06:10 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug 16 23:06:36 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=9d05dcbe
16.0.0: add TLS patch
Bug: https://gcc.gnu.org/PR121572
Signed-off-by: Sam James <sam <AT> gentoo.org>
...he-TLS-call-before-all-FLAGS_REG-setting-.patch | 202 +++++++++++++++++++++
16.0.0/gentoo/README.history | 4 +
2 files changed, 206 insertions(+)
diff --git a/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
new file mode 100644
index 0000000..62ccbe9
--- /dev/null
+++ b/16.0.0/gentoo/86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
@@ -0,0 +1,202 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121572#c4
+
+From caceadf47fe1b278311c73d5cbd062dca62298ac Mon Sep 17 00:00:00 2001
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Sat, 16 Aug 2025 14:04:33 -0700
+Subject: [PATCH] x86: Place the TLS call before all FLAGS_REG setting BBs
+
+We can't place a TLS call before a conditional jump in a basic block like
+
+(code_label 13 11 14 4 2 (nil) [1 uses])
+(note 14 13 16 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
+(jump_insn 16 14 17 4 (set (pc)
+ (if_then_else (le (reg:CCNO 17 flags)
+ (const_int 0 [0]))
+ (label_ref 27)
+ (pc))) "x.c":10:21 discrim 1 1462 {*jcc}
+ (expr_list:REG_DEAD (reg:CCNO 17 flags)
+ (int_list:REG_BR_PROB 628353713 (nil)))
+ -> 27)
+
+since the TLS call will clobber flags register. Instead, we should place
+such call before all register setting basic blocks which dominate the
+current basic block.
+
+NB: GNU2 TLS:
+
+(insn 66 2 5 2 (parallel [
+ (set (reg:DI 116)
+ (plus:DI (unspec:DI [
+ (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
+ (unspec:DI [
+ (symbol_ref:DI ("_TLS_MODULE_BASE_") [flags 0x10])
+ ] UNSPEC_TLSDESC)
+ (reg/f:DI 7 sp)] UNSPEC_TLSDESC)
+ (const:DI (unspec:DI [
+ (symbol_ref:DI ("tv_cache") [flags 0x5a])
+ ] UNSPEC_DTPOFF))))
+ (clobber (reg:CC 17 flags))]) 1678 {*tls_dynamic_gnu2_combine_64_di}
+ (nil))
+
+only clobbers flags register.
+
+gcc/
+
+ PR target/121572
+ * config/i386/i386-features.cc (ix86_place_single_tls_call): Also
+ search for REG_DEAD notes if flag register is alive. Place the
+ TLS call before all FLAGS_REG setting BBs for conditional jump.
+
+gcc/testsuite/
+
+ PR target/121572
+ * gcc.target/i386/pr121572-1a.c: New test.
+ * gcc.target/i386/pr121572-1b.c: Likewise.
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+---
+ gcc/config/i386/i386-features.cc | 41 ++++++++++++++++++++-
+ gcc/testsuite/gcc.target/i386/pr121572-1a.c | 40 ++++++++++++++++++++
+ gcc/testsuite/gcc.target/i386/pr121572-1b.c | 18 +++++++++
+ 3 files changed, 98 insertions(+), 1 deletion(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121572-1b.c
+
+diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
+index f0bdc5c1880..7cdf98c5778 100644
+--- a/gcc/config/i386/i386-features.cc
++++ b/gcc/config/i386/i386-features.cc
+@@ -3748,6 +3748,7 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+ bb = get_immediate_dominator (CDI_DOMINATORS,
+ bb->loop_father->header);
+
++place_tls_call:
+ rtx_insn *insn = BB_HEAD (bb);
+ while (insn && !NONDEBUG_INSN_P (insn))
+ {
+@@ -3837,7 +3838,7 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+ && bitmap_bit_p (in, i))
+ bitmap_set_bit (live_caller_saved_regs, i);
+
+- if (!bitmap_empty_p (live_caller_saved_regs))
++ if (flags_live_p || !bitmap_empty_p (live_caller_saved_regs))
+ {
+ /* Search for REG_DEAD notes in this basic block. */
+ FOR_BB_INSNS (bb, insn)
+@@ -3845,6 +3846,44 @@ ix86_place_single_tls_call (rtx dest, rtx val, x86_cse_kind kind,
+ if (!NONDEBUG_INSN_P (insn))
+ continue;
+
++ if (JUMP_P (insn))
++ {
++ /* This must be a conditional jump. */
++ rtx label = JUMP_LABEL (insn);
++ if (label == nullptr
++ || ANY_RETURN_P (label)
++ || !(LABEL_P (label) || SYMBOL_REF_P (label)))
++ gcc_unreachable ();
++
++ rtx_insn *set_insn;
++ basic_block set_bb;
++ auto_bitmap set_bbs;
++
++ /* Get all BBs which define FLAGS_REG and dominate the
++ current BB from all DEFs of FLAGS_REG. */
++ for (df_ref def = DF_REG_DEF_CHAIN (FLAGS_REG);
++ def;
++ def = DF_REF_NEXT_REG (def))
++ if (!DF_REF_IS_ARTIFICIAL (def)
++ && !DF_REF_FLAGS_IS_SET (def, DF_REF_MAY_CLOBBER)
++ && !DF_REF_FLAGS_IS_SET (def, DF_REF_MUST_CLOBBER))
++ {
++ set_insn = DF_REF_INSN (def);
++ set = single_set (set_insn);
++ gcc_assert (set);
++ set_bb = DF_REF_BB (def);
++ if (dominated_by_p (CDI_DOMINATORS, bb, set_bb))
++ bitmap_set_bit (set_bbs, set_bb->index);
++ }
++
++ /* Place the call before all FLAGS_REG setting BBs since
++ we can't place a call before nor after a conditional
++ jump. */
++ bb = nearest_common_dominator_for_set (CDI_DOMINATORS,
++ set_bbs);
++ goto place_tls_call;
++ }
++
+ /* Check if FLAGS register is live. */
+ set = single_set (insn);
+ if (set)
+diff --git a/gcc/testsuite/gcc.target/i386/pr121572-1a.c b/gcc/testsuite/gcc.target/i386/pr121572-1a.c
+new file mode 100644
+index 00000000000..179a1a9e66c
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121572-1a.c
+@@ -0,0 +1,40 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O0 -fpic -fplt -mtls-dialect=gnu" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
++
++/*
++**bug:
++**.LFB[0-9]+:
++**...
++** leaq tv_cache@tlsld\(%rip\), %rdi
++** call __tls_get_addr@PLT
++** movl \$-1, %edi
++** mov[l|q] %[e|r]ax, %[e|r]bx
++** call val@PLT
++**...
++*/
++
++extern __thread int tv_cache __attribute__ ((visibility("hidden")));
++extern void use_cache (int);
++extern int val (int v);
++
++__attribute__((optimize(2)))
++void
++bug (void)
++{
++ int compared = val(-1);
++
++ if (compared == 0 || (compared > 0 && val(2) == 0))
++ {
++ __builtin_trap();
++ }
++
++ if (compared < 0) {
++ use_cache(tv_cache);
++ return;
++ }
++
++ use_cache(tv_cache);
++ __builtin_trap();
++}
+diff --git a/gcc/testsuite/gcc.target/i386/pr121572-1b.c b/gcc/testsuite/gcc.target/i386/pr121572-1b.c
+new file mode 100644
+index 00000000000..8a6089109f5
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121572-1b.c
+@@ -0,0 +1,18 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O0 -fpic -fplt -mtls-dialect=gnu2" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
++
++/*
++**bug:
++**.LFB[0-9]+:
++**...
++** lea[l|q] tv_cache@TLSDESC\(%rip\), %[e|r]ax
++** movl \$-1, %edi
++** call \*tv_cache@TLSCALL\(%[e|r]ax\)
++** mov[l|q] %[e|r]ax, %[e|r]bx
++** call val@PLT
++**...
++*/
++
++#include "pr121572-1a.c"
+--
+2.50.1
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 4c3a42a..64aa256 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+10 ???
+
+ + 86_all_PR121572_x86-Place-the-TLS-call-before-all-FLAGS_REG-setting-.patch
+
9 5 August 2025
- 86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-08-05 0:23 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-08-05 0:23 UTC (permalink / raw
To: gentoo-commits
commit: 1a2132068c43cce40943c365af7f1404576fc2ce
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 5 00:22:38 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Aug 5 00:22:38 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=1a213206
16.0.0: cut patchset 9
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/README.history | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index c130b16..4c3a42a 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,4 +1,4 @@
-9 ???
+9 5 August 2025
- 86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
- 87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-30 22:35 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-30 22:35 UTC (permalink / raw
To: gentoo-commits
commit: 86b8df0c6eb87e1351819442ba5caaab1ecd11a1
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 30 22:35:04 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jul 30 22:35:04 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=86b8df0c
16.0.0: drop upstreamed patches
Signed-off-by: Sam James <sam <AT> gentoo.org>
...sufficient-alignment-requirement-for-spec.patch | 164 ---------------------
...ssing-skip-vector-check-for-peeling-with-.patch | 144 ------------------
...ommon-Remove-reference-to-obsolete-termio.patch | 74 ----------
16.0.0/gentoo/README.history | 7 +-
4 files changed, 4 insertions(+), 385 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch b/16.0.0/gentoo/86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
deleted file mode 100644
index f05e749..0000000
--- a/16.0.0/gentoo/86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
+++ /dev/null
@@ -1,164 +0,0 @@
-https://bugs.gentoo.org/959698
-https://inbox.sourceware.org/gcc-patches/DB3PR08MB89626FA52FEA5FB7ACE33B19A425A@DB3PR08MB8962.eurprd08.prod.outlook.com/
-
-From f91a62751e8198e6f02c21dffa35ac803b46d048 Mon Sep 17 00:00:00 2001
-Message-ID: <f91a62751e8198e6f02c21dffa35ac803b46d048.1753836047.git.sam@gentoo.org>
-From: Pengfei Li <Pengfei.Li2@arm.com>
-Date: Tue, 29 Jul 2025 14:58:18 +0000
-Subject: [PATCH 1/2] vect: Fix insufficient alignment requirement for
- speculative loads [PR121190]
-
-This patch fixes a segmentation fault issue that can occur in vectorized
-loops with an early break. When GCC vectorizes such loops, it may insert
-a versioning check to ensure that data references (DRs) with speculative
-loads are aligned. The check normally requires DRs to be aligned to the
-vector mode size, which prevents generated vector load instructions from
-crossing page boundaries.
-
-However, this is not sufficient when a single scalar load is vectorized
-into multiple loads within the same iteration. In such cases, even if
-none of the vector loads crosses page boundaries, subsequent loads after
-the first one may still access memory beyond current valid page.
-
-Consider the following loop as an example:
-
- while (i < MAX_COMPARE) {
- if (*(p + i) != *(q + i))
- return i;
- i++;
- }
-
-When compiled with "-O3 -march=znver2" on x86, the vectorized loop may
-include instructions like:
-
- vmovdqa (%rcx,%rax), %ymm0
- vmovdqa 32(%rcx,%rax), %ymm1
- vpcmpeqq (%rdx,%rax), %ymm0, %ymm0
- vpcmpeqq 32(%rdx,%rax), %ymm1, %ymm1
-
-Note two speculative vector loads are generated for each DR (p and q).
-The first vmovdqa and vpcmpeqq are safe due to the vector size (32-byte)
-alignment, but the following ones (at offset 32) may not be safe because
-they could read from the beginning of the next memory page, potentially
-leading to segmentation faults.
-
-To avoid the issue, this patch increases the alignment requirement to
-DR_TARGET_ALIGNMENT. It ensures all vector loads in the same vector
-iteration access memory within the same page.
-
-This patch is bootstrapped and regression-tested on x86_64-linux-gnu,
-arm-linux-gnueabihf and aarch64-linux-gnu.
-
- PR tree-optimization/121190
-
-gcc/ChangeLog:
-
- * tree-vect-data-refs.cc (vect_enhance_data_refs_alignment):
- Increase alignment requirement for speculative loads.
-
-gcc/testsuite/ChangeLog:
-
-* gcc.dg/vect/vect-early-break_52.c: Update an unsafe test.
- * gcc.dg/vect/vect-early-break_137.c-pr121190: New test.
----
- .../vect/vect-early-break_137-pr121190.c | 62 +++++++++++++++++++
- .../gcc.dg/vect/vect-early-break_52.c | 2 +-
- gcc/tree-vect-data-refs.cc | 3 +-
- 3 files changed, 65 insertions(+), 2 deletions(-)
- create mode 100644 gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c
-
-diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c
-new file mode 100644
-index 000000000000..e6b071c411cf
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c
-@@ -0,0 +1,62 @@
-+/* PR tree-optimization/121190 */
-+/* { dg-options "-O3" } */
-+/* { dg-additional-options "-march=znver2" { target x86_64-*-* i?86-*-* } } */
-+/* { dg-require-effective-target mmap } */
-+/* { dg-require-effective-target vect_early_break } */
-+
-+#include <stdint.h>
-+#include <string.h>
-+#include <stdio.h>
-+#include <sys/mman.h>
-+#include <unistd.h>
-+#include "tree-vect.h"
-+
-+#define MAX_COMPARE 5000
-+
-+__attribute__((noipa))
-+int diff (uint64_t *restrict p, uint64_t *restrict q)
-+{
-+ int i = 0;
-+ while (i < MAX_COMPARE) {
-+ if (*(p + i) != *(q + i))
-+ return i;
-+ i++;
-+ }
-+ return -1;
-+}
-+
-+int main ()
-+{
-+ check_vect ();
-+
-+ long pgsz = sysconf (_SC_PAGESIZE);
-+ if (pgsz == -1) {
-+ fprintf (stderr, "sysconf failed\n");
-+ return 0;
-+ }
-+
-+ /* Allocate 2 consecutive pages of memory and let p1 and p2 point to the
-+ beginning of each. */
-+ void *mem = mmap (NULL, pgsz * 2, PROT_READ | PROT_WRITE,
-+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-+ if (mem == MAP_FAILED) {
-+ fprintf (stderr, "mmap failed\n");
-+ return 0;
-+ }
-+ uint64_t *p1 = (uint64_t *) mem;
-+ uint64_t *p2 = (uint64_t *) mem + pgsz / sizeof (uint64_t);
-+
-+ /* Fill the first page with zeros, except for its last 64 bits. */
-+ memset (p1, 0, pgsz);
-+ *(p2 - 1) = -1;
-+
-+ /* Make the 2nd page not accessable. */
-+ mprotect (p2, pgsz, PROT_NONE);
-+
-+ /* Calls to diff should not read the 2nd page. */
-+ for (int i = 1; i <= 20; i++) {
-+ if (diff (p2 - i, p1) != i - 1)
-+ __builtin_abort ();
-+ }
-+}
-+
-diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c
-index 86a632f2a822..6abfcd6580e4 100644
---- a/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c
-+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c
-@@ -18,4 +18,4 @@ int main1 (short X)
- }
- }
-
--/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */
-+/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { ! "x86_64-*-* i?86-*-* arm*-*-*" } } } } */
-diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
-index e7919b73c258..66217c54b050 100644
---- a/gcc/tree-vect-data-refs.cc
-+++ b/gcc/tree-vect-data-refs.cc
-@@ -2969,7 +2969,8 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
- VF is a power of two. We could relax this if we added
- a way of enforcing a power-of-two size. */
- unsigned HOST_WIDE_INT size;
-- if (!GET_MODE_SIZE (TYPE_MODE (vectype)).is_constant (&size))
-+ if (!LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant ()
-+ || !DR_TARGET_ALIGNMENT (dr_info).is_constant (&size))
- {
- do_versioning = false;
- break;
---
-2.50.1
-
diff --git a/16.0.0/gentoo/87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch b/16.0.0/gentoo/87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
deleted file mode 100644
index c472d5d..0000000
--- a/16.0.0/gentoo/87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
+++ /dev/null
@@ -1,144 +0,0 @@
-https://bugs.gentoo.org/959698
-https://inbox.sourceware.org/gcc-patches/DB3PR08MB8962138B27178069736147E5A425A@DB3PR08MB8962.eurprd08.prod.outlook.com/
-
-From 652f42c43949e64961721b7c78758030a8b9b1e0 Mon Sep 17 00:00:00 2001
-Message-ID: <652f42c43949e64961721b7c78758030a8b9b1e0.1753836047.git.sam@gentoo.org>
-In-Reply-To: <f91a62751e8198e6f02c21dffa35ac803b46d048.1753836047.git.sam@gentoo.org>
-References: <f91a62751e8198e6f02c21dffa35ac803b46d048.1753836047.git.sam@gentoo.org>
-From: Pengfei Li <Pengfei.Li2@arm.com>
-Date: Tue, 29 Jul 2025 14:53:46 +0000
-Subject: [PATCH 2/2] vect: Add missing skip-vector check for peeling with
- versioning [PR121020]
-
-This fixes a miscompilation issue introduced by the enablement of
-combined loop peeling and versioning. A test case that reproduces the
-issue is included in the patch.
-
-When performing loop peeling, GCC usually inserts a skip-vector check.
-This ensures that after peeling, there are enough remaining iterations
-to enter the main vectorized loop. Previously, the check was omitted if
-loop versioning for alignment was applied. It was safe before because
-versioning and peeling for alignment were mutually exclusive.
-
-However, with combined peeling and versioning enabled, this is not safe
-any more. A loop may be peeled and versioned at the same time. Without
-the skip-vector check, the main vectorized loop can be entered even if
-its iteration count is zero. This can cause the loop running many more
-iterations than needed, resulting in incorrect results.
-
-To fix this, the patch updates the condition of omitting the skip-vector
-check to when versioning is performed alone without peeling.
-
-This patch is bootstrapped and regression-tested on x86_64-linux-gnu,
-arm-linux-gnueabihf and aarch64-linux-gnu.
-
- PR tree-optimization/121020
-
-gcc/ChangeLog:
-
- * tree-vect-loop-manip.cc (vect_do_peeling): Update the
- condition of omitting the skip-vector check.
- * tree-vectorizer.h (LOOP_VINFO_USE_VERSIONING_WITHOUT_PEELING):
- Add a helper macro.
-
-gcc/testsuite/ChangeLog:
-
-* gcc.dg/vect/vect-early-break_138-pr121020.c: New test.
----
- .../vect/vect-early-break_138-pr121020.c | 54 +++++++++++++++++++
- gcc/tree-vect-loop-manip.cc | 2 +-
- gcc/tree-vectorizer.h | 4 ++
- 3 files changed, 59 insertions(+), 1 deletion(-)
- create mode 100644 gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c
-
-diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c
-new file mode 100644
-index 000000000000..8cb62bf5bc93
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c
-@@ -0,0 +1,54 @@
-+/* PR tree-optimization/121020 */
-+/* { dg-options "-O3 --vect-cost-model=unlimited" } */
-+/* { dg-additional-options "-march=znver2" { target x86_64-*-* i?86-*-* } } */
-+/* { dg-require-effective-target mmap } */
-+/* { dg-require-effective-target vect_early_break } */
-+
-+#include <stdint.h>
-+#include <stdio.h>
-+#include <sys/mman.h>
-+#include <unistd.h>
-+#include "tree-vect.h"
-+
-+__attribute__((noipa))
-+bool equal (uint64_t *restrict p, uint64_t *restrict q, int length)
-+{
-+ for (int i = 0; i < length; i++) {
-+ if (*(p + i) != *(q + i))
-+ return false;
-+ }
-+ return true;
-+}
-+
-+int main ()
-+{
-+ check_vect ();
-+
-+ long pgsz = sysconf (_SC_PAGESIZE);
-+ if (pgsz == -1) {
-+ fprintf (stderr, "sysconf failed\n");
-+ return 0;
-+ }
-+
-+ /* Allocate a whole page of memory. */
-+ void *mem = mmap (NULL, pgsz, PROT_READ | PROT_WRITE,
-+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-+ if (mem == MAP_FAILED) {
-+ fprintf (stderr, "mmap failed\n");
-+ return 0;
-+ }
-+ uint64_t *p1 = (uint64_t *) mem;
-+ uint64_t *p2 = (uint64_t *) mem + 32;
-+
-+ /* The first 16 elements pointed to by p1 and p2 are the same. */
-+ for (int i = 0; i < 32; i++) {
-+ *(p1 + i) = 0;
-+ *(p2 + i) = (i < 16 ? 0 : -1);
-+ }
-+
-+ /* All calls to equal should return true. */
-+ for (int len = 0; len < 16; len++) {
-+ if (!equal (p1 + 1, p2 + 1, len))
-+ __builtin_abort();
-+ }
-+}
-diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
-index 2d01a4b0ed1c..7fcbc1ad2eb8 100644
---- a/gcc/tree-vect-loop-manip.cc
-+++ b/gcc/tree-vect-loop-manip.cc
-@@ -3295,7 +3295,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
- bool skip_vector = (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
- ? maybe_lt (LOOP_VINFO_INT_NITERS (loop_vinfo),
- bound_prolog + bound_epilog)
-- : (!LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo)
-+ : (!LOOP_VINFO_USE_VERSIONING_WITHOUT_PEELING (loop_vinfo)
- || vect_epilogues));
-
- /* Epilog loop must be executed if the number of iterations for epilog
-diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
-index 203e5ad964a6..e19002794324 100644
---- a/gcc/tree-vectorizer.h
-+++ b/gcc/tree-vectorizer.h
-@@ -1197,6 +1197,10 @@ public:
- || LOOP_REQUIRES_VERSIONING_FOR_NITERS (L) \
- || LOOP_REQUIRES_VERSIONING_FOR_SIMD_IF_COND (L))
-
-+#define LOOP_VINFO_USE_VERSIONING_WITHOUT_PEELING(L) \
-+ ((L)->may_misalign_stmts.length () > 0 \
-+ && !LOOP_VINFO_ALLOW_MUTUAL_ALIGNMENT (L))
-+
- #define LOOP_VINFO_NITERS_KNOWN_P(L) \
- (tree_fits_shwi_p ((L)->num_iters) && tree_to_shwi ((L)->num_iters) > 0)
-
---
-2.50.1
-
diff --git a/16.0.0/gentoo/88_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch b/16.0.0/gentoo/88_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch
deleted file mode 100644
index eece80d..0000000
--- a/16.0.0/gentoo/88_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch
+++ /dev/null
@@ -1,74 +0,0 @@
-From 50cff2194bcb8321414437169d443bf48695972c Mon Sep 17 00:00:00 2001
-Message-ID: <50cff2194bcb8321414437169d443bf48695972c.1753469285.git.sam@gentoo.org>
-From: Sam James <sam@gentoo.org>
-Date: Fri, 25 Jul 2025 19:45:18 +0100
-Subject: [PATCH] [sanitizer_common] Remove reference to obsolete termio ioctls
- (#138822)
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Cherry picked from LLVM commit c99b1bcd505064f2e086e6b1034ce0b0c91ea5b9.
-
-The termio ioctls are no longer used after commit 59978b21ad9c
-("[sanitizer_common] Remove interceptors for deprecated struct termio
-(#137403)"), remove them. Fixes this build error:
-
-../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:765:27: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
- 765 | unsigned IOCTL_TCGETA = TCGETA;
- | ^~~~~~
-../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:769:27: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
- 769 | unsigned IOCTL_TCSETA = TCSETA;
- | ^~~~~~
-../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:770:28: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
- 770 | unsigned IOCTL_TCSETAF = TCSETAF;
- | ^~~~~~~
-../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:771:28: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
- 771 | unsigned IOCTL_TCSETAW = TCSETAW;
- | ^~~~~~~
----
- .../sanitizer_common/sanitizer_platform_limits_posix.cpp | 4 ----
- .../sanitizer_common/sanitizer_platform_limits_posix.h | 4 ----
- 2 files changed, 8 deletions(-)
-
-diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-index 490e75fe8f65..9856ac3c3ec4 100644
---- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-@@ -762,13 +762,9 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
- unsigned IOCTL_SOUND_PCM_WRITE_FILTER = SOUND_PCM_WRITE_FILTER;
- #endif // SOUND_VERSION
- unsigned IOCTL_TCFLSH = TCFLSH;
-- unsigned IOCTL_TCGETA = TCGETA;
- unsigned IOCTL_TCGETS = TCGETS;
- unsigned IOCTL_TCSBRK = TCSBRK;
- unsigned IOCTL_TCSBRKP = TCSBRKP;
-- unsigned IOCTL_TCSETA = TCSETA;
-- unsigned IOCTL_TCSETAF = TCSETAF;
-- unsigned IOCTL_TCSETAW = TCSETAW;
- unsigned IOCTL_TCSETS = TCSETS;
- unsigned IOCTL_TCSETSF = TCSETSF;
- unsigned IOCTL_TCSETSW = TCSETSW;
-diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-index a80df656826e..cfac4903b76b 100644
---- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-@@ -1274,13 +1274,9 @@ extern unsigned IOCTL_SNDCTL_COPR_SENDMSG;
- extern unsigned IOCTL_SNDCTL_COPR_WCODE;
- extern unsigned IOCTL_SNDCTL_COPR_WDATA;
- extern unsigned IOCTL_TCFLSH;
--extern unsigned IOCTL_TCGETA;
- extern unsigned IOCTL_TCGETS;
- extern unsigned IOCTL_TCSBRK;
- extern unsigned IOCTL_TCSBRKP;
--extern unsigned IOCTL_TCSETA;
--extern unsigned IOCTL_TCSETAF;
--extern unsigned IOCTL_TCSETAW;
- extern unsigned IOCTL_TCSETS;
- extern unsigned IOCTL_TCSETSF;
- extern unsigned IOCTL_TCSETSW;
-
-base-commit: ba5a6787374dea3e90f09771134d16b9f6d2714e
---
-2.50.1
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index c0dd40f..c130b16 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,7 +1,8 @@
-9 ????
+9 ???
- U 86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
- U 87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
+ - 86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
+ - 87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
+ - 88_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch
8 30 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-30 0:44 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-30 0:44 UTC (permalink / raw
To: gentoo-commits
commit: 8cda62318174b911a7cba57fcf70efd38f265f0e
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 30 00:44:05 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jul 30 00:44:48 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=8cda6231
16.0.0: update patches
Signed-off-by: Sam James <sam <AT> gentoo.org>
...sufficient-alignment-requirement-for-spec.patch | 55 ++++++++--------------
...ssing-skip-vector-check-for-peeling-with-.patch | 28 ++++++-----
16.0.0/gentoo/README.history | 5 ++
3 files changed, 39 insertions(+), 49 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch b/16.0.0/gentoo/86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
index 9a03cdd..f05e749 100644
--- a/16.0.0/gentoo/86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
+++ b/16.0.0/gentoo/86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
@@ -1,10 +1,10 @@
https://bugs.gentoo.org/959698
-https://inbox.sourceware.org/gcc-patches/20250721110232.186244-1-Pengfei.Li2@arm.com/T/#u
+https://inbox.sourceware.org/gcc-patches/DB3PR08MB89626FA52FEA5FB7ACE33B19A425A@DB3PR08MB8962.eurprd08.prod.outlook.com/
-From e120f6cb794a4d104b37913c918aabe0ae6b2c64 Mon Sep 17 00:00:00 2001
-Message-ID: <e120f6cb794a4d104b37913c918aabe0ae6b2c64.1753106388.git.sam@gentoo.org>
+From f91a62751e8198e6f02c21dffa35ac803b46d048 Mon Sep 17 00:00:00 2001
+Message-ID: <f91a62751e8198e6f02c21dffa35ac803b46d048.1753836047.git.sam@gentoo.org>
From: Pengfei Li <Pengfei.Li2@arm.com>
-Date: Mon, 21 Jul 2025 11:02:32 +0000
+Date: Tue, 29 Jul 2025 14:58:18 +0000
Subject: [PATCH 1/2] vect: Fix insufficient alignment requirement for
speculative loads [PR121190]
@@ -42,9 +42,9 @@ alignment, but the following ones (at offset 32) may not be safe because
they could read from the beginning of the next memory page, potentially
leading to segmentation faults.
-To avoid the issue, this patch increases the alignment requirement for
-speculative loads to DR_TARGET_ALIGNMENT. It ensures all vector loads in
-the same vector iteration access memory within the same page.
+To avoid the issue, this patch increases the alignment requirement to
+DR_TARGET_ALIGNMENT. It ensures all vector loads in the same vector
+iteration access memory within the same page.
This patch is bootstrapped and regression-tested on x86_64-linux-gnu,
arm-linux-gnueabihf and aarch64-linux-gnu.
@@ -61,20 +61,19 @@ gcc/testsuite/ChangeLog:
* gcc.dg/vect/vect-early-break_52.c: Update an unsafe test.
* gcc.dg/vect/vect-early-break_137.c-pr121190: New test.
---
- .../vect/vect-early-break_137-pr121190.c | 60 +++++++++++++++++++
+ .../vect/vect-early-break_137-pr121190.c | 62 +++++++++++++++++++
.../gcc.dg/vect/vect-early-break_52.c | 2 +-
- gcc/tree-vect-data-refs.cc | 15 ++++-
- 3 files changed, 75 insertions(+), 2 deletions(-)
+ gcc/tree-vect-data-refs.cc | 3 +-
+ 3 files changed, 65 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c
diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c
new file mode 100644
-index 000000000000..da11146c578e
+index 000000000000..e6b071c411cf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c
-@@ -0,0 +1,60 @@
+@@ -0,0 +1,62 @@
+/* PR tree-optimization/121190 */
-+/* { dg-do run } */
+/* { dg-options "-O3" } */
+/* { dg-additional-options "-march=znver2" { target x86_64-*-* i?86-*-* } } */
+/* { dg-require-effective-target mmap } */
@@ -85,6 +84,7 @@ index 000000000000..da11146c578e
+#include <stdio.h>
+#include <sys/mman.h>
+#include <unistd.h>
++#include "tree-vect.h"
+
+#define MAX_COMPARE 5000
+
@@ -102,6 +102,8 @@ index 000000000000..da11146c578e
+
+int main ()
+{
++ check_vect ();
++
+ long pgsz = sysconf (_SC_PAGESIZE);
+ if (pgsz == -1) {
+ fprintf (stderr, "sysconf failed\n");
@@ -144,38 +146,19 @@ index 86a632f2a822..6abfcd6580e4 100644
-/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */
+/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { ! "x86_64-*-* i?86-*-* arm*-*-*" } } } } */
diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
-index a24ddfbc3841..24048086857f 100644
+index e7919b73c258..66217c54b050 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
-@@ -2964,12 +2964,25 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
- break;
- }
-
-+ /* Normally, we require DRs to be aligned to the vector mode size.
-+ However, this is not sufficient when a statement involves safe
-+ speculative read. In such cases, a single scalar load can be
-+ vectorized into multiple vector loads in one loop iteration.
-+ Even if the first vector load is safe, subsequent loads might
-+ still access an invalid memory page. We increase the alignment
-+ requirement to prevent this. */
-+ poly_uint64 required_align_size;
-+ if (dr_safe_speculative_read_required (stmt_info))
-+ required_align_size = DR_TARGET_ALIGNMENT (dr_info);
-+ else
-+ required_align_size = GET_MODE_SIZE (TYPE_MODE (vectype));
-+
- /* At present we don't support versioning for alignment
- with variable VF, since there's no guarantee that the
+@@ -2969,7 +2969,8 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
VF is a power of two. We could relax this if we added
a way of enforcing a power-of-two size. */
unsigned HOST_WIDE_INT size;
- if (!GET_MODE_SIZE (TYPE_MODE (vectype)).is_constant (&size))
-+ if (!required_align_size.is_constant (&size))
++ if (!LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant ()
++ || !DR_TARGET_ALIGNMENT (dr_info).is_constant (&size))
{
do_versioning = false;
break;
-
-base-commit: b441d735c092f5d60c4a9c7167ed9153003d49fa
--
2.50.1
diff --git a/16.0.0/gentoo/87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch b/16.0.0/gentoo/87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
index 5aae3a5..c472d5d 100644
--- a/16.0.0/gentoo/87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
+++ b/16.0.0/gentoo/87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
@@ -1,12 +1,12 @@
https://bugs.gentoo.org/959698
-https://inbox.sourceware.org/gcc-patches/20250721110642.186287-1-Pengfei.Li2@arm.com/T/#u
+https://inbox.sourceware.org/gcc-patches/DB3PR08MB8962138B27178069736147E5A425A@DB3PR08MB8962.eurprd08.prod.outlook.com/
-From f66323025c47ba09cee296a8a638cfe63d1bdad3 Mon Sep 17 00:00:00 2001
-Message-ID: <f66323025c47ba09cee296a8a638cfe63d1bdad3.1753106388.git.sam@gentoo.org>
-In-Reply-To: <e120f6cb794a4d104b37913c918aabe0ae6b2c64.1753106388.git.sam@gentoo.org>
-References: <e120f6cb794a4d104b37913c918aabe0ae6b2c64.1753106388.git.sam@gentoo.org>
+From 652f42c43949e64961721b7c78758030a8b9b1e0 Mon Sep 17 00:00:00 2001
+Message-ID: <652f42c43949e64961721b7c78758030a8b9b1e0.1753836047.git.sam@gentoo.org>
+In-Reply-To: <f91a62751e8198e6f02c21dffa35ac803b46d048.1753836047.git.sam@gentoo.org>
+References: <f91a62751e8198e6f02c21dffa35ac803b46d048.1753836047.git.sam@gentoo.org>
From: Pengfei Li <Pengfei.Li2@arm.com>
-Date: Mon, 21 Jul 2025 11:06:42 +0000
+Date: Tue, 29 Jul 2025 14:53:46 +0000
Subject: [PATCH 2/2] vect: Add missing skip-vector check for peeling with
versioning [PR121020]
@@ -45,20 +45,19 @@ gcc/testsuite/ChangeLog:
* gcc.dg/vect/vect-early-break_138-pr121020.c: New test.
---
- .../vect/vect-early-break_138-pr121020.c | 52 +++++++++++++++++++
+ .../vect/vect-early-break_138-pr121020.c | 54 +++++++++++++++++++
gcc/tree-vect-loop-manip.cc | 2 +-
gcc/tree-vectorizer.h | 4 ++
- 3 files changed, 57 insertions(+), 1 deletion(-)
+ 3 files changed, 59 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c
diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c
new file mode 100644
-index 000000000000..86661e445a83
+index 000000000000..8cb62bf5bc93
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c
-@@ -0,0 +1,52 @@
+@@ -0,0 +1,54 @@
+/* PR tree-optimization/121020 */
-+/* { dg-do run } */
+/* { dg-options "-O3 --vect-cost-model=unlimited" } */
+/* { dg-additional-options "-march=znver2" { target x86_64-*-* i?86-*-* } } */
+/* { dg-require-effective-target mmap } */
@@ -68,6 +67,7 @@ index 000000000000..86661e445a83
+#include <stdio.h>
+#include <sys/mman.h>
+#include <unistd.h>
++#include "tree-vect.h"
+
+__attribute__((noipa))
+bool equal (uint64_t *restrict p, uint64_t *restrict q, int length)
@@ -81,6 +81,8 @@ index 000000000000..86661e445a83
+
+int main ()
+{
++ check_vect ();
++
+ long pgsz = sysconf (_SC_PAGESIZE);
+ if (pgsz == -1) {
+ fprintf (stderr, "sysconf failed\n");
@@ -123,10 +125,10 @@ index 2d01a4b0ed1c..7fcbc1ad2eb8 100644
/* Epilog loop must be executed if the number of iterations for epilog
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
-index 80f8853733de..69428f1747cb 100644
+index 203e5ad964a6..e19002794324 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
-@@ -1168,6 +1168,10 @@ public:
+@@ -1197,6 +1197,10 @@ public:
|| LOOP_REQUIRES_VERSIONING_FOR_NITERS (L) \
|| LOOP_REQUIRES_VERSIONING_FOR_SIMD_IF_COND (L))
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 89b8363..c0dd40f 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,8 @@
+9 ????
+
+ U 86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
+ U 87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
+
8 30 July 2025
+ 86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-30 0:44 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-30 0:44 UTC (permalink / raw
To: gentoo-commits
commit: 5e8bc1b9f2421144316c8239e4dc55685b94c4cc
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 30 00:43:14 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jul 30 00:44:30 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=5e8bc1b9
16.0.0: cut patchset 8
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/README.history | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index a0f16ff..89b8363 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,4 +1,4 @@
-8 ????
+8 30 July 2025
+ 86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
+ 87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-25 18:49 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-25 18:49 UTC (permalink / raw
To: gentoo-commits
commit: 69c1c8e9629f7b5014b041b4d12b4d80af683e4e
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 25 18:48:37 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jul 25 18:49:11 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=69c1c8e9
16.0.0: fix libsanitizer build w/ glibc-2.42
Signed-off-by: Sam James <sam <AT> gentoo.org>
...ommon-Remove-reference-to-obsolete-termio.patch | 74 ++++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 75 insertions(+)
diff --git a/16.0.0/gentoo/88_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch b/16.0.0/gentoo/88_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch
new file mode 100644
index 0000000..eece80d
--- /dev/null
+++ b/16.0.0/gentoo/88_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch
@@ -0,0 +1,74 @@
+From 50cff2194bcb8321414437169d443bf48695972c Mon Sep 17 00:00:00 2001
+Message-ID: <50cff2194bcb8321414437169d443bf48695972c.1753469285.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Fri, 25 Jul 2025 19:45:18 +0100
+Subject: [PATCH] [sanitizer_common] Remove reference to obsolete termio ioctls
+ (#138822)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Cherry picked from LLVM commit c99b1bcd505064f2e086e6b1034ce0b0c91ea5b9.
+
+The termio ioctls are no longer used after commit 59978b21ad9c
+("[sanitizer_common] Remove interceptors for deprecated struct termio
+(#137403)"), remove them. Fixes this build error:
+
+../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:765:27: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
+ 765 | unsigned IOCTL_TCGETA = TCGETA;
+ | ^~~~~~
+../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:769:27: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
+ 769 | unsigned IOCTL_TCSETA = TCSETA;
+ | ^~~~~~
+../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:770:28: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
+ 770 | unsigned IOCTL_TCSETAF = TCSETAF;
+ | ^~~~~~~
+../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:771:28: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
+ 771 | unsigned IOCTL_TCSETAW = TCSETAW;
+ | ^~~~~~~
+---
+ .../sanitizer_common/sanitizer_platform_limits_posix.cpp | 4 ----
+ .../sanitizer_common/sanitizer_platform_limits_posix.h | 4 ----
+ 2 files changed, 8 deletions(-)
+
+diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
+index 490e75fe8f65..9856ac3c3ec4 100644
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
+@@ -762,13 +762,9 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ unsigned IOCTL_SOUND_PCM_WRITE_FILTER = SOUND_PCM_WRITE_FILTER;
+ #endif // SOUND_VERSION
+ unsigned IOCTL_TCFLSH = TCFLSH;
+- unsigned IOCTL_TCGETA = TCGETA;
+ unsigned IOCTL_TCGETS = TCGETS;
+ unsigned IOCTL_TCSBRK = TCSBRK;
+ unsigned IOCTL_TCSBRKP = TCSBRKP;
+- unsigned IOCTL_TCSETA = TCSETA;
+- unsigned IOCTL_TCSETAF = TCSETAF;
+- unsigned IOCTL_TCSETAW = TCSETAW;
+ unsigned IOCTL_TCSETS = TCSETS;
+ unsigned IOCTL_TCSETSF = TCSETSF;
+ unsigned IOCTL_TCSETSW = TCSETSW;
+diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+index a80df656826e..cfac4903b76b 100644
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+@@ -1274,13 +1274,9 @@ extern unsigned IOCTL_SNDCTL_COPR_SENDMSG;
+ extern unsigned IOCTL_SNDCTL_COPR_WCODE;
+ extern unsigned IOCTL_SNDCTL_COPR_WDATA;
+ extern unsigned IOCTL_TCFLSH;
+-extern unsigned IOCTL_TCGETA;
+ extern unsigned IOCTL_TCGETS;
+ extern unsigned IOCTL_TCSBRK;
+ extern unsigned IOCTL_TCSBRKP;
+-extern unsigned IOCTL_TCSETA;
+-extern unsigned IOCTL_TCSETAF;
+-extern unsigned IOCTL_TCSETAW;
+ extern unsigned IOCTL_TCSETS;
+ extern unsigned IOCTL_TCSETSF;
+ extern unsigned IOCTL_TCSETSW;
+
+base-commit: ba5a6787374dea3e90f09771134d16b9f6d2714e
+--
+2.50.1
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 7020432..a0f16ff 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -2,6 +2,7 @@
+ 86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
+ 87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
+ + 88_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch
7 21 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-23 11:22 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-23 11:22 UTC (permalink / raw
To: gentoo-commits
commit: 835e4be642a04df875528e32adc04ac5676aff9e
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 23 11:22:03 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jul 23 11:22:03 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=835e4be6
16.0.0: drop SRA patch merged upstream
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/88_all_PR119085.patch | 111 ------------------------------------
16.0.0/gentoo/README.history | 1 -
2 files changed, 112 deletions(-)
diff --git a/16.0.0/gentoo/88_all_PR119085.patch b/16.0.0/gentoo/88_all_PR119085.patch
deleted file mode 100644
index 92d9c68..0000000
--- a/16.0.0/gentoo/88_all_PR119085.patch
+++ /dev/null
@@ -1,111 +0,0 @@
-https://inbox.sourceware.org/gcc-patches/ri6wm80s22z.fsf@virgil.suse.cz/
-
-From d767af4c6d02ec7150f891f15f3c5713bfad6d47 Mon Sep 17 00:00:00 2001
-Message-ID: <d767af4c6d02ec7150f891f15f3c5713bfad6d47.1753228537.git.sam@gentoo.org>
-From: Martin Jambor <mjambor@suse.cz>
-Date: Tue, 22 Jul 2025 17:00:04 +0200
-Subject: [PATCH] tree-sra: Avoid total SRA if there are incompat. aggregate
- accesses (PR119085)
-
-Hi,
-
-we currently use the types encountered in the function body and not in
-type declaration to perform total scalarization. Bug PR 119085
-uncovered that we miss a check that when the same data is accessed
-with aggregate types that those are actually compatible. Without it,
-we can base total scalarization on a type that does not "cover" all
-live data in a different part of the function. This patch adds the
-check.
-
-Bootstrapped and tested on x86_64-linux. OK for master and all active
-release branches?
-
-Thanks,
-
-Martin
-
-gcc/ChangeLog:
-
-2025-07-21 Martin Jambor <mjambor@suse.cz>
-
- PR tree-optimization/119085
- * tree-sra.cc (sort_and_splice_var_accesses): Prevent total
- scalarization if two incompatible aggregates access the same place.
-
-gcc/testsuite/ChangeLog:
-
-2025-07-21 Martin Jambor <mjambor@suse.cz>
-
-PR tree-optimization/119085
- * gcc.dg/tree-ssa/pr119085.c: New test.
----
- gcc/testsuite/gcc.dg/tree-ssa/pr119085.c | 37 ++++++++++++++++++++++++
- gcc/tree-sra.cc | 6 ++++
- 2 files changed, 43 insertions(+)
- create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr119085.c
-
-diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr119085.c b/gcc/testsuite/gcc.dg/tree-ssa/pr119085.c
-new file mode 100644
-index 000000000000..e9811ce12b58
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr119085.c
-@@ -0,0 +1,37 @@
-+/* { dg-do run } */
-+/* { dg-options "-O1" } */
-+
-+struct with_hole {
-+ int x;
-+ long y;
-+};
-+struct without_hole {
-+ int x;
-+ int y;
-+};
-+union u {
-+ struct with_hole with_hole;
-+ struct without_hole without_hole;
-+};
-+
-+void __attribute__((noinline))
-+test (union u *up, union u u)
-+{
-+ union u u2;
-+ volatile int f = 0;
-+ u2 = u;
-+ if (f)
-+ u2.with_hole = u.with_hole;
-+ *up = u2;
-+}
-+
-+int main(void)
-+{
-+ union u u;
-+ union u u2;
-+ u2.without_hole.y = -1;
-+ test (&u, u2);
-+ if (u.without_hole.y != -1)
-+ __builtin_abort ();
-+ return 0;
-+}
-diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
-index 240af676ea33..032f27704847 100644
---- a/gcc/tree-sra.cc
-+++ b/gcc/tree-sra.cc
-@@ -2504,6 +2504,12 @@ sort_and_splice_var_accesses (tree var)
- }
- unscalarizable_region = true;
- }
-+ /* If there the same place is accessed with two incompatible
-+ aggregate types, trying to base total scalarization on either of
-+ them can be wrong. */
-+ if (!first_scalar && !types_compatible_p (access->type, ac2->type))
-+ bitmap_set_bit (cannot_scalarize_away_bitmap,
-+ DECL_UID (access->base));
-
- if (grp_same_access_path
- && (!ac2->grp_same_access_path
-
-base-commit: fdbc5ff61b471076cc9c758fb6c30d62f7ef1c56
---
-2.50.1
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index eeac906..7020432 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -2,7 +2,6 @@
+ 86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
+ 87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
- + 88_all_PR119085.patch
7 21 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-22 23:56 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-22 23:56 UTC (permalink / raw
To: gentoo-commits
commit: d5205478a62f3bd5b7aff6cfad00d336657398fc
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 22 23:56:02 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jul 22 23:56:18 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=d5205478
16.0.0: add SRA patch (for Emacs)
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/88_all_PR119085.patch | 111 ++++++++++++++++++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 112 insertions(+)
diff --git a/16.0.0/gentoo/88_all_PR119085.patch b/16.0.0/gentoo/88_all_PR119085.patch
new file mode 100644
index 0000000..92d9c68
--- /dev/null
+++ b/16.0.0/gentoo/88_all_PR119085.patch
@@ -0,0 +1,111 @@
+https://inbox.sourceware.org/gcc-patches/ri6wm80s22z.fsf@virgil.suse.cz/
+
+From d767af4c6d02ec7150f891f15f3c5713bfad6d47 Mon Sep 17 00:00:00 2001
+Message-ID: <d767af4c6d02ec7150f891f15f3c5713bfad6d47.1753228537.git.sam@gentoo.org>
+From: Martin Jambor <mjambor@suse.cz>
+Date: Tue, 22 Jul 2025 17:00:04 +0200
+Subject: [PATCH] tree-sra: Avoid total SRA if there are incompat. aggregate
+ accesses (PR119085)
+
+Hi,
+
+we currently use the types encountered in the function body and not in
+type declaration to perform total scalarization. Bug PR 119085
+uncovered that we miss a check that when the same data is accessed
+with aggregate types that those are actually compatible. Without it,
+we can base total scalarization on a type that does not "cover" all
+live data in a different part of the function. This patch adds the
+check.
+
+Bootstrapped and tested on x86_64-linux. OK for master and all active
+release branches?
+
+Thanks,
+
+Martin
+
+gcc/ChangeLog:
+
+2025-07-21 Martin Jambor <mjambor@suse.cz>
+
+ PR tree-optimization/119085
+ * tree-sra.cc (sort_and_splice_var_accesses): Prevent total
+ scalarization if two incompatible aggregates access the same place.
+
+gcc/testsuite/ChangeLog:
+
+2025-07-21 Martin Jambor <mjambor@suse.cz>
+
+PR tree-optimization/119085
+ * gcc.dg/tree-ssa/pr119085.c: New test.
+---
+ gcc/testsuite/gcc.dg/tree-ssa/pr119085.c | 37 ++++++++++++++++++++++++
+ gcc/tree-sra.cc | 6 ++++
+ 2 files changed, 43 insertions(+)
+ create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr119085.c
+
+diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr119085.c b/gcc/testsuite/gcc.dg/tree-ssa/pr119085.c
+new file mode 100644
+index 000000000000..e9811ce12b58
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/tree-ssa/pr119085.c
+@@ -0,0 +1,37 @@
++/* { dg-do run } */
++/* { dg-options "-O1" } */
++
++struct with_hole {
++ int x;
++ long y;
++};
++struct without_hole {
++ int x;
++ int y;
++};
++union u {
++ struct with_hole with_hole;
++ struct without_hole without_hole;
++};
++
++void __attribute__((noinline))
++test (union u *up, union u u)
++{
++ union u u2;
++ volatile int f = 0;
++ u2 = u;
++ if (f)
++ u2.with_hole = u.with_hole;
++ *up = u2;
++}
++
++int main(void)
++{
++ union u u;
++ union u u2;
++ u2.without_hole.y = -1;
++ test (&u, u2);
++ if (u.without_hole.y != -1)
++ __builtin_abort ();
++ return 0;
++}
+diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
+index 240af676ea33..032f27704847 100644
+--- a/gcc/tree-sra.cc
++++ b/gcc/tree-sra.cc
+@@ -2504,6 +2504,12 @@ sort_and_splice_var_accesses (tree var)
+ }
+ unscalarizable_region = true;
+ }
++ /* If there the same place is accessed with two incompatible
++ aggregate types, trying to base total scalarization on either of
++ them can be wrong. */
++ if (!first_scalar && !types_compatible_p (access->type, ac2->type))
++ bitmap_set_bit (cannot_scalarize_away_bitmap,
++ DECL_UID (access->base));
+
+ if (grp_same_access_path
+ && (!ac2->grp_same_access_path
+
+base-commit: fdbc5ff61b471076cc9c758fb6c30d62f7ef1c56
+--
+2.50.1
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 7020432..eeac906 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -2,6 +2,7 @@
+ 86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
+ 87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
+ + 88_all_PR119085.patch
7 21 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-21 14:02 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-21 14:02 UTC (permalink / raw
To: gentoo-commits
commit: 4462db3ded9dc8bf07f321ac7d538e311e0b79ac
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 21 14:01:49 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 21 14:01:49 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=4462db3d
16.0.0: add vect fixes
Bug: https://bugs.gentoo.org/959698
Bug: https://gcc.gnu.org/PR121190
Bug: https://gcc.gnu.org/PR121020
Signed-off-by: Sam James <sam <AT> gentoo.org>
...sufficient-alignment-requirement-for-spec.patch | 181 +++++++++++++++++++++
...ssing-skip-vector-check-for-peeling-with-.patch | 142 ++++++++++++++++
16.0.0/gentoo/README.history | 5 +
3 files changed, 328 insertions(+)
diff --git a/16.0.0/gentoo/86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch b/16.0.0/gentoo/86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
new file mode 100644
index 0000000..9a03cdd
--- /dev/null
+++ b/16.0.0/gentoo/86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
@@ -0,0 +1,181 @@
+https://bugs.gentoo.org/959698
+https://inbox.sourceware.org/gcc-patches/20250721110232.186244-1-Pengfei.Li2@arm.com/T/#u
+
+From e120f6cb794a4d104b37913c918aabe0ae6b2c64 Mon Sep 17 00:00:00 2001
+Message-ID: <e120f6cb794a4d104b37913c918aabe0ae6b2c64.1753106388.git.sam@gentoo.org>
+From: Pengfei Li <Pengfei.Li2@arm.com>
+Date: Mon, 21 Jul 2025 11:02:32 +0000
+Subject: [PATCH 1/2] vect: Fix insufficient alignment requirement for
+ speculative loads [PR121190]
+
+This patch fixes a segmentation fault issue that can occur in vectorized
+loops with an early break. When GCC vectorizes such loops, it may insert
+a versioning check to ensure that data references (DRs) with speculative
+loads are aligned. The check normally requires DRs to be aligned to the
+vector mode size, which prevents generated vector load instructions from
+crossing page boundaries.
+
+However, this is not sufficient when a single scalar load is vectorized
+into multiple loads within the same iteration. In such cases, even if
+none of the vector loads crosses page boundaries, subsequent loads after
+the first one may still access memory beyond current valid page.
+
+Consider the following loop as an example:
+
+ while (i < MAX_COMPARE) {
+ if (*(p + i) != *(q + i))
+ return i;
+ i++;
+ }
+
+When compiled with "-O3 -march=znver2" on x86, the vectorized loop may
+include instructions like:
+
+ vmovdqa (%rcx,%rax), %ymm0
+ vmovdqa 32(%rcx,%rax), %ymm1
+ vpcmpeqq (%rdx,%rax), %ymm0, %ymm0
+ vpcmpeqq 32(%rdx,%rax), %ymm1, %ymm1
+
+Note two speculative vector loads are generated for each DR (p and q).
+The first vmovdqa and vpcmpeqq are safe due to the vector size (32-byte)
+alignment, but the following ones (at offset 32) may not be safe because
+they could read from the beginning of the next memory page, potentially
+leading to segmentation faults.
+
+To avoid the issue, this patch increases the alignment requirement for
+speculative loads to DR_TARGET_ALIGNMENT. It ensures all vector loads in
+the same vector iteration access memory within the same page.
+
+This patch is bootstrapped and regression-tested on x86_64-linux-gnu,
+arm-linux-gnueabihf and aarch64-linux-gnu.
+
+ PR tree-optimization/121190
+
+gcc/ChangeLog:
+
+ * tree-vect-data-refs.cc (vect_enhance_data_refs_alignment):
+ Increase alignment requirement for speculative loads.
+
+gcc/testsuite/ChangeLog:
+
+* gcc.dg/vect/vect-early-break_52.c: Update an unsafe test.
+ * gcc.dg/vect/vect-early-break_137.c-pr121190: New test.
+---
+ .../vect/vect-early-break_137-pr121190.c | 60 +++++++++++++++++++
+ .../gcc.dg/vect/vect-early-break_52.c | 2 +-
+ gcc/tree-vect-data-refs.cc | 15 ++++-
+ 3 files changed, 75 insertions(+), 2 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c
+
+diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c
+new file mode 100644
+index 000000000000..da11146c578e
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_137-pr121190.c
+@@ -0,0 +1,60 @@
++/* PR tree-optimization/121190 */
++/* { dg-do run } */
++/* { dg-options "-O3" } */
++/* { dg-additional-options "-march=znver2" { target x86_64-*-* i?86-*-* } } */
++/* { dg-require-effective-target mmap } */
++/* { dg-require-effective-target vect_early_break } */
++
++#include <stdint.h>
++#include <string.h>
++#include <stdio.h>
++#include <sys/mman.h>
++#include <unistd.h>
++
++#define MAX_COMPARE 5000
++
++__attribute__((noipa))
++int diff (uint64_t *restrict p, uint64_t *restrict q)
++{
++ int i = 0;
++ while (i < MAX_COMPARE) {
++ if (*(p + i) != *(q + i))
++ return i;
++ i++;
++ }
++ return -1;
++}
++
++int main ()
++{
++ long pgsz = sysconf (_SC_PAGESIZE);
++ if (pgsz == -1) {
++ fprintf (stderr, "sysconf failed\n");
++ return 0;
++ }
++
++ /* Allocate 2 consecutive pages of memory and let p1 and p2 point to the
++ beginning of each. */
++ void *mem = mmap (NULL, pgsz * 2, PROT_READ | PROT_WRITE,
++ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
++ if (mem == MAP_FAILED) {
++ fprintf (stderr, "mmap failed\n");
++ return 0;
++ }
++ uint64_t *p1 = (uint64_t *) mem;
++ uint64_t *p2 = (uint64_t *) mem + pgsz / sizeof (uint64_t);
++
++ /* Fill the first page with zeros, except for its last 64 bits. */
++ memset (p1, 0, pgsz);
++ *(p2 - 1) = -1;
++
++ /* Make the 2nd page not accessable. */
++ mprotect (p2, pgsz, PROT_NONE);
++
++ /* Calls to diff should not read the 2nd page. */
++ for (int i = 1; i <= 20; i++) {
++ if (diff (p2 - i, p1) != i - 1)
++ __builtin_abort ();
++ }
++}
++
+diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c
+index 86a632f2a822..6abfcd6580e4 100644
+--- a/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c
++++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_52.c
+@@ -18,4 +18,4 @@ int main1 (short X)
+ }
+ }
+
+-/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { ! "x86_64-*-* i?86-*-*" } } } } */
++/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" { target { ! "x86_64-*-* i?86-*-* arm*-*-*" } } } } */
+diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
+index a24ddfbc3841..24048086857f 100644
+--- a/gcc/tree-vect-data-refs.cc
++++ b/gcc/tree-vect-data-refs.cc
+@@ -2964,12 +2964,25 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
+ break;
+ }
+
++ /* Normally, we require DRs to be aligned to the vector mode size.
++ However, this is not sufficient when a statement involves safe
++ speculative read. In such cases, a single scalar load can be
++ vectorized into multiple vector loads in one loop iteration.
++ Even if the first vector load is safe, subsequent loads might
++ still access an invalid memory page. We increase the alignment
++ requirement to prevent this. */
++ poly_uint64 required_align_size;
++ if (dr_safe_speculative_read_required (stmt_info))
++ required_align_size = DR_TARGET_ALIGNMENT (dr_info);
++ else
++ required_align_size = GET_MODE_SIZE (TYPE_MODE (vectype));
++
+ /* At present we don't support versioning for alignment
+ with variable VF, since there's no guarantee that the
+ VF is a power of two. We could relax this if we added
+ a way of enforcing a power-of-two size. */
+ unsigned HOST_WIDE_INT size;
+- if (!GET_MODE_SIZE (TYPE_MODE (vectype)).is_constant (&size))
++ if (!required_align_size.is_constant (&size))
+ {
+ do_versioning = false;
+ break;
+
+base-commit: b441d735c092f5d60c4a9c7167ed9153003d49fa
+--
+2.50.1
+
diff --git a/16.0.0/gentoo/87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch b/16.0.0/gentoo/87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
new file mode 100644
index 0000000..5aae3a5
--- /dev/null
+++ b/16.0.0/gentoo/87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
@@ -0,0 +1,142 @@
+https://bugs.gentoo.org/959698
+https://inbox.sourceware.org/gcc-patches/20250721110642.186287-1-Pengfei.Li2@arm.com/T/#u
+
+From f66323025c47ba09cee296a8a638cfe63d1bdad3 Mon Sep 17 00:00:00 2001
+Message-ID: <f66323025c47ba09cee296a8a638cfe63d1bdad3.1753106388.git.sam@gentoo.org>
+In-Reply-To: <e120f6cb794a4d104b37913c918aabe0ae6b2c64.1753106388.git.sam@gentoo.org>
+References: <e120f6cb794a4d104b37913c918aabe0ae6b2c64.1753106388.git.sam@gentoo.org>
+From: Pengfei Li <Pengfei.Li2@arm.com>
+Date: Mon, 21 Jul 2025 11:06:42 +0000
+Subject: [PATCH 2/2] vect: Add missing skip-vector check for peeling with
+ versioning [PR121020]
+
+This fixes a miscompilation issue introduced by the enablement of
+combined loop peeling and versioning. A test case that reproduces the
+issue is included in the patch.
+
+When performing loop peeling, GCC usually inserts a skip-vector check.
+This ensures that after peeling, there are enough remaining iterations
+to enter the main vectorized loop. Previously, the check was omitted if
+loop versioning for alignment was applied. It was safe before because
+versioning and peeling for alignment were mutually exclusive.
+
+However, with combined peeling and versioning enabled, this is not safe
+any more. A loop may be peeled and versioned at the same time. Without
+the skip-vector check, the main vectorized loop can be entered even if
+its iteration count is zero. This can cause the loop running many more
+iterations than needed, resulting in incorrect results.
+
+To fix this, the patch updates the condition of omitting the skip-vector
+check to when versioning is performed alone without peeling.
+
+This patch is bootstrapped and regression-tested on x86_64-linux-gnu,
+arm-linux-gnueabihf and aarch64-linux-gnu.
+
+ PR tree-optimization/121020
+
+gcc/ChangeLog:
+
+ * tree-vect-loop-manip.cc (vect_do_peeling): Update the
+ condition of omitting the skip-vector check.
+ * tree-vectorizer.h (LOOP_VINFO_USE_VERSIONING_WITHOUT_PEELING):
+ Add a helper macro.
+
+gcc/testsuite/ChangeLog:
+
+* gcc.dg/vect/vect-early-break_138-pr121020.c: New test.
+---
+ .../vect/vect-early-break_138-pr121020.c | 52 +++++++++++++++++++
+ gcc/tree-vect-loop-manip.cc | 2 +-
+ gcc/tree-vectorizer.h | 4 ++
+ 3 files changed, 57 insertions(+), 1 deletion(-)
+ create mode 100644 gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c
+
+diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c
+new file mode 100644
+index 000000000000..86661e445a83
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_138-pr121020.c
+@@ -0,0 +1,52 @@
++/* PR tree-optimization/121020 */
++/* { dg-do run } */
++/* { dg-options "-O3 --vect-cost-model=unlimited" } */
++/* { dg-additional-options "-march=znver2" { target x86_64-*-* i?86-*-* } } */
++/* { dg-require-effective-target mmap } */
++/* { dg-require-effective-target vect_early_break } */
++
++#include <stdint.h>
++#include <stdio.h>
++#include <sys/mman.h>
++#include <unistd.h>
++
++__attribute__((noipa))
++bool equal (uint64_t *restrict p, uint64_t *restrict q, int length)
++{
++ for (int i = 0; i < length; i++) {
++ if (*(p + i) != *(q + i))
++ return false;
++ }
++ return true;
++}
++
++int main ()
++{
++ long pgsz = sysconf (_SC_PAGESIZE);
++ if (pgsz == -1) {
++ fprintf (stderr, "sysconf failed\n");
++ return 0;
++ }
++
++ /* Allocate a whole page of memory. */
++ void *mem = mmap (NULL, pgsz, PROT_READ | PROT_WRITE,
++ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
++ if (mem == MAP_FAILED) {
++ fprintf (stderr, "mmap failed\n");
++ return 0;
++ }
++ uint64_t *p1 = (uint64_t *) mem;
++ uint64_t *p2 = (uint64_t *) mem + 32;
++
++ /* The first 16 elements pointed to by p1 and p2 are the same. */
++ for (int i = 0; i < 32; i++) {
++ *(p1 + i) = 0;
++ *(p2 + i) = (i < 16 ? 0 : -1);
++ }
++
++ /* All calls to equal should return true. */
++ for (int len = 0; len < 16; len++) {
++ if (!equal (p1 + 1, p2 + 1, len))
++ __builtin_abort();
++ }
++}
+diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
+index 2d01a4b0ed1c..7fcbc1ad2eb8 100644
+--- a/gcc/tree-vect-loop-manip.cc
++++ b/gcc/tree-vect-loop-manip.cc
+@@ -3295,7 +3295,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
+ bool skip_vector = (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
+ ? maybe_lt (LOOP_VINFO_INT_NITERS (loop_vinfo),
+ bound_prolog + bound_epilog)
+- : (!LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo)
++ : (!LOOP_VINFO_USE_VERSIONING_WITHOUT_PEELING (loop_vinfo)
+ || vect_epilogues));
+
+ /* Epilog loop must be executed if the number of iterations for epilog
+diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
+index 80f8853733de..69428f1747cb 100644
+--- a/gcc/tree-vectorizer.h
++++ b/gcc/tree-vectorizer.h
+@@ -1168,6 +1168,10 @@ public:
+ || LOOP_REQUIRES_VERSIONING_FOR_NITERS (L) \
+ || LOOP_REQUIRES_VERSIONING_FOR_SIMD_IF_COND (L))
+
++#define LOOP_VINFO_USE_VERSIONING_WITHOUT_PEELING(L) \
++ ((L)->may_misalign_stmts.length () > 0 \
++ && !LOOP_VINFO_ALLOW_MUTUAL_ALIGNMENT (L))
++
+ #define LOOP_VINFO_NITERS_KNOWN_P(L) \
+ (tree_fits_shwi_p ((L)->num_iters) && tree_to_shwi ((L)->num_iters) > 0)
+
+--
+2.50.1
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index d0f985b..7020432 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,8 @@
+8 ????
+
+ + 86_all_PR121190-vect-Fix-insufficient-alignment-requirement-for-spec.patch
+ + 87_all_PR121020-vect-Add-missing-skip-vector-check-for-peeling-with-.patch
+
7 21 July 2025
- 86_all_PR120881-x86-64-Add-enable-x86-64-mfentry.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-21 1:12 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-21 1:12 UTC (permalink / raw
To: gentoo-commits
commit: f8a875becd8c78247abf74bd4882276bec9979c0
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 21 00:24:02 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 21 00:24:02 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=f8a875be
16.0.0: cut patchset 7, drop tuning patch
The tuning patch only helped avoid the CPython issue in a narrow
set of circumstances, not worth keeping.
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/88_all_PR120870-tuning.patch | 12 ------------
16.0.0/gentoo/README.history | 3 +--
2 files changed, 1 insertion(+), 14 deletions(-)
diff --git a/16.0.0/gentoo/88_all_PR120870-tuning.patch b/16.0.0/gentoo/88_all_PR120870-tuning.patch
deleted file mode 100644
index 9f166af..0000000
--- a/16.0.0/gentoo/88_all_PR120870-tuning.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120870#c17
---- a/gcc/config/i386/x86-tune-costs.h
-+++ b/gcc/config/i386/x86-tune-costs.h
-@@ -1774,7 +1774,7 @@ struct processor_costs znver2_cost = {
- Relative to reg-reg move (2). */
- {8, 8, 8}, /* cost of storing integer
- registers. */
-- {6, 6, 6, 6, 12}, /* cost of loading SSE registers
-+ {4, 3, 12, 12, 24}, /* cost of loading SSE register
- in 32bit, 64bit, 128bit, 256bit and 512bit */
- {8, 8, 8, 8, 16}, /* cost of storing SSE register
- in 32bit, 64bit, 128bit, 256bit and 512bit */
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 88b3fa4..d0f985b 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,7 +1,6 @@
-7 ????
+7 21 July 2025
- 86_all_PR120881-x86-64-Add-enable-x86-64-mfentry.patch
- + 88_all_PR120870-tuning.patch
6 14 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-14 16:03 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-14 16:03 UTC (permalink / raw
To: gentoo-commits
commit: 37758405f27f9ebf31a0e59044da0c0aa9eda679
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 14 16:03:10 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 14 16:03:10 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=37758405
16.0.0: drop mfentry patch (merged)
Signed-off-by: Sam James <sam <AT> gentoo.org>
...PR120881-x86-64-Add-enable-x86-64-mfentry.patch | 563 ---------------------
16.0.0/gentoo/README.history | 1 +
2 files changed, 1 insertion(+), 563 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR120881-x86-64-Add-enable-x86-64-mfentry.patch b/16.0.0/gentoo/86_all_PR120881-x86-64-Add-enable-x86-64-mfentry.patch
deleted file mode 100644
index bc7ebce..0000000
--- a/16.0.0/gentoo/86_all_PR120881-x86-64-Add-enable-x86-64-mfentry.patch
+++ /dev/null
@@ -1,563 +0,0 @@
-https://inbox.sourceware.org/gcc-patches/CAMe9rOoxxaxWSAuyJL2=s3jSyQ5_tmg78Nr+oz+t3x-2xgc7+w@mail.gmail.com/
-
-From d6f3358aeab4f2acbe6793f4773248bdcd56c10d Mon Sep 17 00:00:00 2001
-Message-ID: <d6f3358aeab4f2acbe6793f4773248bdcd56c10d.1752368830.git.sam@gentoo.org>
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Wed, 2 Jul 2025 08:58:23 +0800
-Subject: [PATCH] x86-64: Add --enable-x86-64-mfentry
-
-When profiling is enabled with shrink wrapping, the mcount call may not
-be placed at the function entry after
-
- pushq %rbp
- movq %rsp,%rbp
-
-As the result, the profile data may be skewed which makes PGO less
-effective.
-
-Add --enable-x86-64-mfentry to enable -mfentry by default to use
-__fentry__, added to glibc in 2010 by:
-
-commit d22e4cc9397ed41534c9422d0b0ffef8c77bfa53
-Author: Andi Kleen <ak@linux.intel.com>
-Date: Sat Aug 7 21:24:05 2010 -0700
-
- x86: Add support for frame pointer less mcount
-
-instead of mcount, which is placed before the prologue so that -pg can
-be used with -fshrink-wrap-separate enabled at -O1. This option is
-64-bit only because __fentry__ doesn't support PIC in 32-bit mode. The
-default it to enable -mfentry when targeting glibc.
-
-Also warn -pg without -mfentry with shrink wrapping enabled. The warning
-is disable for PIC in 32-bit mode.
-
-gcc/
-
- PR target/120881
- * config.in: Regenerated.
- * configure: Likewise.
- * configure.ac: Add --enable-x86-64-mfentry.
- * config/i386/i386-options.cc (ix86_option_override_internal):
- Enable __fentry__ in 64-bit mode if ENABLE_X86_64_MFENTRY is set
- to 1. Warn -pg without -mfentry with shrink wrapping enabled.
- * doc/install.texi: Document --enable-x86-64-mfentry.
-
-gcc/testsuite/
-
- PR target/120881
- * gcc.dg/20021014-1.c: Add additional -mfentry -fno-pic options
- for x86.
- * gcc.dg/aru-2.c: Likewise.
- * gcc.dg/nest.c: Likewise.
- * gcc.dg/pr32450.c: Likewise.
- * gcc.dg/pr43643.c: Likewise.
- * gcc.target/i386/pr104447.c: Likewise.
- * gcc.target/i386/pr113122-3.c: Likewise.
- * gcc.target/i386/pr119386-1.c: Add additional -mfentry if not
- ia32.
- * gcc.target/i386/pr119386-2.c: Likewise.
- * gcc.target/i386/pr120881-1a.c: New test.
- * gcc.target/i386/pr120881-1b.c: Likewise.
- * gcc.target/i386/pr120881-1c.c: Likewise.
- * gcc.target/i386/pr120881-1d.c: Likewise.
- * gcc.target/i386/pr120881-2a.c: Likewise.
- * gcc.target/i386/pr120881-2b.c: Likewise.
- * gcc.target/i386/pr82699-1.c: Add additional -mfentry.
- * lib/target-supports.exp (check_effective_target_fentry): New.
-
-Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
----
- gcc/config.in | 6 +++
- gcc/config/i386/i386-options.cc | 11 ++++-
- gcc/configure | 46 +++++++++++++++++++-
- gcc/configure.ac | 35 +++++++++++++++
- gcc/doc/install.texi | 11 +++++
- gcc/testsuite/gcc.dg/20021014-1.c | 1 +
- gcc/testsuite/gcc.dg/aru-2.c | 1 +
- gcc/testsuite/gcc.dg/nest.c | 1 +
- gcc/testsuite/gcc.dg/pr32450.c | 2 +-
- gcc/testsuite/gcc.dg/pr43643.c | 1 +
- gcc/testsuite/gcc.target/i386/pr104447.c | 2 +-
- gcc/testsuite/gcc.target/i386/pr113122-3.c | 2 +-
- gcc/testsuite/gcc.target/i386/pr119386-1.c | 4 +-
- gcc/testsuite/gcc.target/i386/pr119386-2.c | 3 +-
- gcc/testsuite/gcc.target/i386/pr120881-1a.c | 4 ++
- gcc/testsuite/gcc.target/i386/pr120881-1b.c | 4 ++
- gcc/testsuite/gcc.target/i386/pr120881-1c.c | 3 ++
- gcc/testsuite/gcc.target/i386/pr120881-1d.c | 3 ++
- gcc/testsuite/gcc.target/i386/pr120881-2a.c | 21 +++++++++
- gcc/testsuite/gcc.target/i386/pr120881-2b.c | 6 +++
- gcc/testsuite/gcc.target/i386/pr82699-1.c | 2 +-
- gcc/testsuite/lib/target-supports.exp | 48 +++++++++++++++++++++
- 22 files changed, 208 insertions(+), 9 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-1a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-1b.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-1c.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-1d.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-2a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-2b.c
-
-diff --git a/gcc/config.in b/gcc/config.in
-index ab62c1566cbb..353d1bc94078 100644
---- a/gcc/config.in
-+++ b/gcc/config.in
-@@ -318,6 +318,12 @@
- #endif
-
-
-+/* Define to enable -mfentry by default on x86-64. */
-+#ifndef USED_FOR_TARGET
-+#undef ENABLE_X86_64_MFENTRY
-+#endif
-+
-+
- /* Define to the name of a file containing a list of extra machine modes for
- this architecture. */
- #ifndef USED_FOR_TARGET
-diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
-index 09cb1337f94c..53658496efdc 100644
---- a/gcc/config/i386/i386-options.cc
-+++ b/gcc/config/i386/i386-options.cc
-@@ -2839,7 +2839,9 @@ ix86_option_override_internal (bool main_args_p,
-
- /* Set the default value for -mfentry. */
- if (!opts_set->x_flag_fentry)
-- opts->x_flag_fentry = TARGET_SEH;
-+ opts->x_flag_fentry = (TARGET_SEH
-+ || (TARGET_64BIT_P (opts->x_ix86_isa_flags)
-+ && ENABLE_X86_64_MFENTRY));
- else
- {
- if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) && opts->x_flag_pic
-@@ -2850,6 +2852,13 @@ ix86_option_override_internal (bool main_args_p,
- sorry ("%<-mno-fentry%> isn%'t compatible with SEH");
- }
-
-+ if (!opts->x_flag_fentry
-+ && (TARGET_64BIT_P (opts->x_ix86_isa_flags) || !opts->x_flag_pic)
-+ && opts->x_flag_shrink_wrap
-+ && opts->x_profile_flag)
-+ warning (0, "%<-pg%> without %<-mfentry%> may be unreliable with "
-+ "shrink wrapping");
-+
- if (TARGET_SEH && TARGET_CALL_MS2SYSV_XLOGUES)
- sorry ("%<-mcall-ms2sysv-xlogues%> isn%'t currently supported with SEH");
-
-diff --git a/gcc/configure b/gcc/configure
-index f056cfe9677e..7537da20291a 100755
---- a/gcc/configure
-+++ b/gcc/configure
-@@ -1064,6 +1064,7 @@ enable_versioned_jit
- enable_default_pie
- enable_cet
- enable_s390_excess_float_precision
-+enable_x86_64_mfentry
- '
- ac_precious_vars='build_alias
- host_alias
-@@ -1842,6 +1843,7 @@ Optional Features:
- --enable-s390-excess-float-precision
- on s390 targets, evaluate float with double
- precision when in standards-conforming mode
-+ --enable-x86-64-mfentry enable -mfentry by default on x86-64 targets
-
- Optional Packages:
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
-@@ -21520,7 +21522,7 @@ else
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<_LT_EOF
--#line 21523 "configure"
-+#line 21525 "configure"
- #include "confdefs.h"
-
- #if HAVE_DLFCN_H
-@@ -21626,7 +21628,7 @@ else
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<_LT_EOF
--#line 21629 "configure"
-+#line 21631 "configure"
- #include "confdefs.h"
-
- #if HAVE_DLFCN_H
-@@ -35022,6 +35024,46 @@ $as_echo "#define ENABLE_S390_EXCESS_FLOAT_PRECISION 1" >>confdefs.h
- ;;
- esac
-
-+# On x86-64, when profiling is enabled with shrink wrapping, the mcount
-+# call may not be placed at the function entry after
-+# pushq %rbp
-+# movq %rsp,%rbp
-+# As the result, the profile data may be skewed which makes PGO less
-+# effective:
-+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120881
-+# Enable -mfentry by default on x86-64 to put the profiling counter call
-+# before the prologue.
-+# Check whether --enable-x86-64-mfentry was given.
-+if test "${enable_x86_64_mfentry+set}" = set; then :
-+ enableval=$enable_x86_64_mfentry; case "${enableval}" in
-+ yes | no | auto)
-+ enable_x86_64_mfentry=$enableval
-+ ;;
-+ *)
-+ as_fn_error $? "'$enable_x86_64_mfentry' is an invalid value for --enable-x86-64-mfentry. Valid choices are 'yes', 'no' and 'auto'." "$LINENO" 5
-+ ;;
-+ esac
-+else
-+ enable_x86_64_mfentry=auto
-+fi
-+
-+
-+if test x"$enable_x86_64_mfentry" = xauto; then
-+ case "${target}" in
-+ i?86-*-*gnu* | x86_64-*-*gnu*)
-+ # Enable -mfentry by default with glibc on x86.
-+ enable_x86_64_mfentry=yes
-+ ;;
-+ esac
-+fi
-+
-+gif=`if test x$enable_x86_64_mfentry = xyes; then echo 1; else echo 0; fi`
-+
-+cat >>confdefs.h <<_ACEOF
-+#define ENABLE_X86_64_MFENTRY $gif
-+_ACEOF
-+
-+
- # Check if the linker supports '-z now'
- ld_now_support=no
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker -z now option" >&5
-diff --git a/gcc/configure.ac b/gcc/configure.ac
-index 58bf63f8be9e..24e0aa69c0f6 100644
---- a/gcc/configure.ac
-+++ b/gcc/configure.ac
-@@ -7972,6 +7972,41 @@ standards-compatible mode on s390 targets.])
- ;;
- esac
-
-+# On x86-64, when profiling is enabled with shrink wrapping, the mcount
-+# call may not be placed at the function entry after
-+# pushq %rbp
-+# movq %rsp,%rbp
-+# As the result, the profile data may be skewed which makes PGO less
-+# effective:
-+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120881
-+# Enable -mfentry by default on x86-64 to put the profiling counter call
-+# before the prologue.
-+AC_ARG_ENABLE(x86-64-mfentry,
-+ [AS_HELP_STRING([--enable-x86-64-mfentry],
-+ [enable -mfentry by default on x86-64 targets])],
-+ [case "${enableval}" in
-+ yes | no | auto)
-+ enable_x86_64_mfentry=$enableval
-+ ;;
-+ *)
-+ AC_MSG_ERROR(['$enable_x86_64_mfentry' is an invalid value for --enable-x86-64-mfentry. Valid choices are 'yes', 'no' and 'auto'.])
-+ ;;
-+ esac],
-+ [enable_x86_64_mfentry=auto])
-+
-+if test x"$enable_x86_64_mfentry" = xauto; then
-+ case "${target}" in
-+ i?86-*-*gnu* | x86_64-*-*gnu*)
-+ # Enable -mfentry by default with glibc on x86.
-+ enable_x86_64_mfentry=yes
-+ ;;
-+ esac
-+fi
-+
-+gif=`if test x$enable_x86_64_mfentry = xyes; then echo 1; else echo 0; fi`
-+AC_DEFINE_UNQUOTED(ENABLE_X86_64_MFENTRY, $gif,
-+[Define to enable -mfentry by default on x86-64.])
-+
- # Check if the linker supports '-z now'
- ld_now_support=no
- AC_MSG_CHECKING(linker -z now option)
-diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
-index 80ee2cd6ebad..09ea87aa8120 100644
---- a/gcc/doc/install.texi
-+++ b/gcc/doc/install.texi
-@@ -2667,6 +2667,17 @@ target binutils supports @code{Intel CET} instructions and disabled
- otherwise. In this case, the target libraries are configured to get
- additional @option{-fcf-protection} option.
-
-+@item --enable-x86-64-mfentry
-+@itemx --disable-x86-64-mfentry
-+Enable @option {-mfentry} by default on x86-64 to put the profiling
-+counter call, @code{__fentry__}, before the prologue so that @option{-pg}
-+can be used with @option{-fshrink-wrap} which is enabled at @option{-O1}.
-+This configure option is 64-bit only because @code{__fentry__} doesn't
-+support PIC in 32-bit mode.
-+
-+@option{--enable-x86-64-mfentry=auto} is default. @option{-mfentry} is
-+enabled on Linux/x86-64 by default.
-+
- @item --with-riscv-attribute=@samp{yes}, @samp{no} or @samp{default}
- Generate RISC-V attribute by default, in order to record extra build
- information in object.
-diff --git a/gcc/testsuite/gcc.dg/20021014-1.c b/gcc/testsuite/gcc.dg/20021014-1.c
-index e43f7b297c5e..f5f6fcf36251 100644
---- a/gcc/testsuite/gcc.dg/20021014-1.c
-+++ b/gcc/testsuite/gcc.dg/20021014-1.c
-@@ -2,6 +2,7 @@
- /* { dg-require-profiling "-p" } */
- /* { dg-options "-O2 -p" } */
- /* { dg-options "-O2 -p -static" { target hppa*-*-hpux* } } */
-+/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* } } */
- /* { dg-error "profiler" "No profiler support" { target xstormy16-*-* } 0 } */
- /* { dg-message "" "consider using `-pg' instead of `-p' with gprof(1)" { target *-*-freebsd* } 0 } */
-
-diff --git a/gcc/testsuite/gcc.dg/aru-2.c b/gcc/testsuite/gcc.dg/aru-2.c
-index 054223c151b2..102ece177264 100644
---- a/gcc/testsuite/gcc.dg/aru-2.c
-+++ b/gcc/testsuite/gcc.dg/aru-2.c
-@@ -1,6 +1,7 @@
- /* { dg-do run } */
- /* { dg-require-profiling "-pg" } */
- /* { dg-options "-O2 -pg" } */
-+/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* } } */
-
- static int __attribute__((noinline))
- bar (int x)
-diff --git a/gcc/testsuite/gcc.dg/nest.c b/gcc/testsuite/gcc.dg/nest.c
-index 5734c11f1a3e..9221ed1c8f81 100644
---- a/gcc/testsuite/gcc.dg/nest.c
-+++ b/gcc/testsuite/gcc.dg/nest.c
-@@ -3,6 +3,7 @@
- /* { dg-require-profiling "-pg" } */
- /* { dg-options "-O2 -pg" } */
- /* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */
-+/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* } } */
- /* { dg-error "profiler" "No profiler support" { target xstormy16-*-* } 0 } */
-
- extern void abort (void);
-diff --git a/gcc/testsuite/gcc.dg/pr32450.c b/gcc/testsuite/gcc.dg/pr32450.c
-index 9606e3021eab..4aaeb7dd6546 100644
---- a/gcc/testsuite/gcc.dg/pr32450.c
-+++ b/gcc/testsuite/gcc.dg/pr32450.c
-@@ -3,7 +3,7 @@
- /* { dg-do run } */
- /* { dg-require-profiling "-pg" } */
- /* { dg-options "-O2 -pg" } */
--/* { dg-options "-O2 -pg -mtune=core2" { target { i?86-*-* x86_64-*-* } } } */
-+/* { dg-options "-O2 -pg -mtune=core2 -mfentry -fno-pic" { target { i?86-*-* x86_64-*-* } } } */
- /* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */
-
- extern void abort (void);
-diff --git a/gcc/testsuite/gcc.dg/pr43643.c b/gcc/testsuite/gcc.dg/pr43643.c
-index 43896abd85af..a62586dc7196 100644
---- a/gcc/testsuite/gcc.dg/pr43643.c
-+++ b/gcc/testsuite/gcc.dg/pr43643.c
-@@ -4,6 +4,7 @@
- /* { dg-require-profiling "-pg" } */
- /* { dg-options "-O2 -pg" } */
- /* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */
-+/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* } } */
-
- extern char *strdup (const char *);
-
-diff --git a/gcc/testsuite/gcc.target/i386/pr104447.c b/gcc/testsuite/gcc.target/i386/pr104447.c
-index cb618c7b8bb3..f58170db7ecf 100644
---- a/gcc/testsuite/gcc.target/i386/pr104447.c
-+++ b/gcc/testsuite/gcc.target/i386/pr104447.c
-@@ -1,6 +1,6 @@
- /* { dg-do compile } */
- /* { dg-require-profiling "-pg" } */
--/* { dg-options "-O2 -pg" } */
-+/* { dg-options "-O2 -pg -mfentry -fno-pic" } */
-
- int
- bar (int x)
-diff --git a/gcc/testsuite/gcc.target/i386/pr113122-3.c b/gcc/testsuite/gcc.target/i386/pr113122-3.c
-index 71aa240ba98c..c46805dd7722 100644
---- a/gcc/testsuite/gcc.target/i386/pr113122-3.c
-+++ b/gcc/testsuite/gcc.target/i386/pr113122-3.c
-@@ -1,7 +1,7 @@
- /* PR target/113122 */
- /* { dg-do assemble { target *-*-linux* } } */
- /* { dg-require-effective-target masm_intel } */
--/* { dg-options "-fprofile -O2 -masm=intel" } */
-+/* { dg-options "-fprofile -mfentry -fno-pic -O2 -masm=intel" } */
-
- void
- func (void)
-diff --git a/gcc/testsuite/gcc.target/i386/pr119386-1.c b/gcc/testsuite/gcc.target/i386/pr119386-1.c
-index 9a0dc64b5b93..39a3e1d2e806 100644
---- a/gcc/testsuite/gcc.target/i386/pr119386-1.c
-+++ b/gcc/testsuite/gcc.target/i386/pr119386-1.c
-@@ -1,7 +1,9 @@
- /* PR target/119386 */
- /* { dg-do compile { target *-*-linux* } } */
- /* { dg-options "-O2 -fpic -pg" } */
--/* { dg-final { scan-assembler "call\[ \t\]+mcount@PLT" } } */
-+/* { dg-additional-options "-mfentry" { target { ! ia32 } } } */
-+/* { dg-final { scan-assembler "call\[ \t\]+mcount@PLT" { target ia32 } } } */
-+/* { dg-final { scan-assembler "call\[ \t\]+__fentry__@PLT" { target { ! ia32 } } } } */
-
- int
- main ()
-diff --git a/gcc/testsuite/gcc.target/i386/pr119386-2.c b/gcc/testsuite/gcc.target/i386/pr119386-2.c
-index 3ea978ecfdfd..d516aa9bd6af 100644
---- a/gcc/testsuite/gcc.target/i386/pr119386-2.c
-+++ b/gcc/testsuite/gcc.target/i386/pr119386-2.c
-@@ -1,7 +1,8 @@
- /* PR target/119386 */
- /* { dg-do compile { target *-*-linux* } } */
- /* { dg-options "-O2 -fpic -fno-plt -pg" } */
--/* { dg-final { scan-assembler "call\[ \t\]+\\*mcount@GOTPCREL\\(" { target { ! ia32 } } } } */
-+/* { dg-additional-options "-mfentry" { target { ! ia32 } } } */
-+/* { dg-final { scan-assembler "call\[ \t\]+\\*__fentry__@GOTPCREL" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler "call\[ \t\]+\\*mcount@GOT\\(" { target ia32 } } } */
-
-
-diff --git a/gcc/testsuite/gcc.target/i386/pr120881-1a.c b/gcc/testsuite/gcc.target/i386/pr120881-1a.c
-new file mode 100644
-index 000000000000..3d9ac0e9e866
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr120881-1a.c
-@@ -0,0 +1,4 @@
-+/* { dg-do compile { target fpic } } */
-+/* { dg-require-profiling "-pg" } */
-+/* { dg-options "-O2 -pg -mno-fentry -fno-pic" } */
-+/* { dg-message "'-pg' without '-mfentry' may be unreliable with shrink wrapping" "" { target *-*-* } 0 } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr120881-1b.c b/gcc/testsuite/gcc.target/i386/pr120881-1b.c
-new file mode 100644
-index 000000000000..082640726b1d
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr120881-1b.c
-@@ -0,0 +1,4 @@
-+/* { dg-do compile { target { fpic && { ! ia32 } } } } */
-+/* { dg-require-profiling "-pg" } */
-+/* { dg-options "-O2 -pg -mno-fentry -fpic" } */
-+/* { dg-message "'-pg' without '-mfentry' may be unreliable with shrink wrapping" "" { target *-*-* } 0 } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr120881-1c.c b/gcc/testsuite/gcc.target/i386/pr120881-1c.c
-new file mode 100644
-index 000000000000..c21979f8eb1f
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr120881-1c.c
-@@ -0,0 +1,3 @@
-+/* { dg-do compile { target { fpic && ia32 } } } */
-+/* { dg-require-profiling "-pg" } */
-+/* { dg-options "-O2 -pg -mno-fentry -fpic" } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr120881-1d.c b/gcc/testsuite/gcc.target/i386/pr120881-1d.c
-new file mode 100644
-index 000000000000..f74af23ff5c8
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr120881-1d.c
-@@ -0,0 +1,3 @@
-+/* { dg-do compile { target { fpic && ia32 } } } */
-+/* { dg-require-profiling "-pg" } */
-+/* { dg-options "-O2 -pg -mno-fentry -fno-shrink-wrap -fno-pic" } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr120881-2a.c b/gcc/testsuite/gcc.target/i386/pr120881-2a.c
-new file mode 100644
-index 000000000000..52e3e5292e5f
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr120881-2a.c
-@@ -0,0 +1,21 @@
-+/* { dg-do compile { target fentry } } */
-+/* { dg-options "-O2 -pg" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
-+
-+/*
-+**f2:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+** call __fentry__
-+**...
-+*/
-+
-+extern void f1 (void);
-+
-+void
-+f2 (int count)
-+{
-+ for (int i = 0; i < count; ++i)
-+ f1 ();
-+}
-diff --git a/gcc/testsuite/gcc.target/i386/pr120881-2b.c b/gcc/testsuite/gcc.target/i386/pr120881-2b.c
-new file mode 100644
-index 000000000000..43a12f007749
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr120881-2b.c
-@@ -0,0 +1,6 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue -march=x86-64" } */
-+/* { dg-final { scan-rtl-dump "Now spread 1 times" "pro_and_epilogue" } } */
-+
-+#include "pr120881-2a.c"
-+
-diff --git a/gcc/testsuite/gcc.target/i386/pr82699-1.c b/gcc/testsuite/gcc.target/i386/pr82699-1.c
-index 272d0797ff8f..96e3ccb27076 100644
---- a/gcc/testsuite/gcc.target/i386/pr82699-1.c
-+++ b/gcc/testsuite/gcc.target/i386/pr82699-1.c
-@@ -1,5 +1,5 @@
- /* { dg-do compile { target *-*-linux* } } */
--/* { dg-options "-O2 -fno-pic -fcf-protection -pg -fasynchronous-unwind-tables" } */
-+/* { dg-options "-O2 -mfentry -fno-pic -fcf-protection -pg -fasynchronous-unwind-tables" } */
- /* { dg-final { scan-assembler-times {\t\.cfi_startproc\n\tendbr} 1 } } */
-
- extern int bar (int);
-diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
-index 9ab46a0eab43..c37a30a32ed4 100644
---- a/gcc/testsuite/lib/target-supports.exp
-+++ b/gcc/testsuite/lib/target-supports.exp
-@@ -14528,3 +14528,51 @@ proc check_effective_target_foldable_pi_based_trigonometry { } {
- }
- }]
- }
-+#
-+# Return 1 if the x86-64 target enables -mfentry by default, 0
-+# otherwise. Cache the result.
-+
-+proc check_effective_target_fentry { } {
-+ global tool
-+ global GCC_UNDER_TEST
-+
-+ if { ![check_effective_target_x86] } {
-+ return 0
-+ }
-+
-+ # Need auto-host.h to check linker support.
-+ if { ![file exists ../../auto-host.h ] } {
-+ return 0
-+ }
-+
-+ return [check_cached_effective_target fentry {
-+ # Set up and compile to see if ENABLE_X86_64_MFENTRY is
-+ # non-zero. Include the current process ID in the file
-+ # names to prevent conflicts with invocations for multiple
-+ # testsuites.
-+
-+ set src pie[pid].c
-+ set obj pie[pid].o
-+
-+ set f [open $src "w"]
-+ puts $f "#include \"../../auto-host.h\""
-+ puts $f "#if ENABLE_X86_64_MFENTRY == 0 || !defined __x86_64__"
-+ puts $f "# error -mfentry is not enabled by default."
-+ puts $f "#endif"
-+ close $f
-+
-+ verbose "check_effective_target_fentry compiling testfile $src" 2
-+ set lines [${tool}_target_compile $src $obj object ""]
-+
-+ file delete $src
-+ file delete $obj
-+
-+ if [string match "" $lines] then {
-+ verbose "check_effective_target_fentry testfile compilation passed" 2
-+ return 1
-+ } else {
-+ verbose "check_effective_target_fentry testfile compilation failed" 2
-+ return 0
-+ }
-+ }]
-+}
-
-base-commit: 598455fd73b2061e461c54c18fae8bcc2b4b6d72
---
-2.50.1
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 9fba669..88b3fa4 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,5 +1,6 @@
7 ????
+ - 86_all_PR120881-x86-64-Add-enable-x86-64-mfentry.patch
+ 88_all_PR120870-tuning.patch
6 14 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-14 4:09 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-14 4:09 UTC (permalink / raw
To: gentoo-commits
commit: dd1b89460dc2ac980a1aba86c46aeb77148127af
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 14 04:09:23 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 14 04:09:46 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=dd1b8946
16.0.0: drop Blender patch again
Uros has further comments.
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/87_all_PR121015-blender.patch | 1042 ---------------------------
16.0.0/gentoo/README.history | 1 -
2 files changed, 1043 deletions(-)
diff --git a/16.0.0/gentoo/87_all_PR121015-blender.patch b/16.0.0/gentoo/87_all_PR121015-blender.patch
deleted file mode 100644
index 3eaec37..0000000
--- a/16.0.0/gentoo/87_all_PR121015-blender.patch
+++ /dev/null
@@ -1,1042 +0,0 @@
-https://inbox.sourceware.org/gcc-patches/CAMe9rOp5dSWgFmZ=Ps8R9M0OkRFTXZtCHnHQL0AqBk+ddNQw5A@mail.gmail.com/
-
-From 393baf5d3fd2408a0be029c09ab2e18219867087 Mon Sep 17 00:00:00 2001
-Message-ID: <393baf5d3fd2408a0be029c09ab2e18219867087.1752460761.git.sam@gentoo.org>
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Sun, 13 Jul 2025 08:59:34 +0800
-Subject: [PATCH] x86: Update MMX moves to support all 1s vectors
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-commit 77473a27bae04da99d6979d43e7bd0a8106f4557
-Author: H.J. Lu <hjl.tools@gmail.com>
-Date: Thu Jun 26 06:08:51 2025 +0800
-
- x86: Also handle all 1s float vector constant
-
-replaces
-
-(insn 29 28 30 5 (set (reg:V2SF 107)
- (mem/u/c:V2SF (symbol_ref/u:DI ("*.LC0") [flags 0x2]) [0 S8 A64])) 2031 {*movv2sf_internal}
- (expr_list:REG_EQUAL (const_vector:V2SF [
- (const_double:SF -QNaN [-QNaN]) repeated x2
- ])
- (nil)))
-
-with
-
-(insn 98 13 14 3 (set (reg:V8QI 112)
- (const_vector:V8QI [
- (const_int -1 [0xffffffffffffffff]) repeated x8
- ])) -1
- (nil))
-...
-(insn 29 28 30 5 (set (reg:V2SF 107)
- (subreg:V2SF (reg:V8QI 112) 0)) 2031 {*movv2sf_internal}
- (expr_list:REG_EQUAL (const_vector:V2SF [
- (const_double:SF -QNaN [-QNaN]) repeated x2
- ])
- (nil)))
-
-which leads to
-
-pr121015.c: In function ‘render_result_from_bake_h’:
-pr121015.c:34:1: error: unrecognizable insn:
- 34 | }
- | ^
-(insn 98 13 14 3 (set (reg:V8QI 112)
- (const_vector:V8QI [
- (const_int -1 [0xffffffffffffffff]) repeated x8
- ])) -1
- (expr_list:REG_EQUIV (const_vector:V8QI [
- (const_int -1 [0xffffffffffffffff]) repeated x8
- ])
- (nil)))
-during RTL pass: ira
-
-1. Add BZ constraint for constant 0 in 64-bit or without SSE to replace
-C constraint in 8-byte MMX zeroing stores so that we can generate
-
- pxor %xmm0, %xmm0
- movq %xmm0, (%edx)
-
-with SSE in 32-bit.
-2. Extend standard_sse_constant_p to cover 4-byte and 8-byte all 1s to
-support
-
-(set (reg:V8QI 100)
- (const_vector:V8QI [
- (const_int -1 [0xffffffffffffffff]) repeated x8]))
-
-and
-
-(set (mem/c:V4QI (reg/f:SI 99)
- (const_vector:V4QI [
- (const_int -1 [0xffffffffffffffff]) repeated x4]))
-
-3. Update 4-byte and 8-byte MMX moves to support constant all 1s vectors.
-4. Split 4-byte and 8-byte MMX CONSTM1 moves by loading from memory if
-they haven't been eliminated.
-
-gcc/
-
- PR target/121015
- * config/i386/constraints.md (BZ): New constraint.
- * config/i386/i386.cc (standard_sse_constant_p): Support 4-byte
- and 8-byte all 1s.
- (ix86_print_operand): Support CONSTM1_RTX.
- * config/i386/mmx.md (mmxconstm1): New.
- (MMXMODE:mov<mode>): Replace nonimm_or_0_operand with
- nonimmediate_or_sse_const_operand.
- (MMXMODE:*mov<mode>_internal): Replace C with BZ in zeroing
- stores. Add <m,<<mmxconstm1>> and <v,<mmxconstm1>> alternatives.
- Add a MMXMODE splitter to split CONSTM1_RTX moves.
- (V_32:mov<mode>): Replace nonimm_or_0_operand with
- nonimmediate_or_sse_const_operand.
- (V_32:*mov<mode>_internal): Add <rm,<<mmxconstm1>> and
- <v,<mmxconstm1>> alternatives.
- Add a V_32 splitter to split CONSTM1_RTX stores.
-
-gcc/testsuite/
-
- PR target/121015
- * gcc.target/i386/pr117839-1b.c: Updated assembler scan for 8-byte
- zeroing store with XMM register in 32-bit.
- * gcc.target/i386/pr117839-2.c: Likewise.
- * gcc.target/i386/pr121015-1.c: New test.
- * gcc.target/i386/pr121015-2a.c: Likewise.
- * gcc.target/i386/pr121015-2b.c: Likewise.
- * gcc.target/i386/pr121015-3.c: Likewise.
- * gcc.target/i386/pr121015-4.c: Likewise.
- * gcc.target/i386/pr121015-5a.c: Likewise.
- * gcc.target/i386/pr121015-5b.c: Likewise.
- * gcc.target/i386/pr121015-5c.c: Likewise.
- * gcc.target/i386/pr121015-6.c: Likewise.
- * gcc.target/i386/pr121015-7a.c: Likewise.
- * gcc.target/i386/pr121015-7b.c: Likewise.
- * gcc.target/i386/pr121015-7c.c: Likewise.
- * gcc.target/i386/pr121015-8.c: Likewise.
- * gcc.target/i386/pr121015-9.c: Likewise.
- * gcc.target/i386/pr121015-10a.c: Likewise.
- * gcc.target/i386/pr121015-10b.c: Likewise.
- * gcc.target/i386/pr121015-10c.c: Likewise.
-
-Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
-Co-Authored-By: Uros Bizjak <ubizjak@gmail.com>
----
- gcc/config/i386/constraints.md | 7 +
- gcc/config/i386/i386.cc | 13 +-
- gcc/config/i386/mmx.md | 130 ++++++++++++++-----
- gcc/testsuite/gcc.target/i386/pr117839-1b.c | 5 +-
- gcc/testsuite/gcc.target/i386/pr117839-2.c | 5 +-
- gcc/testsuite/gcc.target/i386/pr121015-1.c | 34 +++++
- gcc/testsuite/gcc.target/i386/pr121015-10a.c | 32 +++++
- gcc/testsuite/gcc.target/i386/pr121015-10b.c | 16 +++
- gcc/testsuite/gcc.target/i386/pr121015-10c.c | 21 +++
- gcc/testsuite/gcc.target/i386/pr121015-11a.c | 21 +++
- gcc/testsuite/gcc.target/i386/pr121015-11b.c | 13 ++
- gcc/testsuite/gcc.target/i386/pr121015-11c.c | 17 +++
- gcc/testsuite/gcc.target/i386/pr121015-2a.c | 24 ++++
- gcc/testsuite/gcc.target/i386/pr121015-2b.c | 6 +
- gcc/testsuite/gcc.target/i386/pr121015-3.c | 35 +++++
- gcc/testsuite/gcc.target/i386/pr121015-4.c | 22 ++++
- gcc/testsuite/gcc.target/i386/pr121015-5a.c | 21 +++
- gcc/testsuite/gcc.target/i386/pr121015-5b.c | 16 +++
- gcc/testsuite/gcc.target/i386/pr121015-5c.c | 20 +++
- gcc/testsuite/gcc.target/i386/pr121015-6.c | 23 ++++
- gcc/testsuite/gcc.target/i386/pr121015-7a.c | 23 ++++
- gcc/testsuite/gcc.target/i386/pr121015-7b.c | 6 +
- gcc/testsuite/gcc.target/i386/pr121015-7c.c | 8 ++
- gcc/testsuite/gcc.target/i386/pr121015-8.c | 14 ++
- gcc/testsuite/gcc.target/i386/pr121015-9.c | 14 ++
- 25 files changed, 512 insertions(+), 34 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-1.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-10a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-10b.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-10c.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-11a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-11b.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-11c.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-2a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-2b.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-3.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-4.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-5a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-5b.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-5c.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-6.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-7a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-7b.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-7c.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-8.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-9.c
-
-diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
-index 38877a7e61bd..4bfd9b2a4580 100644
---- a/gcc/config/i386/constraints.md
-+++ b/gcc/config/i386/constraints.md
-@@ -174,6 +174,7 @@ (define_register_constraint "YW"
- ;; and zero-extand to 256/512bit, or 128bit all ones
- ;; and zero-extend to 512bit.
- ;; M x86-64 memory operand.
-+;; Z Constant zero operand in 64-bit or without SSE.
-
- (define_constraint "Bf"
- "@internal Flags register operand."
-@@ -246,6 +247,12 @@ (define_constraint "BM"
- (match_test "memory_address_addr_space_p (GET_MODE (op), XEXP (op, 0),
- MEM_ADDR_SPACE (op))")))
-
-+(define_constraint "BZ"
-+ "@internal Constant zero operand in 64-bit or without SSE."
-+ (and (match_test "TARGET_64BIT || !TARGET_SSE")
-+ (ior (match_test "op == const0_rtx")
-+ (match_operand 0 "const0_operand"))))
-+
- ;; Integer constant constraints.
- (define_constraint "Wb"
- "Integer constant in the range 0 @dots{} 7, for 8-bit shifts."
-diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
-index 313522b88e3c..a9c1418a2bf5 100644
---- a/gcc/config/i386/i386.cc
-+++ b/gcc/config/i386/i386.cc
-@@ -5448,6 +5448,8 @@ standard_sse_constant_p (rtx x, machine_mode pred_mode)
- return 2;
- break;
- case 16:
-+ case 8:
-+ case 4:
- if (TARGET_SSE2)
- return 2;
- break;
-@@ -14671,9 +14673,14 @@ ix86_print_operand (FILE *file, rtx x, int code)
- since we can in fact encode that into an immediate. */
- if (GET_CODE (x) == CONST_VECTOR)
- {
-- if (x != CONST0_RTX (GET_MODE (x)))
-- output_operand_lossage ("invalid vector immediate");
-- x = const0_rtx;
-+ if (x == CONSTM1_RTX (GET_MODE (x)))
-+ x = constm1_rtx;
-+ else
-+ {
-+ if (x != CONST0_RTX (GET_MODE (x)))
-+ output_operand_lossage ("invalid vector immediate");
-+ x = const0_rtx;
-+ }
- }
-
- if (code == 'P')
-diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
-index 29a8cb599a7e..3b013e3db311 100644
---- a/gcc/config/i386/mmx.md
-+++ b/gcc/config/i386/mmx.md
-@@ -111,6 +111,13 @@ (define_mode_attr mmxinsnmode
- (V4BF "DI") (V2BF "SI")
- (V2SF "DI")])
-
-+;; MMX constant -1 constraint
-+(define_mode_attr mmxconstm1
-+ [(V8QI "BC") (V4HI "BC") (V2SI "BC") (V1DI "BC")
-+ (V4QI "BC") (V2HI "BC") (V1SI "BC")
-+ (V4HF "BF") (V4BF "BF") (V2SF "BF")
-+ (V2HF "BF") (V2BF "BF")])
-+
- (define_mode_attr mmxdoublemode
- [(V8QI "V8HI") (V4HI "V4SI")])
-
-@@ -174,20 +181,25 @@ (define_mode_attr Yv_Yw
-
- (define_expand "mov<mode>"
- [(set (match_operand:MMXMODE 0 "nonimmediate_operand")
-- (match_operand:MMXMODE 1 "nonimm_or_0_operand"))]
-+ (match_operand:MMXMODE 1 "nonimmediate_or_sse_const_operand"))]
- "TARGET_MMX || TARGET_MMX_WITH_SSE"
- {
- ix86_expand_vector_move (<MODE>mode, operands);
- DONE;
- })
-
-+;; There must no CONSTM1_RTX vector loads after reload.
- (define_insn "*mov<mode>_internal"
- [(set (match_operand:MMXMODE 0 "nonimmediate_operand"
-- "=r ,o ,r,r ,m ,?!y,!y,?!y,m ,r ,?!y,v,v,v,m,r,v,!y,*x")
-- (match_operand:MMXMODE 1 "nonimm_or_0_operand"
-- "rCo,rC,C,rm,rC,C ,!y,m ,?!y,?!y,r ,C,v,m,v,v,r,*x,!y"))]
-+ "=r ,o ,r,r ,m ,m ,?!y,!y,?!y,m ,r ,?!y,v,v ,v,v,m,r,v,!y,*x")
-+ (match_operand:MMXMODE 1 "nonimmediate_or_sse_const_operand"
-+ "rCo,rBZ,C,rm,rBZ,<mmxconstm1>,C ,!y,m ,?!y,?!y,r ,C,<mmxconstm1>,v,m,v,v,r,*x,!y"))]
- "(TARGET_MMX || TARGET_MMX_WITH_SSE)
- && !(MEM_P (operands[0]) && MEM_P (operands[1]))
-+ && (!reload_completed
-+ || !(SSE_REG_P (operands[0])
-+ && int_float_vector_all_ones_operand (operands[1],
-+ <MODE>mode)))
- && ix86_hardreg_mov_ok (operands[0], operands[1])"
- {
- switch (get_attr_type (insn))
-@@ -230,31 +242,31 @@ (define_insn "*mov<mode>_internal"
- [(set (attr "isa")
- (cond [(eq_attr "alternative" "0,1")
- (const_string "nox64")
-- (eq_attr "alternative" "2,3,4,9,10")
-+ (eq_attr "alternative" "2,3,4,10,11")
- (const_string "x64")
-- (eq_attr "alternative" "15,16")
-+ (eq_attr "alternative" "5,17,18")
- (const_string "x64_sse2")
-- (eq_attr "alternative" "17,18")
-+ (eq_attr "alternative" "13,19,20")
- (const_string "sse2")
- ]
- (const_string "*")))
- (set (attr "type")
- (cond [(eq_attr "alternative" "0,1")
- (const_string "multi")
-- (eq_attr "alternative" "2,3,4")
-+ (eq_attr "alternative" "2,3,4,5")
- (const_string "imov")
-- (eq_attr "alternative" "5")
-+ (eq_attr "alternative" "6")
- (const_string "mmx")
-- (eq_attr "alternative" "6,7,8,9,10")
-+ (eq_attr "alternative" "7,8,9,10,11")
- (const_string "mmxmov")
-- (eq_attr "alternative" "11")
-+ (eq_attr "alternative" "12,13")
- (const_string "sselog1")
-- (eq_attr "alternative" "17,18")
-+ (eq_attr "alternative" "19,20")
- (const_string "ssecvt")
- ]
- (const_string "ssemov")))
- (set (attr "prefix_rex")
-- (if_then_else (eq_attr "alternative" "9,10,15,16")
-+ (if_then_else (eq_attr "alternative" "10,11,17,18")
- (const_string "1")
- (const_string "*")))
- (set (attr "prefix")
-@@ -269,7 +281,7 @@ (define_insn "*mov<mode>_internal"
- (set (attr "mode")
- (cond [(eq_attr "alternative" "2")
- (const_string "SI")
-- (eq_attr "alternative" "11,12")
-+ (eq_attr "alternative" "12,13,14")
- (cond [(match_test "<MODE>mode == V2SFmode
- || <MODE>mode == V4HFmode
- || <MODE>mode == V4BFmode")
-@@ -280,7 +292,7 @@ (define_insn "*mov<mode>_internal"
- ]
- (const_string "TI"))
-
-- (and (eq_attr "alternative" "13")
-+ (and (eq_attr "alternative" "15")
- (ior (ior (and (match_test "<MODE>mode == V2SFmode")
- (not (match_test "TARGET_MMX_WITH_SSE")))
- (not (match_test "TARGET_SSE2")))
-@@ -288,7 +300,7 @@ (define_insn "*mov<mode>_internal"
- || <MODE>mode == V4BFmode")))
- (const_string "V2SF")
-
-- (and (eq_attr "alternative" "14")
-+ (and (eq_attr "alternative" "16")
- (ior (ior (match_test "<MODE>mode == V2SFmode")
- (not (match_test "TARGET_SSE2")))
- (match_test "<MODE>mode == V4HFmode
-@@ -297,13 +309,49 @@ (define_insn "*mov<mode>_internal"
- ]
- (const_string "DI")))
- (set (attr "preferred_for_speed")
-- (cond [(eq_attr "alternative" "9,15")
-+ (cond [(eq_attr "alternative" "10,17")
- (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
-- (eq_attr "alternative" "10,16")
-+ (eq_attr "alternative" "11,18")
- (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
- ]
- (symbol_ref "true")))])
-
-+;; Split
-+;;
-+;; (set (reg:V8QI 100)
-+;; (const_vector:V8QI [
-+;; (const_int -1 [0xffffffffffffffff]) repeated x8]))
-+;;
-+;; by loading from memory if it hasn't been eliminated to make top bits
-+;; cleared in vector register. For 32-bit PIC, we also must split
-+;;
-+;; (set (mem/c:V8QI (reg/f:SI 99)
-+;; (const_vector:V8QI [
-+;; (const_int -1 [0xffffffffffffffff]) repeated x8]))
-+;;
-+;; before reload since 32-bit doesn't support 8-byte immediate store and
-+;; PIC register can't be allocated after reload.
-+(define_split
-+ [(set (match_operand:MMXMODE 0 "nonimmediate_operand")
-+ (match_operand:MMXMODE 1 "int_float_vector_all_ones_operand"))]
-+ "TARGET_SSE
-+ && (SSE_REG_P (operands[0])
-+ || (!reload_completed && flag_pic && !TARGET_64BIT))"
-+ [(const_int 0)]
-+{
-+ operands[1] = validize_mem (force_const_mem (<MODE>mode,
-+ operands[1]));
-+ rtx src;
-+ if (REG_P (operands[0]))
-+ src = operands[1];
-+ else
-+ {
-+ src = gen_reg_rtx (<MODE>mode);
-+ emit_move_insn (src, operands[1]);
-+ }
-+ emit_move_insn (operands[0], src);
-+})
-+
- (define_split
- [(set (match_operand:MMXMODE 0 "nonimmediate_gr_operand")
- (match_operand:MMXMODE 1 "nonimmediate_gr_operand"))]
-@@ -329,19 +377,24 @@ (define_expand "movmisalign<mode>"
-
- (define_expand "mov<mode>"
- [(set (match_operand:V_32 0 "nonimmediate_operand")
-- (match_operand:V_32 1 "nonimm_or_0_operand"))]
-+ (match_operand:V_32 1 "nonimmediate_or_sse_const_operand"))]
- ""
- {
- ix86_expand_vector_move (<MODE>mode, operands);
- DONE;
- })
-
-+;; There must no CONSTM1_RTX vector loads after reload.
- (define_insn "*mov<mode>_internal"
- [(set (match_operand:V_32 0 "nonimmediate_operand"
-- "=r ,m ,v,v,v,m,r,v")
-- (match_operand:V_32 1 "nonimm_or_0_operand"
-- "rmC,rC,C,v,m,v,v,r"))]
-+ "=r ,m ,rm ,v,v ,v,v,m,r,v")
-+ (match_operand:V_32 1 "nonimmediate_or_sse_const_operand"
-+ "rmC,rC,<mmxconstm1>,C,<mmxconstm1>,v,m,v,v,r"))]
- "!(MEM_P (operands[0]) && MEM_P (operands[1]))
-+ && (!reload_completed
-+ || !(SSE_REG_P (operands[0])
-+ && int_float_vector_all_ones_operand (operands[1],
-+ <MODE>mode)))
- && ix86_hardreg_mov_ok (operands[0], operands[1])"
- {
- switch (get_attr_type (insn))
-@@ -360,14 +413,14 @@ (define_insn "*mov<mode>_internal"
- }
- }
- [(set (attr "isa")
-- (cond [(eq_attr "alternative" "6,7")
-+ (cond [(eq_attr "alternative" "2,4,8,9")
- (const_string "sse2")
- ]
- (const_string "*")))
- (set (attr "type")
-- (cond [(eq_attr "alternative" "2")
-+ (cond [(eq_attr "alternative" "3,4")
- (const_string "sselog1")
-- (eq_attr "alternative" "3,4,5,6,7")
-+ (eq_attr "alternative" "5,6,7,8,9")
- (const_string "ssemov")
- ]
- (const_string "imov")))
-@@ -380,7 +433,7 @@ (define_insn "*mov<mode>_internal"
- (const_string "1")
- (const_string "*")))
- (set (attr "mode")
-- (cond [(eq_attr "alternative" "2,3")
-+ (cond [(eq_attr "alternative" "3,4,5")
- (cond [(match_test "<MODE>mode == V2HFmode
- || <MODE>mode == V2BFmode")
- (const_string "V4SF")
-@@ -392,7 +445,7 @@ (define_insn "*mov<mode>_internal"
- ]
- (const_string "TI"))
-
-- (and (eq_attr "alternative" "4,5")
-+ (and (eq_attr "alternative" "6,7")
- (ior (match_test "<MODE>mode == V2HFmode
- || <MODE>mode == V2BFmode")
- (not (match_test "TARGET_SSE2"))))
-@@ -400,13 +453,32 @@ (define_insn "*mov<mode>_internal"
- ]
- (const_string "SI")))
- (set (attr "preferred_for_speed")
-- (cond [(eq_attr "alternative" "6")
-+ (cond [(eq_attr "alternative" "8")
- (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
-- (eq_attr "alternative" "7")
-+ (eq_attr "alternative" "9")
- (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
- ]
- (symbol_ref "true")))])
-
-+;; Split
-+;;
-+;; (set (reg:V4QI 100)
-+;; (const_vector:V4QI [
-+;; (const_int -1 [0xffffffffffffffff]) repeated x4]))
-+;;
-+;; by loading from memory if it hasn't been eliminated to make top bits
-+;; cleared in vector register.
-+(define_split
-+ [(set (match_operand:V_32 0 "register_operand")
-+ (match_operand:V_32 1 "int_float_vector_all_ones_operand"))]
-+ "TARGET_SSE && SSE_REG_P (operands[0])"
-+ [(const_int 0)]
-+{
-+ operands[1] = validize_mem (force_const_mem (<MODE>mode,
-+ operands[1]));
-+ emit_move_insn (operands[0], operands[1]);
-+})
-+
- ;; 16-bit, 32-bit and 64-bit constant vector stores. After reload,
- ;; convert them to immediate integer stores.
- (define_insn_and_split "*mov<mode>_imm"
-diff --git a/gcc/testsuite/gcc.target/i386/pr117839-1b.c b/gcc/testsuite/gcc.target/i386/pr117839-1b.c
-index e71b991a2073..6b181f35dff9 100644
---- a/gcc/testsuite/gcc.target/i386/pr117839-1b.c
-+++ b/gcc/testsuite/gcc.target/i386/pr117839-1b.c
-@@ -1,5 +1,8 @@
- /* { dg-do compile } */
- /* { dg-options "-O2 -march=x86-64-v3" } */
--/* { dg-final { scan-assembler-times "xor\[a-z\]*\[\t \]*%xmm\[0-9\]\+,\[^,\]*" 1 } } */
-+/* { dg-final { scan-assembler-times "xor\[\t \]+%xmm\[0-9\]+, \[^,\]+" 1 { target { ! ia32 } } } } */
-+/* { dg-final { scan-assembler-times "xor\[\t \]+%xmm\[0-9\]+, \[^,\]+" 2 { target ia32 } } } */
-+/* { dg-final { scan-assembler-times "movl\[\t \]+\\\$0, " 3 { target ia32 } } } */
-+/* { dg-final { scan-assembler-times "movq\[\t \]+%xmm\[0-9\]+, \[^,\]+" 1 { target ia32 } } } */
-
- #include "pr117839-1a.c"
-diff --git a/gcc/testsuite/gcc.target/i386/pr117839-2.c b/gcc/testsuite/gcc.target/i386/pr117839-2.c
-index c76744cf98b8..b00d8eaec5c2 100644
---- a/gcc/testsuite/gcc.target/i386/pr117839-2.c
-+++ b/gcc/testsuite/gcc.target/i386/pr117839-2.c
-@@ -1,6 +1,9 @@
- /* { dg-do compile } */
- /* { dg-options "-O2 -march=x86-64-v3" } */
--/* { dg-final { scan-assembler-times "xor\[a-z\]*\[\t \]*%xmm\[0-9\]\+,\[^,\]*" 1 } } */
-+/* { dg-final { scan-assembler-times "xor\[\t \]+%xmm\[0-9\]+, \[^,\]+" 1 { target { ! ia32 } } } } */
-+/* { dg-final { scan-assembler-times "xor\[\t \]+%xmm\[0-9\]+, \[^,\]+" 3 { target ia32 } } } */
-+/* { dg-final { scan-assembler-times "movl\[\t \]+\\\$0, " 1 { target ia32 } } } */
-+/* { dg-final { scan-assembler-times "movq\[\t \]+%xmm\[0-9\]+, \[^,\]+" 2 { target ia32 } } } */
-
- #include <stddef.h>
-
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-1.c b/gcc/testsuite/gcc.target/i386/pr121015-1.c
-new file mode 100644
-index 000000000000..fefa5185be4d
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-1.c
-@@ -0,0 +1,34 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -march=x86-64-v3" } */
-+/* { dg-final { scan-assembler-not "\tmovl\[\\t \]+\\\$-1, %" { target { ! ia32 } } } } */
-+/* { dg-final { scan-assembler "\tmovq\[\\t \]+\\\$-1, " { target { ! ia32 } } } } */
-+
-+extern union {
-+ int i;
-+ float f;
-+} int_as_float_u;
-+
-+extern int render_result_from_bake_w;
-+extern int render_result_from_bake_h_seed_pass;
-+extern float *render_result_from_bake_h_primitive;
-+extern float *render_result_from_bake_h_seed;
-+
-+float
-+int_as_float(int i)
-+{
-+ int_as_float_u.i = i;
-+ return int_as_float_u.f;
-+}
-+
-+void
-+render_result_from_bake_h(int tx)
-+{
-+ while (render_result_from_bake_w) {
-+ for (; tx < render_result_from_bake_w; tx++)
-+ render_result_from_bake_h_primitive[1] =
-+ render_result_from_bake_h_primitive[2] = int_as_float(-1);
-+ if (render_result_from_bake_h_seed_pass) {
-+ *render_result_from_bake_h_seed = 0;
-+ }
-+ }
-+}
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-10a.c b/gcc/testsuite/gcc.target/i386/pr121015-10a.c
-new file mode 100644
-index 000000000000..67b574cc8374
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-10a.c
-@@ -0,0 +1,32 @@
-+/* { dg-do compile { target fpic } } */
-+/* { dg-options "-O2 -march=x86-64 -fpic" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
-+
-+/*
-+**__bid64_to_binary80:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+** mov(l|q) __bid64_to_binary80_x_out@GOTPCREL\(%rip\), %(r|e)ax
-+** movq \$-1, \(%(r|e)ax\)
-+** ret
-+**...
-+*/
-+
-+typedef struct {
-+ struct {
-+ unsigned short lo4;
-+ unsigned short lo3;
-+ unsigned short lo2;
-+ unsigned short lo1;
-+ } i;
-+} BID_BINARY80LDOUBLE;
-+extern BID_BINARY80LDOUBLE __bid64_to_binary80_x_out;
-+void
-+__bid64_to_binary80 (void)
-+{
-+ __bid64_to_binary80_x_out.i.lo4
-+ = __bid64_to_binary80_x_out.i.lo3
-+ = __bid64_to_binary80_x_out.i.lo2
-+ = __bid64_to_binary80_x_out.i.lo1 = 65535;
-+}
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-10b.c b/gcc/testsuite/gcc.target/i386/pr121015-10b.c
-new file mode 100644
-index 000000000000..06cb58f702d3
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-10b.c
-@@ -0,0 +1,16 @@
-+/* { dg-do compile { target { fpic && lp64 } } } */
-+/* { dg-options "-O2 -march=x86-64 -fno-pic -mcmodel=large" } */
-+
-+/*
-+**__bid64_to_binary80:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+** movabsq \$.LC0, %rax
-+** movq \(%rax\), %rdx
-+** movabsq \$__bid64_to_binary80_x_out, %rax
-+** movq %rdx, \(%rax\)
-+** ret
-+**...
-+*/
-+
-+#include "pr121015-10a.c"
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-10c.c b/gcc/testsuite/gcc.target/i386/pr121015-10c.c
-new file mode 100644
-index 000000000000..573a15628830
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-10c.c
-@@ -0,0 +1,21 @@
-+/* { dg-do compile { target { fpic && lp64 } } } */
-+/* { dg-options "-O2 -march=x86-64 -fpic -mcmodel=large" } */
-+
-+/*
-+**__bid64_to_binary80:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+**.L2:
-+** leaq .L2\(%rip\), %rax
-+** movabsq \$_GLOBAL_OFFSET_TABLE_-.L2, %r11
-+** movabsq \$__bid64_to_binary80_x_out@GOT, %rdx
-+** movabsq \$.LC0@GOTOFF, %rcx
-+** addq %r11, %rax
-+** movq \(%rax,%rdx\), %rdx
-+** movq \(%rax,%rcx\), %rax
-+** movq %rax, \(%rdx\)
-+** ret
-+**...
-+*/
-+
-+#include "pr121015-10a.c"
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-11a.c b/gcc/testsuite/gcc.target/i386/pr121015-11a.c
-new file mode 100644
-index 000000000000..5aafb2806b12
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-11a.c
-@@ -0,0 +1,21 @@
-+/* { dg-do compile { target fpic } } */
-+/* { dg-options "-O2 -march=x86-64 -fpic" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
-+
-+/*
-+**foo:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+** movd .LC0\(%rip\), %xmm0
-+**...
-+*/
-+
-+typedef char __v4qi __attribute__ ((__vector_size__ (4)));
-+
-+void
-+foo (void)
-+{
-+ register __v4qi x asm ("xmm0") = __extension__(__v4qi){-1, -1, -1, -1};
-+ asm ("reg %0" : : "v" (x));
-+}
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-11b.c b/gcc/testsuite/gcc.target/i386/pr121015-11b.c
-new file mode 100644
-index 000000000000..9ff2908829b6
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-11b.c
-@@ -0,0 +1,13 @@
-+/* { dg-do compile { target { fpic && lp64 } } } */
-+/* { dg-options "-O2 -march=x86-64 -fno-pic -mcmodel=large" } */
-+
-+/*
-+**foo:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+** movabsq \$.LC0, %rax
-+** movd \(%rax\), %xmm0
-+**...
-+*/
-+
-+#include "pr121015-11a.c"
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-11c.c b/gcc/testsuite/gcc.target/i386/pr121015-11c.c
-new file mode 100644
-index 000000000000..f0e6ccb2b92f
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-11c.c
-@@ -0,0 +1,17 @@
-+/* { dg-do compile { target { fpic && lp64 } } } */
-+/* { dg-options "-O2 -march=x86-64 -fpic -mcmodel=large" } */
-+
-+/*
-+**foo:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+**.L2:
-+** movabsq \$_GLOBAL_OFFSET_TABLE_-.L2, %r11
-+** leaq .L2\(%rip\), %rax
-+** movabsq \$.LC0@GOTOFF, %rdx
-+** addq %r11, %rax
-+** movd \(%rax,%rdx\), %xmm0
-+**...
-+*/
-+
-+#include "pr121015-11a.c"
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-2a.c b/gcc/testsuite/gcc.target/i386/pr121015-2a.c
-new file mode 100644
-index 000000000000..e8840b0ffd6d
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-2a.c
-@@ -0,0 +1,24 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -march=x86-64" } */
-+
-+void
-+foo (int *c1, int *c2)
-+{
-+ if (c1)
-+ {
-+ c1 = __builtin_assume_aligned (c1, 16);
-+ c1[0] = 0;
-+ c1[1] = 0;
-+ }
-+ if (c2)
-+ {
-+ c2 = __builtin_assume_aligned (c2, 16);
-+ c2[0] = 0;
-+ c2[1] = 0;
-+ }
-+}
-+
-+/* { dg-final { scan-assembler-times "pxor\[ \\t\]+\[^\n\]*%xmm" 2 { target ia32 } } } */
-+/* { dg-final { scan-assembler-times "movq\[ \\t\]+\[^\n\]*%xmm" 2 { target ia32 } } } */
-+/* { dg-final { scan-assembler-times "movq\[ \\t\]+\\\$0," 2 { target { ! ia32 } } } } */
-+/* { dg-final { scan-assembler-not "xmm" { target { ! ia32 } } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-2b.c b/gcc/testsuite/gcc.target/i386/pr121015-2b.c
-new file mode 100644
-index 000000000000..9df2766c6120
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-2b.c
-@@ -0,0 +1,6 @@
-+/* { dg-do compile { target ia32 } } */
-+/* { dg-options "-O2 -mno-sse" } */
-+
-+#include "pr121015-2a.c"
-+
-+/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$0," 4 } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-3.c b/gcc/testsuite/gcc.target/i386/pr121015-3.c
-new file mode 100644
-index 000000000000..44bf63c73e69
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-3.c
-@@ -0,0 +1,35 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -march=x86-64" } */
-+
-+typedef enum { CPP_NUMBER } cpp_ttype;
-+typedef struct {
-+ bool unsignedp;
-+ bool overflow;
-+} cpp_num;
-+extern cpp_num value, __trans_tmp_1;
-+extern cpp_ttype eval_token_token_0;
-+extern int eval_token_temp;
-+static cpp_num
-+eval_token(void)
-+{
-+ cpp_num __trans_tmp_2, result;
-+ result.overflow = false;
-+ switch (eval_token_token_0)
-+ {
-+ case CPP_NUMBER:
-+ switch (eval_token_temp)
-+ {
-+ case 1:
-+ return __trans_tmp_1;
-+ }
-+ result.unsignedp = false;
-+ __trans_tmp_2 = result;
-+ return __trans_tmp_2;
-+ }
-+ return result;
-+}
-+void
-+_cpp_parse_expr_pfile(void)
-+{
-+ value = eval_token();
-+}
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-4.c b/gcc/testsuite/gcc.target/i386/pr121015-4.c
-new file mode 100644
-index 000000000000..2848a946dd16
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-4.c
-@@ -0,0 +1,22 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -march=x86-64" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
-+
-+/*
-+**zero:
-+**.LFB0:
-+** .cfi_startproc
-+** xorps %xmm0, %xmm0
-+** ret
-+**...
-+*/
-+
-+typedef float __v2sf __attribute__ ((__vector_size__ (8)));
-+extern __v2sf f1;
-+
-+__v2sf
-+zero (void)
-+{
-+ return __extension__(__v2sf){0, 0};
-+}
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-5a.c b/gcc/testsuite/gcc.target/i386/pr121015-5a.c
-new file mode 100644
-index 000000000000..605a87db1fc4
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-5a.c
-@@ -0,0 +1,21 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -march=x86-64" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
-+
-+/*
-+**m1:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+** movq .LC[0-9]+\(%rip\), %xmm0
-+** ret
-+**...
-+*/
-+
-+typedef char __v8qi __attribute__ ((__vector_size__ (8)));
-+
-+__v8qi
-+m1 (void)
-+{
-+ return __extension__(__v8qi){-1, -1, -1, -1, -1, -1, -1, -1};
-+}
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-5b.c b/gcc/testsuite/gcc.target/i386/pr121015-5b.c
-new file mode 100644
-index 000000000000..22d51fd33efd
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-5b.c
-@@ -0,0 +1,16 @@
-+/* { dg-do compile { target { fpic && lp64 } } } */
-+/* { dg-options "-O2 -march=x86-64 -fno-pic -mcmodel=large" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
-+
-+/*
-+**m1:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+** movabsq \$.LC0, %rax
-+** movq \(%rax\), %xmm0
-+** ret
-+**...
-+*/
-+
-+#include "pr121015-5a.c"
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-5c.c b/gcc/testsuite/gcc.target/i386/pr121015-5c.c
-new file mode 100644
-index 000000000000..bb210fa71ff5
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-5c.c
-@@ -0,0 +1,20 @@
-+/* { dg-do compile { target { fpic && lp64 } } } */
-+/* { dg-options "-O2 -march=x86-64 -fpic -mcmodel=large" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
-+
-+/*
-+**m1:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+**.L2:
-+** movabsq \$_GLOBAL_OFFSET_TABLE_-.L2, %r11
-+** leaq .L2\(%rip\), %rax
-+** movabsq \$.LC0@GOTOFF, %rdx
-+** addq %r11, %rax
-+** movq \(%rax,%rdx\), %xmm0
-+** ret
-+**...
-+*/
-+
-+#include "pr121015-5a.c"
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-6.c b/gcc/testsuite/gcc.target/i386/pr121015-6.c
-new file mode 100644
-index 000000000000..daebcb0acc51
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-6.c
-@@ -0,0 +1,23 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -march=x86-64" } */
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
-+
-+/*
-+**m1:
-+**.LFB[0-9]+:
-+** .cfi_startproc
-+** pcmpeqd %xmm0, %xmm0
-+** ret
-+**...
-+*/
-+
-+#include <x86intrin.h>
-+
-+__m128i
-+m1 (void)
-+{
-+ __m64 x = _mm_set1_pi8 (-1);
-+ __m128i y = _mm_set1_epi64 (x);
-+ return y;
-+}
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-7a.c b/gcc/testsuite/gcc.target/i386/pr121015-7a.c
-new file mode 100644
-index 000000000000..94037e33d811
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-7a.c
-@@ -0,0 +1,23 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -march=x86-64" } */
-+
-+void
-+foo (int *c1, int *c2)
-+{
-+ if (c1)
-+ {
-+ c1 = __builtin_assume_aligned (c1, 16);
-+ c1[0] = -1;
-+ c1[1] = -1;
-+ }
-+ if (c2)
-+ {
-+ c2 = __builtin_assume_aligned (c2, 16);
-+ c2[0] = -1;
-+ c2[1] = -1;
-+ }
-+}
-+
-+/* { dg-final { scan-assembler-times "movq\[ \\t\]+\[^\n\]*%xmm" 4 { target ia32 } } } */
-+/* { dg-final { scan-assembler-times "movq\[ \\t\]+\\\$-1," 2 { target { ! ia32 } } } } */
-+/* { dg-final { scan-assembler-not "xmm" { target { ! ia32 } } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-7b.c b/gcc/testsuite/gcc.target/i386/pr121015-7b.c
-new file mode 100644
-index 000000000000..3784ce0dfeda
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-7b.c
-@@ -0,0 +1,6 @@
-+/* { dg-do compile { target ia32 } } */
-+/* { dg-options "-O2 -mno-sse" } */
-+
-+#include "pr121015-7a.c"
-+
-+/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$-1," 4 } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-7c.c b/gcc/testsuite/gcc.target/i386/pr121015-7c.c
-new file mode 100644
-index 000000000000..33b2df3ac9ec
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-7c.c
-@@ -0,0 +1,8 @@
-+/* { dg-do compile { target fpic } } */
-+/* { dg-options "-O2 -march=x86-64 -fpic" } */
-+
-+#include "pr121015-7a.c"
-+
-+/* { dg-final { scan-assembler-times "movq\[ \\t\]+\[^\n\]*%xmm" 4 { target ia32 } } } */
-+/* { dg-final { scan-assembler-times "movq\[ \\t\]+\\\$-1," 2 { target { ! ia32 } } } } */
-+/* { dg-final { scan-assembler-not "xmm" { target { ! ia32 } } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-8.c b/gcc/testsuite/gcc.target/i386/pr121015-8.c
-new file mode 100644
-index 000000000000..de2db2a2b0de
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-8.c
-@@ -0,0 +1,14 @@
-+/* { dg-do compile } */
-+/* { dg-options "-Og -fno-dce -mtune=generic" } */
-+
-+typedef int __attribute__((__vector_size__ (4))) S;
-+extern int bar (S);
-+
-+int
-+foo ()
-+{
-+ return bar ((S){-1});
-+}
-+
-+/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$-1, \\(%esp\\)" 1 { target ia32 } } } */
-+/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$-1, %edi" 1 { target { ! ia32 } } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015-9.c b/gcc/testsuite/gcc.target/i386/pr121015-9.c
-new file mode 100644
-index 000000000000..05c2021ba057
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015-9.c
-@@ -0,0 +1,14 @@
-+/* { dg-do compile } */
-+/* { dg-options "-Og -fno-dce -mtune=generic" } */
-+
-+typedef int __attribute__((__vector_size__ (4))) S;
-+extern int bar (S);
-+
-+int
-+foo ()
-+{
-+ return bar ((S){0});
-+}
-+
-+/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$0, \\(%esp\\)" 1 { target ia32 } } } */
-+/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$0, %edi" 1 { target { ! ia32 } } } } */
-
-base-commit: db3afff48fc7ed896b3dd17eb93f0cfe3cc41da8
---
-2.50.1
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 0830184..9fba669 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,5 @@
7 ????
- + 87_all_PR121015-blender.patch
+ 88_all_PR120870-tuning.patch
6 14 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-14 2:55 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-14 2:55 UTC (permalink / raw
To: gentoo-commits
commit: cf360ccd6d035d08ea7e495e5fed75666d96c5a3
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 14 02:54:46 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 14 02:54:46 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=cf360ccd
16.0.0: add tuning patch from H.J. for CPython issue
Bug: https://gcc.gnu.org/PR120870
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/88_all_PR120870-tuning.patch | 12 ++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 13 insertions(+)
diff --git a/16.0.0/gentoo/88_all_PR120870-tuning.patch b/16.0.0/gentoo/88_all_PR120870-tuning.patch
new file mode 100644
index 0000000..9f166af
--- /dev/null
+++ b/16.0.0/gentoo/88_all_PR120870-tuning.patch
@@ -0,0 +1,12 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120870#c17
+--- a/gcc/config/i386/x86-tune-costs.h
++++ b/gcc/config/i386/x86-tune-costs.h
+@@ -1774,7 +1774,7 @@ struct processor_costs znver2_cost = {
+ Relative to reg-reg move (2). */
+ {8, 8, 8}, /* cost of storing integer
+ registers. */
+- {6, 6, 6, 6, 12}, /* cost of loading SSE registers
++ {4, 3, 12, 12, 24}, /* cost of loading SSE register
+ in 32bit, 64bit, 128bit, 256bit and 512bit */
+ {8, 8, 8, 8, 16}, /* cost of storing SSE register
+ in 32bit, 64bit, 128bit, 256bit and 512bit */
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index c8496a3..0830184 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,7 @@
7 ????
+ 87_all_PR121015-blender.patch
+ + 88_all_PR120870-tuning.patch
6 14 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-14 2:55 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-14 2:55 UTC (permalink / raw
To: gentoo-commits
commit: 2756d2184952f993a4abc7de24cae716175916c0
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 14 02:54:15 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 14 02:54:15 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=2756d218
16.0.0: rename Blender patch
We already have a 86*.
Signed-off-by: Sam James <sam <AT> gentoo.org>
.../{86_all_PR121015-blender.patch => 87_all_PR121015-blender.patch} | 0
16.0.0/gentoo/README.history | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/86_all_PR121015-blender.patch b/16.0.0/gentoo/87_all_PR121015-blender.patch
similarity index 100%
rename from 16.0.0/gentoo/86_all_PR121015-blender.patch
rename to 16.0.0/gentoo/87_all_PR121015-blender.patch
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index e6bfa85..c8496a3 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,6 @@
7 ????
- + 86_all_PR121015-blender.patch
+ + 87_all_PR121015-blender.patch
6 14 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-14 2:40 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-14 2:40 UTC (permalink / raw
To: gentoo-commits
commit: 7da6fc44822ed4cce6b19b2943258b55c2a5537b
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 14 02:40:05 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 14 02:40:36 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=7da6fc44
16.0.0: add 86_all_PR121015-blender.patch again (new version)
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/86_all_PR121015-blender.patch | 1042 +++++++++++++++++++++++++++
16.0.0/gentoo/README.history | 4 +
2 files changed, 1046 insertions(+)
diff --git a/16.0.0/gentoo/86_all_PR121015-blender.patch b/16.0.0/gentoo/86_all_PR121015-blender.patch
new file mode 100644
index 0000000..3eaec37
--- /dev/null
+++ b/16.0.0/gentoo/86_all_PR121015-blender.patch
@@ -0,0 +1,1042 @@
+https://inbox.sourceware.org/gcc-patches/CAMe9rOp5dSWgFmZ=Ps8R9M0OkRFTXZtCHnHQL0AqBk+ddNQw5A@mail.gmail.com/
+
+From 393baf5d3fd2408a0be029c09ab2e18219867087 Mon Sep 17 00:00:00 2001
+Message-ID: <393baf5d3fd2408a0be029c09ab2e18219867087.1752460761.git.sam@gentoo.org>
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Sun, 13 Jul 2025 08:59:34 +0800
+Subject: [PATCH] x86: Update MMX moves to support all 1s vectors
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+commit 77473a27bae04da99d6979d43e7bd0a8106f4557
+Author: H.J. Lu <hjl.tools@gmail.com>
+Date: Thu Jun 26 06:08:51 2025 +0800
+
+ x86: Also handle all 1s float vector constant
+
+replaces
+
+(insn 29 28 30 5 (set (reg:V2SF 107)
+ (mem/u/c:V2SF (symbol_ref/u:DI ("*.LC0") [flags 0x2]) [0 S8 A64])) 2031 {*movv2sf_internal}
+ (expr_list:REG_EQUAL (const_vector:V2SF [
+ (const_double:SF -QNaN [-QNaN]) repeated x2
+ ])
+ (nil)))
+
+with
+
+(insn 98 13 14 3 (set (reg:V8QI 112)
+ (const_vector:V8QI [
+ (const_int -1 [0xffffffffffffffff]) repeated x8
+ ])) -1
+ (nil))
+...
+(insn 29 28 30 5 (set (reg:V2SF 107)
+ (subreg:V2SF (reg:V8QI 112) 0)) 2031 {*movv2sf_internal}
+ (expr_list:REG_EQUAL (const_vector:V2SF [
+ (const_double:SF -QNaN [-QNaN]) repeated x2
+ ])
+ (nil)))
+
+which leads to
+
+pr121015.c: In function ‘render_result_from_bake_h’:
+pr121015.c:34:1: error: unrecognizable insn:
+ 34 | }
+ | ^
+(insn 98 13 14 3 (set (reg:V8QI 112)
+ (const_vector:V8QI [
+ (const_int -1 [0xffffffffffffffff]) repeated x8
+ ])) -1
+ (expr_list:REG_EQUIV (const_vector:V8QI [
+ (const_int -1 [0xffffffffffffffff]) repeated x8
+ ])
+ (nil)))
+during RTL pass: ira
+
+1. Add BZ constraint for constant 0 in 64-bit or without SSE to replace
+C constraint in 8-byte MMX zeroing stores so that we can generate
+
+ pxor %xmm0, %xmm0
+ movq %xmm0, (%edx)
+
+with SSE in 32-bit.
+2. Extend standard_sse_constant_p to cover 4-byte and 8-byte all 1s to
+support
+
+(set (reg:V8QI 100)
+ (const_vector:V8QI [
+ (const_int -1 [0xffffffffffffffff]) repeated x8]))
+
+and
+
+(set (mem/c:V4QI (reg/f:SI 99)
+ (const_vector:V4QI [
+ (const_int -1 [0xffffffffffffffff]) repeated x4]))
+
+3. Update 4-byte and 8-byte MMX moves to support constant all 1s vectors.
+4. Split 4-byte and 8-byte MMX CONSTM1 moves by loading from memory if
+they haven't been eliminated.
+
+gcc/
+
+ PR target/121015
+ * config/i386/constraints.md (BZ): New constraint.
+ * config/i386/i386.cc (standard_sse_constant_p): Support 4-byte
+ and 8-byte all 1s.
+ (ix86_print_operand): Support CONSTM1_RTX.
+ * config/i386/mmx.md (mmxconstm1): New.
+ (MMXMODE:mov<mode>): Replace nonimm_or_0_operand with
+ nonimmediate_or_sse_const_operand.
+ (MMXMODE:*mov<mode>_internal): Replace C with BZ in zeroing
+ stores. Add <m,<<mmxconstm1>> and <v,<mmxconstm1>> alternatives.
+ Add a MMXMODE splitter to split CONSTM1_RTX moves.
+ (V_32:mov<mode>): Replace nonimm_or_0_operand with
+ nonimmediate_or_sse_const_operand.
+ (V_32:*mov<mode>_internal): Add <rm,<<mmxconstm1>> and
+ <v,<mmxconstm1>> alternatives.
+ Add a V_32 splitter to split CONSTM1_RTX stores.
+
+gcc/testsuite/
+
+ PR target/121015
+ * gcc.target/i386/pr117839-1b.c: Updated assembler scan for 8-byte
+ zeroing store with XMM register in 32-bit.
+ * gcc.target/i386/pr117839-2.c: Likewise.
+ * gcc.target/i386/pr121015-1.c: New test.
+ * gcc.target/i386/pr121015-2a.c: Likewise.
+ * gcc.target/i386/pr121015-2b.c: Likewise.
+ * gcc.target/i386/pr121015-3.c: Likewise.
+ * gcc.target/i386/pr121015-4.c: Likewise.
+ * gcc.target/i386/pr121015-5a.c: Likewise.
+ * gcc.target/i386/pr121015-5b.c: Likewise.
+ * gcc.target/i386/pr121015-5c.c: Likewise.
+ * gcc.target/i386/pr121015-6.c: Likewise.
+ * gcc.target/i386/pr121015-7a.c: Likewise.
+ * gcc.target/i386/pr121015-7b.c: Likewise.
+ * gcc.target/i386/pr121015-7c.c: Likewise.
+ * gcc.target/i386/pr121015-8.c: Likewise.
+ * gcc.target/i386/pr121015-9.c: Likewise.
+ * gcc.target/i386/pr121015-10a.c: Likewise.
+ * gcc.target/i386/pr121015-10b.c: Likewise.
+ * gcc.target/i386/pr121015-10c.c: Likewise.
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+Co-Authored-By: Uros Bizjak <ubizjak@gmail.com>
+---
+ gcc/config/i386/constraints.md | 7 +
+ gcc/config/i386/i386.cc | 13 +-
+ gcc/config/i386/mmx.md | 130 ++++++++++++++-----
+ gcc/testsuite/gcc.target/i386/pr117839-1b.c | 5 +-
+ gcc/testsuite/gcc.target/i386/pr117839-2.c | 5 +-
+ gcc/testsuite/gcc.target/i386/pr121015-1.c | 34 +++++
+ gcc/testsuite/gcc.target/i386/pr121015-10a.c | 32 +++++
+ gcc/testsuite/gcc.target/i386/pr121015-10b.c | 16 +++
+ gcc/testsuite/gcc.target/i386/pr121015-10c.c | 21 +++
+ gcc/testsuite/gcc.target/i386/pr121015-11a.c | 21 +++
+ gcc/testsuite/gcc.target/i386/pr121015-11b.c | 13 ++
+ gcc/testsuite/gcc.target/i386/pr121015-11c.c | 17 +++
+ gcc/testsuite/gcc.target/i386/pr121015-2a.c | 24 ++++
+ gcc/testsuite/gcc.target/i386/pr121015-2b.c | 6 +
+ gcc/testsuite/gcc.target/i386/pr121015-3.c | 35 +++++
+ gcc/testsuite/gcc.target/i386/pr121015-4.c | 22 ++++
+ gcc/testsuite/gcc.target/i386/pr121015-5a.c | 21 +++
+ gcc/testsuite/gcc.target/i386/pr121015-5b.c | 16 +++
+ gcc/testsuite/gcc.target/i386/pr121015-5c.c | 20 +++
+ gcc/testsuite/gcc.target/i386/pr121015-6.c | 23 ++++
+ gcc/testsuite/gcc.target/i386/pr121015-7a.c | 23 ++++
+ gcc/testsuite/gcc.target/i386/pr121015-7b.c | 6 +
+ gcc/testsuite/gcc.target/i386/pr121015-7c.c | 8 ++
+ gcc/testsuite/gcc.target/i386/pr121015-8.c | 14 ++
+ gcc/testsuite/gcc.target/i386/pr121015-9.c | 14 ++
+ 25 files changed, 512 insertions(+), 34 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-1.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-10a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-10b.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-10c.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-11a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-11b.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-11c.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-2a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-2b.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-3.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-4.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-5a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-5b.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-5c.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-6.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-7a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-7b.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-7c.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-8.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015-9.c
+
+diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
+index 38877a7e61bd..4bfd9b2a4580 100644
+--- a/gcc/config/i386/constraints.md
++++ b/gcc/config/i386/constraints.md
+@@ -174,6 +174,7 @@ (define_register_constraint "YW"
+ ;; and zero-extand to 256/512bit, or 128bit all ones
+ ;; and zero-extend to 512bit.
+ ;; M x86-64 memory operand.
++;; Z Constant zero operand in 64-bit or without SSE.
+
+ (define_constraint "Bf"
+ "@internal Flags register operand."
+@@ -246,6 +247,12 @@ (define_constraint "BM"
+ (match_test "memory_address_addr_space_p (GET_MODE (op), XEXP (op, 0),
+ MEM_ADDR_SPACE (op))")))
+
++(define_constraint "BZ"
++ "@internal Constant zero operand in 64-bit or without SSE."
++ (and (match_test "TARGET_64BIT || !TARGET_SSE")
++ (ior (match_test "op == const0_rtx")
++ (match_operand 0 "const0_operand"))))
++
+ ;; Integer constant constraints.
+ (define_constraint "Wb"
+ "Integer constant in the range 0 @dots{} 7, for 8-bit shifts."
+diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
+index 313522b88e3c..a9c1418a2bf5 100644
+--- a/gcc/config/i386/i386.cc
++++ b/gcc/config/i386/i386.cc
+@@ -5448,6 +5448,8 @@ standard_sse_constant_p (rtx x, machine_mode pred_mode)
+ return 2;
+ break;
+ case 16:
++ case 8:
++ case 4:
+ if (TARGET_SSE2)
+ return 2;
+ break;
+@@ -14671,9 +14673,14 @@ ix86_print_operand (FILE *file, rtx x, int code)
+ since we can in fact encode that into an immediate. */
+ if (GET_CODE (x) == CONST_VECTOR)
+ {
+- if (x != CONST0_RTX (GET_MODE (x)))
+- output_operand_lossage ("invalid vector immediate");
+- x = const0_rtx;
++ if (x == CONSTM1_RTX (GET_MODE (x)))
++ x = constm1_rtx;
++ else
++ {
++ if (x != CONST0_RTX (GET_MODE (x)))
++ output_operand_lossage ("invalid vector immediate");
++ x = const0_rtx;
++ }
+ }
+
+ if (code == 'P')
+diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
+index 29a8cb599a7e..3b013e3db311 100644
+--- a/gcc/config/i386/mmx.md
++++ b/gcc/config/i386/mmx.md
+@@ -111,6 +111,13 @@ (define_mode_attr mmxinsnmode
+ (V4BF "DI") (V2BF "SI")
+ (V2SF "DI")])
+
++;; MMX constant -1 constraint
++(define_mode_attr mmxconstm1
++ [(V8QI "BC") (V4HI "BC") (V2SI "BC") (V1DI "BC")
++ (V4QI "BC") (V2HI "BC") (V1SI "BC")
++ (V4HF "BF") (V4BF "BF") (V2SF "BF")
++ (V2HF "BF") (V2BF "BF")])
++
+ (define_mode_attr mmxdoublemode
+ [(V8QI "V8HI") (V4HI "V4SI")])
+
+@@ -174,20 +181,25 @@ (define_mode_attr Yv_Yw
+
+ (define_expand "mov<mode>"
+ [(set (match_operand:MMXMODE 0 "nonimmediate_operand")
+- (match_operand:MMXMODE 1 "nonimm_or_0_operand"))]
++ (match_operand:MMXMODE 1 "nonimmediate_or_sse_const_operand"))]
+ "TARGET_MMX || TARGET_MMX_WITH_SSE"
+ {
+ ix86_expand_vector_move (<MODE>mode, operands);
+ DONE;
+ })
+
++;; There must no CONSTM1_RTX vector loads after reload.
+ (define_insn "*mov<mode>_internal"
+ [(set (match_operand:MMXMODE 0 "nonimmediate_operand"
+- "=r ,o ,r,r ,m ,?!y,!y,?!y,m ,r ,?!y,v,v,v,m,r,v,!y,*x")
+- (match_operand:MMXMODE 1 "nonimm_or_0_operand"
+- "rCo,rC,C,rm,rC,C ,!y,m ,?!y,?!y,r ,C,v,m,v,v,r,*x,!y"))]
++ "=r ,o ,r,r ,m ,m ,?!y,!y,?!y,m ,r ,?!y,v,v ,v,v,m,r,v,!y,*x")
++ (match_operand:MMXMODE 1 "nonimmediate_or_sse_const_operand"
++ "rCo,rBZ,C,rm,rBZ,<mmxconstm1>,C ,!y,m ,?!y,?!y,r ,C,<mmxconstm1>,v,m,v,v,r,*x,!y"))]
+ "(TARGET_MMX || TARGET_MMX_WITH_SSE)
+ && !(MEM_P (operands[0]) && MEM_P (operands[1]))
++ && (!reload_completed
++ || !(SSE_REG_P (operands[0])
++ && int_float_vector_all_ones_operand (operands[1],
++ <MODE>mode)))
+ && ix86_hardreg_mov_ok (operands[0], operands[1])"
+ {
+ switch (get_attr_type (insn))
+@@ -230,31 +242,31 @@ (define_insn "*mov<mode>_internal"
+ [(set (attr "isa")
+ (cond [(eq_attr "alternative" "0,1")
+ (const_string "nox64")
+- (eq_attr "alternative" "2,3,4,9,10")
++ (eq_attr "alternative" "2,3,4,10,11")
+ (const_string "x64")
+- (eq_attr "alternative" "15,16")
++ (eq_attr "alternative" "5,17,18")
+ (const_string "x64_sse2")
+- (eq_attr "alternative" "17,18")
++ (eq_attr "alternative" "13,19,20")
+ (const_string "sse2")
+ ]
+ (const_string "*")))
+ (set (attr "type")
+ (cond [(eq_attr "alternative" "0,1")
+ (const_string "multi")
+- (eq_attr "alternative" "2,3,4")
++ (eq_attr "alternative" "2,3,4,5")
+ (const_string "imov")
+- (eq_attr "alternative" "5")
++ (eq_attr "alternative" "6")
+ (const_string "mmx")
+- (eq_attr "alternative" "6,7,8,9,10")
++ (eq_attr "alternative" "7,8,9,10,11")
+ (const_string "mmxmov")
+- (eq_attr "alternative" "11")
++ (eq_attr "alternative" "12,13")
+ (const_string "sselog1")
+- (eq_attr "alternative" "17,18")
++ (eq_attr "alternative" "19,20")
+ (const_string "ssecvt")
+ ]
+ (const_string "ssemov")))
+ (set (attr "prefix_rex")
+- (if_then_else (eq_attr "alternative" "9,10,15,16")
++ (if_then_else (eq_attr "alternative" "10,11,17,18")
+ (const_string "1")
+ (const_string "*")))
+ (set (attr "prefix")
+@@ -269,7 +281,7 @@ (define_insn "*mov<mode>_internal"
+ (set (attr "mode")
+ (cond [(eq_attr "alternative" "2")
+ (const_string "SI")
+- (eq_attr "alternative" "11,12")
++ (eq_attr "alternative" "12,13,14")
+ (cond [(match_test "<MODE>mode == V2SFmode
+ || <MODE>mode == V4HFmode
+ || <MODE>mode == V4BFmode")
+@@ -280,7 +292,7 @@ (define_insn "*mov<mode>_internal"
+ ]
+ (const_string "TI"))
+
+- (and (eq_attr "alternative" "13")
++ (and (eq_attr "alternative" "15")
+ (ior (ior (and (match_test "<MODE>mode == V2SFmode")
+ (not (match_test "TARGET_MMX_WITH_SSE")))
+ (not (match_test "TARGET_SSE2")))
+@@ -288,7 +300,7 @@ (define_insn "*mov<mode>_internal"
+ || <MODE>mode == V4BFmode")))
+ (const_string "V2SF")
+
+- (and (eq_attr "alternative" "14")
++ (and (eq_attr "alternative" "16")
+ (ior (ior (match_test "<MODE>mode == V2SFmode")
+ (not (match_test "TARGET_SSE2")))
+ (match_test "<MODE>mode == V4HFmode
+@@ -297,13 +309,49 @@ (define_insn "*mov<mode>_internal"
+ ]
+ (const_string "DI")))
+ (set (attr "preferred_for_speed")
+- (cond [(eq_attr "alternative" "9,15")
++ (cond [(eq_attr "alternative" "10,17")
+ (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
+- (eq_attr "alternative" "10,16")
++ (eq_attr "alternative" "11,18")
+ (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
+ ]
+ (symbol_ref "true")))])
+
++;; Split
++;;
++;; (set (reg:V8QI 100)
++;; (const_vector:V8QI [
++;; (const_int -1 [0xffffffffffffffff]) repeated x8]))
++;;
++;; by loading from memory if it hasn't been eliminated to make top bits
++;; cleared in vector register. For 32-bit PIC, we also must split
++;;
++;; (set (mem/c:V8QI (reg/f:SI 99)
++;; (const_vector:V8QI [
++;; (const_int -1 [0xffffffffffffffff]) repeated x8]))
++;;
++;; before reload since 32-bit doesn't support 8-byte immediate store and
++;; PIC register can't be allocated after reload.
++(define_split
++ [(set (match_operand:MMXMODE 0 "nonimmediate_operand")
++ (match_operand:MMXMODE 1 "int_float_vector_all_ones_operand"))]
++ "TARGET_SSE
++ && (SSE_REG_P (operands[0])
++ || (!reload_completed && flag_pic && !TARGET_64BIT))"
++ [(const_int 0)]
++{
++ operands[1] = validize_mem (force_const_mem (<MODE>mode,
++ operands[1]));
++ rtx src;
++ if (REG_P (operands[0]))
++ src = operands[1];
++ else
++ {
++ src = gen_reg_rtx (<MODE>mode);
++ emit_move_insn (src, operands[1]);
++ }
++ emit_move_insn (operands[0], src);
++})
++
+ (define_split
+ [(set (match_operand:MMXMODE 0 "nonimmediate_gr_operand")
+ (match_operand:MMXMODE 1 "nonimmediate_gr_operand"))]
+@@ -329,19 +377,24 @@ (define_expand "movmisalign<mode>"
+
+ (define_expand "mov<mode>"
+ [(set (match_operand:V_32 0 "nonimmediate_operand")
+- (match_operand:V_32 1 "nonimm_or_0_operand"))]
++ (match_operand:V_32 1 "nonimmediate_or_sse_const_operand"))]
+ ""
+ {
+ ix86_expand_vector_move (<MODE>mode, operands);
+ DONE;
+ })
+
++;; There must no CONSTM1_RTX vector loads after reload.
+ (define_insn "*mov<mode>_internal"
+ [(set (match_operand:V_32 0 "nonimmediate_operand"
+- "=r ,m ,v,v,v,m,r,v")
+- (match_operand:V_32 1 "nonimm_or_0_operand"
+- "rmC,rC,C,v,m,v,v,r"))]
++ "=r ,m ,rm ,v,v ,v,v,m,r,v")
++ (match_operand:V_32 1 "nonimmediate_or_sse_const_operand"
++ "rmC,rC,<mmxconstm1>,C,<mmxconstm1>,v,m,v,v,r"))]
+ "!(MEM_P (operands[0]) && MEM_P (operands[1]))
++ && (!reload_completed
++ || !(SSE_REG_P (operands[0])
++ && int_float_vector_all_ones_operand (operands[1],
++ <MODE>mode)))
+ && ix86_hardreg_mov_ok (operands[0], operands[1])"
+ {
+ switch (get_attr_type (insn))
+@@ -360,14 +413,14 @@ (define_insn "*mov<mode>_internal"
+ }
+ }
+ [(set (attr "isa")
+- (cond [(eq_attr "alternative" "6,7")
++ (cond [(eq_attr "alternative" "2,4,8,9")
+ (const_string "sse2")
+ ]
+ (const_string "*")))
+ (set (attr "type")
+- (cond [(eq_attr "alternative" "2")
++ (cond [(eq_attr "alternative" "3,4")
+ (const_string "sselog1")
+- (eq_attr "alternative" "3,4,5,6,7")
++ (eq_attr "alternative" "5,6,7,8,9")
+ (const_string "ssemov")
+ ]
+ (const_string "imov")))
+@@ -380,7 +433,7 @@ (define_insn "*mov<mode>_internal"
+ (const_string "1")
+ (const_string "*")))
+ (set (attr "mode")
+- (cond [(eq_attr "alternative" "2,3")
++ (cond [(eq_attr "alternative" "3,4,5")
+ (cond [(match_test "<MODE>mode == V2HFmode
+ || <MODE>mode == V2BFmode")
+ (const_string "V4SF")
+@@ -392,7 +445,7 @@ (define_insn "*mov<mode>_internal"
+ ]
+ (const_string "TI"))
+
+- (and (eq_attr "alternative" "4,5")
++ (and (eq_attr "alternative" "6,7")
+ (ior (match_test "<MODE>mode == V2HFmode
+ || <MODE>mode == V2BFmode")
+ (not (match_test "TARGET_SSE2"))))
+@@ -400,13 +453,32 @@ (define_insn "*mov<mode>_internal"
+ ]
+ (const_string "SI")))
+ (set (attr "preferred_for_speed")
+- (cond [(eq_attr "alternative" "6")
++ (cond [(eq_attr "alternative" "8")
+ (symbol_ref "TARGET_INTER_UNIT_MOVES_FROM_VEC")
+- (eq_attr "alternative" "7")
++ (eq_attr "alternative" "9")
+ (symbol_ref "TARGET_INTER_UNIT_MOVES_TO_VEC")
+ ]
+ (symbol_ref "true")))])
+
++;; Split
++;;
++;; (set (reg:V4QI 100)
++;; (const_vector:V4QI [
++;; (const_int -1 [0xffffffffffffffff]) repeated x4]))
++;;
++;; by loading from memory if it hasn't been eliminated to make top bits
++;; cleared in vector register.
++(define_split
++ [(set (match_operand:V_32 0 "register_operand")
++ (match_operand:V_32 1 "int_float_vector_all_ones_operand"))]
++ "TARGET_SSE && SSE_REG_P (operands[0])"
++ [(const_int 0)]
++{
++ operands[1] = validize_mem (force_const_mem (<MODE>mode,
++ operands[1]));
++ emit_move_insn (operands[0], operands[1]);
++})
++
+ ;; 16-bit, 32-bit and 64-bit constant vector stores. After reload,
+ ;; convert them to immediate integer stores.
+ (define_insn_and_split "*mov<mode>_imm"
+diff --git a/gcc/testsuite/gcc.target/i386/pr117839-1b.c b/gcc/testsuite/gcc.target/i386/pr117839-1b.c
+index e71b991a2073..6b181f35dff9 100644
+--- a/gcc/testsuite/gcc.target/i386/pr117839-1b.c
++++ b/gcc/testsuite/gcc.target/i386/pr117839-1b.c
+@@ -1,5 +1,8 @@
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -march=x86-64-v3" } */
+-/* { dg-final { scan-assembler-times "xor\[a-z\]*\[\t \]*%xmm\[0-9\]\+,\[^,\]*" 1 } } */
++/* { dg-final { scan-assembler-times "xor\[\t \]+%xmm\[0-9\]+, \[^,\]+" 1 { target { ! ia32 } } } } */
++/* { dg-final { scan-assembler-times "xor\[\t \]+%xmm\[0-9\]+, \[^,\]+" 2 { target ia32 } } } */
++/* { dg-final { scan-assembler-times "movl\[\t \]+\\\$0, " 3 { target ia32 } } } */
++/* { dg-final { scan-assembler-times "movq\[\t \]+%xmm\[0-9\]+, \[^,\]+" 1 { target ia32 } } } */
+
+ #include "pr117839-1a.c"
+diff --git a/gcc/testsuite/gcc.target/i386/pr117839-2.c b/gcc/testsuite/gcc.target/i386/pr117839-2.c
+index c76744cf98b8..b00d8eaec5c2 100644
+--- a/gcc/testsuite/gcc.target/i386/pr117839-2.c
++++ b/gcc/testsuite/gcc.target/i386/pr117839-2.c
+@@ -1,6 +1,9 @@
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -march=x86-64-v3" } */
+-/* { dg-final { scan-assembler-times "xor\[a-z\]*\[\t \]*%xmm\[0-9\]\+,\[^,\]*" 1 } } */
++/* { dg-final { scan-assembler-times "xor\[\t \]+%xmm\[0-9\]+, \[^,\]+" 1 { target { ! ia32 } } } } */
++/* { dg-final { scan-assembler-times "xor\[\t \]+%xmm\[0-9\]+, \[^,\]+" 3 { target ia32 } } } */
++/* { dg-final { scan-assembler-times "movl\[\t \]+\\\$0, " 1 { target ia32 } } } */
++/* { dg-final { scan-assembler-times "movq\[\t \]+%xmm\[0-9\]+, \[^,\]+" 2 { target ia32 } } } */
+
+ #include <stddef.h>
+
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-1.c b/gcc/testsuite/gcc.target/i386/pr121015-1.c
+new file mode 100644
+index 000000000000..fefa5185be4d
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-1.c
+@@ -0,0 +1,34 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -march=x86-64-v3" } */
++/* { dg-final { scan-assembler-not "\tmovl\[\\t \]+\\\$-1, %" { target { ! ia32 } } } } */
++/* { dg-final { scan-assembler "\tmovq\[\\t \]+\\\$-1, " { target { ! ia32 } } } } */
++
++extern union {
++ int i;
++ float f;
++} int_as_float_u;
++
++extern int render_result_from_bake_w;
++extern int render_result_from_bake_h_seed_pass;
++extern float *render_result_from_bake_h_primitive;
++extern float *render_result_from_bake_h_seed;
++
++float
++int_as_float(int i)
++{
++ int_as_float_u.i = i;
++ return int_as_float_u.f;
++}
++
++void
++render_result_from_bake_h(int tx)
++{
++ while (render_result_from_bake_w) {
++ for (; tx < render_result_from_bake_w; tx++)
++ render_result_from_bake_h_primitive[1] =
++ render_result_from_bake_h_primitive[2] = int_as_float(-1);
++ if (render_result_from_bake_h_seed_pass) {
++ *render_result_from_bake_h_seed = 0;
++ }
++ }
++}
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-10a.c b/gcc/testsuite/gcc.target/i386/pr121015-10a.c
+new file mode 100644
+index 000000000000..67b574cc8374
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-10a.c
+@@ -0,0 +1,32 @@
++/* { dg-do compile { target fpic } } */
++/* { dg-options "-O2 -march=x86-64 -fpic" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
++
++/*
++**__bid64_to_binary80:
++**.LFB[0-9]+:
++** .cfi_startproc
++** mov(l|q) __bid64_to_binary80_x_out@GOTPCREL\(%rip\), %(r|e)ax
++** movq \$-1, \(%(r|e)ax\)
++** ret
++**...
++*/
++
++typedef struct {
++ struct {
++ unsigned short lo4;
++ unsigned short lo3;
++ unsigned short lo2;
++ unsigned short lo1;
++ } i;
++} BID_BINARY80LDOUBLE;
++extern BID_BINARY80LDOUBLE __bid64_to_binary80_x_out;
++void
++__bid64_to_binary80 (void)
++{
++ __bid64_to_binary80_x_out.i.lo4
++ = __bid64_to_binary80_x_out.i.lo3
++ = __bid64_to_binary80_x_out.i.lo2
++ = __bid64_to_binary80_x_out.i.lo1 = 65535;
++}
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-10b.c b/gcc/testsuite/gcc.target/i386/pr121015-10b.c
+new file mode 100644
+index 000000000000..06cb58f702d3
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-10b.c
+@@ -0,0 +1,16 @@
++/* { dg-do compile { target { fpic && lp64 } } } */
++/* { dg-options "-O2 -march=x86-64 -fno-pic -mcmodel=large" } */
++
++/*
++**__bid64_to_binary80:
++**.LFB[0-9]+:
++** .cfi_startproc
++** movabsq \$.LC0, %rax
++** movq \(%rax\), %rdx
++** movabsq \$__bid64_to_binary80_x_out, %rax
++** movq %rdx, \(%rax\)
++** ret
++**...
++*/
++
++#include "pr121015-10a.c"
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-10c.c b/gcc/testsuite/gcc.target/i386/pr121015-10c.c
+new file mode 100644
+index 000000000000..573a15628830
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-10c.c
+@@ -0,0 +1,21 @@
++/* { dg-do compile { target { fpic && lp64 } } } */
++/* { dg-options "-O2 -march=x86-64 -fpic -mcmodel=large" } */
++
++/*
++**__bid64_to_binary80:
++**.LFB[0-9]+:
++** .cfi_startproc
++**.L2:
++** leaq .L2\(%rip\), %rax
++** movabsq \$_GLOBAL_OFFSET_TABLE_-.L2, %r11
++** movabsq \$__bid64_to_binary80_x_out@GOT, %rdx
++** movabsq \$.LC0@GOTOFF, %rcx
++** addq %r11, %rax
++** movq \(%rax,%rdx\), %rdx
++** movq \(%rax,%rcx\), %rax
++** movq %rax, \(%rdx\)
++** ret
++**...
++*/
++
++#include "pr121015-10a.c"
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-11a.c b/gcc/testsuite/gcc.target/i386/pr121015-11a.c
+new file mode 100644
+index 000000000000..5aafb2806b12
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-11a.c
+@@ -0,0 +1,21 @@
++/* { dg-do compile { target fpic } } */
++/* { dg-options "-O2 -march=x86-64 -fpic" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
++
++/*
++**foo:
++**.LFB[0-9]+:
++** .cfi_startproc
++** movd .LC0\(%rip\), %xmm0
++**...
++*/
++
++typedef char __v4qi __attribute__ ((__vector_size__ (4)));
++
++void
++foo (void)
++{
++ register __v4qi x asm ("xmm0") = __extension__(__v4qi){-1, -1, -1, -1};
++ asm ("reg %0" : : "v" (x));
++}
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-11b.c b/gcc/testsuite/gcc.target/i386/pr121015-11b.c
+new file mode 100644
+index 000000000000..9ff2908829b6
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-11b.c
+@@ -0,0 +1,13 @@
++/* { dg-do compile { target { fpic && lp64 } } } */
++/* { dg-options "-O2 -march=x86-64 -fno-pic -mcmodel=large" } */
++
++/*
++**foo:
++**.LFB[0-9]+:
++** .cfi_startproc
++** movabsq \$.LC0, %rax
++** movd \(%rax\), %xmm0
++**...
++*/
++
++#include "pr121015-11a.c"
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-11c.c b/gcc/testsuite/gcc.target/i386/pr121015-11c.c
+new file mode 100644
+index 000000000000..f0e6ccb2b92f
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-11c.c
+@@ -0,0 +1,17 @@
++/* { dg-do compile { target { fpic && lp64 } } } */
++/* { dg-options "-O2 -march=x86-64 -fpic -mcmodel=large" } */
++
++/*
++**foo:
++**.LFB[0-9]+:
++** .cfi_startproc
++**.L2:
++** movabsq \$_GLOBAL_OFFSET_TABLE_-.L2, %r11
++** leaq .L2\(%rip\), %rax
++** movabsq \$.LC0@GOTOFF, %rdx
++** addq %r11, %rax
++** movd \(%rax,%rdx\), %xmm0
++**...
++*/
++
++#include "pr121015-11a.c"
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-2a.c b/gcc/testsuite/gcc.target/i386/pr121015-2a.c
+new file mode 100644
+index 000000000000..e8840b0ffd6d
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-2a.c
+@@ -0,0 +1,24 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -march=x86-64" } */
++
++void
++foo (int *c1, int *c2)
++{
++ if (c1)
++ {
++ c1 = __builtin_assume_aligned (c1, 16);
++ c1[0] = 0;
++ c1[1] = 0;
++ }
++ if (c2)
++ {
++ c2 = __builtin_assume_aligned (c2, 16);
++ c2[0] = 0;
++ c2[1] = 0;
++ }
++}
++
++/* { dg-final { scan-assembler-times "pxor\[ \\t\]+\[^\n\]*%xmm" 2 { target ia32 } } } */
++/* { dg-final { scan-assembler-times "movq\[ \\t\]+\[^\n\]*%xmm" 2 { target ia32 } } } */
++/* { dg-final { scan-assembler-times "movq\[ \\t\]+\\\$0," 2 { target { ! ia32 } } } } */
++/* { dg-final { scan-assembler-not "xmm" { target { ! ia32 } } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-2b.c b/gcc/testsuite/gcc.target/i386/pr121015-2b.c
+new file mode 100644
+index 000000000000..9df2766c6120
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-2b.c
+@@ -0,0 +1,6 @@
++/* { dg-do compile { target ia32 } } */
++/* { dg-options "-O2 -mno-sse" } */
++
++#include "pr121015-2a.c"
++
++/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$0," 4 } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-3.c b/gcc/testsuite/gcc.target/i386/pr121015-3.c
+new file mode 100644
+index 000000000000..44bf63c73e69
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-3.c
+@@ -0,0 +1,35 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -march=x86-64" } */
++
++typedef enum { CPP_NUMBER } cpp_ttype;
++typedef struct {
++ bool unsignedp;
++ bool overflow;
++} cpp_num;
++extern cpp_num value, __trans_tmp_1;
++extern cpp_ttype eval_token_token_0;
++extern int eval_token_temp;
++static cpp_num
++eval_token(void)
++{
++ cpp_num __trans_tmp_2, result;
++ result.overflow = false;
++ switch (eval_token_token_0)
++ {
++ case CPP_NUMBER:
++ switch (eval_token_temp)
++ {
++ case 1:
++ return __trans_tmp_1;
++ }
++ result.unsignedp = false;
++ __trans_tmp_2 = result;
++ return __trans_tmp_2;
++ }
++ return result;
++}
++void
++_cpp_parse_expr_pfile(void)
++{
++ value = eval_token();
++}
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-4.c b/gcc/testsuite/gcc.target/i386/pr121015-4.c
+new file mode 100644
+index 000000000000..2848a946dd16
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-4.c
+@@ -0,0 +1,22 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -march=x86-64" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
++
++/*
++**zero:
++**.LFB0:
++** .cfi_startproc
++** xorps %xmm0, %xmm0
++** ret
++**...
++*/
++
++typedef float __v2sf __attribute__ ((__vector_size__ (8)));
++extern __v2sf f1;
++
++__v2sf
++zero (void)
++{
++ return __extension__(__v2sf){0, 0};
++}
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-5a.c b/gcc/testsuite/gcc.target/i386/pr121015-5a.c
+new file mode 100644
+index 000000000000..605a87db1fc4
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-5a.c
+@@ -0,0 +1,21 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -march=x86-64" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
++
++/*
++**m1:
++**.LFB[0-9]+:
++** .cfi_startproc
++** movq .LC[0-9]+\(%rip\), %xmm0
++** ret
++**...
++*/
++
++typedef char __v8qi __attribute__ ((__vector_size__ (8)));
++
++__v8qi
++m1 (void)
++{
++ return __extension__(__v8qi){-1, -1, -1, -1, -1, -1, -1, -1};
++}
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-5b.c b/gcc/testsuite/gcc.target/i386/pr121015-5b.c
+new file mode 100644
+index 000000000000..22d51fd33efd
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-5b.c
+@@ -0,0 +1,16 @@
++/* { dg-do compile { target { fpic && lp64 } } } */
++/* { dg-options "-O2 -march=x86-64 -fno-pic -mcmodel=large" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
++
++/*
++**m1:
++**.LFB[0-9]+:
++** .cfi_startproc
++** movabsq \$.LC0, %rax
++** movq \(%rax\), %xmm0
++** ret
++**...
++*/
++
++#include "pr121015-5a.c"
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-5c.c b/gcc/testsuite/gcc.target/i386/pr121015-5c.c
+new file mode 100644
+index 000000000000..bb210fa71ff5
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-5c.c
+@@ -0,0 +1,20 @@
++/* { dg-do compile { target { fpic && lp64 } } } */
++/* { dg-options "-O2 -march=x86-64 -fpic -mcmodel=large" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
++
++/*
++**m1:
++**.LFB[0-9]+:
++** .cfi_startproc
++**.L2:
++** movabsq \$_GLOBAL_OFFSET_TABLE_-.L2, %r11
++** leaq .L2\(%rip\), %rax
++** movabsq \$.LC0@GOTOFF, %rdx
++** addq %r11, %rax
++** movq \(%rax,%rdx\), %xmm0
++** ret
++**...
++*/
++
++#include "pr121015-5a.c"
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-6.c b/gcc/testsuite/gcc.target/i386/pr121015-6.c
+new file mode 100644
+index 000000000000..daebcb0acc51
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-6.c
+@@ -0,0 +1,23 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -march=x86-64" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target { ! ia32 } } {^\t?\.} } } */
++
++/*
++**m1:
++**.LFB[0-9]+:
++** .cfi_startproc
++** pcmpeqd %xmm0, %xmm0
++** ret
++**...
++*/
++
++#include <x86intrin.h>
++
++__m128i
++m1 (void)
++{
++ __m64 x = _mm_set1_pi8 (-1);
++ __m128i y = _mm_set1_epi64 (x);
++ return y;
++}
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-7a.c b/gcc/testsuite/gcc.target/i386/pr121015-7a.c
+new file mode 100644
+index 000000000000..94037e33d811
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-7a.c
+@@ -0,0 +1,23 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -march=x86-64" } */
++
++void
++foo (int *c1, int *c2)
++{
++ if (c1)
++ {
++ c1 = __builtin_assume_aligned (c1, 16);
++ c1[0] = -1;
++ c1[1] = -1;
++ }
++ if (c2)
++ {
++ c2 = __builtin_assume_aligned (c2, 16);
++ c2[0] = -1;
++ c2[1] = -1;
++ }
++}
++
++/* { dg-final { scan-assembler-times "movq\[ \\t\]+\[^\n\]*%xmm" 4 { target ia32 } } } */
++/* { dg-final { scan-assembler-times "movq\[ \\t\]+\\\$-1," 2 { target { ! ia32 } } } } */
++/* { dg-final { scan-assembler-not "xmm" { target { ! ia32 } } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-7b.c b/gcc/testsuite/gcc.target/i386/pr121015-7b.c
+new file mode 100644
+index 000000000000..3784ce0dfeda
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-7b.c
+@@ -0,0 +1,6 @@
++/* { dg-do compile { target ia32 } } */
++/* { dg-options "-O2 -mno-sse" } */
++
++#include "pr121015-7a.c"
++
++/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$-1," 4 } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-7c.c b/gcc/testsuite/gcc.target/i386/pr121015-7c.c
+new file mode 100644
+index 000000000000..33b2df3ac9ec
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-7c.c
+@@ -0,0 +1,8 @@
++/* { dg-do compile { target fpic } } */
++/* { dg-options "-O2 -march=x86-64 -fpic" } */
++
++#include "pr121015-7a.c"
++
++/* { dg-final { scan-assembler-times "movq\[ \\t\]+\[^\n\]*%xmm" 4 { target ia32 } } } */
++/* { dg-final { scan-assembler-times "movq\[ \\t\]+\\\$-1," 2 { target { ! ia32 } } } } */
++/* { dg-final { scan-assembler-not "xmm" { target { ! ia32 } } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-8.c b/gcc/testsuite/gcc.target/i386/pr121015-8.c
+new file mode 100644
+index 000000000000..de2db2a2b0de
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-8.c
+@@ -0,0 +1,14 @@
++/* { dg-do compile } */
++/* { dg-options "-Og -fno-dce -mtune=generic" } */
++
++typedef int __attribute__((__vector_size__ (4))) S;
++extern int bar (S);
++
++int
++foo ()
++{
++ return bar ((S){-1});
++}
++
++/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$-1, \\(%esp\\)" 1 { target ia32 } } } */
++/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$-1, %edi" 1 { target { ! ia32 } } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015-9.c b/gcc/testsuite/gcc.target/i386/pr121015-9.c
+new file mode 100644
+index 000000000000..05c2021ba057
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015-9.c
+@@ -0,0 +1,14 @@
++/* { dg-do compile } */
++/* { dg-options "-Og -fno-dce -mtune=generic" } */
++
++typedef int __attribute__((__vector_size__ (4))) S;
++extern int bar (S);
++
++int
++foo ()
++{
++ return bar ((S){0});
++}
++
++/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$0, \\(%esp\\)" 1 { target ia32 } } } */
++/* { dg-final { scan-assembler-times "movl\[ \\t\]+\\\$0, %edi" 1 { target { ! ia32 } } } } */
+
+base-commit: db3afff48fc7ed896b3dd17eb93f0cfe3cc41da8
+--
+2.50.1
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index acd3457..e6bfa85 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+7 ????
+
+ + 86_all_PR121015-blender.patch
+
6 14 July 2025
- 85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-13 23:11 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-13 23:11 UTC (permalink / raw
To: gentoo-commits
commit: 2ae465fd7e43ebd54bff6c8cbb7903875ef14a85
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 13 23:11:06 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jul 13 23:11:06 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=2ae465fd
16.0.0: cut patchset 6
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/README.history | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 6c31a82..acd3457 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,4 +1,4 @@
-6 ????
+6 14 July 2025
- 85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
- 86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-13 1:09 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-13 1:09 UTC (permalink / raw
To: gentoo-commits
commit: 75eb74164ed09313584a6cf8292b7790dbc36673
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 13 01:08:54 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jul 13 01:09:30 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=75eb7416
16.0.0: add -mfentry by default patch
Bug: https://gcc.gnu.org/PR120881
Signed-off-by: Sam James <sam <AT> gentoo.org>
...PR120881-x86-64-Add-enable-x86-64-mfentry.patch | 563 +++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 564 insertions(+)
diff --git a/16.0.0/gentoo/86_all_PR120881-x86-64-Add-enable-x86-64-mfentry.patch b/16.0.0/gentoo/86_all_PR120881-x86-64-Add-enable-x86-64-mfentry.patch
new file mode 100644
index 0000000..bc7ebce
--- /dev/null
+++ b/16.0.0/gentoo/86_all_PR120881-x86-64-Add-enable-x86-64-mfentry.patch
@@ -0,0 +1,563 @@
+https://inbox.sourceware.org/gcc-patches/CAMe9rOoxxaxWSAuyJL2=s3jSyQ5_tmg78Nr+oz+t3x-2xgc7+w@mail.gmail.com/
+
+From d6f3358aeab4f2acbe6793f4773248bdcd56c10d Mon Sep 17 00:00:00 2001
+Message-ID: <d6f3358aeab4f2acbe6793f4773248bdcd56c10d.1752368830.git.sam@gentoo.org>
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Wed, 2 Jul 2025 08:58:23 +0800
+Subject: [PATCH] x86-64: Add --enable-x86-64-mfentry
+
+When profiling is enabled with shrink wrapping, the mcount call may not
+be placed at the function entry after
+
+ pushq %rbp
+ movq %rsp,%rbp
+
+As the result, the profile data may be skewed which makes PGO less
+effective.
+
+Add --enable-x86-64-mfentry to enable -mfentry by default to use
+__fentry__, added to glibc in 2010 by:
+
+commit d22e4cc9397ed41534c9422d0b0ffef8c77bfa53
+Author: Andi Kleen <ak@linux.intel.com>
+Date: Sat Aug 7 21:24:05 2010 -0700
+
+ x86: Add support for frame pointer less mcount
+
+instead of mcount, which is placed before the prologue so that -pg can
+be used with -fshrink-wrap-separate enabled at -O1. This option is
+64-bit only because __fentry__ doesn't support PIC in 32-bit mode. The
+default it to enable -mfentry when targeting glibc.
+
+Also warn -pg without -mfentry with shrink wrapping enabled. The warning
+is disable for PIC in 32-bit mode.
+
+gcc/
+
+ PR target/120881
+ * config.in: Regenerated.
+ * configure: Likewise.
+ * configure.ac: Add --enable-x86-64-mfentry.
+ * config/i386/i386-options.cc (ix86_option_override_internal):
+ Enable __fentry__ in 64-bit mode if ENABLE_X86_64_MFENTRY is set
+ to 1. Warn -pg without -mfentry with shrink wrapping enabled.
+ * doc/install.texi: Document --enable-x86-64-mfentry.
+
+gcc/testsuite/
+
+ PR target/120881
+ * gcc.dg/20021014-1.c: Add additional -mfentry -fno-pic options
+ for x86.
+ * gcc.dg/aru-2.c: Likewise.
+ * gcc.dg/nest.c: Likewise.
+ * gcc.dg/pr32450.c: Likewise.
+ * gcc.dg/pr43643.c: Likewise.
+ * gcc.target/i386/pr104447.c: Likewise.
+ * gcc.target/i386/pr113122-3.c: Likewise.
+ * gcc.target/i386/pr119386-1.c: Add additional -mfentry if not
+ ia32.
+ * gcc.target/i386/pr119386-2.c: Likewise.
+ * gcc.target/i386/pr120881-1a.c: New test.
+ * gcc.target/i386/pr120881-1b.c: Likewise.
+ * gcc.target/i386/pr120881-1c.c: Likewise.
+ * gcc.target/i386/pr120881-1d.c: Likewise.
+ * gcc.target/i386/pr120881-2a.c: Likewise.
+ * gcc.target/i386/pr120881-2b.c: Likewise.
+ * gcc.target/i386/pr82699-1.c: Add additional -mfentry.
+ * lib/target-supports.exp (check_effective_target_fentry): New.
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+---
+ gcc/config.in | 6 +++
+ gcc/config/i386/i386-options.cc | 11 ++++-
+ gcc/configure | 46 +++++++++++++++++++-
+ gcc/configure.ac | 35 +++++++++++++++
+ gcc/doc/install.texi | 11 +++++
+ gcc/testsuite/gcc.dg/20021014-1.c | 1 +
+ gcc/testsuite/gcc.dg/aru-2.c | 1 +
+ gcc/testsuite/gcc.dg/nest.c | 1 +
+ gcc/testsuite/gcc.dg/pr32450.c | 2 +-
+ gcc/testsuite/gcc.dg/pr43643.c | 1 +
+ gcc/testsuite/gcc.target/i386/pr104447.c | 2 +-
+ gcc/testsuite/gcc.target/i386/pr113122-3.c | 2 +-
+ gcc/testsuite/gcc.target/i386/pr119386-1.c | 4 +-
+ gcc/testsuite/gcc.target/i386/pr119386-2.c | 3 +-
+ gcc/testsuite/gcc.target/i386/pr120881-1a.c | 4 ++
+ gcc/testsuite/gcc.target/i386/pr120881-1b.c | 4 ++
+ gcc/testsuite/gcc.target/i386/pr120881-1c.c | 3 ++
+ gcc/testsuite/gcc.target/i386/pr120881-1d.c | 3 ++
+ gcc/testsuite/gcc.target/i386/pr120881-2a.c | 21 +++++++++
+ gcc/testsuite/gcc.target/i386/pr120881-2b.c | 6 +++
+ gcc/testsuite/gcc.target/i386/pr82699-1.c | 2 +-
+ gcc/testsuite/lib/target-supports.exp | 48 +++++++++++++++++++++
+ 22 files changed, 208 insertions(+), 9 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-1a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-1b.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-1c.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-1d.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-2a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr120881-2b.c
+
+diff --git a/gcc/config.in b/gcc/config.in
+index ab62c1566cbb..353d1bc94078 100644
+--- a/gcc/config.in
++++ b/gcc/config.in
+@@ -318,6 +318,12 @@
+ #endif
+
+
++/* Define to enable -mfentry by default on x86-64. */
++#ifndef USED_FOR_TARGET
++#undef ENABLE_X86_64_MFENTRY
++#endif
++
++
+ /* Define to the name of a file containing a list of extra machine modes for
+ this architecture. */
+ #ifndef USED_FOR_TARGET
+diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
+index 09cb1337f94c..53658496efdc 100644
+--- a/gcc/config/i386/i386-options.cc
++++ b/gcc/config/i386/i386-options.cc
+@@ -2839,7 +2839,9 @@ ix86_option_override_internal (bool main_args_p,
+
+ /* Set the default value for -mfentry. */
+ if (!opts_set->x_flag_fentry)
+- opts->x_flag_fentry = TARGET_SEH;
++ opts->x_flag_fentry = (TARGET_SEH
++ || (TARGET_64BIT_P (opts->x_ix86_isa_flags)
++ && ENABLE_X86_64_MFENTRY));
+ else
+ {
+ if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) && opts->x_flag_pic
+@@ -2850,6 +2852,13 @@ ix86_option_override_internal (bool main_args_p,
+ sorry ("%<-mno-fentry%> isn%'t compatible with SEH");
+ }
+
++ if (!opts->x_flag_fentry
++ && (TARGET_64BIT_P (opts->x_ix86_isa_flags) || !opts->x_flag_pic)
++ && opts->x_flag_shrink_wrap
++ && opts->x_profile_flag)
++ warning (0, "%<-pg%> without %<-mfentry%> may be unreliable with "
++ "shrink wrapping");
++
+ if (TARGET_SEH && TARGET_CALL_MS2SYSV_XLOGUES)
+ sorry ("%<-mcall-ms2sysv-xlogues%> isn%'t currently supported with SEH");
+
+diff --git a/gcc/configure b/gcc/configure
+index f056cfe9677e..7537da20291a 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -1064,6 +1064,7 @@ enable_versioned_jit
+ enable_default_pie
+ enable_cet
+ enable_s390_excess_float_precision
++enable_x86_64_mfentry
+ '
+ ac_precious_vars='build_alias
+ host_alias
+@@ -1842,6 +1843,7 @@ Optional Features:
+ --enable-s390-excess-float-precision
+ on s390 targets, evaluate float with double
+ precision when in standards-conforming mode
++ --enable-x86-64-mfentry enable -mfentry by default on x86-64 targets
+
+ Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+@@ -21520,7 +21522,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 21523 "configure"
++#line 21525 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -21626,7 +21628,7 @@ else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 21629 "configure"
++#line 21631 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -35022,6 +35024,46 @@ $as_echo "#define ENABLE_S390_EXCESS_FLOAT_PRECISION 1" >>confdefs.h
+ ;;
+ esac
+
++# On x86-64, when profiling is enabled with shrink wrapping, the mcount
++# call may not be placed at the function entry after
++# pushq %rbp
++# movq %rsp,%rbp
++# As the result, the profile data may be skewed which makes PGO less
++# effective:
++# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120881
++# Enable -mfentry by default on x86-64 to put the profiling counter call
++# before the prologue.
++# Check whether --enable-x86-64-mfentry was given.
++if test "${enable_x86_64_mfentry+set}" = set; then :
++ enableval=$enable_x86_64_mfentry; case "${enableval}" in
++ yes | no | auto)
++ enable_x86_64_mfentry=$enableval
++ ;;
++ *)
++ as_fn_error $? "'$enable_x86_64_mfentry' is an invalid value for --enable-x86-64-mfentry. Valid choices are 'yes', 'no' and 'auto'." "$LINENO" 5
++ ;;
++ esac
++else
++ enable_x86_64_mfentry=auto
++fi
++
++
++if test x"$enable_x86_64_mfentry" = xauto; then
++ case "${target}" in
++ i?86-*-*gnu* | x86_64-*-*gnu*)
++ # Enable -mfentry by default with glibc on x86.
++ enable_x86_64_mfentry=yes
++ ;;
++ esac
++fi
++
++gif=`if test x$enable_x86_64_mfentry = xyes; then echo 1; else echo 0; fi`
++
++cat >>confdefs.h <<_ACEOF
++#define ENABLE_X86_64_MFENTRY $gif
++_ACEOF
++
++
+ # Check if the linker supports '-z now'
+ ld_now_support=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker -z now option" >&5
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 58bf63f8be9e..24e0aa69c0f6 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -7972,6 +7972,41 @@ standards-compatible mode on s390 targets.])
+ ;;
+ esac
+
++# On x86-64, when profiling is enabled with shrink wrapping, the mcount
++# call may not be placed at the function entry after
++# pushq %rbp
++# movq %rsp,%rbp
++# As the result, the profile data may be skewed which makes PGO less
++# effective:
++# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120881
++# Enable -mfentry by default on x86-64 to put the profiling counter call
++# before the prologue.
++AC_ARG_ENABLE(x86-64-mfentry,
++ [AS_HELP_STRING([--enable-x86-64-mfentry],
++ [enable -mfentry by default on x86-64 targets])],
++ [case "${enableval}" in
++ yes | no | auto)
++ enable_x86_64_mfentry=$enableval
++ ;;
++ *)
++ AC_MSG_ERROR(['$enable_x86_64_mfentry' is an invalid value for --enable-x86-64-mfentry. Valid choices are 'yes', 'no' and 'auto'.])
++ ;;
++ esac],
++ [enable_x86_64_mfentry=auto])
++
++if test x"$enable_x86_64_mfentry" = xauto; then
++ case "${target}" in
++ i?86-*-*gnu* | x86_64-*-*gnu*)
++ # Enable -mfentry by default with glibc on x86.
++ enable_x86_64_mfentry=yes
++ ;;
++ esac
++fi
++
++gif=`if test x$enable_x86_64_mfentry = xyes; then echo 1; else echo 0; fi`
++AC_DEFINE_UNQUOTED(ENABLE_X86_64_MFENTRY, $gif,
++[Define to enable -mfentry by default on x86-64.])
++
+ # Check if the linker supports '-z now'
+ ld_now_support=no
+ AC_MSG_CHECKING(linker -z now option)
+diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
+index 80ee2cd6ebad..09ea87aa8120 100644
+--- a/gcc/doc/install.texi
++++ b/gcc/doc/install.texi
+@@ -2667,6 +2667,17 @@ target binutils supports @code{Intel CET} instructions and disabled
+ otherwise. In this case, the target libraries are configured to get
+ additional @option{-fcf-protection} option.
+
++@item --enable-x86-64-mfentry
++@itemx --disable-x86-64-mfentry
++Enable @option {-mfentry} by default on x86-64 to put the profiling
++counter call, @code{__fentry__}, before the prologue so that @option{-pg}
++can be used with @option{-fshrink-wrap} which is enabled at @option{-O1}.
++This configure option is 64-bit only because @code{__fentry__} doesn't
++support PIC in 32-bit mode.
++
++@option{--enable-x86-64-mfentry=auto} is default. @option{-mfentry} is
++enabled on Linux/x86-64 by default.
++
+ @item --with-riscv-attribute=@samp{yes}, @samp{no} or @samp{default}
+ Generate RISC-V attribute by default, in order to record extra build
+ information in object.
+diff --git a/gcc/testsuite/gcc.dg/20021014-1.c b/gcc/testsuite/gcc.dg/20021014-1.c
+index e43f7b297c5e..f5f6fcf36251 100644
+--- a/gcc/testsuite/gcc.dg/20021014-1.c
++++ b/gcc/testsuite/gcc.dg/20021014-1.c
+@@ -2,6 +2,7 @@
+ /* { dg-require-profiling "-p" } */
+ /* { dg-options "-O2 -p" } */
+ /* { dg-options "-O2 -p -static" { target hppa*-*-hpux* } } */
++/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* } } */
+ /* { dg-error "profiler" "No profiler support" { target xstormy16-*-* } 0 } */
+ /* { dg-message "" "consider using `-pg' instead of `-p' with gprof(1)" { target *-*-freebsd* } 0 } */
+
+diff --git a/gcc/testsuite/gcc.dg/aru-2.c b/gcc/testsuite/gcc.dg/aru-2.c
+index 054223c151b2..102ece177264 100644
+--- a/gcc/testsuite/gcc.dg/aru-2.c
++++ b/gcc/testsuite/gcc.dg/aru-2.c
+@@ -1,6 +1,7 @@
+ /* { dg-do run } */
+ /* { dg-require-profiling "-pg" } */
+ /* { dg-options "-O2 -pg" } */
++/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* } } */
+
+ static int __attribute__((noinline))
+ bar (int x)
+diff --git a/gcc/testsuite/gcc.dg/nest.c b/gcc/testsuite/gcc.dg/nest.c
+index 5734c11f1a3e..9221ed1c8f81 100644
+--- a/gcc/testsuite/gcc.dg/nest.c
++++ b/gcc/testsuite/gcc.dg/nest.c
+@@ -3,6 +3,7 @@
+ /* { dg-require-profiling "-pg" } */
+ /* { dg-options "-O2 -pg" } */
+ /* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */
++/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* } } */
+ /* { dg-error "profiler" "No profiler support" { target xstormy16-*-* } 0 } */
+
+ extern void abort (void);
+diff --git a/gcc/testsuite/gcc.dg/pr32450.c b/gcc/testsuite/gcc.dg/pr32450.c
+index 9606e3021eab..4aaeb7dd6546 100644
+--- a/gcc/testsuite/gcc.dg/pr32450.c
++++ b/gcc/testsuite/gcc.dg/pr32450.c
+@@ -3,7 +3,7 @@
+ /* { dg-do run } */
+ /* { dg-require-profiling "-pg" } */
+ /* { dg-options "-O2 -pg" } */
+-/* { dg-options "-O2 -pg -mtune=core2" { target { i?86-*-* x86_64-*-* } } } */
++/* { dg-options "-O2 -pg -mtune=core2 -mfentry -fno-pic" { target { i?86-*-* x86_64-*-* } } } */
+ /* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */
+
+ extern void abort (void);
+diff --git a/gcc/testsuite/gcc.dg/pr43643.c b/gcc/testsuite/gcc.dg/pr43643.c
+index 43896abd85af..a62586dc7196 100644
+--- a/gcc/testsuite/gcc.dg/pr43643.c
++++ b/gcc/testsuite/gcc.dg/pr43643.c
+@@ -4,6 +4,7 @@
+ /* { dg-require-profiling "-pg" } */
+ /* { dg-options "-O2 -pg" } */
+ /* { dg-options "-O2 -pg -static" { target hppa*-*-hpux* } } */
++/* { dg-additional-options "-mfentry -fno-pic" { target i?86-*-* x86_64-*-* } } */
+
+ extern char *strdup (const char *);
+
+diff --git a/gcc/testsuite/gcc.target/i386/pr104447.c b/gcc/testsuite/gcc.target/i386/pr104447.c
+index cb618c7b8bb3..f58170db7ecf 100644
+--- a/gcc/testsuite/gcc.target/i386/pr104447.c
++++ b/gcc/testsuite/gcc.target/i386/pr104447.c
+@@ -1,6 +1,6 @@
+ /* { dg-do compile } */
+ /* { dg-require-profiling "-pg" } */
+-/* { dg-options "-O2 -pg" } */
++/* { dg-options "-O2 -pg -mfentry -fno-pic" } */
+
+ int
+ bar (int x)
+diff --git a/gcc/testsuite/gcc.target/i386/pr113122-3.c b/gcc/testsuite/gcc.target/i386/pr113122-3.c
+index 71aa240ba98c..c46805dd7722 100644
+--- a/gcc/testsuite/gcc.target/i386/pr113122-3.c
++++ b/gcc/testsuite/gcc.target/i386/pr113122-3.c
+@@ -1,7 +1,7 @@
+ /* PR target/113122 */
+ /* { dg-do assemble { target *-*-linux* } } */
+ /* { dg-require-effective-target masm_intel } */
+-/* { dg-options "-fprofile -O2 -masm=intel" } */
++/* { dg-options "-fprofile -mfentry -fno-pic -O2 -masm=intel" } */
+
+ void
+ func (void)
+diff --git a/gcc/testsuite/gcc.target/i386/pr119386-1.c b/gcc/testsuite/gcc.target/i386/pr119386-1.c
+index 9a0dc64b5b93..39a3e1d2e806 100644
+--- a/gcc/testsuite/gcc.target/i386/pr119386-1.c
++++ b/gcc/testsuite/gcc.target/i386/pr119386-1.c
+@@ -1,7 +1,9 @@
+ /* PR target/119386 */
+ /* { dg-do compile { target *-*-linux* } } */
+ /* { dg-options "-O2 -fpic -pg" } */
+-/* { dg-final { scan-assembler "call\[ \t\]+mcount@PLT" } } */
++/* { dg-additional-options "-mfentry" { target { ! ia32 } } } */
++/* { dg-final { scan-assembler "call\[ \t\]+mcount@PLT" { target ia32 } } } */
++/* { dg-final { scan-assembler "call\[ \t\]+__fentry__@PLT" { target { ! ia32 } } } } */
+
+ int
+ main ()
+diff --git a/gcc/testsuite/gcc.target/i386/pr119386-2.c b/gcc/testsuite/gcc.target/i386/pr119386-2.c
+index 3ea978ecfdfd..d516aa9bd6af 100644
+--- a/gcc/testsuite/gcc.target/i386/pr119386-2.c
++++ b/gcc/testsuite/gcc.target/i386/pr119386-2.c
+@@ -1,7 +1,8 @@
+ /* PR target/119386 */
+ /* { dg-do compile { target *-*-linux* } } */
+ /* { dg-options "-O2 -fpic -fno-plt -pg" } */
+-/* { dg-final { scan-assembler "call\[ \t\]+\\*mcount@GOTPCREL\\(" { target { ! ia32 } } } } */
++/* { dg-additional-options "-mfentry" { target { ! ia32 } } } */
++/* { dg-final { scan-assembler "call\[ \t\]+\\*__fentry__@GOTPCREL" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler "call\[ \t\]+\\*mcount@GOT\\(" { target ia32 } } } */
+
+
+diff --git a/gcc/testsuite/gcc.target/i386/pr120881-1a.c b/gcc/testsuite/gcc.target/i386/pr120881-1a.c
+new file mode 100644
+index 000000000000..3d9ac0e9e866
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr120881-1a.c
+@@ -0,0 +1,4 @@
++/* { dg-do compile { target fpic } } */
++/* { dg-require-profiling "-pg" } */
++/* { dg-options "-O2 -pg -mno-fentry -fno-pic" } */
++/* { dg-message "'-pg' without '-mfentry' may be unreliable with shrink wrapping" "" { target *-*-* } 0 } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr120881-1b.c b/gcc/testsuite/gcc.target/i386/pr120881-1b.c
+new file mode 100644
+index 000000000000..082640726b1d
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr120881-1b.c
+@@ -0,0 +1,4 @@
++/* { dg-do compile { target { fpic && { ! ia32 } } } } */
++/* { dg-require-profiling "-pg" } */
++/* { dg-options "-O2 -pg -mno-fentry -fpic" } */
++/* { dg-message "'-pg' without '-mfentry' may be unreliable with shrink wrapping" "" { target *-*-* } 0 } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr120881-1c.c b/gcc/testsuite/gcc.target/i386/pr120881-1c.c
+new file mode 100644
+index 000000000000..c21979f8eb1f
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr120881-1c.c
+@@ -0,0 +1,3 @@
++/* { dg-do compile { target { fpic && ia32 } } } */
++/* { dg-require-profiling "-pg" } */
++/* { dg-options "-O2 -pg -mno-fentry -fpic" } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr120881-1d.c b/gcc/testsuite/gcc.target/i386/pr120881-1d.c
+new file mode 100644
+index 000000000000..f74af23ff5c8
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr120881-1d.c
+@@ -0,0 +1,3 @@
++/* { dg-do compile { target { fpic && ia32 } } } */
++/* { dg-require-profiling "-pg" } */
++/* { dg-options "-O2 -pg -mno-fentry -fno-shrink-wrap -fno-pic" } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr120881-2a.c b/gcc/testsuite/gcc.target/i386/pr120881-2a.c
+new file mode 100644
+index 000000000000..52e3e5292e5f
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr120881-2a.c
+@@ -0,0 +1,21 @@
++/* { dg-do compile { target fentry } } */
++/* { dg-options "-O2 -pg" } */
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.} } } */
++
++/*
++**f2:
++**.LFB[0-9]+:
++** .cfi_startproc
++** call __fentry__
++**...
++*/
++
++extern void f1 (void);
++
++void
++f2 (int count)
++{
++ for (int i = 0; i < count; ++i)
++ f1 ();
++}
+diff --git a/gcc/testsuite/gcc.target/i386/pr120881-2b.c b/gcc/testsuite/gcc.target/i386/pr120881-2b.c
+new file mode 100644
+index 000000000000..43a12f007749
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr120881-2b.c
+@@ -0,0 +1,6 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue -march=x86-64" } */
++/* { dg-final { scan-rtl-dump "Now spread 1 times" "pro_and_epilogue" } } */
++
++#include "pr120881-2a.c"
++
+diff --git a/gcc/testsuite/gcc.target/i386/pr82699-1.c b/gcc/testsuite/gcc.target/i386/pr82699-1.c
+index 272d0797ff8f..96e3ccb27076 100644
+--- a/gcc/testsuite/gcc.target/i386/pr82699-1.c
++++ b/gcc/testsuite/gcc.target/i386/pr82699-1.c
+@@ -1,5 +1,5 @@
+ /* { dg-do compile { target *-*-linux* } } */
+-/* { dg-options "-O2 -fno-pic -fcf-protection -pg -fasynchronous-unwind-tables" } */
++/* { dg-options "-O2 -mfentry -fno-pic -fcf-protection -pg -fasynchronous-unwind-tables" } */
+ /* { dg-final { scan-assembler-times {\t\.cfi_startproc\n\tendbr} 1 } } */
+
+ extern int bar (int);
+diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
+index 9ab46a0eab43..c37a30a32ed4 100644
+--- a/gcc/testsuite/lib/target-supports.exp
++++ b/gcc/testsuite/lib/target-supports.exp
+@@ -14528,3 +14528,51 @@ proc check_effective_target_foldable_pi_based_trigonometry { } {
+ }
+ }]
+ }
++#
++# Return 1 if the x86-64 target enables -mfentry by default, 0
++# otherwise. Cache the result.
++
++proc check_effective_target_fentry { } {
++ global tool
++ global GCC_UNDER_TEST
++
++ if { ![check_effective_target_x86] } {
++ return 0
++ }
++
++ # Need auto-host.h to check linker support.
++ if { ![file exists ../../auto-host.h ] } {
++ return 0
++ }
++
++ return [check_cached_effective_target fentry {
++ # Set up and compile to see if ENABLE_X86_64_MFENTRY is
++ # non-zero. Include the current process ID in the file
++ # names to prevent conflicts with invocations for multiple
++ # testsuites.
++
++ set src pie[pid].c
++ set obj pie[pid].o
++
++ set f [open $src "w"]
++ puts $f "#include \"../../auto-host.h\""
++ puts $f "#if ENABLE_X86_64_MFENTRY == 0 || !defined __x86_64__"
++ puts $f "# error -mfentry is not enabled by default."
++ puts $f "#endif"
++ close $f
++
++ verbose "check_effective_target_fentry compiling testfile $src" 2
++ set lines [${tool}_target_compile $src $obj object ""]
++
++ file delete $src
++ file delete $obj
++
++ if [string match "" $lines] then {
++ verbose "check_effective_target_fentry testfile compilation passed" 2
++ return 1
++ } else {
++ verbose "check_effective_target_fentry testfile compilation failed" 2
++ return 0
++ }
++ }]
++}
+
+base-commit: 598455fd73b2061e461c54c18fae8bcc2b4b6d72
+--
+2.50.1
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index f54456e..6c31a82 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -3,6 +3,7 @@
- 85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
- 86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch
+ 85_all_PR120987-ipa-modref-typo.patch
+ + 86_all_PR120881-x86-64-Add-enable-x86-64-mfentry.patch
5 6 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-12 15:24 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-12 15:24 UTC (permalink / raw
To: gentoo-commits
commit: fe1f0199d8773ec7dffa4b7b7c26b1dd56cf6fd6
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 12 15:23:58 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jul 12 15:23:58 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=fe1f0199
16.0.0: add patch link
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/85_all_PR120987-ipa-modref-typo.patch | 2 ++
1 file changed, 2 insertions(+)
diff --git a/16.0.0/gentoo/85_all_PR120987-ipa-modref-typo.patch b/16.0.0/gentoo/85_all_PR120987-ipa-modref-typo.patch
index fdd82ef..da78bb7 100644
--- a/16.0.0/gentoo/85_all_PR120987-ipa-modref-typo.patch
+++ b/16.0.0/gentoo/85_all_PR120987-ipa-modref-typo.patch
@@ -1,3 +1,5 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120987#c20
+
From 7c782da4518edbc4e6ae5a8ca8ee319f362af437 Mon Sep 17 00:00:00 2001
Message-ID: <7c782da4518edbc4e6ae5a8ca8ee319f362af437.1752333776.git.sam@gentoo.org>
From: Sam James <sam@gentoo.org>
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-12 15:23 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-12 15:23 UTC (permalink / raw
To: gentoo-commits
commit: c23cb039297642d628b837d2c7e09eced60b0ed5
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 12 15:23:30 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jul 12 15:23:30 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=c23cb039
16.0.0: add ipa-modref typo fix
Bug: https://gcc.gnu.org/PR120987
Signed-off-by: Sam James <sam <AT> gentoo.org>
.../gentoo/85_all_PR120987-ipa-modref-typo.patch | 34 ++++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 35 insertions(+)
diff --git a/16.0.0/gentoo/85_all_PR120987-ipa-modref-typo.patch b/16.0.0/gentoo/85_all_PR120987-ipa-modref-typo.patch
new file mode 100644
index 0000000..fdd82ef
--- /dev/null
+++ b/16.0.0/gentoo/85_all_PR120987-ipa-modref-typo.patch
@@ -0,0 +1,34 @@
+From 7c782da4518edbc4e6ae5a8ca8ee319f362af437 Mon Sep 17 00:00:00 2001
+Message-ID: <7c782da4518edbc4e6ae5a8ca8ee319f362af437.1752333776.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Sat, 12 Jul 2025 16:22:02 +0100
+Subject: [PATCH] ipa-modref: don't call flags_from_decl_or_type on
+ non-inlined_to node
+
+ PR ipa/120987
+
+gcc/ChangeLog:
+
+ * ipa-modref.cc (ipa_merge_modref_summary_after_inlining): Drop
+ duplicate, unguarded flags_from_decl_or_type call.
+---
+ gcc/ipa-modref.cc | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/gcc/ipa-modref.cc b/gcc/ipa-modref.cc
+index d3e510195b53..cbf5042d14bf 100644
+--- a/gcc/ipa-modref.cc
++++ b/gcc/ipa-modref.cc
+@@ -5347,7 +5347,6 @@ ipa_merge_modref_summary_after_inlining (cgraph_edge *edge)
+ cgraph_node *n;
+ for (n = edge->caller; n->inlined_to; n = n->callers->caller)
+ flags |= flags_from_decl_or_type (n->decl);
+- flags |= flags_from_decl_or_type (n->decl);
+ bool ignore_stores = ignore_stores_p (edge->caller->decl, flags);
+
+ if (!callee_info && to_info)
+
+base-commit: e6d3c88e7bb07f94308074f9751e4384a191e022
+--
+2.50.1
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 48846cc..f54456e 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -2,6 +2,7 @@
- 85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
- 86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch
+ + 85_all_PR120987-ipa-modref-typo.patch
5 6 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-10 12:34 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-10 12:34 UTC (permalink / raw
To: gentoo-commits
commit: 3334eb199f61b84566232cf91bfa4ccc0629b607
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 10 12:33:52 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jul 10 12:33:52 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=3334eb19
16.0.0: drop Blender patch
It's changed a few times and received a nack on ML.
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/85_all_PR121015-blender.patch | 249 ----------------------------
16.0.0/gentoo/README.history | 1 -
2 files changed, 250 deletions(-)
diff --git a/16.0.0/gentoo/85_all_PR121015-blender.patch b/16.0.0/gentoo/85_all_PR121015-blender.patch
deleted file mode 100644
index 383589c..0000000
--- a/16.0.0/gentoo/85_all_PR121015-blender.patch
+++ /dev/null
@@ -1,249 +0,0 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121015#c5
-
-From 9f7e70f5e1172650653e13554d984ec9d7e50298 Mon Sep 17 00:00:00 2001
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Thu, 10 Jul 2025 06:21:58 +0800
-Subject: [PATCH] x86: Handle integer all 1s vectors in mmx.md
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-commit 77473a27bae04da99d6979d43e7bd0a8106f4557
-Author: H.J. Lu <hjl.tools@gmail.com>
-Date: Thu Jun 26 06:08:51 2025 +0800
-
- x86: Also handle all 1s float vector constant
-
-replaces
-
-(insn 29 28 30 5 (set (reg:V2SF 107)
- (mem/u/c:V2SF (symbol_ref/u:DI ("*.LC0") [flags 0x2]) [0 S8 A64])) 2031 {*movv2sf_internal}
- (expr_list:REG_EQUAL (const_vector:V2SF [
- (const_double:SF -QNaN [-QNaN]) repeated x2
- ])
- (nil)))
-
-with
-
-(insn 98 13 14 3 (set (reg:V8QI 112)
- (const_vector:V8QI [
- (const_int -1 [0xffffffffffffffff]) repeated x8
- ])) -1
- (nil))
-...
-(insn 29 28 30 5 (set (reg:V2SF 107)
- (subreg:V2SF (reg:V8QI 112) 0)) 2031 {*movv2sf_internal}
- (expr_list:REG_EQUAL (const_vector:V2SF [
- (const_double:SF -QNaN [-QNaN]) repeated x2
- ])
- (nil)))
-
-which leads to
-
-pr121015.c: In function ‘render_result_from_bake_h’:
-pr121015.c:34:1: error: unrecognizable insn:
- 34 | }
- | ^
-(insn 98 13 14 3 (set (reg:V8QI 112)
- (const_vector:V8QI [
- (const_int -1 [0xffffffffffffffff]) repeated x8
- ])) -1
- (expr_list:REG_EQUIV (const_vector:V8QI [
- (const_int -1 [0xffffffffffffffff]) repeated x8
- ])
- (nil)))
-during RTL pass: ira
-
-1. Update constm1_operand to also return true for integer and float all
-1s vectors.
-2. Add nonimm_or_0_or_m1_operand for nonimmediate, zero or -1 operand.
-3. Add BI for constant all 0s/1s operand.
-4. Update "*mov<mode>_internal" in mmx.md to handle integer all 1s vectors.
-5. Update MMXMODE move splitter to also split all 1s source operand.
-
-gcc/
-
- PR target/121015
- * config/i386/constraints.md (BI): New constraint.
- * config/i386/i386.cc (ix86_print_operand): Support CONSTM1_RTX.
- * config/i386/mmx.md (*mov<mode>_internal): Replace C with BI
- memory and integer register destination.
- Update MMXMODE move splitter to also split all 1s source operand.
- * config/i386/predicates.md (constm1_operand): Also return true
- for int_float_vector_all_ones_operand.
- (nonimm_or_0_or_m1_operand): New predicate.
-
-gcc/testsuite/
-
- PR target/121015
- * gcc.target/i386/pr121015.c: New test.
-
-Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
----
- gcc/config/i386/constraints.md | 5 ++++
- gcc/config/i386/i386.cc | 7 ++++--
- gcc/config/i386/mmx.md | 8 +++---
- gcc/config/i386/predicates.md | 26 +++++++++++--------
- gcc/testsuite/gcc.target/i386/pr121015.c | 32 ++++++++++++++++++++++++
- 5 files changed, 62 insertions(+), 16 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr121015.c
-
-diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
-index 38877a7e61b..b436893bce4 100644
---- a/gcc/config/i386/constraints.md
-+++ b/gcc/config/i386/constraints.md
-@@ -173,6 +173,7 @@ (define_register_constraint "YW"
- ;; H Integer SSE constant that is 128/256bit all ones
- ;; and zero-extand to 256/512bit, or 128bit all ones
- ;; and zero-extend to 512bit.
-+;; I Integer vector constant with all 0s/1s operand.
- ;; M x86-64 memory operand.
-
- (define_constraint "Bf"
-@@ -237,6 +238,10 @@ (define_constraint "BH"
- (ior (match_operand 0 "vector_all_ones_zero_extend_half_operand")
- (match_operand 0 "vector_all_ones_zero_extend_quarter_operand")))
-
-+(define_constraint "BI"
-+ "@internal constant all 0s/1s operand."
-+ (match_operand 0 "const0_or_m1_operand"))
-+
- ;; NB: Similar to 'm', but don't use define_memory_constraint on x86-64
- ;; to prevent LRA from converting the operand to the form '(mem (reg X))'
- ;; where X is a base register.
-diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
-index ad7360ec71a..6c7cc7c15f2 100644
---- a/gcc/config/i386/i386.cc
-+++ b/gcc/config/i386/i386.cc
-@@ -14671,9 +14671,12 @@ ix86_print_operand (FILE *file, rtx x, int code)
- since we can in fact encode that into an immediate. */
- if (GET_CODE (x) == CONST_VECTOR)
- {
-- if (x != CONST0_RTX (GET_MODE (x)))
-+ if (x == CONST0_RTX (GET_MODE (x)))
-+ x = const0_rtx;
-+ else if (x == CONSTM1_RTX (GET_MODE (x)))
-+ x = constm1_rtx;
-+ else
- output_operand_lossage ("invalid vector immediate");
-- x = const0_rtx;
- }
-
- if (code == 'P')
-diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
-index 79202323e53..d9020ef3da6 100644
---- a/gcc/config/i386/mmx.md
-+++ b/gcc/config/i386/mmx.md
-@@ -183,9 +183,9 @@ (define_expand "mov<mode>"
-
- (define_insn "*mov<mode>_internal"
- [(set (match_operand:MMXMODE 0 "nonimmediate_operand"
-- "=r ,o ,r,r ,m ,?!y,!y,?!y,m ,r ,?!y,v,v,v,m,r,v,!y,*x")
-- (match_operand:MMXMODE 1 "nonimm_or_0_operand"
-- "rCo,rC,C,rm,rC,C ,!y,m ,?!y,?!y,r ,C,v,m,v,v,r,*x,!y"))]
-+ "=r ,o ,r ,r ,m ,?!y,!y,?!y,m ,r ,?!y,v,v,v,m,r,v,!y,*x")
-+ (match_operand:MMXMODE 1 "nonimm_or_0_or_m1_operand"
-+ "rBIo,rBI,BI,rm,rBI,C ,!y,m ,?!y,?!y,r ,C,v,m,v,v,r,*x,!y"))]
- "(TARGET_MMX || TARGET_MMX_WITH_SSE)
- && !(MEM_P (operands[0]) && MEM_P (operands[1]))
- && ix86_hardreg_mov_ok (operands[0], operands[1])"
-@@ -313,7 +313,7 @@ (define_split
-
- (define_split
- [(set (match_operand:MMXMODE 0 "nonimmediate_gr_operand")
-- (match_operand:MMXMODE 1 "const0_operand"))]
-+ (match_operand:MMXMODE 1 "const0_or_m1_operand"))]
- "!TARGET_64BIT && reload_completed"
- [(const_int 0)]
- "ix86_split_long_move (operands); DONE;")
-diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
-index 3afaf83a7a0..7def9b89b48 100644
---- a/gcc/config/i386/predicates.md
-+++ b/gcc/config/i386/predicates.md
-@@ -833,16 +833,6 @@ (define_predicate "const1_operand"
- return op == CONST1_RTX (mode);
- })
-
--;; Match exactly -1.
--(define_predicate "constm1_operand"
-- (and (match_code "const_int")
-- (match_test "op == constm1_rtx")))
--
--;; Match 0 or -1.
--(define_predicate "const0_or_m1_operand"
-- (ior (match_operand 0 "const0_operand")
-- (match_operand 0 "constm1_operand")))
--
- ;; Match exactly eight.
- (define_predicate "const8_operand"
- (and (match_code "const_int")
-@@ -1218,6 +1208,17 @@ (define_predicate "int_float_vector_all_ones_operand"
- (match_operand 0 "float_vector_all_ones_operand")
- (match_test "op == constm1_rtx")))
-
-+;; Match exactly -1.
-+(define_predicate "constm1_operand"
-+ (ior (and (match_code "const_int")
-+ (match_test "op == constm1_rtx"))
-+ (match_operand 0 "int_float_vector_all_ones_operand")))
-+
-+;; Match 0 or -1.
-+(define_predicate "const0_or_m1_operand"
-+ (ior (match_operand 0 "const0_operand")
-+ (match_operand 0 "constm1_operand")))
-+
- /* Return true if operand is an 128/256bit all ones vector
- that zero-extends to 256/512bit. */
- (define_predicate "vector_all_ones_zero_extend_half_operand"
-@@ -1359,6 +1360,11 @@ (define_predicate "nonimm_or_0_operand"
- (ior (match_operand 0 "nonimmediate_operand")
- (match_operand 0 "const0_operand")))
-
-+; Return true when OP is a nonimmediate, zero or -1.
-+(define_predicate "nonimm_or_0_or_m1_operand"
-+ (ior (match_operand 0 "nonimmediate_operand")
-+ (match_operand 0 "const0_or_m1_operand")))
-+
- ; Return true when OP is a nonimmediate or zero or all ones.
- (define_predicate "nonimm_or_0_or_1s_operand"
- (ior (match_operand 0 "nonimmediate_operand")
-diff --git a/gcc/testsuite/gcc.target/i386/pr121015.c b/gcc/testsuite/gcc.target/i386/pr121015.c
-new file mode 100644
-index 00000000000..57c8bff14ef
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr121015.c
-@@ -0,0 +1,32 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -march=x86-64-v3" } */
-+
-+extern union {
-+ int i;
-+ float f;
-+} int_as_float_u;
-+
-+extern int render_result_from_bake_w;
-+extern int render_result_from_bake_h_seed_pass;
-+extern float *render_result_from_bake_h_primitive;
-+extern float *render_result_from_bake_h_seed;
-+
-+float
-+int_as_float(int i)
-+{
-+ int_as_float_u.i = i;
-+ return int_as_float_u.f;
-+}
-+
-+void
-+render_result_from_bake_h(int tx)
-+{
-+ while (render_result_from_bake_w) {
-+ for (; tx < render_result_from_bake_w; tx++)
-+ render_result_from_bake_h_primitive[1] =
-+ render_result_from_bake_h_primitive[2] = int_as_float(-1);
-+ if (render_result_from_bake_h_seed_pass) {
-+ *render_result_from_bake_h_seed = 0;
-+ }
-+ }
-+}
---
-2.50.0
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index caee4e9..48846cc 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -2,7 +2,6 @@
- 85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
- 86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch
- + 85_all_PR121015-blender.patch
5 6 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-10 1:22 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-10 1:22 UTC (permalink / raw
To: gentoo-commits
commit: e50f848e50400f359967baa430c3f1ad9665018d
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 10 01:22:10 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jul 10 01:22:10 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=e50f848e
16.0.0: update Blender patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/85_all_PR121015-blender.patch | 252 +++++++++++++++-------------
1 file changed, 136 insertions(+), 116 deletions(-)
diff --git a/16.0.0/gentoo/85_all_PR121015-blender.patch b/16.0.0/gentoo/85_all_PR121015-blender.patch
index 3adc1a7..383589c 100644
--- a/16.0.0/gentoo/85_all_PR121015-blender.patch
+++ b/16.0.0/gentoo/85_all_PR121015-blender.patch
@@ -1,9 +1,9 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121015#c4
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121015#c5
-From 0ded000129390b21ec7dbab8db4cf64f85915ba6 Mon Sep 17 00:00:00 2001
+From 9f7e70f5e1172650653e13554d984ec9d7e50298 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 10 Jul 2025 06:21:58 +0800
-Subject: [PATCH] x86: Handle broadcast all 1s to V8QI
+Subject: [PATCH] x86: Handle integer all 1s vectors in mmx.md
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@@ -54,30 +54,24 @@ pr121015.c:34:1: error: unrecognizable insn:
(nil)))
during RTL pass: ira
-Generate
-
-(insn 99 13 98 3 (set (reg:V16QI 113)
- (const_vector:V16QI [
- (const_int -1 [0xffffffffffffffff]) repeated x16
- ])) -1
- (nil))
-(insn 98 99 14 3 (set (reg:V8QI 112)
- (subreg:V8QI (reg:V16QI 113) 0)) -1
- (nil))
-
-instead of
-
-(insn 98 13 14 3 (set (reg:V8QI 112)
- (const_vector:V8QI [
- (const_int -1 [0xffffffffffffffff]) repeated x8
- ])) -1
- (nil))
+1. Update constm1_operand to also return true for integer and float all
+1s vectors.
+2. Add nonimm_or_0_or_m1_operand for nonimmediate, zero or -1 operand.
+3. Add BI for constant all 0s/1s operand.
+4. Update "*mov<mode>_internal" in mmx.md to handle integer all 1s vectors.
+5. Update MMXMODE move splitter to also split all 1s source operand.
gcc/
PR target/121015
- * config/i386/i386-features.cc (ix86_place_single_vector_set):
- Handle broadcast all 1s to V8QI.
+ * config/i386/constraints.md (BI): New constraint.
+ * config/i386/i386.cc (ix86_print_operand): Support CONSTM1_RTX.
+ * config/i386/mmx.md (*mov<mode>_internal): Replace C with BI
+ memory and integer register destination.
+ Update MMXMODE move splitter to also split all 1s source operand.
+ * config/i386/predicates.md (constm1_operand): Also return true
+ for int_float_vector_all_ones_operand.
+ (nonimm_or_0_or_m1_operand): New predicate.
gcc/testsuite/
@@ -86,115 +80,141 @@ gcc/testsuite/
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
- gcc/config/i386/i386-features.cc | 60 +++++++++++++++++-------
- gcc/testsuite/gcc.target/i386/pr121015.c | 34 ++++++++++++++
- 2 files changed, 78 insertions(+), 16 deletions(-)
+ gcc/config/i386/constraints.md | 5 ++++
+ gcc/config/i386/i386.cc | 7 ++++--
+ gcc/config/i386/mmx.md | 8 +++---
+ gcc/config/i386/predicates.md | 26 +++++++++++--------
+ gcc/testsuite/gcc.target/i386/pr121015.c | 32 ++++++++++++++++++++++++
+ 5 files changed, 62 insertions(+), 16 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr121015.c
-diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
-index 054f8d5ddc8..f7629644380 100644
---- a/gcc/config/i386/i386-features.cc
-+++ b/gcc/config/i386/i386-features.cc
-@@ -3085,6 +3085,9 @@ ix86_rpad_gate ()
- && optimize_function_for_speed_p (cfun));
- }
+diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
+index 38877a7e61b..b436893bce4 100644
+--- a/gcc/config/i386/constraints.md
++++ b/gcc/config/i386/constraints.md
+@@ -173,6 +173,7 @@ (define_register_constraint "YW"
+ ;; H Integer SSE constant that is 128/256bit all ones
+ ;; and zero-extand to 256/512bit, or 128bit all ones
+ ;; and zero-extend to 512bit.
++;; I Integer vector constant with all 0s/1s operand.
+ ;; M x86-64 memory operand.
-+static machine_mode ix86_get_vector_cse_mode (unsigned int,
-+ machine_mode smode);
-+
- /* Generate a vector set, DEST = SRC, at entry of the nearest dominator
- for basic block map BBS, which is in the fake loop that contains the
- whole function, so that there is only a single vector set in the
-@@ -3101,6 +3104,26 @@ ix86_place_single_vector_set (rtx dest, rtx src, bitmap bbs,
- bb = get_immediate_dominator (CDI_DOMINATORS,
- bb->loop_father->header);
+ (define_constraint "Bf"
+@@ -237,6 +238,10 @@ (define_constraint "BH"
+ (ior (match_operand 0 "vector_all_ones_zero_extend_half_operand")
+ (match_operand 0 "vector_all_ones_zero_extend_quarter_operand")))
-+ machine_mode mode = GET_MODE (dest);
-+ rtx set_xmm = nullptr;
-+ rtx_insn *set_xmm_insn = nullptr;
-+ if (GET_MODE_SIZE (mode) < 16)
-+ {
-+ /* Handle
++(define_constraint "BI"
++ "@internal constant all 0s/1s operand."
++ (match_operand 0 "const0_or_m1_operand"))
+
-+ (const_vector:V8QI
-+ [(const_int -1 [0xffffffffffffffff]) repeated x8 ])
-+
-+ */
-+ if (src != CONSTM1_RTX (mode))
-+ gcc_unreachable ();
-+ machine_mode xmm_mode
-+ = ix86_get_vector_cse_mode (16, GET_MODE_INNER (mode));
-+ rtx xmm_src = gen_reg_rtx (xmm_mode);
-+ set_xmm = gen_rtx_SET (xmm_src, CONSTM1_RTX (xmm_mode));
-+ src = gen_rtx_SUBREG (mode, xmm_src, 0);
-+ }
-+
- rtx set = gen_rtx_SET (dest, src);
+ ;; NB: Similar to 'm', but don't use define_memory_constraint on x86-64
+ ;; to prevent LRA from converting the operand to the form '(mem (reg X))'
+ ;; where X is a base register.
+diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
+index ad7360ec71a..6c7cc7c15f2 100644
+--- a/gcc/config/i386/i386.cc
++++ b/gcc/config/i386/i386.cc
+@@ -14671,9 +14671,12 @@ ix86_print_operand (FILE *file, rtx x, int code)
+ since we can in fact encode that into an immediate. */
+ if (GET_CODE (x) == CONST_VECTOR)
+ {
+- if (x != CONST0_RTX (GET_MODE (x)))
++ if (x == CONST0_RTX (GET_MODE (x)))
++ x = const0_rtx;
++ else if (x == CONSTM1_RTX (GET_MODE (x)))
++ x = constm1_rtx;
++ else
+ output_operand_lossage ("invalid vector immediate");
+- x = const0_rtx;
+ }
- rtx_insn *insn = BB_HEAD (bb);
-@@ -3114,31 +3137,36 @@ ix86_place_single_vector_set (rtx dest, rtx src, bitmap bbs,
- insn = NEXT_INSN (insn);
- }
+ if (code == 'P')
+diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
+index 79202323e53..d9020ef3da6 100644
+--- a/gcc/config/i386/mmx.md
++++ b/gcc/config/i386/mmx.md
+@@ -183,9 +183,9 @@ (define_expand "mov<mode>"
-+ rtx_insn *after = nullptr;
- rtx_insn *set_insn;
- if (insn == BB_HEAD (bb))
-- {
-- set_insn = emit_insn_before (set, insn);
-- if (dump_file)
-- {
-- fprintf (dump_file, "\nPlace:\n\n");
-- print_rtl_single (dump_file, set_insn);
-- fprintf (dump_file, "\nbefore:\n\n");
-- print_rtl_single (dump_file, insn);
-- fprintf (dump_file, "\n");
-- }
-- }
-+ set_insn = emit_insn_before (set, insn);
- else
- {
-- rtx_insn *after = insn ? PREV_INSN (insn) : BB_END (bb);
-+ after = insn ? PREV_INSN (insn) : BB_END (bb);
- set_insn = emit_insn_after (set, after);
-- if (dump_file)
-+ }
+ (define_insn "*mov<mode>_internal"
+ [(set (match_operand:MMXMODE 0 "nonimmediate_operand"
+- "=r ,o ,r,r ,m ,?!y,!y,?!y,m ,r ,?!y,v,v,v,m,r,v,!y,*x")
+- (match_operand:MMXMODE 1 "nonimm_or_0_operand"
+- "rCo,rC,C,rm,rC,C ,!y,m ,?!y,?!y,r ,C,v,m,v,v,r,*x,!y"))]
++ "=r ,o ,r ,r ,m ,?!y,!y,?!y,m ,r ,?!y,v,v,v,m,r,v,!y,*x")
++ (match_operand:MMXMODE 1 "nonimm_or_0_or_m1_operand"
++ "rBIo,rBI,BI,rm,rBI,C ,!y,m ,?!y,?!y,r ,C,v,m,v,v,r,*x,!y"))]
+ "(TARGET_MMX || TARGET_MMX_WITH_SSE)
+ && !(MEM_P (operands[0]) && MEM_P (operands[1]))
+ && ix86_hardreg_mov_ok (operands[0], operands[1])"
+@@ -313,7 +313,7 @@ (define_split
+
+ (define_split
+ [(set (match_operand:MMXMODE 0 "nonimmediate_gr_operand")
+- (match_operand:MMXMODE 1 "const0_operand"))]
++ (match_operand:MMXMODE 1 "const0_or_m1_operand"))]
+ "!TARGET_64BIT && reload_completed"
+ [(const_int 0)]
+ "ix86_split_long_move (operands); DONE;")
+diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
+index 3afaf83a7a0..7def9b89b48 100644
+--- a/gcc/config/i386/predicates.md
++++ b/gcc/config/i386/predicates.md
+@@ -833,16 +833,6 @@ (define_predicate "const1_operand"
+ return op == CONST1_RTX (mode);
+ })
+
+-;; Match exactly -1.
+-(define_predicate "constm1_operand"
+- (and (match_code "const_int")
+- (match_test "op == constm1_rtx")))
+-
+-;; Match 0 or -1.
+-(define_predicate "const0_or_m1_operand"
+- (ior (match_operand 0 "const0_operand")
+- (match_operand 0 "constm1_operand")))
+-
+ ;; Match exactly eight.
+ (define_predicate "const8_operand"
+ (and (match_code "const_int")
+@@ -1218,6 +1208,17 @@ (define_predicate "int_float_vector_all_ones_operand"
+ (match_operand 0 "float_vector_all_ones_operand")
+ (match_test "op == constm1_rtx")))
+
++;; Match exactly -1.
++(define_predicate "constm1_operand"
++ (ior (and (match_code "const_int")
++ (match_test "op == constm1_rtx"))
++ (match_operand 0 "int_float_vector_all_ones_operand")))
+
-+ if (set_xmm)
-+ set_xmm_insn = emit_insn_before (set_xmm, set_insn);
++;; Match 0 or -1.
++(define_predicate "const0_or_m1_operand"
++ (ior (match_operand 0 "const0_operand")
++ (match_operand 0 "constm1_operand")))
+
-+ if (dump_file)
-+ {
-+ fprintf (dump_file, "\nPlace:\n\n");
-+ if (set_xmm_insn)
-+ print_rtl_single (dump_file, set_xmm_insn);
-+ print_rtl_single (dump_file, set_insn);
-+ if (after)
- {
-- fprintf (dump_file, "\nPlace:\n\n");
-- print_rtl_single (dump_file, set_insn);
- fprintf (dump_file, "\nafter:\n\n");
- print_rtl_single (dump_file, after);
-- fprintf (dump_file, "\n");
- }
-+ else
-+ {
-+ fprintf (dump_file, "\nbefore:\n\n");
-+ print_rtl_single (dump_file, insn);
-+ }
-+ fprintf (dump_file, "\n");
- }
+ /* Return true if operand is an 128/256bit all ones vector
+ that zero-extends to 256/512bit. */
+ (define_predicate "vector_all_ones_zero_extend_half_operand"
+@@ -1359,6 +1360,11 @@ (define_predicate "nonimm_or_0_operand"
+ (ior (match_operand 0 "nonimmediate_operand")
+ (match_operand 0 "const0_operand")))
- if (inner_scalar)
++; Return true when OP is a nonimmediate, zero or -1.
++(define_predicate "nonimm_or_0_or_m1_operand"
++ (ior (match_operand 0 "nonimmediate_operand")
++ (match_operand 0 "const0_or_m1_operand")))
++
+ ; Return true when OP is a nonimmediate or zero or all ones.
+ (define_predicate "nonimm_or_0_or_1s_operand"
+ (ior (match_operand 0 "nonimmediate_operand")
diff --git a/gcc/testsuite/gcc.target/i386/pr121015.c b/gcc/testsuite/gcc.target/i386/pr121015.c
new file mode 100644
-index 00000000000..ad1fdccf50c
+index 00000000000..57c8bff14ef
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr121015.c
-@@ -0,0 +1,34 @@
+@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=x86-64-v3" } */
-+/* { dg-final { scan-assembler-times "vpcmpeq" 1 { target { ! ia32 } } } } */
-+/* { dg-final { scan-assembler-not "\.long\[ \t\]+-1\n" { target { ! ia32 } } } } */
+
+extern union {
+ int i;
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-10 0:50 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-10 0:50 UTC (permalink / raw
To: gentoo-commits
commit: 0524bc303ca3c2207a9b100719e21ab4a51c7e2e
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 10 00:50:14 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jul 10 00:50:14 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=0524bc30
16.0.0: add fix for Blender
Bug: https://gcc.gnu.org/PR121015
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/85_all_PR121015-blender.patch | 229 ++++++++++++++++++++++++++++
16.0.0/gentoo/README.history | 1 +
2 files changed, 230 insertions(+)
diff --git a/16.0.0/gentoo/85_all_PR121015-blender.patch b/16.0.0/gentoo/85_all_PR121015-blender.patch
new file mode 100644
index 0000000..3adc1a7
--- /dev/null
+++ b/16.0.0/gentoo/85_all_PR121015-blender.patch
@@ -0,0 +1,229 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121015#c4
+
+From 0ded000129390b21ec7dbab8db4cf64f85915ba6 Mon Sep 17 00:00:00 2001
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Thu, 10 Jul 2025 06:21:58 +0800
+Subject: [PATCH] x86: Handle broadcast all 1s to V8QI
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+commit 77473a27bae04da99d6979d43e7bd0a8106f4557
+Author: H.J. Lu <hjl.tools@gmail.com>
+Date: Thu Jun 26 06:08:51 2025 +0800
+
+ x86: Also handle all 1s float vector constant
+
+replaces
+
+(insn 29 28 30 5 (set (reg:V2SF 107)
+ (mem/u/c:V2SF (symbol_ref/u:DI ("*.LC0") [flags 0x2]) [0 S8 A64])) 2031 {*movv2sf_internal}
+ (expr_list:REG_EQUAL (const_vector:V2SF [
+ (const_double:SF -QNaN [-QNaN]) repeated x2
+ ])
+ (nil)))
+
+with
+
+(insn 98 13 14 3 (set (reg:V8QI 112)
+ (const_vector:V8QI [
+ (const_int -1 [0xffffffffffffffff]) repeated x8
+ ])) -1
+ (nil))
+...
+(insn 29 28 30 5 (set (reg:V2SF 107)
+ (subreg:V2SF (reg:V8QI 112) 0)) 2031 {*movv2sf_internal}
+ (expr_list:REG_EQUAL (const_vector:V2SF [
+ (const_double:SF -QNaN [-QNaN]) repeated x2
+ ])
+ (nil)))
+
+which leads to
+
+pr121015.c: In function ‘render_result_from_bake_h’:
+pr121015.c:34:1: error: unrecognizable insn:
+ 34 | }
+ | ^
+(insn 98 13 14 3 (set (reg:V8QI 112)
+ (const_vector:V8QI [
+ (const_int -1 [0xffffffffffffffff]) repeated x8
+ ])) -1
+ (expr_list:REG_EQUIV (const_vector:V8QI [
+ (const_int -1 [0xffffffffffffffff]) repeated x8
+ ])
+ (nil)))
+during RTL pass: ira
+
+Generate
+
+(insn 99 13 98 3 (set (reg:V16QI 113)
+ (const_vector:V16QI [
+ (const_int -1 [0xffffffffffffffff]) repeated x16
+ ])) -1
+ (nil))
+(insn 98 99 14 3 (set (reg:V8QI 112)
+ (subreg:V8QI (reg:V16QI 113) 0)) -1
+ (nil))
+
+instead of
+
+(insn 98 13 14 3 (set (reg:V8QI 112)
+ (const_vector:V8QI [
+ (const_int -1 [0xffffffffffffffff]) repeated x8
+ ])) -1
+ (nil))
+
+gcc/
+
+ PR target/121015
+ * config/i386/i386-features.cc (ix86_place_single_vector_set):
+ Handle broadcast all 1s to V8QI.
+
+gcc/testsuite/
+
+ PR target/121015
+ * gcc.target/i386/pr121015.c: New test.
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+---
+ gcc/config/i386/i386-features.cc | 60 +++++++++++++++++-------
+ gcc/testsuite/gcc.target/i386/pr121015.c | 34 ++++++++++++++
+ 2 files changed, 78 insertions(+), 16 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr121015.c
+
+diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
+index 054f8d5ddc8..f7629644380 100644
+--- a/gcc/config/i386/i386-features.cc
++++ b/gcc/config/i386/i386-features.cc
+@@ -3085,6 +3085,9 @@ ix86_rpad_gate ()
+ && optimize_function_for_speed_p (cfun));
+ }
+
++static machine_mode ix86_get_vector_cse_mode (unsigned int,
++ machine_mode smode);
++
+ /* Generate a vector set, DEST = SRC, at entry of the nearest dominator
+ for basic block map BBS, which is in the fake loop that contains the
+ whole function, so that there is only a single vector set in the
+@@ -3101,6 +3104,26 @@ ix86_place_single_vector_set (rtx dest, rtx src, bitmap bbs,
+ bb = get_immediate_dominator (CDI_DOMINATORS,
+ bb->loop_father->header);
+
++ machine_mode mode = GET_MODE (dest);
++ rtx set_xmm = nullptr;
++ rtx_insn *set_xmm_insn = nullptr;
++ if (GET_MODE_SIZE (mode) < 16)
++ {
++ /* Handle
++
++ (const_vector:V8QI
++ [(const_int -1 [0xffffffffffffffff]) repeated x8 ])
++
++ */
++ if (src != CONSTM1_RTX (mode))
++ gcc_unreachable ();
++ machine_mode xmm_mode
++ = ix86_get_vector_cse_mode (16, GET_MODE_INNER (mode));
++ rtx xmm_src = gen_reg_rtx (xmm_mode);
++ set_xmm = gen_rtx_SET (xmm_src, CONSTM1_RTX (xmm_mode));
++ src = gen_rtx_SUBREG (mode, xmm_src, 0);
++ }
++
+ rtx set = gen_rtx_SET (dest, src);
+
+ rtx_insn *insn = BB_HEAD (bb);
+@@ -3114,31 +3137,36 @@ ix86_place_single_vector_set (rtx dest, rtx src, bitmap bbs,
+ insn = NEXT_INSN (insn);
+ }
+
++ rtx_insn *after = nullptr;
+ rtx_insn *set_insn;
+ if (insn == BB_HEAD (bb))
+- {
+- set_insn = emit_insn_before (set, insn);
+- if (dump_file)
+- {
+- fprintf (dump_file, "\nPlace:\n\n");
+- print_rtl_single (dump_file, set_insn);
+- fprintf (dump_file, "\nbefore:\n\n");
+- print_rtl_single (dump_file, insn);
+- fprintf (dump_file, "\n");
+- }
+- }
++ set_insn = emit_insn_before (set, insn);
+ else
+ {
+- rtx_insn *after = insn ? PREV_INSN (insn) : BB_END (bb);
++ after = insn ? PREV_INSN (insn) : BB_END (bb);
+ set_insn = emit_insn_after (set, after);
+- if (dump_file)
++ }
++
++ if (set_xmm)
++ set_xmm_insn = emit_insn_before (set_xmm, set_insn);
++
++ if (dump_file)
++ {
++ fprintf (dump_file, "\nPlace:\n\n");
++ if (set_xmm_insn)
++ print_rtl_single (dump_file, set_xmm_insn);
++ print_rtl_single (dump_file, set_insn);
++ if (after)
+ {
+- fprintf (dump_file, "\nPlace:\n\n");
+- print_rtl_single (dump_file, set_insn);
+ fprintf (dump_file, "\nafter:\n\n");
+ print_rtl_single (dump_file, after);
+- fprintf (dump_file, "\n");
+ }
++ else
++ {
++ fprintf (dump_file, "\nbefore:\n\n");
++ print_rtl_single (dump_file, insn);
++ }
++ fprintf (dump_file, "\n");
+ }
+
+ if (inner_scalar)
+diff --git a/gcc/testsuite/gcc.target/i386/pr121015.c b/gcc/testsuite/gcc.target/i386/pr121015.c
+new file mode 100644
+index 00000000000..ad1fdccf50c
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr121015.c
+@@ -0,0 +1,34 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -march=x86-64-v3" } */
++/* { dg-final { scan-assembler-times "vpcmpeq" 1 { target { ! ia32 } } } } */
++/* { dg-final { scan-assembler-not "\.long\[ \t\]+-1\n" { target { ! ia32 } } } } */
++
++extern union {
++ int i;
++ float f;
++} int_as_float_u;
++
++extern int render_result_from_bake_w;
++extern int render_result_from_bake_h_seed_pass;
++extern float *render_result_from_bake_h_primitive;
++extern float *render_result_from_bake_h_seed;
++
++float
++int_as_float(int i)
++{
++ int_as_float_u.i = i;
++ return int_as_float_u.f;
++}
++
++void
++render_result_from_bake_h(int tx)
++{
++ while (render_result_from_bake_w) {
++ for (; tx < render_result_from_bake_w; tx++)
++ render_result_from_bake_h_primitive[1] =
++ render_result_from_bake_h_primitive[2] = int_as_float(-1);
++ if (render_result_from_bake_h_seed_pass) {
++ *render_result_from_bake_h_seed = 0;
++ }
++ }
++}
+--
+2.50.0
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 48846cc..caee4e9 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -2,6 +2,7 @@
- 85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
- 86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch
+ + 85_all_PR121015-blender.patch
5 6 July 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-07 20:49 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-07 20:49 UTC (permalink / raw
To: gentoo-commits
commit: c1d634a2dd8b4e6c526fc44a2ec3b2c588a1c851
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 7 20:49:13 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 7 20:49:35 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=c1d634a2
16.0.0: drop reverts
These reverts landed upstream.
Signed-off-by: Sam James <sam <AT> gentoo.org>
...the-counted_by-attribute-of-pointers-in-a.patch | 670 ---------------------
...the-counted_by-attribute-of-pointers-in-b.patch | 382 ------------
16.0.0/gentoo/README.history | 5 +
3 files changed, 5 insertions(+), 1052 deletions(-)
diff --git a/16.0.0/gentoo/85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch b/16.0.0/gentoo/85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
deleted file mode 100644
index b503500..0000000
--- a/16.0.0/gentoo/85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-https://gcc.gnu.org/PR120929
-
-From 75017c57b4f66552d02efda7e7d5eade1ba0ee80 Mon Sep 17 00:00:00 2001
-Message-ID: <75017c57b4f66552d02efda7e7d5eade1ba0ee80.1751506033.git.sam@gentoo.org>
-From: Sam James <sam@gentoo.org>
-Date: Thu, 3 Jul 2025 02:26:55 +0100
-Subject: [PATCH 1/2] Revert "Use the counted_by attribute of pointers in array
- bound checker."
-
-This reverts commit 9d579c522d551eaa807e438206e19a91a3def67f.
----
- gcc/c-family/c-gimplify.cc | 28 --
- gcc/c-family/c-ubsan.cc | 316 +-----------------
- .../ubsan/pointer-counted-by-bounds-2.c | 51 ---
- .../ubsan/pointer-counted-by-bounds-3.c | 42 ---
- .../ubsan/pointer-counted-by-bounds-4.c | 42 ---
- .../ubsan/pointer-counted-by-bounds-5.c | 40 ---
- .../gcc.dg/ubsan/pointer-counted-by-bounds.c | 46 ---
- 7 files changed, 16 insertions(+), 549 deletions(-)
- delete mode 100644 gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c
- delete mode 100644 gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c
- delete mode 100644 gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c
- delete mode 100644 gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c
- delete mode 100644 gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c
-
-diff --git a/gcc/c-family/c-gimplify.cc b/gcc/c-family/c-gimplify.cc
-index e905059708f7..c6fb7646567e 100644
---- a/gcc/c-family/c-gimplify.cc
-+++ b/gcc/c-family/c-gimplify.cc
-@@ -66,20 +66,6 @@ along with GCC; see the file COPYING3. If not see
- walk back up, we check that they fit our constraints, and copy them
- into temporaries if not. */
-
--
--/* Check whether TP is an address computation whose base is a call to
-- .ACCESS_WITH_SIZE. */
--
--static bool
--is_address_with_access_with_size (tree tp)
--{
-- if (TREE_CODE (tp) == POINTER_PLUS_EXPR
-- && (TREE_CODE (TREE_OPERAND (tp, 0)) == INDIRECT_REF)
-- && (is_access_with_size_p (TREE_OPERAND (TREE_OPERAND (tp, 0), 0))))
-- return true;
-- return false;
--}
--
- /* Callback for c_genericize. */
-
- static tree
-@@ -135,20 +121,6 @@ ubsan_walk_array_refs_r (tree *tp, int *walk_subtrees, void *data)
- walk_tree (&TREE_OPERAND (*tp, 1), ubsan_walk_array_refs_r, pset, pset);
- walk_tree (&TREE_OPERAND (*tp, 0), ubsan_walk_array_refs_r, pset, pset);
- }
-- else if (TREE_CODE (*tp) == INDIRECT_REF
-- && is_address_with_access_with_size (TREE_OPERAND (*tp, 0)))
-- {
-- ubsan_maybe_instrument_array_ref (&TREE_OPERAND (*tp, 0), false);
-- /* Make sure ubsan_maybe_instrument_array_ref is not called again on
-- the POINTER_PLUS_EXPR, so ensure it is not walked again and walk
-- its subtrees manually. */
-- tree aref = TREE_OPERAND (*tp, 0);
-- pset->add (aref);
-- *walk_subtrees = 0;
-- walk_tree (&TREE_OPERAND (aref, 0), ubsan_walk_array_refs_r, pset, pset);
-- }
-- else if (is_address_with_access_with_size (*tp))
-- ubsan_maybe_instrument_array_ref (tp, true);
- return NULL_TREE;
- }
-
-diff --git a/gcc/c-family/c-ubsan.cc b/gcc/c-family/c-ubsan.cc
-index 38514a4046c3..78b786854699 100644
---- a/gcc/c-family/c-ubsan.cc
-+++ b/gcc/c-family/c-ubsan.cc
-@@ -554,322 +554,38 @@ ubsan_instrument_bounds (location_t loc, tree array, tree *index,
- *index, bound);
- }
-
--
--/* Instrument array bounds for the pointer array address which is
-- an INDIRECT_REF to the call to .ACCESS_WITH_SIZE. We create special
-- builtin, that gets expanded in the sanopt pass, and make an array
-- dimention of it. POINTER_ADDR is the pointer array's base address.
-- *INDEX is an index to the array.
-- IGNORE_OFF_BY_ONE is true if the POINTER_ADDR is not inside an
-- INDIRECT_REF.
-- Return NULL_TREE if no instrumentation is emitted. */
--
--tree
--ubsan_instrument_bounds_pointer_address (location_t loc, tree pointer_addr,
-- tree *index,
-- bool ignore_off_by_one)
--{
-- gcc_assert (TREE_CODE (pointer_addr) == INDIRECT_REF);
-- tree call = TREE_OPERAND (pointer_addr, 0);
-- if (!is_access_with_size_p (call))
-- return NULL_TREE;
-- tree bound = get_bound_from_access_with_size (call);
--
-- if (ignore_off_by_one)
-- bound = fold_build2 (PLUS_EXPR, TREE_TYPE (bound), bound,
-- build_int_cst (TREE_TYPE (bound),
-- 1));
--
-- /* Don't emit instrumentation in the most common cases. */
-- tree idx = NULL_TREE;
-- if (TREE_CODE (*index) == INTEGER_CST)
-- idx = *index;
-- else if (TREE_CODE (*index) == BIT_AND_EXPR
-- && TREE_CODE (TREE_OPERAND (*index, 1)) == INTEGER_CST)
-- idx = TREE_OPERAND (*index, 1);
-- if (idx
-- && TREE_CODE (bound) == INTEGER_CST
-- && tree_int_cst_sgn (idx) >= 0
-- && tree_int_cst_lt (idx, bound))
-- return NULL_TREE;
--
-- *index = save_expr (*index);
--
-- /* Create an array_type for the corresponding pointer array. */
-- tree itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
-- /* The array's element type can be get from the return type of the call to
-- .ACCESS_WITH_SIZE. */
-- tree element_type = TREE_TYPE (TREE_TYPE (TREE_TYPE (call)));
-- tree array_type = build_array_type (element_type, itype);
-- /* Create a "(T *) 0" tree node to describe the array type. */
-- tree zero_with_type = build_int_cst (build_pointer_type (array_type), 0);
-- return build_call_expr_internal_loc (loc, IFN_UBSAN_BOUNDS,
-- void_type_node, 3, zero_with_type,
-- *index, bound);
--}
--
--/* This structure is to combine a factor with its parent and its position
-- * in its parent tree. */
--struct factor_t
--{
-- tree factor;
-- tree parent; /* the parent tree of this factor. */
-- int pos; /* the position of this factor in its parent tree. */
--};
--
--/* for a multiply expression like:
-- ((long unsigned int) m * (long unsigned int) SAVE_EXPR <n>) * 4
--
-- locate all the factors, the parents of the factor and the position of
-- the factor in its parent, and put them to VEC_FACTORS. */
--
--static void
--get_factors_from_mul_expr (tree mult_expr, tree parent,
-- int pos, auto_vec<factor_t> *vec_factors)
--{
-- struct factor_t mult_factor = {0, 0, -1};
-- mult_factor.factor = mult_expr;
-- mult_factor.parent = parent;
-- mult_factor.pos = pos;
--
-- while (CONVERT_EXPR_CODE_P (TREE_CODE (mult_expr)))
-- {
-- mult_factor.parent = mult_expr;
-- mult_factor.pos = 0;
-- mult_expr = TREE_OPERAND (mult_expr, 0);
-- mult_factor.factor = mult_expr;
-- }
-- if (TREE_CODE (mult_expr) != MULT_EXPR)
-- vec_factors->safe_push (mult_factor);
-- else
-- {
-- get_factors_from_mul_expr (TREE_OPERAND (mult_expr, 0), mult_expr,
-- 0, vec_factors);
-- get_factors_from_mul_expr (TREE_OPERAND (mult_expr, 1), mult_expr,
-- 1, vec_factors);
-- }
--}
--
--/* Given an OFFSET expression, and the ELEMENT_SIZE,
-- get the index expression from OFFSET and return it.
-- For example:
-- OFFSET:
-- ((long unsigned int) m * (long unsigned int) SAVE_EXPR <n>) * 4
-- ELEMENT_SIZE:
-- (sizetype) SAVE_EXPR <n> * 4
-- get the index as (long unsigned int) m, and return it.
-- The INDEX_P holds the pointer to the parent tree of the index,
-- INDEX_N holds the position of the index in its parent. */
--
--static tree
--get_index_from_offset (tree offset, tree *index_p,
-- int *index_n, tree element_size)
--{
-- if (TREE_CODE (offset) != MULT_EXPR)
-- return NULL_TREE;
--
-- auto_vec<factor_t> e_factors, o_factors;
-- get_factors_from_mul_expr (element_size, NULL, -1, &e_factors);
-- get_factors_from_mul_expr (offset, *index_p, *index_n, &o_factors);
--
-- if (e_factors.is_empty () || o_factors.is_empty ())
-- return NULL_TREE;
--
-- bool all_found = true;
-- for (unsigned i = 0; i < e_factors.length (); i++)
-- {
-- factor_t e_size_factor = e_factors[i];
-- bool found = false;
-- for (unsigned j = 0; j < o_factors.length ();)
-- {
-- factor_t o_exp_factor = o_factors[j];
-- if (operand_equal_p (e_size_factor.factor, o_exp_factor.factor))
-- {
-- o_factors.unordered_remove (j);
-- found = true;
-- break;
-- }
-- else
-- j++;
-- }
-- if (!found)
-- all_found = false;
-- }
--
-- if (!all_found)
-- return NULL_TREE;
--
-- if (o_factors.length () != 1)
-- return NULL_TREE;
--
-- *index_p = o_factors[0].parent;
-- *index_n = o_factors[0].pos;
-- return o_factors[0].factor;
--}
--
--/* For an pointer + offset computation expression, such as,
-- *.ACCESS_WITH_SIZE (p->c, &p->b, 1, 0, -1, 0B)
-- + (sizetype) ((long unsigned int) index * 4
-- Return the index of this pointer array reference,
-- set the parent tree of INDEX to *INDEX_P.
-- set the operand position of the INDEX in the parent tree to *INDEX_N.
-- If failed, return NULL_TREE. */
--
--static tree
--get_index_from_pointer_addr_expr (tree pointer, tree *index_p, int *index_n)
--{
-- *index_p = NULL_TREE;
-- *index_n = -1;
-- if (TREE_CODE (TREE_OPERAND (pointer, 0)) != INDIRECT_REF)
-- return NULL_TREE;
-- tree call = TREE_OPERAND (TREE_OPERAND (pointer, 0), 0);
-- if (!is_access_with_size_p (call))
-- return NULL_TREE;
--
-- /* Get the pointee type of the call to .ACCESS_WITH_SIZE.
-- This should be the element type of the pointer array. */
-- tree pointee_type = TREE_TYPE (TREE_TYPE (TREE_TYPE (call)));
-- tree pointee_size = TYPE_SIZE_UNIT (pointee_type);
--
-- tree index_exp = TREE_OPERAND (pointer, 1);
-- *index_p = pointer;
-- *index_n = 1;
--
-- if (!(TREE_CODE (index_exp) != MULT_EXPR
-- && tree_int_cst_equal (pointee_size, integer_one_node)))
-- {
-- while (CONVERT_EXPR_CODE_P (TREE_CODE (index_exp)))
-- {
-- *index_p = index_exp;
-- *index_n = 0;
-- index_exp = TREE_OPERAND (index_exp, 0);
-- }
-- index_exp = get_index_from_offset (index_exp, index_p,
-- index_n, pointee_size);
--
-- if (!index_exp)
-- return NULL_TREE;
-- }
--
-- while (CONVERT_EXPR_CODE_P (TREE_CODE (index_exp)))
-- {
-- *index_p = index_exp;
-- *index_n = 0;
-- index_exp = TREE_OPERAND (index_exp, 0);
-- }
--
-- return index_exp;
--}
--
--/* Return TRUE when the EXPR is a pointer array address that could be
-- instrumented.
-- We only instrument an address computation similar as the following:
-- *.ACCESS_WITH_SIZE (p->c, &p->b, 1, 0, -1, 0B)
-- + (sizetype) ((long unsigned int) index * 4)
-- if the EXPR is instrumentable, return TRUE and
-- set the index to *INDEX.
-- set the *.ACCESS_WITH_SIZE to *BASE.
-- set the parent tree of INDEX to *INDEX_P.
-- set the operand position of the INDEX in the parent tree to INDEX_N. */
--
--static bool
--is_instrumentable_pointer_array_address (tree expr, tree *base,
-- tree *index, tree *index_p,
-- int *index_n)
--{
-- /* For a poiner array address as:
-- (*.ACCESS_WITH_SIZE (p->c, &p->b, 1, 0, -1, 0B)
-- + (sizetype) ((long unsigned int) index * 4)
-- op0 is the call to *.ACCESS_WITH_SIZE;
-- op1 is the index. */
-- if (TREE_CODE (expr) != POINTER_PLUS_EXPR)
-- return false;
--
-- tree op0 = TREE_OPERAND (expr, 0);
-- if (TREE_CODE (op0) != INDIRECT_REF)
-- return false;
-- if (!is_access_with_size_p (TREE_OPERAND (op0, 0)))
-- return false;
-- tree op1 = get_index_from_pointer_addr_expr (expr, index_p, index_n);
-- if (op1 != NULL_TREE)
-- {
-- *base = op0;
-- *index = op1;
-- return true;
-- }
-- return false;
--}
--
--/* Return true iff T is an array or an indirect reference that was
-- instrumented by SANITIZE_BOUNDS. */
-+/* Return true iff T is an array that was instrumented by SANITIZE_BOUNDS. */
-
- bool
--ubsan_array_ref_instrumented_p (tree t)
-+ubsan_array_ref_instrumented_p (const_tree t)
- {
-- if (TREE_CODE (t) != ARRAY_REF
-- && TREE_CODE (t) != MEM_REF)
-+ if (TREE_CODE (t) != ARRAY_REF)
- return false;
-
-- bool is_array = (TREE_CODE (t) == ARRAY_REF);
-- tree op0 = NULL_TREE;
-- tree op1 = NULL_TREE;
-- tree index_p = NULL_TREE;
-- int index_n = 0;
-- if (is_array)
-- {
-- op1 = TREE_OPERAND (t, 1);
-- return TREE_CODE (op1) == COMPOUND_EXPR
-- && TREE_CODE (TREE_OPERAND (op1, 0)) == CALL_EXPR
-- && CALL_EXPR_FN (TREE_OPERAND (op1, 0)) == NULL_TREE
-- && CALL_EXPR_IFN (TREE_OPERAND (op1, 0)) == IFN_UBSAN_BOUNDS;
-- }
-- else if (is_instrumentable_pointer_array_address (t, &op0, &op1,
-- &index_p, &index_n))
-- return TREE_CODE (op1) == COMPOUND_EXPR
-- && TREE_CODE (TREE_OPERAND (op1, 0)) == CALL_EXPR
-- && CALL_EXPR_FN (TREE_OPERAND (op1, 0)) == NULL_TREE
-- && CALL_EXPR_IFN (TREE_OPERAND (op1, 0)) == IFN_UBSAN_BOUNDS;
--
-- return false;
-+ tree op1 = TREE_OPERAND (t, 1);
-+ return TREE_CODE (op1) == COMPOUND_EXPR
-+ && TREE_CODE (TREE_OPERAND (op1, 0)) == CALL_EXPR
-+ && CALL_EXPR_FN (TREE_OPERAND (op1, 0)) == NULL_TREE
-+ && CALL_EXPR_IFN (TREE_OPERAND (op1, 0)) == IFN_UBSAN_BOUNDS;
- }
-
--/* Instrument an ARRAY_REF or an address computation whose base address is
-- a call to .ACCESS_WITH_SIZE, if it hasn't already been instrumented.
-- IGNORE_OFF_BY_ONE is true if the ARRAY_REF is inside a ADDR_EXPR, or the
-- address computation is not inside a INDIRECT_REF. */
-+/* Instrument an ARRAY_REF, if it hasn't already been instrumented.
-+ IGNORE_OFF_BY_ONE is true if the ARRAY_REF is inside a ADDR_EXPR. */
-
- void
- ubsan_maybe_instrument_array_ref (tree *expr_p, bool ignore_off_by_one)
- {
-- tree e = NULL_TREE;
-- tree op0 = NULL_TREE;
-- tree op1 = NULL_TREE;
-- tree index_p = NULL_TREE; /* the parent tree of INDEX. */
-- int index_n = 0; /* the operand position of INDEX in the parent tree. */
--
- if (!ubsan_array_ref_instrumented_p (*expr_p)
- && sanitize_flags_p (SANITIZE_BOUNDS | SANITIZE_BOUNDS_STRICT)
- && current_function_decl != NULL_TREE)
- {
-- if (TREE_CODE (*expr_p) == ARRAY_REF)
-- {
-- op0 = TREE_OPERAND (*expr_p, 0);
-- op1 = TREE_OPERAND (*expr_p, 1);
-- index_p = *expr_p;
-- index_n = 1;
-- e = ubsan_instrument_bounds (EXPR_LOCATION (*expr_p), op0,
-- &op1, ignore_off_by_one);
-- }
-- else if (is_instrumentable_pointer_array_address (*expr_p, &op0, &op1,
-- &index_p, &index_n))
-- e = ubsan_instrument_bounds_pointer_address (EXPR_LOCATION (*expr_p),
-- op0, &op1,
-- ignore_off_by_one);
--
-- /* Replace the original INDEX with the instrumented INDEX. */
-+ tree op0 = TREE_OPERAND (*expr_p, 0);
-+ tree op1 = TREE_OPERAND (*expr_p, 1);
-+ tree e = ubsan_instrument_bounds (EXPR_LOCATION (*expr_p), op0, &op1,
-+ ignore_off_by_one);
- if (e != NULL_TREE)
-- TREE_OPERAND (index_p, index_n)
-- = build2 (COMPOUND_EXPR, TREE_TYPE (op1), e, op1);
-+ TREE_OPERAND (*expr_p, 1) = build2 (COMPOUND_EXPR, TREE_TYPE (op1),
-+ e, op1);
- }
- }
-
-diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c
-deleted file mode 100644
-index 0653eccff3e1..000000000000
---- a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c
-+++ /dev/null
-@@ -1,51 +0,0 @@
--/* Test the attribute counted_by for pointer fields and its usage in
-- bounds sanitizer combined with VLA. */
--/* { dg-do run } */
--/* { dg-options "-fsanitize=bounds" } */
--/* { dg-output "index 11 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
--/* { dg-output "\[^\n\r]*index 20 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
--/* { dg-output "\[^\n\r]*index 11 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
--/* { dg-output "\[^\n\r]*index 10 out of bounds for type 'int \\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
--
--
--#include <stdlib.h>
--
--void __attribute__((__noinline__)) setup_and_test_vla (int n, int m)
--{
-- struct foo {
-- int n;
-- int (*p)[n] __attribute__((counted_by(n)));
-- } *f;
--
-- f = (struct foo *) malloc (sizeof (struct foo));
-- f->p = (int (*)[n]) malloc (m * sizeof (int[n]));
-- f->n = m;
-- f->p[m][n-1] = 1;
-- free (f->p);
-- free (f);
-- return;
--}
--
--void __attribute__((__noinline__)) setup_and_test_vla_1 (int n1, int n2, int m)
--{
-- struct foo {
-- int n;
-- int (*p)[n2][n1] __attribute__((counted_by(n)));
-- } *f;
--
-- f = (struct foo *) malloc (sizeof(struct foo));
-- f->p = (int (*)[n2][n1]) malloc (m * sizeof (int[n2][n1]));
-- f->n = m;
-- f->p[m][n2][n1] = 1;
-- free (f->p);
-- free (f);
-- return;
--}
--
--int main(int argc, char *argv[])
--{
-- setup_and_test_vla (10, 11);
-- setup_and_test_vla_1 (10, 11, 20);
-- return 0;
--}
--
-diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c
-deleted file mode 100644
-index 731422d7789a..000000000000
---- a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c
-+++ /dev/null
-@@ -1,42 +0,0 @@
--/* Test the attribute counted_by for pointer fields and its usage in bounds
-- sanitizer. when counted_by field is negative value. */
--/* { dg-do run } */
--/* { dg-options "-fsanitize=bounds" } */
--
--#include <stdlib.h>
--
--struct annotated {
-- int b;
-- int *c __attribute__ ((counted_by (b)));
--} *array_annotated;
--
--void __attribute__((__noinline__)) setup (int annotated_count)
--{
-- array_annotated
-- = (struct annotated *)malloc (sizeof (struct annotated));
-- array_annotated->c = (int *) malloc (sizeof (int) * 10);
-- array_annotated->b = annotated_count;
--
-- return;
--}
--
--void __attribute__((__noinline__)) test (int annotated_index)
--{
-- array_annotated->c[annotated_index] = 2;
--}
--
--void cleanup ()
--{
-- free (array_annotated->c);
-- free (array_annotated);
--}
--
--int main(int argc, char *argv[])
--{
-- setup (-3);
-- test (2);
-- cleanup ();
-- return 0;
--}
--
--/* { dg-output "25:21: runtime error: index 2 out of bounds for type" } */
-diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c
-deleted file mode 100644
-index 52f202f51f9f..000000000000
---- a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c
-+++ /dev/null
-@@ -1,42 +0,0 @@
--/* Test the attribute counted_by for pointer fields and its usage in bounds
-- sanitizer. when counted_by field is zero value. */
--/* { dg-do run } */
--/* { dg-options "-fsanitize=bounds" } */
--
--#include <stdlib.h>
--
--struct annotated {
-- int b;
-- int *c __attribute__ ((counted_by (b)));
--} *array_annotated;
--
--void __attribute__((__noinline__)) setup (int annotated_count)
--{
-- array_annotated
-- = (struct annotated *)malloc (sizeof (struct annotated));
-- array_annotated->c = (int *)malloc (sizeof (int) * 10);
-- array_annotated->b = annotated_count;
--
-- return;
--}
--
--void __attribute__((__noinline__)) test (int annotated_index)
--{
-- array_annotated->c[annotated_index] = 2;
--}
--
--void cleanup ()
--{
-- free (array_annotated->c);
-- free (array_annotated);
--}
--
--int main(int argc, char *argv[])
--{
-- setup (0);
-- test (1);
-- cleanup ();
-- return 0;
--}
--
--/* { dg-output "25:21: runtime error: index 1 out of bounds for type" } */
-diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c
-deleted file mode 100644
-index 8ad7572d1405..000000000000
---- a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c
-+++ /dev/null
-@@ -1,40 +0,0 @@
--/* Test the attribute counted_by for pointer fields and its usage in
-- bounds sanitizer. */
--/* { dg-do run } */
--/* { dg-options "-fsanitize=bounds" } */
--
--#include <stdlib.h>
--
--struct annotated {
-- int b;
-- int *c __attribute__ ((counted_by (b)));
--} *p_array_annotated;
--
--void __attribute__((__noinline__)) setup (int annotated_count)
--{
-- p_array_annotated
-- = (struct annotated *)malloc (sizeof (struct annotated));
-- p_array_annotated->c = (int *) malloc (annotated_count * sizeof (int));
-- p_array_annotated->b = annotated_count;
--
-- return;
--}
--
--void cleanup ()
--{
-- free (p_array_annotated->c);
-- free (p_array_annotated);
--}
--
--int main(int argc, char *argv[])
--{
-- int i;
-- setup (10);
-- for (i = 0; i < 11; i++)
-- p_array_annotated->c[i] = 2; // goes boom at i == 10
-- cleanup ();
-- return 0;
--}
--
--
--/* { dg-output "34:25: runtime error: index 10 out of bounds for type" } */
-diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c
-deleted file mode 100644
-index c5a1ac53be6d..000000000000
---- a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c
-+++ /dev/null
-@@ -1,46 +0,0 @@
--/* Test the attribute counted_by for pointer fields and its usage in
-- bounds sanitizer. */
--/* { dg-do run } */
--/* { dg-options "-fsanitize=bounds" } */
--
--#include <stdlib.h>
--
--struct pointer_array {
-- int b;
-- int *c;
--} *p_array;
--
--struct annotated {
-- int b;
-- int *c __attribute__ ((counted_by (b)));
--} *p_array_annotated;
--
--void __attribute__((__noinline__)) setup (int normal_count, int annotated_count)
--{
-- p_array
-- = (struct pointer_array *) malloc (sizeof (struct pointer_array));
-- p_array->c = (int *) malloc (normal_count * sizeof (int));
-- p_array->b = normal_count;
--
-- p_array_annotated
-- = (struct annotated *) malloc (sizeof (struct annotated));
-- p_array_annotated->c = (int *) malloc (annotated_count * sizeof (int));
-- p_array_annotated->b = annotated_count;
--
-- return;
--}
--
--void __attribute__((__noinline__)) test (int normal_index, int annotated_index)
--{
-- p_array->c[normal_index] = 1;
-- p_array_annotated->c[annotated_index] = 2;
--}
--
--int main(int argc, char *argv[])
--{
-- setup (10, 10);
-- test (10, 10);
-- return 0;
--}
--
--/* { dg-output "36:23: runtime error: index 10 out of bounds for type" } */
-
-base-commit: b8a7d51253695febe6598069ccd89280b45d0abe
---
-2.50.0
-
diff --git a/16.0.0/gentoo/86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch b/16.0.0/gentoo/86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch
deleted file mode 100644
index c704da9..0000000
--- a/16.0.0/gentoo/86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch
+++ /dev/null
@@ -1,382 +0,0 @@
-https://gcc.gnu.org/PR120929
-
-From 67769e431a764258ea3b3b983eae19089864fe62 Mon Sep 17 00:00:00 2001
-Message-ID: <67769e431a764258ea3b3b983eae19089864fe62.1751506033.git.sam@gentoo.org>
-In-Reply-To: <75017c57b4f66552d02efda7e7d5eade1ba0ee80.1751506033.git.sam@gentoo.org>
-References: <75017c57b4f66552d02efda7e7d5eade1ba0ee80.1751506033.git.sam@gentoo.org>
-From: Sam James <sam@gentoo.org>
-Date: Thu, 3 Jul 2025 02:27:06 +0100
-Subject: [PATCH 2/2] Revert "Use the counted_by attribute of pointers in
- builtinin-object-size."
-
-This reverts commit 7165ca43caf47007f5ceaa46c034618d397d42ec.
----
- .../gcc.dg/pointer-counted-by-4-char.c | 6 --
- .../gcc.dg/pointer-counted-by-4-float.c | 6 --
- .../gcc.dg/pointer-counted-by-4-struct.c | 10 ---
- .../gcc.dg/pointer-counted-by-4-union.c | 10 ---
- gcc/testsuite/gcc.dg/pointer-counted-by-4.c | 77 -------------------
- gcc/testsuite/gcc.dg/pointer-counted-by-5.c | 56 --------------
- gcc/testsuite/gcc.dg/pointer-counted-by-6.c | 56 --------------
- gcc/testsuite/gcc.dg/pointer-counted-by-7.c | 32 --------
- gcc/tree-object-size.cc | 19 +----
- 9 files changed, 3 insertions(+), 269 deletions(-)
- delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c
- delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c
- delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c
- delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c
- delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-4.c
- delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-5.c
- delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-6.c
- delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-7.c
-
-diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c
-deleted file mode 100644
-index c404e5b8ccec..000000000000
---- a/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c
-+++ /dev/null
-@@ -1,6 +0,0 @@
--/* Test the attribute counted_by for pointer field and its usage in
-- * __builtin_dynamic_object_size. */
--/* { dg-do run } */
--/* { dg-options "-O2" } */
--#define PTR_TYPE char
--#include "pointer-counted-by-4.c"
-diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c
-deleted file mode 100644
-index 383d8fb656df..000000000000
---- a/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c
-+++ /dev/null
-@@ -1,6 +0,0 @@
--/* Test the attribute counted_by for pointer field and its usage in
-- * __builtin_dynamic_object_size. */
--/* { dg-do run } */
--/* { dg-options "-O2" } */
--#define PTR_TYPE float
--#include "pointer-counted-by-4.c"
-diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c
-deleted file mode 100644
-index 50246d29477b..000000000000
---- a/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c
-+++ /dev/null
-@@ -1,10 +0,0 @@
--/* Test the attribute counted_by for pointer field and its usage in
-- * __builtin_dynamic_object_size. */
--/* { dg-do run } */
--/* { dg-options "-O2" } */
--struct A {
-- int a;
-- char *b;
--};
--#define PTR_TYPE struct A
--#include "pointer-counted-by-4.c"
-diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c
-deleted file mode 100644
-index e786d9961475..000000000000
---- a/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c
-+++ /dev/null
-@@ -1,10 +0,0 @@
--/* Test the attribute counted_by for pointer field and its usage in
-- * __builtin_dynamic_object_size. */
--/* { dg-do run } */
--/* { dg-options "-O2" } */
--union A {
-- int a;
-- float b;
--};
--#define PTR_TYPE union A
--#include "pointer-counted-by-4.c"
-diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4.c
-deleted file mode 100644
-index c4b36311c704..000000000000
---- a/gcc/testsuite/gcc.dg/pointer-counted-by-4.c
-+++ /dev/null
-@@ -1,77 +0,0 @@
--/* Test the attribute counted_by for pointer field and its usage in
-- * __builtin_dynamic_object_size. */
--/* { dg-do run } */
--/* { dg-options "-O2" } */
--
--#include "builtin-object-size-common.h"
--#ifndef PTR_TYPE
--#define PTR_TYPE int
--#endif
--struct pointer_array {
-- int b;
-- PTR_TYPE *c;
--} *p_array;
--
--struct annotated {
-- PTR_TYPE *c __attribute__ ((counted_by (b)));
-- int b;
--} *p_array_annotated;
--
--struct nested_annotated {
-- PTR_TYPE *c __attribute__ ((counted_by (b)));
-- struct {
-- union {
-- int b;
-- float f;
-- };
-- int n;
-- };
--} *p_array_nested_annotated;
--
--void __attribute__((__noinline__)) setup (int normal_count, int attr_count)
--{
-- p_array
-- = (struct pointer_array *) malloc (sizeof (struct pointer_array));
-- p_array->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * normal_count);
-- p_array->b = normal_count;
--
-- p_array_annotated
-- = (struct annotated *) malloc (sizeof (struct annotated));
-- p_array_annotated->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * attr_count);
-- p_array_annotated->b = attr_count;
--
-- p_array_nested_annotated
-- = (struct nested_annotated *) malloc (sizeof (struct nested_annotated));
-- p_array_nested_annotated->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * attr_count);
-- p_array_nested_annotated->b = attr_count;
--
-- return;
--}
--
--void __attribute__((__noinline__)) test ()
--{
-- EXPECT(__builtin_dynamic_object_size(p_array->c, 1), -1);
-- EXPECT(__builtin_dynamic_object_size(p_array_annotated->c, 1),
-- p_array_annotated->b * sizeof (PTR_TYPE));
-- EXPECT(__builtin_dynamic_object_size(p_array_nested_annotated->c, 1),
-- p_array_nested_annotated->b * sizeof (PTR_TYPE));
--}
--
--void cleanup ()
--{
-- free (p_array->c);
-- free (p_array);
-- free (p_array_annotated->c);
-- free (p_array_annotated);
-- free (p_array_nested_annotated->c);
-- free (p_array_nested_annotated);
--}
--
--int main(int argc, char *argv[])
--{
-- setup (10,10);
-- test ();
-- DONE ();
-- cleanup ();
-- return 0;
--}
-diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-5.c b/gcc/testsuite/gcc.dg/pointer-counted-by-5.c
-deleted file mode 100644
-index b43ffdf4df9f..000000000000
---- a/gcc/testsuite/gcc.dg/pointer-counted-by-5.c
-+++ /dev/null
-@@ -1,56 +0,0 @@
--/* Test the attribute counted_by for pointer fields and its usage in
-- * __builtin_dynamic_object_size: when the counted_by field is negative. */
--/* { dg-do run } */
--/* { dg-options "-O2" } */
--
--#include "builtin-object-size-common.h"
--
--struct annotated {
-- int b;
-- int *c __attribute__ ((counted_by (b)));
--} *array_annotated;
--
--struct nested_annotated {
-- int *c __attribute__ ((counted_by (b)));
-- struct {
-- union {
-- int b;
-- float f;
-- };
-- int n;
-- };
--} *array_nested_annotated;
--
--void __attribute__((__noinline__)) setup (int attr_count)
--{
-- array_annotated
-- = (struct annotated *)malloc (sizeof (struct annotated));
-- array_annotated->b = attr_count;
--
-- array_nested_annotated
-- = (struct nested_annotated *)malloc (sizeof (struct nested_annotated));
-- array_nested_annotated->b = attr_count - 1;
--
-- return;
--}
--
--void __attribute__((__noinline__)) test ()
--{
-- EXPECT(__builtin_dynamic_object_size(array_annotated->c, 1), 0);
-- EXPECT(__builtin_dynamic_object_size(array_nested_annotated->c, 1), 0);
--}
--
--void cleanup ()
--{
-- free (array_annotated);
-- free (array_nested_annotated);
--}
--
--int main(int argc, char *argv[])
--{
-- setup (-10);
-- test ();
-- DONE ();
-- cleanup ();
-- return 0;
--}
-diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-6.c b/gcc/testsuite/gcc.dg/pointer-counted-by-6.c
-deleted file mode 100644
-index 355558cd161d..000000000000
---- a/gcc/testsuite/gcc.dg/pointer-counted-by-6.c
-+++ /dev/null
-@@ -1,56 +0,0 @@
--/* Test the attribute counted_by for pointer fields and its usage in
-- * __builtin_dynamic_object_size: when the type of the pointer
-- * is casting to another type. */
--/* { dg-do run } */
--/* { dg-options "-O2" } */
--
--#include "builtin-object-size-common.h"
--
--typedef unsigned short u16;
--
--struct info {
-- u16 data_len;
-- char *data __attribute__((counted_by(data_len)));
--};
--
--struct foo {
-- int a;
-- int b;
--};
--
--static __attribute__((__noinline__))
--struct info *setup ()
--{
-- struct info *p;
-- size_t bytes = 3 * sizeof(struct foo);
--
-- p = (struct info *) malloc (sizeof (struct info));
-- p->data = (char *) malloc (bytes);
-- p->data_len = bytes;
--
-- return p;
--}
--
--static void
--__attribute__((__noinline__)) report (struct info *p)
--{
-- struct foo *bar = (struct foo *)p->data;
-- EXPECT(__builtin_dynamic_object_size((char *)(bar + 1), 1),
-- sizeof (struct foo) * 2);
-- EXPECT(__builtin_dynamic_object_size((char *)(bar + 2), 1),
-- sizeof (struct foo));
--}
--
--void cleanup (struct info *p)
--{
-- free (p->data);
-- free (p);
--}
--
--int main(int argc, char *argv[])
--{
-- struct info *p = setup();
-- report(p);
-- cleanup (p);
-- return 0;
--}
-diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-7.c b/gcc/testsuite/gcc.dg/pointer-counted-by-7.c
-deleted file mode 100644
-index af1ab2794007..000000000000
---- a/gcc/testsuite/gcc.dg/pointer-counted-by-7.c
-+++ /dev/null
-@@ -1,32 +0,0 @@
--/* Additional test of the attribute counted_by for pointer field and its usage
-- in __builtin_dynamic_object_size. */
--/* { dg-do run } */
--/* { dg-options "-O2" } */
--
--#include "builtin-object-size-common.h"
--
--struct annotated {
-- int b;
-- int *c __attribute__ ((counted_by (b)));
--};
--
--struct annotated __attribute__((__noinline__)) setup (int attr_count)
--{
-- struct annotated p_array_annotated;
-- p_array_annotated.c = (int *) malloc (sizeof (int) * attr_count);
-- p_array_annotated.b = attr_count;
--
-- return p_array_annotated;
--}
--
--int main(int argc, char *argv[])
--{
-- struct annotated x = setup (10);
-- int *p = x.c;
-- x = setup (20);
-- EXPECT(__builtin_dynamic_object_size (p, 1), 10 * sizeof (int));
-- EXPECT(__builtin_dynamic_object_size (x.c, 1), 20 * sizeof (int));
-- free (p);
-- free (x.c);
-- DONE ();
--}
-diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc
-index ec4419fbab1d..f348673ae758 100644
---- a/gcc/tree-object-size.cc
-+++ b/gcc/tree-object-size.cc
-@@ -773,12 +773,10 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
- 4th argument TYPE_OF_SIZE: A constant 0 with its TYPE being the same as the TYPE
- of the object referenced by REF_TO_SIZE
- 6th argument: A constant 0 with the pointer TYPE to the original flexible
-- array type or pointer field type.
-+ array type.
-
- The size of the element can be retrived from the TYPE of the 6th argument
-- of the call, which is the pointer to the original flexible array type or
-- the type of the original pointer field. */
--
-+ of the call, which is the pointer to the array type. */
- static tree
- access_with_size_object_size (const gcall *call, int object_size_type)
- {
-@@ -788,7 +786,7 @@ access_with_size_object_size (const gcall *call, int object_size_type)
-
- gcc_assert (gimple_call_internal_p (call, IFN_ACCESS_WITH_SIZE));
- /* The type of the 6th argument type is the pointer TYPE to the original
-- flexible array type or to the original pointer type. */
-+ flexible array type. */
- tree pointer_to_array_type = TREE_TYPE (gimple_call_arg (call, 5));
- gcc_assert (POINTER_TYPE_P (pointer_to_array_type));
- tree element_type = TREE_TYPE (TREE_TYPE (pointer_to_array_type));
-@@ -1856,17 +1854,6 @@ collect_object_sizes_for (struct object_size_info *osi, tree var)
- if (TREE_CODE (rhs) == SSA_NAME
- && POINTER_TYPE_P (TREE_TYPE (rhs)))
- reexamine = merge_object_sizes (osi, var, rhs);
-- /* Handle the following stmt #2 to propagate the size from the
-- stmt #1 to #3:
-- 1 _1 = .ACCESS_WITH_SIZE (_3, _4, 1, 0, -1, 0B);
-- 2 _5 = *_1;
-- 3 _6 = __builtin_dynamic_object_size (_5, 1);
-- */
-- else if (TREE_CODE (rhs) == MEM_REF
-- && POINTER_TYPE_P (TREE_TYPE (rhs))
-- && TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME
-- && integer_zerop (TREE_OPERAND (rhs, 1)))
-- reexamine = merge_object_sizes (osi, var, TREE_OPERAND (rhs, 0));
- else
- expr_object_size (osi, var, rhs);
- }
---
-2.50.0
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 05b0388..48846cc 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,8 @@
+6 ????
+
+ - 85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
+ - 86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch
+
5 6 July 2025
- 85_all_PR120840.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-06 22:41 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-06 22:41 UTC (permalink / raw
To: gentoo-commits
commit: e73fb3cf5c5487e7533943fbb9edc52816794082
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 6 22:40:51 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jul 6 22:40:51 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=e73fb3cf
16.0.0: cut patchset 5
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/README.history | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 4fcaa04..05b0388 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,4 +1,4 @@
-5 ????
+5 6 July 2025
- 85_all_PR120840.patch
+ 85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-07-03 1:29 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-07-03 1:29 UTC (permalink / raw
To: gentoo-commits
commit: 9fdf5a30ded9c691d9fcdb787e72f8dd0f111f8a
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 3 01:28:39 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jul 3 01:29:23 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=9fdf5a30
16.0.0: revert patches breaking _FORTIFY_SOURCE
Bug: https://gcc.gnu.org/PR120929
Signed-off-by: Sam James <sam <AT> gentoo.org>
...the-counted_by-attribute-of-pointers-in-a.patch | 670 +++++++++++++++++++++
...the-counted_by-attribute-of-pointers-in-b.patch | 382 ++++++++++++
16.0.0/gentoo/README.history | 2 +
3 files changed, 1054 insertions(+)
diff --git a/16.0.0/gentoo/85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch b/16.0.0/gentoo/85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
new file mode 100644
index 0000000..b503500
--- /dev/null
+++ b/16.0.0/gentoo/85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
@@ -0,0 +1,670 @@
+https://gcc.gnu.org/PR120929
+
+From 75017c57b4f66552d02efda7e7d5eade1ba0ee80 Mon Sep 17 00:00:00 2001
+Message-ID: <75017c57b4f66552d02efda7e7d5eade1ba0ee80.1751506033.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Thu, 3 Jul 2025 02:26:55 +0100
+Subject: [PATCH 1/2] Revert "Use the counted_by attribute of pointers in array
+ bound checker."
+
+This reverts commit 9d579c522d551eaa807e438206e19a91a3def67f.
+---
+ gcc/c-family/c-gimplify.cc | 28 --
+ gcc/c-family/c-ubsan.cc | 316 +-----------------
+ .../ubsan/pointer-counted-by-bounds-2.c | 51 ---
+ .../ubsan/pointer-counted-by-bounds-3.c | 42 ---
+ .../ubsan/pointer-counted-by-bounds-4.c | 42 ---
+ .../ubsan/pointer-counted-by-bounds-5.c | 40 ---
+ .../gcc.dg/ubsan/pointer-counted-by-bounds.c | 46 ---
+ 7 files changed, 16 insertions(+), 549 deletions(-)
+ delete mode 100644 gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c
+ delete mode 100644 gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c
+ delete mode 100644 gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c
+ delete mode 100644 gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c
+ delete mode 100644 gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c
+
+diff --git a/gcc/c-family/c-gimplify.cc b/gcc/c-family/c-gimplify.cc
+index e905059708f7..c6fb7646567e 100644
+--- a/gcc/c-family/c-gimplify.cc
++++ b/gcc/c-family/c-gimplify.cc
+@@ -66,20 +66,6 @@ along with GCC; see the file COPYING3. If not see
+ walk back up, we check that they fit our constraints, and copy them
+ into temporaries if not. */
+
+-
+-/* Check whether TP is an address computation whose base is a call to
+- .ACCESS_WITH_SIZE. */
+-
+-static bool
+-is_address_with_access_with_size (tree tp)
+-{
+- if (TREE_CODE (tp) == POINTER_PLUS_EXPR
+- && (TREE_CODE (TREE_OPERAND (tp, 0)) == INDIRECT_REF)
+- && (is_access_with_size_p (TREE_OPERAND (TREE_OPERAND (tp, 0), 0))))
+- return true;
+- return false;
+-}
+-
+ /* Callback for c_genericize. */
+
+ static tree
+@@ -135,20 +121,6 @@ ubsan_walk_array_refs_r (tree *tp, int *walk_subtrees, void *data)
+ walk_tree (&TREE_OPERAND (*tp, 1), ubsan_walk_array_refs_r, pset, pset);
+ walk_tree (&TREE_OPERAND (*tp, 0), ubsan_walk_array_refs_r, pset, pset);
+ }
+- else if (TREE_CODE (*tp) == INDIRECT_REF
+- && is_address_with_access_with_size (TREE_OPERAND (*tp, 0)))
+- {
+- ubsan_maybe_instrument_array_ref (&TREE_OPERAND (*tp, 0), false);
+- /* Make sure ubsan_maybe_instrument_array_ref is not called again on
+- the POINTER_PLUS_EXPR, so ensure it is not walked again and walk
+- its subtrees manually. */
+- tree aref = TREE_OPERAND (*tp, 0);
+- pset->add (aref);
+- *walk_subtrees = 0;
+- walk_tree (&TREE_OPERAND (aref, 0), ubsan_walk_array_refs_r, pset, pset);
+- }
+- else if (is_address_with_access_with_size (*tp))
+- ubsan_maybe_instrument_array_ref (tp, true);
+ return NULL_TREE;
+ }
+
+diff --git a/gcc/c-family/c-ubsan.cc b/gcc/c-family/c-ubsan.cc
+index 38514a4046c3..78b786854699 100644
+--- a/gcc/c-family/c-ubsan.cc
++++ b/gcc/c-family/c-ubsan.cc
+@@ -554,322 +554,38 @@ ubsan_instrument_bounds (location_t loc, tree array, tree *index,
+ *index, bound);
+ }
+
+-
+-/* Instrument array bounds for the pointer array address which is
+- an INDIRECT_REF to the call to .ACCESS_WITH_SIZE. We create special
+- builtin, that gets expanded in the sanopt pass, and make an array
+- dimention of it. POINTER_ADDR is the pointer array's base address.
+- *INDEX is an index to the array.
+- IGNORE_OFF_BY_ONE is true if the POINTER_ADDR is not inside an
+- INDIRECT_REF.
+- Return NULL_TREE if no instrumentation is emitted. */
+-
+-tree
+-ubsan_instrument_bounds_pointer_address (location_t loc, tree pointer_addr,
+- tree *index,
+- bool ignore_off_by_one)
+-{
+- gcc_assert (TREE_CODE (pointer_addr) == INDIRECT_REF);
+- tree call = TREE_OPERAND (pointer_addr, 0);
+- if (!is_access_with_size_p (call))
+- return NULL_TREE;
+- tree bound = get_bound_from_access_with_size (call);
+-
+- if (ignore_off_by_one)
+- bound = fold_build2 (PLUS_EXPR, TREE_TYPE (bound), bound,
+- build_int_cst (TREE_TYPE (bound),
+- 1));
+-
+- /* Don't emit instrumentation in the most common cases. */
+- tree idx = NULL_TREE;
+- if (TREE_CODE (*index) == INTEGER_CST)
+- idx = *index;
+- else if (TREE_CODE (*index) == BIT_AND_EXPR
+- && TREE_CODE (TREE_OPERAND (*index, 1)) == INTEGER_CST)
+- idx = TREE_OPERAND (*index, 1);
+- if (idx
+- && TREE_CODE (bound) == INTEGER_CST
+- && tree_int_cst_sgn (idx) >= 0
+- && tree_int_cst_lt (idx, bound))
+- return NULL_TREE;
+-
+- *index = save_expr (*index);
+-
+- /* Create an array_type for the corresponding pointer array. */
+- tree itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
+- /* The array's element type can be get from the return type of the call to
+- .ACCESS_WITH_SIZE. */
+- tree element_type = TREE_TYPE (TREE_TYPE (TREE_TYPE (call)));
+- tree array_type = build_array_type (element_type, itype);
+- /* Create a "(T *) 0" tree node to describe the array type. */
+- tree zero_with_type = build_int_cst (build_pointer_type (array_type), 0);
+- return build_call_expr_internal_loc (loc, IFN_UBSAN_BOUNDS,
+- void_type_node, 3, zero_with_type,
+- *index, bound);
+-}
+-
+-/* This structure is to combine a factor with its parent and its position
+- * in its parent tree. */
+-struct factor_t
+-{
+- tree factor;
+- tree parent; /* the parent tree of this factor. */
+- int pos; /* the position of this factor in its parent tree. */
+-};
+-
+-/* for a multiply expression like:
+- ((long unsigned int) m * (long unsigned int) SAVE_EXPR <n>) * 4
+-
+- locate all the factors, the parents of the factor and the position of
+- the factor in its parent, and put them to VEC_FACTORS. */
+-
+-static void
+-get_factors_from_mul_expr (tree mult_expr, tree parent,
+- int pos, auto_vec<factor_t> *vec_factors)
+-{
+- struct factor_t mult_factor = {0, 0, -1};
+- mult_factor.factor = mult_expr;
+- mult_factor.parent = parent;
+- mult_factor.pos = pos;
+-
+- while (CONVERT_EXPR_CODE_P (TREE_CODE (mult_expr)))
+- {
+- mult_factor.parent = mult_expr;
+- mult_factor.pos = 0;
+- mult_expr = TREE_OPERAND (mult_expr, 0);
+- mult_factor.factor = mult_expr;
+- }
+- if (TREE_CODE (mult_expr) != MULT_EXPR)
+- vec_factors->safe_push (mult_factor);
+- else
+- {
+- get_factors_from_mul_expr (TREE_OPERAND (mult_expr, 0), mult_expr,
+- 0, vec_factors);
+- get_factors_from_mul_expr (TREE_OPERAND (mult_expr, 1), mult_expr,
+- 1, vec_factors);
+- }
+-}
+-
+-/* Given an OFFSET expression, and the ELEMENT_SIZE,
+- get the index expression from OFFSET and return it.
+- For example:
+- OFFSET:
+- ((long unsigned int) m * (long unsigned int) SAVE_EXPR <n>) * 4
+- ELEMENT_SIZE:
+- (sizetype) SAVE_EXPR <n> * 4
+- get the index as (long unsigned int) m, and return it.
+- The INDEX_P holds the pointer to the parent tree of the index,
+- INDEX_N holds the position of the index in its parent. */
+-
+-static tree
+-get_index_from_offset (tree offset, tree *index_p,
+- int *index_n, tree element_size)
+-{
+- if (TREE_CODE (offset) != MULT_EXPR)
+- return NULL_TREE;
+-
+- auto_vec<factor_t> e_factors, o_factors;
+- get_factors_from_mul_expr (element_size, NULL, -1, &e_factors);
+- get_factors_from_mul_expr (offset, *index_p, *index_n, &o_factors);
+-
+- if (e_factors.is_empty () || o_factors.is_empty ())
+- return NULL_TREE;
+-
+- bool all_found = true;
+- for (unsigned i = 0; i < e_factors.length (); i++)
+- {
+- factor_t e_size_factor = e_factors[i];
+- bool found = false;
+- for (unsigned j = 0; j < o_factors.length ();)
+- {
+- factor_t o_exp_factor = o_factors[j];
+- if (operand_equal_p (e_size_factor.factor, o_exp_factor.factor))
+- {
+- o_factors.unordered_remove (j);
+- found = true;
+- break;
+- }
+- else
+- j++;
+- }
+- if (!found)
+- all_found = false;
+- }
+-
+- if (!all_found)
+- return NULL_TREE;
+-
+- if (o_factors.length () != 1)
+- return NULL_TREE;
+-
+- *index_p = o_factors[0].parent;
+- *index_n = o_factors[0].pos;
+- return o_factors[0].factor;
+-}
+-
+-/* For an pointer + offset computation expression, such as,
+- *.ACCESS_WITH_SIZE (p->c, &p->b, 1, 0, -1, 0B)
+- + (sizetype) ((long unsigned int) index * 4
+- Return the index of this pointer array reference,
+- set the parent tree of INDEX to *INDEX_P.
+- set the operand position of the INDEX in the parent tree to *INDEX_N.
+- If failed, return NULL_TREE. */
+-
+-static tree
+-get_index_from_pointer_addr_expr (tree pointer, tree *index_p, int *index_n)
+-{
+- *index_p = NULL_TREE;
+- *index_n = -1;
+- if (TREE_CODE (TREE_OPERAND (pointer, 0)) != INDIRECT_REF)
+- return NULL_TREE;
+- tree call = TREE_OPERAND (TREE_OPERAND (pointer, 0), 0);
+- if (!is_access_with_size_p (call))
+- return NULL_TREE;
+-
+- /* Get the pointee type of the call to .ACCESS_WITH_SIZE.
+- This should be the element type of the pointer array. */
+- tree pointee_type = TREE_TYPE (TREE_TYPE (TREE_TYPE (call)));
+- tree pointee_size = TYPE_SIZE_UNIT (pointee_type);
+-
+- tree index_exp = TREE_OPERAND (pointer, 1);
+- *index_p = pointer;
+- *index_n = 1;
+-
+- if (!(TREE_CODE (index_exp) != MULT_EXPR
+- && tree_int_cst_equal (pointee_size, integer_one_node)))
+- {
+- while (CONVERT_EXPR_CODE_P (TREE_CODE (index_exp)))
+- {
+- *index_p = index_exp;
+- *index_n = 0;
+- index_exp = TREE_OPERAND (index_exp, 0);
+- }
+- index_exp = get_index_from_offset (index_exp, index_p,
+- index_n, pointee_size);
+-
+- if (!index_exp)
+- return NULL_TREE;
+- }
+-
+- while (CONVERT_EXPR_CODE_P (TREE_CODE (index_exp)))
+- {
+- *index_p = index_exp;
+- *index_n = 0;
+- index_exp = TREE_OPERAND (index_exp, 0);
+- }
+-
+- return index_exp;
+-}
+-
+-/* Return TRUE when the EXPR is a pointer array address that could be
+- instrumented.
+- We only instrument an address computation similar as the following:
+- *.ACCESS_WITH_SIZE (p->c, &p->b, 1, 0, -1, 0B)
+- + (sizetype) ((long unsigned int) index * 4)
+- if the EXPR is instrumentable, return TRUE and
+- set the index to *INDEX.
+- set the *.ACCESS_WITH_SIZE to *BASE.
+- set the parent tree of INDEX to *INDEX_P.
+- set the operand position of the INDEX in the parent tree to INDEX_N. */
+-
+-static bool
+-is_instrumentable_pointer_array_address (tree expr, tree *base,
+- tree *index, tree *index_p,
+- int *index_n)
+-{
+- /* For a poiner array address as:
+- (*.ACCESS_WITH_SIZE (p->c, &p->b, 1, 0, -1, 0B)
+- + (sizetype) ((long unsigned int) index * 4)
+- op0 is the call to *.ACCESS_WITH_SIZE;
+- op1 is the index. */
+- if (TREE_CODE (expr) != POINTER_PLUS_EXPR)
+- return false;
+-
+- tree op0 = TREE_OPERAND (expr, 0);
+- if (TREE_CODE (op0) != INDIRECT_REF)
+- return false;
+- if (!is_access_with_size_p (TREE_OPERAND (op0, 0)))
+- return false;
+- tree op1 = get_index_from_pointer_addr_expr (expr, index_p, index_n);
+- if (op1 != NULL_TREE)
+- {
+- *base = op0;
+- *index = op1;
+- return true;
+- }
+- return false;
+-}
+-
+-/* Return true iff T is an array or an indirect reference that was
+- instrumented by SANITIZE_BOUNDS. */
++/* Return true iff T is an array that was instrumented by SANITIZE_BOUNDS. */
+
+ bool
+-ubsan_array_ref_instrumented_p (tree t)
++ubsan_array_ref_instrumented_p (const_tree t)
+ {
+- if (TREE_CODE (t) != ARRAY_REF
+- && TREE_CODE (t) != MEM_REF)
++ if (TREE_CODE (t) != ARRAY_REF)
+ return false;
+
+- bool is_array = (TREE_CODE (t) == ARRAY_REF);
+- tree op0 = NULL_TREE;
+- tree op1 = NULL_TREE;
+- tree index_p = NULL_TREE;
+- int index_n = 0;
+- if (is_array)
+- {
+- op1 = TREE_OPERAND (t, 1);
+- return TREE_CODE (op1) == COMPOUND_EXPR
+- && TREE_CODE (TREE_OPERAND (op1, 0)) == CALL_EXPR
+- && CALL_EXPR_FN (TREE_OPERAND (op1, 0)) == NULL_TREE
+- && CALL_EXPR_IFN (TREE_OPERAND (op1, 0)) == IFN_UBSAN_BOUNDS;
+- }
+- else if (is_instrumentable_pointer_array_address (t, &op0, &op1,
+- &index_p, &index_n))
+- return TREE_CODE (op1) == COMPOUND_EXPR
+- && TREE_CODE (TREE_OPERAND (op1, 0)) == CALL_EXPR
+- && CALL_EXPR_FN (TREE_OPERAND (op1, 0)) == NULL_TREE
+- && CALL_EXPR_IFN (TREE_OPERAND (op1, 0)) == IFN_UBSAN_BOUNDS;
+-
+- return false;
++ tree op1 = TREE_OPERAND (t, 1);
++ return TREE_CODE (op1) == COMPOUND_EXPR
++ && TREE_CODE (TREE_OPERAND (op1, 0)) == CALL_EXPR
++ && CALL_EXPR_FN (TREE_OPERAND (op1, 0)) == NULL_TREE
++ && CALL_EXPR_IFN (TREE_OPERAND (op1, 0)) == IFN_UBSAN_BOUNDS;
+ }
+
+-/* Instrument an ARRAY_REF or an address computation whose base address is
+- a call to .ACCESS_WITH_SIZE, if it hasn't already been instrumented.
+- IGNORE_OFF_BY_ONE is true if the ARRAY_REF is inside a ADDR_EXPR, or the
+- address computation is not inside a INDIRECT_REF. */
++/* Instrument an ARRAY_REF, if it hasn't already been instrumented.
++ IGNORE_OFF_BY_ONE is true if the ARRAY_REF is inside a ADDR_EXPR. */
+
+ void
+ ubsan_maybe_instrument_array_ref (tree *expr_p, bool ignore_off_by_one)
+ {
+- tree e = NULL_TREE;
+- tree op0 = NULL_TREE;
+- tree op1 = NULL_TREE;
+- tree index_p = NULL_TREE; /* the parent tree of INDEX. */
+- int index_n = 0; /* the operand position of INDEX in the parent tree. */
+-
+ if (!ubsan_array_ref_instrumented_p (*expr_p)
+ && sanitize_flags_p (SANITIZE_BOUNDS | SANITIZE_BOUNDS_STRICT)
+ && current_function_decl != NULL_TREE)
+ {
+- if (TREE_CODE (*expr_p) == ARRAY_REF)
+- {
+- op0 = TREE_OPERAND (*expr_p, 0);
+- op1 = TREE_OPERAND (*expr_p, 1);
+- index_p = *expr_p;
+- index_n = 1;
+- e = ubsan_instrument_bounds (EXPR_LOCATION (*expr_p), op0,
+- &op1, ignore_off_by_one);
+- }
+- else if (is_instrumentable_pointer_array_address (*expr_p, &op0, &op1,
+- &index_p, &index_n))
+- e = ubsan_instrument_bounds_pointer_address (EXPR_LOCATION (*expr_p),
+- op0, &op1,
+- ignore_off_by_one);
+-
+- /* Replace the original INDEX with the instrumented INDEX. */
++ tree op0 = TREE_OPERAND (*expr_p, 0);
++ tree op1 = TREE_OPERAND (*expr_p, 1);
++ tree e = ubsan_instrument_bounds (EXPR_LOCATION (*expr_p), op0, &op1,
++ ignore_off_by_one);
+ if (e != NULL_TREE)
+- TREE_OPERAND (index_p, index_n)
+- = build2 (COMPOUND_EXPR, TREE_TYPE (op1), e, op1);
++ TREE_OPERAND (*expr_p, 1) = build2 (COMPOUND_EXPR, TREE_TYPE (op1),
++ e, op1);
+ }
+ }
+
+diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c
+deleted file mode 100644
+index 0653eccff3e1..000000000000
+--- a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c
++++ /dev/null
+@@ -1,51 +0,0 @@
+-/* Test the attribute counted_by for pointer fields and its usage in
+- bounds sanitizer combined with VLA. */
+-/* { dg-do run } */
+-/* { dg-options "-fsanitize=bounds" } */
+-/* { dg-output "index 11 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+-/* { dg-output "\[^\n\r]*index 20 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+-/* { dg-output "\[^\n\r]*index 11 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+-/* { dg-output "\[^\n\r]*index 10 out of bounds for type 'int \\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+-
+-
+-#include <stdlib.h>
+-
+-void __attribute__((__noinline__)) setup_and_test_vla (int n, int m)
+-{
+- struct foo {
+- int n;
+- int (*p)[n] __attribute__((counted_by(n)));
+- } *f;
+-
+- f = (struct foo *) malloc (sizeof (struct foo));
+- f->p = (int (*)[n]) malloc (m * sizeof (int[n]));
+- f->n = m;
+- f->p[m][n-1] = 1;
+- free (f->p);
+- free (f);
+- return;
+-}
+-
+-void __attribute__((__noinline__)) setup_and_test_vla_1 (int n1, int n2, int m)
+-{
+- struct foo {
+- int n;
+- int (*p)[n2][n1] __attribute__((counted_by(n)));
+- } *f;
+-
+- f = (struct foo *) malloc (sizeof(struct foo));
+- f->p = (int (*)[n2][n1]) malloc (m * sizeof (int[n2][n1]));
+- f->n = m;
+- f->p[m][n2][n1] = 1;
+- free (f->p);
+- free (f);
+- return;
+-}
+-
+-int main(int argc, char *argv[])
+-{
+- setup_and_test_vla (10, 11);
+- setup_and_test_vla_1 (10, 11, 20);
+- return 0;
+-}
+-
+diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c
+deleted file mode 100644
+index 731422d7789a..000000000000
+--- a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c
++++ /dev/null
+@@ -1,42 +0,0 @@
+-/* Test the attribute counted_by for pointer fields and its usage in bounds
+- sanitizer. when counted_by field is negative value. */
+-/* { dg-do run } */
+-/* { dg-options "-fsanitize=bounds" } */
+-
+-#include <stdlib.h>
+-
+-struct annotated {
+- int b;
+- int *c __attribute__ ((counted_by (b)));
+-} *array_annotated;
+-
+-void __attribute__((__noinline__)) setup (int annotated_count)
+-{
+- array_annotated
+- = (struct annotated *)malloc (sizeof (struct annotated));
+- array_annotated->c = (int *) malloc (sizeof (int) * 10);
+- array_annotated->b = annotated_count;
+-
+- return;
+-}
+-
+-void __attribute__((__noinline__)) test (int annotated_index)
+-{
+- array_annotated->c[annotated_index] = 2;
+-}
+-
+-void cleanup ()
+-{
+- free (array_annotated->c);
+- free (array_annotated);
+-}
+-
+-int main(int argc, char *argv[])
+-{
+- setup (-3);
+- test (2);
+- cleanup ();
+- return 0;
+-}
+-
+-/* { dg-output "25:21: runtime error: index 2 out of bounds for type" } */
+diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c
+deleted file mode 100644
+index 52f202f51f9f..000000000000
+--- a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c
++++ /dev/null
+@@ -1,42 +0,0 @@
+-/* Test the attribute counted_by for pointer fields and its usage in bounds
+- sanitizer. when counted_by field is zero value. */
+-/* { dg-do run } */
+-/* { dg-options "-fsanitize=bounds" } */
+-
+-#include <stdlib.h>
+-
+-struct annotated {
+- int b;
+- int *c __attribute__ ((counted_by (b)));
+-} *array_annotated;
+-
+-void __attribute__((__noinline__)) setup (int annotated_count)
+-{
+- array_annotated
+- = (struct annotated *)malloc (sizeof (struct annotated));
+- array_annotated->c = (int *)malloc (sizeof (int) * 10);
+- array_annotated->b = annotated_count;
+-
+- return;
+-}
+-
+-void __attribute__((__noinline__)) test (int annotated_index)
+-{
+- array_annotated->c[annotated_index] = 2;
+-}
+-
+-void cleanup ()
+-{
+- free (array_annotated->c);
+- free (array_annotated);
+-}
+-
+-int main(int argc, char *argv[])
+-{
+- setup (0);
+- test (1);
+- cleanup ();
+- return 0;
+-}
+-
+-/* { dg-output "25:21: runtime error: index 1 out of bounds for type" } */
+diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c
+deleted file mode 100644
+index 8ad7572d1405..000000000000
+--- a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c
++++ /dev/null
+@@ -1,40 +0,0 @@
+-/* Test the attribute counted_by for pointer fields and its usage in
+- bounds sanitizer. */
+-/* { dg-do run } */
+-/* { dg-options "-fsanitize=bounds" } */
+-
+-#include <stdlib.h>
+-
+-struct annotated {
+- int b;
+- int *c __attribute__ ((counted_by (b)));
+-} *p_array_annotated;
+-
+-void __attribute__((__noinline__)) setup (int annotated_count)
+-{
+- p_array_annotated
+- = (struct annotated *)malloc (sizeof (struct annotated));
+- p_array_annotated->c = (int *) malloc (annotated_count * sizeof (int));
+- p_array_annotated->b = annotated_count;
+-
+- return;
+-}
+-
+-void cleanup ()
+-{
+- free (p_array_annotated->c);
+- free (p_array_annotated);
+-}
+-
+-int main(int argc, char *argv[])
+-{
+- int i;
+- setup (10);
+- for (i = 0; i < 11; i++)
+- p_array_annotated->c[i] = 2; // goes boom at i == 10
+- cleanup ();
+- return 0;
+-}
+-
+-
+-/* { dg-output "34:25: runtime error: index 10 out of bounds for type" } */
+diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c
+deleted file mode 100644
+index c5a1ac53be6d..000000000000
+--- a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c
++++ /dev/null
+@@ -1,46 +0,0 @@
+-/* Test the attribute counted_by for pointer fields and its usage in
+- bounds sanitizer. */
+-/* { dg-do run } */
+-/* { dg-options "-fsanitize=bounds" } */
+-
+-#include <stdlib.h>
+-
+-struct pointer_array {
+- int b;
+- int *c;
+-} *p_array;
+-
+-struct annotated {
+- int b;
+- int *c __attribute__ ((counted_by (b)));
+-} *p_array_annotated;
+-
+-void __attribute__((__noinline__)) setup (int normal_count, int annotated_count)
+-{
+- p_array
+- = (struct pointer_array *) malloc (sizeof (struct pointer_array));
+- p_array->c = (int *) malloc (normal_count * sizeof (int));
+- p_array->b = normal_count;
+-
+- p_array_annotated
+- = (struct annotated *) malloc (sizeof (struct annotated));
+- p_array_annotated->c = (int *) malloc (annotated_count * sizeof (int));
+- p_array_annotated->b = annotated_count;
+-
+- return;
+-}
+-
+-void __attribute__((__noinline__)) test (int normal_index, int annotated_index)
+-{
+- p_array->c[normal_index] = 1;
+- p_array_annotated->c[annotated_index] = 2;
+-}
+-
+-int main(int argc, char *argv[])
+-{
+- setup (10, 10);
+- test (10, 10);
+- return 0;
+-}
+-
+-/* { dg-output "36:23: runtime error: index 10 out of bounds for type" } */
+
+base-commit: b8a7d51253695febe6598069ccd89280b45d0abe
+--
+2.50.0
+
diff --git a/16.0.0/gentoo/86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch b/16.0.0/gentoo/86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch
new file mode 100644
index 0000000..c704da9
--- /dev/null
+++ b/16.0.0/gentoo/86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch
@@ -0,0 +1,382 @@
+https://gcc.gnu.org/PR120929
+
+From 67769e431a764258ea3b3b983eae19089864fe62 Mon Sep 17 00:00:00 2001
+Message-ID: <67769e431a764258ea3b3b983eae19089864fe62.1751506033.git.sam@gentoo.org>
+In-Reply-To: <75017c57b4f66552d02efda7e7d5eade1ba0ee80.1751506033.git.sam@gentoo.org>
+References: <75017c57b4f66552d02efda7e7d5eade1ba0ee80.1751506033.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Thu, 3 Jul 2025 02:27:06 +0100
+Subject: [PATCH 2/2] Revert "Use the counted_by attribute of pointers in
+ builtinin-object-size."
+
+This reverts commit 7165ca43caf47007f5ceaa46c034618d397d42ec.
+---
+ .../gcc.dg/pointer-counted-by-4-char.c | 6 --
+ .../gcc.dg/pointer-counted-by-4-float.c | 6 --
+ .../gcc.dg/pointer-counted-by-4-struct.c | 10 ---
+ .../gcc.dg/pointer-counted-by-4-union.c | 10 ---
+ gcc/testsuite/gcc.dg/pointer-counted-by-4.c | 77 -------------------
+ gcc/testsuite/gcc.dg/pointer-counted-by-5.c | 56 --------------
+ gcc/testsuite/gcc.dg/pointer-counted-by-6.c | 56 --------------
+ gcc/testsuite/gcc.dg/pointer-counted-by-7.c | 32 --------
+ gcc/tree-object-size.cc | 19 +----
+ 9 files changed, 3 insertions(+), 269 deletions(-)
+ delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c
+ delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c
+ delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c
+ delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c
+ delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-4.c
+ delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-5.c
+ delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-6.c
+ delete mode 100644 gcc/testsuite/gcc.dg/pointer-counted-by-7.c
+
+diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c
+deleted file mode 100644
+index c404e5b8ccec..000000000000
+--- a/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c
++++ /dev/null
+@@ -1,6 +0,0 @@
+-/* Test the attribute counted_by for pointer field and its usage in
+- * __builtin_dynamic_object_size. */
+-/* { dg-do run } */
+-/* { dg-options "-O2" } */
+-#define PTR_TYPE char
+-#include "pointer-counted-by-4.c"
+diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c
+deleted file mode 100644
+index 383d8fb656df..000000000000
+--- a/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c
++++ /dev/null
+@@ -1,6 +0,0 @@
+-/* Test the attribute counted_by for pointer field and its usage in
+- * __builtin_dynamic_object_size. */
+-/* { dg-do run } */
+-/* { dg-options "-O2" } */
+-#define PTR_TYPE float
+-#include "pointer-counted-by-4.c"
+diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c
+deleted file mode 100644
+index 50246d29477b..000000000000
+--- a/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c
++++ /dev/null
+@@ -1,10 +0,0 @@
+-/* Test the attribute counted_by for pointer field and its usage in
+- * __builtin_dynamic_object_size. */
+-/* { dg-do run } */
+-/* { dg-options "-O2" } */
+-struct A {
+- int a;
+- char *b;
+-};
+-#define PTR_TYPE struct A
+-#include "pointer-counted-by-4.c"
+diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c
+deleted file mode 100644
+index e786d9961475..000000000000
+--- a/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c
++++ /dev/null
+@@ -1,10 +0,0 @@
+-/* Test the attribute counted_by for pointer field and its usage in
+- * __builtin_dynamic_object_size. */
+-/* { dg-do run } */
+-/* { dg-options "-O2" } */
+-union A {
+- int a;
+- float b;
+-};
+-#define PTR_TYPE union A
+-#include "pointer-counted-by-4.c"
+diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4.c
+deleted file mode 100644
+index c4b36311c704..000000000000
+--- a/gcc/testsuite/gcc.dg/pointer-counted-by-4.c
++++ /dev/null
+@@ -1,77 +0,0 @@
+-/* Test the attribute counted_by for pointer field and its usage in
+- * __builtin_dynamic_object_size. */
+-/* { dg-do run } */
+-/* { dg-options "-O2" } */
+-
+-#include "builtin-object-size-common.h"
+-#ifndef PTR_TYPE
+-#define PTR_TYPE int
+-#endif
+-struct pointer_array {
+- int b;
+- PTR_TYPE *c;
+-} *p_array;
+-
+-struct annotated {
+- PTR_TYPE *c __attribute__ ((counted_by (b)));
+- int b;
+-} *p_array_annotated;
+-
+-struct nested_annotated {
+- PTR_TYPE *c __attribute__ ((counted_by (b)));
+- struct {
+- union {
+- int b;
+- float f;
+- };
+- int n;
+- };
+-} *p_array_nested_annotated;
+-
+-void __attribute__((__noinline__)) setup (int normal_count, int attr_count)
+-{
+- p_array
+- = (struct pointer_array *) malloc (sizeof (struct pointer_array));
+- p_array->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * normal_count);
+- p_array->b = normal_count;
+-
+- p_array_annotated
+- = (struct annotated *) malloc (sizeof (struct annotated));
+- p_array_annotated->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * attr_count);
+- p_array_annotated->b = attr_count;
+-
+- p_array_nested_annotated
+- = (struct nested_annotated *) malloc (sizeof (struct nested_annotated));
+- p_array_nested_annotated->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * attr_count);
+- p_array_nested_annotated->b = attr_count;
+-
+- return;
+-}
+-
+-void __attribute__((__noinline__)) test ()
+-{
+- EXPECT(__builtin_dynamic_object_size(p_array->c, 1), -1);
+- EXPECT(__builtin_dynamic_object_size(p_array_annotated->c, 1),
+- p_array_annotated->b * sizeof (PTR_TYPE));
+- EXPECT(__builtin_dynamic_object_size(p_array_nested_annotated->c, 1),
+- p_array_nested_annotated->b * sizeof (PTR_TYPE));
+-}
+-
+-void cleanup ()
+-{
+- free (p_array->c);
+- free (p_array);
+- free (p_array_annotated->c);
+- free (p_array_annotated);
+- free (p_array_nested_annotated->c);
+- free (p_array_nested_annotated);
+-}
+-
+-int main(int argc, char *argv[])
+-{
+- setup (10,10);
+- test ();
+- DONE ();
+- cleanup ();
+- return 0;
+-}
+diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-5.c b/gcc/testsuite/gcc.dg/pointer-counted-by-5.c
+deleted file mode 100644
+index b43ffdf4df9f..000000000000
+--- a/gcc/testsuite/gcc.dg/pointer-counted-by-5.c
++++ /dev/null
+@@ -1,56 +0,0 @@
+-/* Test the attribute counted_by for pointer fields and its usage in
+- * __builtin_dynamic_object_size: when the counted_by field is negative. */
+-/* { dg-do run } */
+-/* { dg-options "-O2" } */
+-
+-#include "builtin-object-size-common.h"
+-
+-struct annotated {
+- int b;
+- int *c __attribute__ ((counted_by (b)));
+-} *array_annotated;
+-
+-struct nested_annotated {
+- int *c __attribute__ ((counted_by (b)));
+- struct {
+- union {
+- int b;
+- float f;
+- };
+- int n;
+- };
+-} *array_nested_annotated;
+-
+-void __attribute__((__noinline__)) setup (int attr_count)
+-{
+- array_annotated
+- = (struct annotated *)malloc (sizeof (struct annotated));
+- array_annotated->b = attr_count;
+-
+- array_nested_annotated
+- = (struct nested_annotated *)malloc (sizeof (struct nested_annotated));
+- array_nested_annotated->b = attr_count - 1;
+-
+- return;
+-}
+-
+-void __attribute__((__noinline__)) test ()
+-{
+- EXPECT(__builtin_dynamic_object_size(array_annotated->c, 1), 0);
+- EXPECT(__builtin_dynamic_object_size(array_nested_annotated->c, 1), 0);
+-}
+-
+-void cleanup ()
+-{
+- free (array_annotated);
+- free (array_nested_annotated);
+-}
+-
+-int main(int argc, char *argv[])
+-{
+- setup (-10);
+- test ();
+- DONE ();
+- cleanup ();
+- return 0;
+-}
+diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-6.c b/gcc/testsuite/gcc.dg/pointer-counted-by-6.c
+deleted file mode 100644
+index 355558cd161d..000000000000
+--- a/gcc/testsuite/gcc.dg/pointer-counted-by-6.c
++++ /dev/null
+@@ -1,56 +0,0 @@
+-/* Test the attribute counted_by for pointer fields and its usage in
+- * __builtin_dynamic_object_size: when the type of the pointer
+- * is casting to another type. */
+-/* { dg-do run } */
+-/* { dg-options "-O2" } */
+-
+-#include "builtin-object-size-common.h"
+-
+-typedef unsigned short u16;
+-
+-struct info {
+- u16 data_len;
+- char *data __attribute__((counted_by(data_len)));
+-};
+-
+-struct foo {
+- int a;
+- int b;
+-};
+-
+-static __attribute__((__noinline__))
+-struct info *setup ()
+-{
+- struct info *p;
+- size_t bytes = 3 * sizeof(struct foo);
+-
+- p = (struct info *) malloc (sizeof (struct info));
+- p->data = (char *) malloc (bytes);
+- p->data_len = bytes;
+-
+- return p;
+-}
+-
+-static void
+-__attribute__((__noinline__)) report (struct info *p)
+-{
+- struct foo *bar = (struct foo *)p->data;
+- EXPECT(__builtin_dynamic_object_size((char *)(bar + 1), 1),
+- sizeof (struct foo) * 2);
+- EXPECT(__builtin_dynamic_object_size((char *)(bar + 2), 1),
+- sizeof (struct foo));
+-}
+-
+-void cleanup (struct info *p)
+-{
+- free (p->data);
+- free (p);
+-}
+-
+-int main(int argc, char *argv[])
+-{
+- struct info *p = setup();
+- report(p);
+- cleanup (p);
+- return 0;
+-}
+diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-7.c b/gcc/testsuite/gcc.dg/pointer-counted-by-7.c
+deleted file mode 100644
+index af1ab2794007..000000000000
+--- a/gcc/testsuite/gcc.dg/pointer-counted-by-7.c
++++ /dev/null
+@@ -1,32 +0,0 @@
+-/* Additional test of the attribute counted_by for pointer field and its usage
+- in __builtin_dynamic_object_size. */
+-/* { dg-do run } */
+-/* { dg-options "-O2" } */
+-
+-#include "builtin-object-size-common.h"
+-
+-struct annotated {
+- int b;
+- int *c __attribute__ ((counted_by (b)));
+-};
+-
+-struct annotated __attribute__((__noinline__)) setup (int attr_count)
+-{
+- struct annotated p_array_annotated;
+- p_array_annotated.c = (int *) malloc (sizeof (int) * attr_count);
+- p_array_annotated.b = attr_count;
+-
+- return p_array_annotated;
+-}
+-
+-int main(int argc, char *argv[])
+-{
+- struct annotated x = setup (10);
+- int *p = x.c;
+- x = setup (20);
+- EXPECT(__builtin_dynamic_object_size (p, 1), 10 * sizeof (int));
+- EXPECT(__builtin_dynamic_object_size (x.c, 1), 20 * sizeof (int));
+- free (p);
+- free (x.c);
+- DONE ();
+-}
+diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc
+index ec4419fbab1d..f348673ae758 100644
+--- a/gcc/tree-object-size.cc
++++ b/gcc/tree-object-size.cc
+@@ -773,12 +773,10 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
+ 4th argument TYPE_OF_SIZE: A constant 0 with its TYPE being the same as the TYPE
+ of the object referenced by REF_TO_SIZE
+ 6th argument: A constant 0 with the pointer TYPE to the original flexible
+- array type or pointer field type.
++ array type.
+
+ The size of the element can be retrived from the TYPE of the 6th argument
+- of the call, which is the pointer to the original flexible array type or
+- the type of the original pointer field. */
+-
++ of the call, which is the pointer to the array type. */
+ static tree
+ access_with_size_object_size (const gcall *call, int object_size_type)
+ {
+@@ -788,7 +786,7 @@ access_with_size_object_size (const gcall *call, int object_size_type)
+
+ gcc_assert (gimple_call_internal_p (call, IFN_ACCESS_WITH_SIZE));
+ /* The type of the 6th argument type is the pointer TYPE to the original
+- flexible array type or to the original pointer type. */
++ flexible array type. */
+ tree pointer_to_array_type = TREE_TYPE (gimple_call_arg (call, 5));
+ gcc_assert (POINTER_TYPE_P (pointer_to_array_type));
+ tree element_type = TREE_TYPE (TREE_TYPE (pointer_to_array_type));
+@@ -1856,17 +1854,6 @@ collect_object_sizes_for (struct object_size_info *osi, tree var)
+ if (TREE_CODE (rhs) == SSA_NAME
+ && POINTER_TYPE_P (TREE_TYPE (rhs)))
+ reexamine = merge_object_sizes (osi, var, rhs);
+- /* Handle the following stmt #2 to propagate the size from the
+- stmt #1 to #3:
+- 1 _1 = .ACCESS_WITH_SIZE (_3, _4, 1, 0, -1, 0B);
+- 2 _5 = *_1;
+- 3 _6 = __builtin_dynamic_object_size (_5, 1);
+- */
+- else if (TREE_CODE (rhs) == MEM_REF
+- && POINTER_TYPE_P (TREE_TYPE (rhs))
+- && TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME
+- && integer_zerop (TREE_OPERAND (rhs, 1)))
+- reexamine = merge_object_sizes (osi, var, TREE_OPERAND (rhs, 0));
+ else
+ expr_object_size (osi, var, rhs);
+ }
+--
+2.50.0
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 5bf2e2f..4fcaa04 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,8 @@
5 ????
- 85_all_PR120840.patch
+ + 85_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-a.patch
+ + 86_all_PR120929-Revert-Use-the-counted_by-attribute-of-pointers-in-b.patch
4 30 June 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-30 6:26 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-30 6:26 UTC (permalink / raw
To: gentoo-commits
commit: 3008902714edf02caa6d2d66c5aedf3405f59074
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 30 06:25:49 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jun 30 06:25:49 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=30089027
16.0.0: drop patch merged upstream
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/85_all_PR120840.patch | 873 ------------------------------------
16.0.0/gentoo/README.history | 4 +
2 files changed, 4 insertions(+), 873 deletions(-)
diff --git a/16.0.0/gentoo/85_all_PR120840.patch b/16.0.0/gentoo/85_all_PR120840.patch
deleted file mode 100644
index c9c710f..0000000
--- a/16.0.0/gentoo/85_all_PR120840.patch
+++ /dev/null
@@ -1,873 +0,0 @@
-https://inbox.sourceware.org/gcc-patches/CAMe9rOpBxdLoJrGZqt5_JhPAuvWUOpGWMLiGg=dSKkYtdqV9KA@mail.gmail.com/
-
-From cefa274db3abc864bbe4d163d78108fb50fb9e97 Mon Sep 17 00:00:00 2001
-Message-ID: <cefa274db3abc864bbe4d163d78108fb50fb9e97.1751156913.git.sam@gentoo.org>
-From: "H.J. Lu" <hjl.tools@gmail.com>
-Date: Sat, 28 Jun 2025 09:39:41 +0800
-Subject: [PATCH] x86: Preserve frame pointer for no_callee_saved_registers
- attribute
-
-Update functions with no_callee_saved_registers/preserve_none attribute
-to preserve frame pointer since caller may use it to save the current
-stack:
-
- pushq %rbp
- movq %rsp, %rbp
- ...
- call function
- ...
- leave
- ret
-
-If callee changes frame pointer without restoring it, caller will fail
-to restore its stack after callee returns.
-
-There are no regressions on Linux/x86-64. Also tested with
-
-https://github.com/python/cpython
-
-configured with "./configure --with-tail-call-interp".
-
-gcc/
-
- PR target/120840
- * config/i386/i386-expand.cc (ix86_expand_call): Don't mark
- hard frame pointer as clobber.
- * config/i386/i386-options.cc (ix86_set_func_type): Use
- TYPE_NO_CALLEE_SAVED_REGISTERS instead of
- TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP.
- * config/i386/i386.cc (ix86_function_ok_for_sibcall): Remove the
- TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP check.
- (ix86_save_reg): Merge TYPE_NO_CALLEE_SAVED_REGISTERS and
- TYPE_PRESERVE_NONE with TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP.
- * config/i386/i386.h (call_saved_registers_type): Remove
- TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP.
- * doc/extend.texi: Update no_callee_saved_registers documentation.
-
-gcc/testsuite/
-
- PR target/120840
- * gcc.target/i386/no-callee-saved-1.c: Updated.
- * gcc.target/i386/no-callee-saved-2.c: Likewise.
- * gcc.target/i386/no-callee-saved-7.c: Likewise.
- * gcc.target/i386/no-callee-saved-8.c: Likewise.
- * gcc.target/i386/no-callee-saved-9.c: Likewise.
- * gcc.target/i386/no-callee-saved-10.c: Likewise.
- * gcc.target/i386/no-callee-saved-18.c: Likewise.
- * gcc.target/i386/no-callee-saved-19a.c: Likewise.
- * gcc.target/i386/no-callee-saved-19c.c: Likewise.
- * gcc.target/i386/no-callee-saved-19d.c: Likewise.
- * gcc.target/i386/pr119784a.c: Likewise.
- * gcc.target/i386/preserve-none-6.c: Likewise.
- * gcc.target/i386/preserve-none-7.c: Likewise.
- * gcc.target/i386/preserve-none-12.c: Likewise.
- * gcc.target/i386/preserve-none-13.c: Likewise.
- * gcc.target/i386/preserve-none-14.c: Likewise.
- * gcc.target/i386/preserve-none-15.c: Likewise.
- * gcc.target/i386/preserve-none-23.c: Likewise.
- * gcc.target/i386/pr120840-1a.c: New test.
- * gcc.target/i386/pr120840-1b.c: Likewise.
- * gcc.target/i386/pr120840-1c.c: Likewise.
- * gcc.target/i386/pr120840-1d.c: Likewise.
-
-Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
----
- gcc/config/i386/i386-expand.cc | 1 +
- gcc/config/i386/i386-options.cc | 23 +++--
- gcc/config/i386/i386.cc | 5 --
- gcc/config/i386/i386.h | 3 -
- gcc/doc/extend.texi | 9 +-
- .../gcc.target/i386/no-callee-saved-1.c | 6 +-
- .../gcc.target/i386/no-callee-saved-10.c | 4 +-
- .../gcc.target/i386/no-callee-saved-18.c | 4 +-
- .../gcc.target/i386/no-callee-saved-19a.c | 32 ++++---
- .../gcc.target/i386/no-callee-saved-19c.c | 26 +++---
- .../gcc.target/i386/no-callee-saved-19d.c | 28 +++----
- .../gcc.target/i386/no-callee-saved-2.c | 6 +-
- .../gcc.target/i386/no-callee-saved-7.c | 4 +-
- .../gcc.target/i386/no-callee-saved-8.c | 4 +-
- .../gcc.target/i386/no-callee-saved-9.c | 4 +-
- gcc/testsuite/gcc.target/i386/pr119784a.c | 27 +++---
- gcc/testsuite/gcc.target/i386/pr120840-1a.c | 83 +++++++++++++++++++
- gcc/testsuite/gcc.target/i386/pr120840-1b.c | 20 +++++
- gcc/testsuite/gcc.target/i386/pr120840-1c.c | 20 +++++
- gcc/testsuite/gcc.target/i386/pr120840-1d.c | 20 +++++
- .../gcc.target/i386/preserve-none-12.c | 4 +-
- .../gcc.target/i386/preserve-none-13.c | 4 +-
- .../gcc.target/i386/preserve-none-14.c | 4 +-
- .../gcc.target/i386/preserve-none-15.c | 4 +-
- .../gcc.target/i386/preserve-none-23.c | 4 +-
- .../gcc.target/i386/preserve-none-6.c | 6 +-
- .../gcc.target/i386/preserve-none-7.c | 6 +-
- 27 files changed, 248 insertions(+), 113 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr120840-1a.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr120840-1b.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr120840-1c.c
- create mode 100644 gcc/testsuite/gcc.target/i386/pr120840-1d.c
-
-diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
-index c1c0cf9ff80a..83076adb55db 100644
---- a/gcc/config/i386/i386-expand.cc
-+++ b/gcc/config/i386/i386-expand.cc
-@@ -10377,6 +10377,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1,
- char c_mask = CALL_USED_REGISTERS_MASK (is_64bit_ms_abi);
- for (int i = 0; i < FIRST_PSEUDO_REGISTER; i++)
- if (!fixed_regs[i]
-+ && i != HARD_FRAME_POINTER_REGNUM
- && !(ix86_call_used_regs[i] == 1
- || (ix86_call_used_regs[i] & c_mask))
- && !STACK_REGNO_P (i)
-diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
-index 60c04f65d9f9..09cb1337f94c 100644
---- a/gcc/config/i386/i386-options.cc
-+++ b/gcc/config/i386/i386-options.cc
-@@ -3280,19 +3280,18 @@ ix86_set_func_type (tree fndecl)
- if (lookup_attribute ("preserve_none",
- TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
- no_callee_saved_registers = TYPE_PRESERVE_NONE;
-- else if (lookup_attribute ("no_callee_saved_registers",
-- TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
-+ else if ((lookup_attribute ("no_callee_saved_registers",
-+ TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
-+ || (ix86_noreturn_no_callee_saved_registers
-+ && TREE_THIS_VOLATILE (fndecl)
-+ && optimize
-+ && !optimize_debug
-+ && (TREE_NOTHROW (fndecl) || !flag_exceptions)
-+ && !lookup_attribute ("interrupt",
-+ TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))
-+ && !lookup_attribute ("no_caller_saved_registers",
-+ TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))))
- no_callee_saved_registers = TYPE_NO_CALLEE_SAVED_REGISTERS;
-- else if (ix86_noreturn_no_callee_saved_registers
-- && TREE_THIS_VOLATILE (fndecl)
-- && optimize
-- && !optimize_debug
-- && (TREE_NOTHROW (fndecl) || !flag_exceptions)
-- && !lookup_attribute ("interrupt",
-- TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))
-- && !lookup_attribute ("no_caller_saved_registers",
-- TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
-- no_callee_saved_registers = TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP;
-
- if (cfun->machine->func_type == TYPE_UNKNOWN)
- {
-diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
-index 5e9559f5c05e..44763c8eb014 100644
---- a/gcc/config/i386/i386.cc
-+++ b/gcc/config/i386/i386.cc
-@@ -1043,8 +1043,6 @@ ix86_function_ok_for_sibcall (tree decl, tree exp)
- if ((cfun->machine->call_saved_registers
- != TYPE_NO_CALLEE_SAVED_REGISTERS)
- && cfun->machine->call_saved_registers != TYPE_PRESERVE_NONE
-- && (cfun->machine->call_saved_registers
-- != TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP)
- && ix86_type_no_callee_saved_registers_p (type))
- return false;
-
-@@ -6774,9 +6772,6 @@ ix86_save_reg (unsigned int regno, bool maybe_eh_return, bool ignore_outlined)
-
- case TYPE_NO_CALLEE_SAVED_REGISTERS:
- case TYPE_PRESERVE_NONE:
-- return false;
--
-- case TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP:
- if (regno != HARD_FRAME_POINTER_REGNUM)
- return false;
- break;
-diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
-index a275a32682e6..45de61c64b23 100644
---- a/gcc/config/i386/i386.h
-+++ b/gcc/config/i386/i386.h
-@@ -2804,9 +2804,6 @@ enum call_saved_registers_type
- /* The current function is a function specified with the
- "no_callee_saved_registers" attribute. */
- TYPE_NO_CALLEE_SAVED_REGISTERS,
-- /* The current function is a function specified with the "noreturn"
-- attribute. */
-- TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP,
- /* The current function is a function specified with the
- "preserve_none" attribute. */
- TYPE_PRESERVE_NONE,
-diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
-index 946105d5cdcc..e9aa12ba1041 100644
---- a/gcc/doc/extend.texi
-+++ b/gcc/doc/extend.texi
-@@ -6124,10 +6124,11 @@ pass arguments, unless it takes a variable number of arguments.
- @cindex @code{no_callee_saved_registers} function attribute, x86
- @item no_callee_saved_registers
- Use this attribute to indicate that the specified function has no
--callee-saved registers. That is, all registers can be used as scratch
--registers. For example, this attribute can be used for a function
--called from the interrupt handler assembly stub which will preserve
--all registers and return from interrupt.
-+callee-saved registers. That is, all registers, except for stack and
-+frame pointers, can be used as scratch registers. For example, this
-+attribute can be used for a function called from the interrupt handler
-+assembly stub which will preserve all registers and return from
-+interrupt.
-
- @cindex @code{preserve_none} function attribute, x86
- @item preserve_none
-diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-1.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-1.c
-index 599c2a3fa191..e535485b1cf3 100644
---- a/gcc/testsuite/gcc.target/i386/no-callee-saved-1.c
-+++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-1.c
-@@ -26,5 +26,7 @@ foo (void *frame)
- }
- }
-
--/* { dg-final { scan-assembler-not "push" } } */
--/* { dg-final { scan-assembler-not "pop" } } */
-+/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*" 1 } } */
-+/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*" 1 } } */
-diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-10.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-10.c
-index 87766c6cd886..6c54144350e6 100644
---- a/gcc/testsuite/gcc.target/i386/no-callee-saved-10.c
-+++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-10.c
-@@ -18,7 +18,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)cx" 1 } } */
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)dx" 1 } } */
--/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)si" 1 } } */
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)di" 1 } } */
- /* { dg-final { scan-assembler-times "pushq\[\\t \]*%r8" 1 { target { ! ia32 } } } } */
-@@ -33,7 +33,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)cx" 1 } } */
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)dx" 1 } } */
--/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)si" 1 } } */
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)di" 1 } } */
- /* { dg-final { scan-assembler-times "popq\[\\t \]*%r8" 1 { target { ! ia32 } } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-18.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-18.c
-index e7101009be47..128b9c46e8ec 100644
---- a/gcc/testsuite/gcc.target/i386/no-callee-saved-18.c
-+++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-18.c
-@@ -19,7 +19,7 @@ foo (uintptr_t p)
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
-@@ -36,7 +36,7 @@ foo (uintptr_t p)
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-19a.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-19a.c
-index 25ef8558a5db..12f35cfa8bba 100644
---- a/gcc/testsuite/gcc.target/i386/no-callee-saved-19a.c
-+++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-19a.c
-@@ -16,9 +16,9 @@
-
- #define NEXT { op_t *op = next; [[gnu::musttail]] return (*op)(op + 1); }
- #ifdef __x86_64__
--# define CLOBBER asm("" ::: "r12","r13","r14","r15","rbp","rbx")
-+# define CLOBBER asm("" ::: "r12","r13","r14","r15","rbx")
- #else
--# define CLOBBER asm("" ::: "ebp","ebx")
-+# define CLOBBER asm("" ::: "ebx")
- #endif
- #define DONT_SAVE_REGS __attribute__((no_callee_saved_registers))
- #define SAVE_REGS __attribute__((no_caller_saved_registers))
-@@ -83,15 +83,14 @@ op_t code[] = { inc, inc, dec, end, };
- ** .cfi_startproc
- ** subq \$376, %rsp
- **...
--** movq %rax, 256\(%rsp\)
--** movq %rdx, 264\(%rsp\)
--** movq %rcx, 272\(%rsp\)
--** movq %rbx, 280\(%rsp\)
--** movq %rsi, 288\(%rsp\)
--** movq %rdi, 296\(%rsp\)
-+** movq %rdi, 304\(%rsp\)
- **...
- ** movl \$code\+8, %edi
--** movq %rbp, 304\(%rsp\)
-+** movq %rax, 264\(%rsp\)
-+** movq %rdx, 272\(%rsp\)
-+** movq %rcx, 280\(%rsp\)
-+** movq %rbx, 288\(%rsp\)
-+** movq %rsi, 296\(%rsp\)
- ** movq %r8, 312\(%rsp\)
- ** movq %r9, 320\(%rsp\)
- ** movq %r10, 328\(%rsp\)
-@@ -132,13 +131,12 @@ op_t code[] = { inc, inc, dec, end, };
- ** movaps 176\(%rsp\), %xmm11
- ** movaps 192\(%rsp\), %xmm12
- ** movaps 208\(%rsp\), %xmm13
--** movq 256\(%rsp\), %rax
--** movq 264\(%rsp\), %rdx
--** movq 272\(%rsp\), %rcx
--** movq 280\(%rsp\), %rbx
--** movq 288\(%rsp\), %rsi
--** movq 296\(%rsp\), %rdi
--** movq 304\(%rsp\), %rbp
-+** movq 264\(%rsp\), %rax
-+** movq 272\(%rsp\), %rdx
-+** movq 280\(%rsp\), %rcx
-+** movq 288\(%rsp\), %rbx
-+** movq 296\(%rsp\), %rsi
-+** movq 304\(%rsp\), %rdi
- ** movq 312\(%rsp\), %r8
- ** movq 320\(%rsp\), %r9
- ** movq 328\(%rsp\), %r10
-@@ -146,8 +144,8 @@ op_t code[] = { inc, inc, dec, end, };
- ** movq 344\(%rsp\), %r12
- ** movq 352\(%rsp\), %r13
- ** movq 360\(%rsp\), %r14
--** movaps 224\(%rsp\), %xmm14
- ** movq 368\(%rsp\), %r15
-+** movaps 224\(%rsp\), %xmm14
- ** movaps 240\(%rsp\), %xmm15
- ** addq \$376, %rsp
- **...
-diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-19c.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-19c.c
-index 2ad388d1a567..05aca9f4b119 100644
---- a/gcc/testsuite/gcc.target/i386/no-callee-saved-19c.c
-+++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-19c.c
-@@ -51,13 +51,12 @@
- **.LFB[0-9]+:
- ** .cfi_startproc
- **...
--** movl %eax, 140\(%esp\)
--** movl %edx, 144\(%esp\)
--** movl %ecx, 148\(%esp\)
--** movl %ebx, 152\(%esp\)
--** movl %esi, 156\(%esp\)
--** movl %edi, 160\(%esp\)
--** movl %ebp, 164\(%esp\)
-+** movl %eax, 144\(%esp\)
-+** movl %edx, 148\(%esp\)
-+** movl %ecx, 152\(%esp\)
-+** movl %ebx, 156\(%esp\)
-+** movl %esi, 160\(%esp\)
-+** movl %edi, 164\(%esp\)
- ** movaps %xmm0, 12\(%esp\)
- ** movaps %xmm1, 28\(%esp\)
- ** movaps %xmm2, 44\(%esp\)
-@@ -78,13 +77,12 @@
- ** movaps 96\(%esp\), %xmm5
- ** movaps 112\(%esp\), %xmm6
- ** movaps 128\(%esp\), %xmm7
--** movl 144\(%esp\), %eax
--** movl 148\(%esp\), %edx
--** movl 152\(%esp\), %ecx
--** movl 156\(%esp\), %ebx
--** movl 160\(%esp\), %esi
--** movl 164\(%esp\), %edi
--** movl 168\(%esp\), %ebp
-+** movl 148\(%esp\), %eax
-+** movl 152\(%esp\), %edx
-+** movl 156\(%esp\), %ecx
-+** movl 160\(%esp\), %ebx
-+** movl 164\(%esp\), %esi
-+** movl 168\(%esp\), %edi
- **...
- ** ret
- ** .cfi_endproc
-diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-19d.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-19d.c
-index a18d12e58997..b3caa3d81b2d 100644
---- a/gcc/testsuite/gcc.target/i386/no-callee-saved-19d.c
-+++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-19d.c
-@@ -50,15 +50,14 @@
- ** .cfi_startproc
- ** subq \$504, %rsp
- **...
--** movq %rax, 256\(%rsp\)
--** movq %rdx, 264\(%rsp\)
--** movq %rcx, 272\(%rsp\)
--** movq %rbx, 280\(%rsp\)
--** movq %rsi, 288\(%rsp\)
--** movq %rdi, 296\(%rsp\)
-+** movq %rax, 264\(%rsp\)
-+** movq %rdx, 272\(%rsp\)
-+** movq %rcx, 280\(%rsp\)
-+** movq %rbx, 288\(%rsp\)
-+** movq %rsi, 296\(%rsp\)
-+** movq %rdi, 304\(%rsp\)
- **...
- ** movl \$code\+8, %edi
--** movq %rbp, 304\(%rsp\)
- ** movq %r8, 312\(%rsp\)
- ** movq %r9, 320\(%rsp\)
- ** movq %r10, 328\(%rsp\)
-@@ -116,13 +115,12 @@
- ** movaps 176\(%rsp\), %xmm11
- ** movaps 192\(%rsp\), %xmm12
- ** movaps 208\(%rsp\), %xmm13
--** movq 256\(%rsp\), %rax
--** movq 264\(%rsp\), %rdx
--** movq 272\(%rsp\), %rcx
--** movq 280\(%rsp\), %rbx
--** movq 288\(%rsp\), %rsi
--** movq 296\(%rsp\), %rdi
--** movq 304\(%rsp\), %rbp
-+** movq 264\(%rsp\), %rax
-+** movq 272\(%rsp\), %rdx
-+** movq 280\(%rsp\), %rcx
-+** movq 288\(%rsp\), %rbx
-+** movq 296\(%rsp\), %rsi
-+** movq 304\(%rsp\), %rdi
- ** movq 312\(%rsp\), %r8
- ** movq 320\(%rsp\), %r9
- ** movq 328\(%rsp\), %r10
-@@ -132,9 +130,9 @@
- ** movq 360\(%rsp\), %r14
- ** movq 368\(%rsp\), %r15
- ** movq 376\(%rsp\), %r16
-+** movq 384\(%rsp\), %r17
- ** movaps 224\(%rsp\), %xmm14
- ** movaps 240\(%rsp\), %xmm15
--** movq 384\(%rsp\), %r17
- ** movq 392\(%rsp\), %r18
- ** movq 400\(%rsp\), %r19
- ** movq 408\(%rsp\), %r20
-diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-2.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-2.c
-index 98e2701d925e..e074ca51df40 100644
---- a/gcc/testsuite/gcc.target/i386/no-callee-saved-2.c
-+++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-2.c
-@@ -26,5 +26,7 @@ foo (void *frame)
- }
- }
-
--/* { dg-final { scan-assembler-not "push" } } */
--/* { dg-final { scan-assembler-not "pop" } } */
-+/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*" 1 } } */
-+/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*" 1 } } */
-diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-7.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-7.c
-index a1837fdfd4b5..821d1e2a4d42 100644
---- a/gcc/testsuite/gcc.target/i386/no-callee-saved-7.c
-+++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-7.c
-@@ -17,7 +17,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
-@@ -34,7 +34,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-8.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-8.c
-index 90b98a21aef7..ed3d96bdca05 100644
---- a/gcc/testsuite/gcc.target/i386/no-callee-saved-8.c
-+++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-8.c
-@@ -18,7 +18,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
-@@ -35,7 +35,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-9.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-9.c
-index e261100ac1a1..7730c5903d4b 100644
---- a/gcc/testsuite/gcc.target/i386/no-callee-saved-9.c
-+++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-9.c
-@@ -17,7 +17,7 @@ foo (fn_t bar)
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
-@@ -34,7 +34,7 @@ foo (fn_t bar)
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/pr119784a.c b/gcc/testsuite/gcc.target/i386/pr119784a.c
-index 8a119d4cc1f8..a3b7e4aa7cca 100644
---- a/gcc/testsuite/gcc.target/i386/pr119784a.c
-+++ b/gcc/testsuite/gcc.target/i386/pr119784a.c
-@@ -11,14 +11,12 @@
- ** .cfi_startproc
- ** subq \$248, %rsp
- **...
--** movq %rax, \(%rsp\)
--** movq %rdx, 8\(%rsp\)
--** movq %rcx, 16\(%rsp\)
--** movq %rbx, 24\(%rsp\)
--** movq %rsi, 32\(%rsp\)
--** movq %rdi, 40\(%rsp\)
--**...
--** movq %rbp, 48\(%rsp\)
-+** movq %rax, 8\(%rsp\)
-+** movq %rdx, 16\(%rsp\)
-+** movq %rcx, 24\(%rsp\)
-+** movq %rbx, 32\(%rsp\)
-+** movq %rsi, 40\(%rsp\)
-+** movq %rdi, 48\(%rsp\)
- ** movq %r8, 56\(%rsp\)
- ** movq %r9, 64\(%rsp\)
- ** movq %r10, 72\(%rsp\)
-@@ -45,13 +43,12 @@
- ** movq %r31, 240\(%rsp\)
- **...
- ** call \*code\(%rip\)
--** movq \(%rsp\), %rax
--** movq 8\(%rsp\), %rdx
--** movq 16\(%rsp\), %rcx
--** movq 24\(%rsp\), %rbx
--** movq 32\(%rsp\), %rsi
--** movq 40\(%rsp\), %rdi
--** movq 48\(%rsp\), %rbp
-+** movq 8\(%rsp\), %rax
-+** movq 16\(%rsp\), %rdx
-+** movq 24\(%rsp\), %rcx
-+** movq 32\(%rsp\), %rbx
-+** movq 40\(%rsp\), %rsi
-+** movq 48\(%rsp\), %rdi
- ** movq 56\(%rsp\), %r8
- ** movq 64\(%rsp\), %r9
- ** movq 72\(%rsp\), %r10
-diff --git a/gcc/testsuite/gcc.target/i386/pr120840-1a.c b/gcc/testsuite/gcc.target/i386/pr120840-1a.c
-new file mode 100644
-index 000000000000..cc5800311b30
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr120840-1a.c
-@@ -0,0 +1,83 @@
-+/* { dg-do run } */
-+/* { dg-options "-save-temps -O2 -fno-omit-frame-pointer -mtune-ctrl=prologue_using_move,epilogue_using_move,use_leave" } */
-+
-+#ifndef DONT_SAVE_REGS1
-+# define DONT_SAVE_REGS1 __attribute__((no_callee_saved_registers))
-+#endif
-+#ifndef DONT_SAVE_REGS2
-+# define DONT_SAVE_REGS2 __attribute__((no_callee_saved_registers))
-+#endif
-+
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target "*-*-linux*" } {^\t?\.} } } */
-+
-+/*
-+**do_test:
-+**.LFB[0-9]+:
-+**...
-+** leave
-+**...
-+** ret
-+**...
-+*/
-+
-+#include <stdlib.h>
-+
-+DONT_SAVE_REGS1
-+__attribute__ ((weak, __optimize__ ("-fomit-frame-pointer")))
-+void
-+continuation (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
-+{
-+ /* Clobber frame pointer register. */
-+ asm ("xor %%ebp, %%ebp" ::: "ebp");
-+
-+ if (arg1 != 17)
-+ abort ();
-+ if (arg2 != 8)
-+ abort ();
-+ if (arg3 != 20)
-+ abort ();
-+ if (arg4 != -3)
-+ abort ();
-+ if (arg5 != -4)
-+ abort ();
-+ if (arg6 != 26)
-+ abort ();
-+}
-+
-+DONT_SAVE_REGS2
-+__attribute__ ((weak, __optimize__ ("-fomit-frame-pointer")))
-+void
-+entry (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
-+{
-+ /* Clobber frame pointer register. */
-+ asm ("xor %%ebp, %%ebp" ::: "ebp");
-+
-+ if (arg1 != 17)
-+ abort ();
-+ if (arg2 != 8)
-+ abort ();
-+ if (arg3 != 20)
-+ abort ();
-+ if (arg4 != -3)
-+ abort ();
-+ if (arg5 != -4)
-+ abort ();
-+ if (arg6 != 26)
-+ abort ();
-+ continuation (arg1, arg2, arg3, arg4, arg5, arg6);
-+}
-+
-+__attribute__ ((weak))
-+void
-+do_test (void)
-+{
-+ entry (17, 8, 20, -3, -4, 26);
-+}
-+
-+int
-+main (void)
-+{
-+ do_test ();
-+ return 0;
-+}
-diff --git a/gcc/testsuite/gcc.target/i386/pr120840-1b.c b/gcc/testsuite/gcc.target/i386/pr120840-1b.c
-new file mode 100644
-index 000000000000..a759e3402b5c
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr120840-1b.c
-@@ -0,0 +1,20 @@
-+/* { dg-do run } */
-+/* { dg-options "-save-temps -O2 -fno-omit-frame-pointer -mtune-ctrl=prologue_using_move,epilogue_using_move,use_leave" } */
-+
-+#define DONT_SAVE_REGS1 __attribute__((preserve_none))
-+#define DONT_SAVE_REGS2 __attribute__((no_callee_saved_registers))
-+
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target "*-*-linux*" } {^\t?\.} } } */
-+
-+/*
-+**do_test:
-+**.LFB[0-9]+:
-+**...
-+** leave
-+**...
-+** ret
-+**...
-+*/
-+
-+#include "pr120840-1a.c"
-diff --git a/gcc/testsuite/gcc.target/i386/pr120840-1c.c b/gcc/testsuite/gcc.target/i386/pr120840-1c.c
-new file mode 100644
-index 000000000000..84aa353d705b
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr120840-1c.c
-@@ -0,0 +1,20 @@
-+/* { dg-do run } */
-+/* { dg-options "-save-temps -O2 -fno-omit-frame-pointer -mtune-ctrl=prologue_using_move,epilogue_using_move,use_leave" } */
-+
-+#define DONT_SAVE_REGS1 __attribute__((no_callee_saved_registers))
-+#define DONT_SAVE_REGS2 __attribute__((preserve_none))
-+
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target "*-*-linux*" } {^\t?\.} } } */
-+
-+/*
-+**do_test:
-+**.LFB[0-9]+:
-+**...
-+** leave
-+**...
-+** ret
-+**...
-+*/
-+
-+#include "pr120840-1a.c"
-diff --git a/gcc/testsuite/gcc.target/i386/pr120840-1d.c b/gcc/testsuite/gcc.target/i386/pr120840-1d.c
-new file mode 100644
-index 000000000000..a6b38a6aff17
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr120840-1d.c
-@@ -0,0 +1,20 @@
-+/* { dg-do run } */
-+/* { dg-options "-save-temps -O2 -fno-omit-frame-pointer -mtune-ctrl=prologue_using_move,epilogue_using_move,use_leave" } */
-+
-+#define DONT_SAVE_REGS1 __attribute__((preserve_none))
-+#define DONT_SAVE_REGS2 __attribute__((preserve_none))
-+
-+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
-+/* { dg-final { check-function-bodies "**" "" "" { target "*-*-linux*" } {^\t?\.} } } */
-+
-+/*
-+**do_test:
-+**.LFB[0-9]+:
-+**...
-+** leave
-+**...
-+** ret
-+**...
-+*/
-+
-+#include "pr120840-1a.c"
-diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-12.c b/gcc/testsuite/gcc.target/i386/preserve-none-12.c
-index 6960f6607972..b2fd0abcd065 100644
---- a/gcc/testsuite/gcc.target/i386/preserve-none-12.c
-+++ b/gcc/testsuite/gcc.target/i386/preserve-none-12.c
-@@ -17,7 +17,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
-@@ -34,7 +34,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-13.c b/gcc/testsuite/gcc.target/i386/preserve-none-13.c
-index 31b33201e852..d0f309979c64 100644
---- a/gcc/testsuite/gcc.target/i386/preserve-none-13.c
-+++ b/gcc/testsuite/gcc.target/i386/preserve-none-13.c
-@@ -18,7 +18,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
-@@ -35,7 +35,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-14.c b/gcc/testsuite/gcc.target/i386/preserve-none-14.c
-index 64a957ddf833..ca23b586fa16 100644
---- a/gcc/testsuite/gcc.target/i386/preserve-none-14.c
-+++ b/gcc/testsuite/gcc.target/i386/preserve-none-14.c
-@@ -17,7 +17,7 @@ foo (fn_t bar)
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
-@@ -34,7 +34,7 @@ foo (fn_t bar)
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-15.c b/gcc/testsuite/gcc.target/i386/preserve-none-15.c
-index 8af930bd9141..54527e3a8479 100644
---- a/gcc/testsuite/gcc.target/i386/preserve-none-15.c
-+++ b/gcc/testsuite/gcc.target/i386/preserve-none-15.c
-@@ -18,7 +18,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)cx" 1 } } */
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)dx" 1 } } */
--/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)si" 1 } } */
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)di" 1 } } */
- /* { dg-final { scan-assembler-times "pushq\[\\t \]*%r8" 1 { target { ! ia32 } } } } */
-@@ -33,7 +33,7 @@ foo (void)
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)cx" 1 } } */
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)dx" 1 } } */
--/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)si" 1 } } */
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)di" 1 } } */
- /* { dg-final { scan-assembler-times "popq\[\\t \]*%r8" 1 { target { ! ia32 } } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-23.c b/gcc/testsuite/gcc.target/i386/preserve-none-23.c
-index 8cc933f8aa8f..8e83879443fa 100644
---- a/gcc/testsuite/gcc.target/i386/preserve-none-23.c
-+++ b/gcc/testsuite/gcc.target/i386/preserve-none-23.c
-@@ -19,7 +19,7 @@ foo (uintptr_t p)
- /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
-@@ -36,7 +36,7 @@ foo (uintptr_t p)
- /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
- /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
--/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
- /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
- /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
-diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-6.c b/gcc/testsuite/gcc.target/i386/preserve-none-6.c
-index 2606ea3bc198..037f9ecfa036 100644
---- a/gcc/testsuite/gcc.target/i386/preserve-none-6.c
-+++ b/gcc/testsuite/gcc.target/i386/preserve-none-6.c
-@@ -26,5 +26,7 @@ foo (void *frame)
- }
- }
-
--/* { dg-final { scan-assembler-not "push" } } */
--/* { dg-final { scan-assembler-not "pop" } } */
-+/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*" 1 } } */
-+/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*" 1 } } */
-diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-7.c b/gcc/testsuite/gcc.target/i386/preserve-none-7.c
-index 79ce761eaf5c..2c80560887c2 100644
---- a/gcc/testsuite/gcc.target/i386/preserve-none-7.c
-+++ b/gcc/testsuite/gcc.target/i386/preserve-none-7.c
-@@ -26,5 +26,7 @@ foo (void *frame)
- }
- }
-
--/* { dg-final { scan-assembler-not "push" } } */
--/* { dg-final { scan-assembler-not "pop" } } */
-+/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
-+/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*" 1 } } */
-+/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*" 1 } } */
-
-base-commit: 8dcb922452516ebbf362e7c202b48d8ef547edce
---
-2.50.0
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 1e14c73..5bf2e2f 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+5 ????
+
+ - 85_all_PR120840.patch
+
4 30 June 2025
+ 85_all_PR120840.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-29 0:29 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-29 0:29 UTC (permalink / raw
To: gentoo-commits
commit: ae7d2c2f05513ca58a1f4cf98220fd8710fd354c
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 29 00:28:53 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun 29 00:29:23 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=ae7d2c2f
16.0.0: add 85_all_PR120840.patch
Bug: https://gcc.gnu.org/PR120840
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/85_all_PR120840.patch | 873 ++++++++++++++++++++++++++++++++++++
16.0.0/gentoo/README.history | 4 +
2 files changed, 877 insertions(+)
diff --git a/16.0.0/gentoo/85_all_PR120840.patch b/16.0.0/gentoo/85_all_PR120840.patch
new file mode 100644
index 0000000..c9c710f
--- /dev/null
+++ b/16.0.0/gentoo/85_all_PR120840.patch
@@ -0,0 +1,873 @@
+https://inbox.sourceware.org/gcc-patches/CAMe9rOpBxdLoJrGZqt5_JhPAuvWUOpGWMLiGg=dSKkYtdqV9KA@mail.gmail.com/
+
+From cefa274db3abc864bbe4d163d78108fb50fb9e97 Mon Sep 17 00:00:00 2001
+Message-ID: <cefa274db3abc864bbe4d163d78108fb50fb9e97.1751156913.git.sam@gentoo.org>
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Sat, 28 Jun 2025 09:39:41 +0800
+Subject: [PATCH] x86: Preserve frame pointer for no_callee_saved_registers
+ attribute
+
+Update functions with no_callee_saved_registers/preserve_none attribute
+to preserve frame pointer since caller may use it to save the current
+stack:
+
+ pushq %rbp
+ movq %rsp, %rbp
+ ...
+ call function
+ ...
+ leave
+ ret
+
+If callee changes frame pointer without restoring it, caller will fail
+to restore its stack after callee returns.
+
+There are no regressions on Linux/x86-64. Also tested with
+
+https://github.com/python/cpython
+
+configured with "./configure --with-tail-call-interp".
+
+gcc/
+
+ PR target/120840
+ * config/i386/i386-expand.cc (ix86_expand_call): Don't mark
+ hard frame pointer as clobber.
+ * config/i386/i386-options.cc (ix86_set_func_type): Use
+ TYPE_NO_CALLEE_SAVED_REGISTERS instead of
+ TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP.
+ * config/i386/i386.cc (ix86_function_ok_for_sibcall): Remove the
+ TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP check.
+ (ix86_save_reg): Merge TYPE_NO_CALLEE_SAVED_REGISTERS and
+ TYPE_PRESERVE_NONE with TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP.
+ * config/i386/i386.h (call_saved_registers_type): Remove
+ TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP.
+ * doc/extend.texi: Update no_callee_saved_registers documentation.
+
+gcc/testsuite/
+
+ PR target/120840
+ * gcc.target/i386/no-callee-saved-1.c: Updated.
+ * gcc.target/i386/no-callee-saved-2.c: Likewise.
+ * gcc.target/i386/no-callee-saved-7.c: Likewise.
+ * gcc.target/i386/no-callee-saved-8.c: Likewise.
+ * gcc.target/i386/no-callee-saved-9.c: Likewise.
+ * gcc.target/i386/no-callee-saved-10.c: Likewise.
+ * gcc.target/i386/no-callee-saved-18.c: Likewise.
+ * gcc.target/i386/no-callee-saved-19a.c: Likewise.
+ * gcc.target/i386/no-callee-saved-19c.c: Likewise.
+ * gcc.target/i386/no-callee-saved-19d.c: Likewise.
+ * gcc.target/i386/pr119784a.c: Likewise.
+ * gcc.target/i386/preserve-none-6.c: Likewise.
+ * gcc.target/i386/preserve-none-7.c: Likewise.
+ * gcc.target/i386/preserve-none-12.c: Likewise.
+ * gcc.target/i386/preserve-none-13.c: Likewise.
+ * gcc.target/i386/preserve-none-14.c: Likewise.
+ * gcc.target/i386/preserve-none-15.c: Likewise.
+ * gcc.target/i386/preserve-none-23.c: Likewise.
+ * gcc.target/i386/pr120840-1a.c: New test.
+ * gcc.target/i386/pr120840-1b.c: Likewise.
+ * gcc.target/i386/pr120840-1c.c: Likewise.
+ * gcc.target/i386/pr120840-1d.c: Likewise.
+
+Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
+---
+ gcc/config/i386/i386-expand.cc | 1 +
+ gcc/config/i386/i386-options.cc | 23 +++--
+ gcc/config/i386/i386.cc | 5 --
+ gcc/config/i386/i386.h | 3 -
+ gcc/doc/extend.texi | 9 +-
+ .../gcc.target/i386/no-callee-saved-1.c | 6 +-
+ .../gcc.target/i386/no-callee-saved-10.c | 4 +-
+ .../gcc.target/i386/no-callee-saved-18.c | 4 +-
+ .../gcc.target/i386/no-callee-saved-19a.c | 32 ++++---
+ .../gcc.target/i386/no-callee-saved-19c.c | 26 +++---
+ .../gcc.target/i386/no-callee-saved-19d.c | 28 +++----
+ .../gcc.target/i386/no-callee-saved-2.c | 6 +-
+ .../gcc.target/i386/no-callee-saved-7.c | 4 +-
+ .../gcc.target/i386/no-callee-saved-8.c | 4 +-
+ .../gcc.target/i386/no-callee-saved-9.c | 4 +-
+ gcc/testsuite/gcc.target/i386/pr119784a.c | 27 +++---
+ gcc/testsuite/gcc.target/i386/pr120840-1a.c | 83 +++++++++++++++++++
+ gcc/testsuite/gcc.target/i386/pr120840-1b.c | 20 +++++
+ gcc/testsuite/gcc.target/i386/pr120840-1c.c | 20 +++++
+ gcc/testsuite/gcc.target/i386/pr120840-1d.c | 20 +++++
+ .../gcc.target/i386/preserve-none-12.c | 4 +-
+ .../gcc.target/i386/preserve-none-13.c | 4 +-
+ .../gcc.target/i386/preserve-none-14.c | 4 +-
+ .../gcc.target/i386/preserve-none-15.c | 4 +-
+ .../gcc.target/i386/preserve-none-23.c | 4 +-
+ .../gcc.target/i386/preserve-none-6.c | 6 +-
+ .../gcc.target/i386/preserve-none-7.c | 6 +-
+ 27 files changed, 248 insertions(+), 113 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr120840-1a.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr120840-1b.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr120840-1c.c
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr120840-1d.c
+
+diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
+index c1c0cf9ff80a..83076adb55db 100644
+--- a/gcc/config/i386/i386-expand.cc
++++ b/gcc/config/i386/i386-expand.cc
+@@ -10377,6 +10377,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1,
+ char c_mask = CALL_USED_REGISTERS_MASK (is_64bit_ms_abi);
+ for (int i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+ if (!fixed_regs[i]
++ && i != HARD_FRAME_POINTER_REGNUM
+ && !(ix86_call_used_regs[i] == 1
+ || (ix86_call_used_regs[i] & c_mask))
+ && !STACK_REGNO_P (i)
+diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
+index 60c04f65d9f9..09cb1337f94c 100644
+--- a/gcc/config/i386/i386-options.cc
++++ b/gcc/config/i386/i386-options.cc
+@@ -3280,19 +3280,18 @@ ix86_set_func_type (tree fndecl)
+ if (lookup_attribute ("preserve_none",
+ TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
+ no_callee_saved_registers = TYPE_PRESERVE_NONE;
+- else if (lookup_attribute ("no_callee_saved_registers",
+- TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
++ else if ((lookup_attribute ("no_callee_saved_registers",
++ TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
++ || (ix86_noreturn_no_callee_saved_registers
++ && TREE_THIS_VOLATILE (fndecl)
++ && optimize
++ && !optimize_debug
++ && (TREE_NOTHROW (fndecl) || !flag_exceptions)
++ && !lookup_attribute ("interrupt",
++ TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))
++ && !lookup_attribute ("no_caller_saved_registers",
++ TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))))
+ no_callee_saved_registers = TYPE_NO_CALLEE_SAVED_REGISTERS;
+- else if (ix86_noreturn_no_callee_saved_registers
+- && TREE_THIS_VOLATILE (fndecl)
+- && optimize
+- && !optimize_debug
+- && (TREE_NOTHROW (fndecl) || !flag_exceptions)
+- && !lookup_attribute ("interrupt",
+- TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))
+- && !lookup_attribute ("no_caller_saved_registers",
+- TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
+- no_callee_saved_registers = TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP;
+
+ if (cfun->machine->func_type == TYPE_UNKNOWN)
+ {
+diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
+index 5e9559f5c05e..44763c8eb014 100644
+--- a/gcc/config/i386/i386.cc
++++ b/gcc/config/i386/i386.cc
+@@ -1043,8 +1043,6 @@ ix86_function_ok_for_sibcall (tree decl, tree exp)
+ if ((cfun->machine->call_saved_registers
+ != TYPE_NO_CALLEE_SAVED_REGISTERS)
+ && cfun->machine->call_saved_registers != TYPE_PRESERVE_NONE
+- && (cfun->machine->call_saved_registers
+- != TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP)
+ && ix86_type_no_callee_saved_registers_p (type))
+ return false;
+
+@@ -6774,9 +6772,6 @@ ix86_save_reg (unsigned int regno, bool maybe_eh_return, bool ignore_outlined)
+
+ case TYPE_NO_CALLEE_SAVED_REGISTERS:
+ case TYPE_PRESERVE_NONE:
+- return false;
+-
+- case TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP:
+ if (regno != HARD_FRAME_POINTER_REGNUM)
+ return false;
+ break;
+diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
+index a275a32682e6..45de61c64b23 100644
+--- a/gcc/config/i386/i386.h
++++ b/gcc/config/i386/i386.h
+@@ -2804,9 +2804,6 @@ enum call_saved_registers_type
+ /* The current function is a function specified with the
+ "no_callee_saved_registers" attribute. */
+ TYPE_NO_CALLEE_SAVED_REGISTERS,
+- /* The current function is a function specified with the "noreturn"
+- attribute. */
+- TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP,
+ /* The current function is a function specified with the
+ "preserve_none" attribute. */
+ TYPE_PRESERVE_NONE,
+diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
+index 946105d5cdcc..e9aa12ba1041 100644
+--- a/gcc/doc/extend.texi
++++ b/gcc/doc/extend.texi
+@@ -6124,10 +6124,11 @@ pass arguments, unless it takes a variable number of arguments.
+ @cindex @code{no_callee_saved_registers} function attribute, x86
+ @item no_callee_saved_registers
+ Use this attribute to indicate that the specified function has no
+-callee-saved registers. That is, all registers can be used as scratch
+-registers. For example, this attribute can be used for a function
+-called from the interrupt handler assembly stub which will preserve
+-all registers and return from interrupt.
++callee-saved registers. That is, all registers, except for stack and
++frame pointers, can be used as scratch registers. For example, this
++attribute can be used for a function called from the interrupt handler
++assembly stub which will preserve all registers and return from
++interrupt.
+
+ @cindex @code{preserve_none} function attribute, x86
+ @item preserve_none
+diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-1.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-1.c
+index 599c2a3fa191..e535485b1cf3 100644
+--- a/gcc/testsuite/gcc.target/i386/no-callee-saved-1.c
++++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-1.c
+@@ -26,5 +26,7 @@ foo (void *frame)
+ }
+ }
+
+-/* { dg-final { scan-assembler-not "push" } } */
+-/* { dg-final { scan-assembler-not "pop" } } */
++/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*" 1 } } */
++/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*" 1 } } */
+diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-10.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-10.c
+index 87766c6cd886..6c54144350e6 100644
+--- a/gcc/testsuite/gcc.target/i386/no-callee-saved-10.c
++++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-10.c
+@@ -18,7 +18,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)cx" 1 } } */
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)dx" 1 } } */
+-/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)si" 1 } } */
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)di" 1 } } */
+ /* { dg-final { scan-assembler-times "pushq\[\\t \]*%r8" 1 { target { ! ia32 } } } } */
+@@ -33,7 +33,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)cx" 1 } } */
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)dx" 1 } } */
+-/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)si" 1 } } */
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)di" 1 } } */
+ /* { dg-final { scan-assembler-times "popq\[\\t \]*%r8" 1 { target { ! ia32 } } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-18.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-18.c
+index e7101009be47..128b9c46e8ec 100644
+--- a/gcc/testsuite/gcc.target/i386/no-callee-saved-18.c
++++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-18.c
+@@ -19,7 +19,7 @@ foo (uintptr_t p)
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
+@@ -36,7 +36,7 @@ foo (uintptr_t p)
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-19a.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-19a.c
+index 25ef8558a5db..12f35cfa8bba 100644
+--- a/gcc/testsuite/gcc.target/i386/no-callee-saved-19a.c
++++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-19a.c
+@@ -16,9 +16,9 @@
+
+ #define NEXT { op_t *op = next; [[gnu::musttail]] return (*op)(op + 1); }
+ #ifdef __x86_64__
+-# define CLOBBER asm("" ::: "r12","r13","r14","r15","rbp","rbx")
++# define CLOBBER asm("" ::: "r12","r13","r14","r15","rbx")
+ #else
+-# define CLOBBER asm("" ::: "ebp","ebx")
++# define CLOBBER asm("" ::: "ebx")
+ #endif
+ #define DONT_SAVE_REGS __attribute__((no_callee_saved_registers))
+ #define SAVE_REGS __attribute__((no_caller_saved_registers))
+@@ -83,15 +83,14 @@ op_t code[] = { inc, inc, dec, end, };
+ ** .cfi_startproc
+ ** subq \$376, %rsp
+ **...
+-** movq %rax, 256\(%rsp\)
+-** movq %rdx, 264\(%rsp\)
+-** movq %rcx, 272\(%rsp\)
+-** movq %rbx, 280\(%rsp\)
+-** movq %rsi, 288\(%rsp\)
+-** movq %rdi, 296\(%rsp\)
++** movq %rdi, 304\(%rsp\)
+ **...
+ ** movl \$code\+8, %edi
+-** movq %rbp, 304\(%rsp\)
++** movq %rax, 264\(%rsp\)
++** movq %rdx, 272\(%rsp\)
++** movq %rcx, 280\(%rsp\)
++** movq %rbx, 288\(%rsp\)
++** movq %rsi, 296\(%rsp\)
+ ** movq %r8, 312\(%rsp\)
+ ** movq %r9, 320\(%rsp\)
+ ** movq %r10, 328\(%rsp\)
+@@ -132,13 +131,12 @@ op_t code[] = { inc, inc, dec, end, };
+ ** movaps 176\(%rsp\), %xmm11
+ ** movaps 192\(%rsp\), %xmm12
+ ** movaps 208\(%rsp\), %xmm13
+-** movq 256\(%rsp\), %rax
+-** movq 264\(%rsp\), %rdx
+-** movq 272\(%rsp\), %rcx
+-** movq 280\(%rsp\), %rbx
+-** movq 288\(%rsp\), %rsi
+-** movq 296\(%rsp\), %rdi
+-** movq 304\(%rsp\), %rbp
++** movq 264\(%rsp\), %rax
++** movq 272\(%rsp\), %rdx
++** movq 280\(%rsp\), %rcx
++** movq 288\(%rsp\), %rbx
++** movq 296\(%rsp\), %rsi
++** movq 304\(%rsp\), %rdi
+ ** movq 312\(%rsp\), %r8
+ ** movq 320\(%rsp\), %r9
+ ** movq 328\(%rsp\), %r10
+@@ -146,8 +144,8 @@ op_t code[] = { inc, inc, dec, end, };
+ ** movq 344\(%rsp\), %r12
+ ** movq 352\(%rsp\), %r13
+ ** movq 360\(%rsp\), %r14
+-** movaps 224\(%rsp\), %xmm14
+ ** movq 368\(%rsp\), %r15
++** movaps 224\(%rsp\), %xmm14
+ ** movaps 240\(%rsp\), %xmm15
+ ** addq \$376, %rsp
+ **...
+diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-19c.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-19c.c
+index 2ad388d1a567..05aca9f4b119 100644
+--- a/gcc/testsuite/gcc.target/i386/no-callee-saved-19c.c
++++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-19c.c
+@@ -51,13 +51,12 @@
+ **.LFB[0-9]+:
+ ** .cfi_startproc
+ **...
+-** movl %eax, 140\(%esp\)
+-** movl %edx, 144\(%esp\)
+-** movl %ecx, 148\(%esp\)
+-** movl %ebx, 152\(%esp\)
+-** movl %esi, 156\(%esp\)
+-** movl %edi, 160\(%esp\)
+-** movl %ebp, 164\(%esp\)
++** movl %eax, 144\(%esp\)
++** movl %edx, 148\(%esp\)
++** movl %ecx, 152\(%esp\)
++** movl %ebx, 156\(%esp\)
++** movl %esi, 160\(%esp\)
++** movl %edi, 164\(%esp\)
+ ** movaps %xmm0, 12\(%esp\)
+ ** movaps %xmm1, 28\(%esp\)
+ ** movaps %xmm2, 44\(%esp\)
+@@ -78,13 +77,12 @@
+ ** movaps 96\(%esp\), %xmm5
+ ** movaps 112\(%esp\), %xmm6
+ ** movaps 128\(%esp\), %xmm7
+-** movl 144\(%esp\), %eax
+-** movl 148\(%esp\), %edx
+-** movl 152\(%esp\), %ecx
+-** movl 156\(%esp\), %ebx
+-** movl 160\(%esp\), %esi
+-** movl 164\(%esp\), %edi
+-** movl 168\(%esp\), %ebp
++** movl 148\(%esp\), %eax
++** movl 152\(%esp\), %edx
++** movl 156\(%esp\), %ecx
++** movl 160\(%esp\), %ebx
++** movl 164\(%esp\), %esi
++** movl 168\(%esp\), %edi
+ **...
+ ** ret
+ ** .cfi_endproc
+diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-19d.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-19d.c
+index a18d12e58997..b3caa3d81b2d 100644
+--- a/gcc/testsuite/gcc.target/i386/no-callee-saved-19d.c
++++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-19d.c
+@@ -50,15 +50,14 @@
+ ** .cfi_startproc
+ ** subq \$504, %rsp
+ **...
+-** movq %rax, 256\(%rsp\)
+-** movq %rdx, 264\(%rsp\)
+-** movq %rcx, 272\(%rsp\)
+-** movq %rbx, 280\(%rsp\)
+-** movq %rsi, 288\(%rsp\)
+-** movq %rdi, 296\(%rsp\)
++** movq %rax, 264\(%rsp\)
++** movq %rdx, 272\(%rsp\)
++** movq %rcx, 280\(%rsp\)
++** movq %rbx, 288\(%rsp\)
++** movq %rsi, 296\(%rsp\)
++** movq %rdi, 304\(%rsp\)
+ **...
+ ** movl \$code\+8, %edi
+-** movq %rbp, 304\(%rsp\)
+ ** movq %r8, 312\(%rsp\)
+ ** movq %r9, 320\(%rsp\)
+ ** movq %r10, 328\(%rsp\)
+@@ -116,13 +115,12 @@
+ ** movaps 176\(%rsp\), %xmm11
+ ** movaps 192\(%rsp\), %xmm12
+ ** movaps 208\(%rsp\), %xmm13
+-** movq 256\(%rsp\), %rax
+-** movq 264\(%rsp\), %rdx
+-** movq 272\(%rsp\), %rcx
+-** movq 280\(%rsp\), %rbx
+-** movq 288\(%rsp\), %rsi
+-** movq 296\(%rsp\), %rdi
+-** movq 304\(%rsp\), %rbp
++** movq 264\(%rsp\), %rax
++** movq 272\(%rsp\), %rdx
++** movq 280\(%rsp\), %rcx
++** movq 288\(%rsp\), %rbx
++** movq 296\(%rsp\), %rsi
++** movq 304\(%rsp\), %rdi
+ ** movq 312\(%rsp\), %r8
+ ** movq 320\(%rsp\), %r9
+ ** movq 328\(%rsp\), %r10
+@@ -132,9 +130,9 @@
+ ** movq 360\(%rsp\), %r14
+ ** movq 368\(%rsp\), %r15
+ ** movq 376\(%rsp\), %r16
++** movq 384\(%rsp\), %r17
+ ** movaps 224\(%rsp\), %xmm14
+ ** movaps 240\(%rsp\), %xmm15
+-** movq 384\(%rsp\), %r17
+ ** movq 392\(%rsp\), %r18
+ ** movq 400\(%rsp\), %r19
+ ** movq 408\(%rsp\), %r20
+diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-2.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-2.c
+index 98e2701d925e..e074ca51df40 100644
+--- a/gcc/testsuite/gcc.target/i386/no-callee-saved-2.c
++++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-2.c
+@@ -26,5 +26,7 @@ foo (void *frame)
+ }
+ }
+
+-/* { dg-final { scan-assembler-not "push" } } */
+-/* { dg-final { scan-assembler-not "pop" } } */
++/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*" 1 } } */
++/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*" 1 } } */
+diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-7.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-7.c
+index a1837fdfd4b5..821d1e2a4d42 100644
+--- a/gcc/testsuite/gcc.target/i386/no-callee-saved-7.c
++++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-7.c
+@@ -17,7 +17,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
+@@ -34,7 +34,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-8.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-8.c
+index 90b98a21aef7..ed3d96bdca05 100644
+--- a/gcc/testsuite/gcc.target/i386/no-callee-saved-8.c
++++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-8.c
+@@ -18,7 +18,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
+@@ -35,7 +35,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/no-callee-saved-9.c b/gcc/testsuite/gcc.target/i386/no-callee-saved-9.c
+index e261100ac1a1..7730c5903d4b 100644
+--- a/gcc/testsuite/gcc.target/i386/no-callee-saved-9.c
++++ b/gcc/testsuite/gcc.target/i386/no-callee-saved-9.c
+@@ -17,7 +17,7 @@ foo (fn_t bar)
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
+@@ -34,7 +34,7 @@ foo (fn_t bar)
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/pr119784a.c b/gcc/testsuite/gcc.target/i386/pr119784a.c
+index 8a119d4cc1f8..a3b7e4aa7cca 100644
+--- a/gcc/testsuite/gcc.target/i386/pr119784a.c
++++ b/gcc/testsuite/gcc.target/i386/pr119784a.c
+@@ -11,14 +11,12 @@
+ ** .cfi_startproc
+ ** subq \$248, %rsp
+ **...
+-** movq %rax, \(%rsp\)
+-** movq %rdx, 8\(%rsp\)
+-** movq %rcx, 16\(%rsp\)
+-** movq %rbx, 24\(%rsp\)
+-** movq %rsi, 32\(%rsp\)
+-** movq %rdi, 40\(%rsp\)
+-**...
+-** movq %rbp, 48\(%rsp\)
++** movq %rax, 8\(%rsp\)
++** movq %rdx, 16\(%rsp\)
++** movq %rcx, 24\(%rsp\)
++** movq %rbx, 32\(%rsp\)
++** movq %rsi, 40\(%rsp\)
++** movq %rdi, 48\(%rsp\)
+ ** movq %r8, 56\(%rsp\)
+ ** movq %r9, 64\(%rsp\)
+ ** movq %r10, 72\(%rsp\)
+@@ -45,13 +43,12 @@
+ ** movq %r31, 240\(%rsp\)
+ **...
+ ** call \*code\(%rip\)
+-** movq \(%rsp\), %rax
+-** movq 8\(%rsp\), %rdx
+-** movq 16\(%rsp\), %rcx
+-** movq 24\(%rsp\), %rbx
+-** movq 32\(%rsp\), %rsi
+-** movq 40\(%rsp\), %rdi
+-** movq 48\(%rsp\), %rbp
++** movq 8\(%rsp\), %rax
++** movq 16\(%rsp\), %rdx
++** movq 24\(%rsp\), %rcx
++** movq 32\(%rsp\), %rbx
++** movq 40\(%rsp\), %rsi
++** movq 48\(%rsp\), %rdi
+ ** movq 56\(%rsp\), %r8
+ ** movq 64\(%rsp\), %r9
+ ** movq 72\(%rsp\), %r10
+diff --git a/gcc/testsuite/gcc.target/i386/pr120840-1a.c b/gcc/testsuite/gcc.target/i386/pr120840-1a.c
+new file mode 100644
+index 000000000000..cc5800311b30
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr120840-1a.c
+@@ -0,0 +1,83 @@
++/* { dg-do run } */
++/* { dg-options "-save-temps -O2 -fno-omit-frame-pointer -mtune-ctrl=prologue_using_move,epilogue_using_move,use_leave" } */
++
++#ifndef DONT_SAVE_REGS1
++# define DONT_SAVE_REGS1 __attribute__((no_callee_saved_registers))
++#endif
++#ifndef DONT_SAVE_REGS2
++# define DONT_SAVE_REGS2 __attribute__((no_callee_saved_registers))
++#endif
++
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target "*-*-linux*" } {^\t?\.} } } */
++
++/*
++**do_test:
++**.LFB[0-9]+:
++**...
++** leave
++**...
++** ret
++**...
++*/
++
++#include <stdlib.h>
++
++DONT_SAVE_REGS1
++__attribute__ ((weak, __optimize__ ("-fomit-frame-pointer")))
++void
++continuation (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
++{
++ /* Clobber frame pointer register. */
++ asm ("xor %%ebp, %%ebp" ::: "ebp");
++
++ if (arg1 != 17)
++ abort ();
++ if (arg2 != 8)
++ abort ();
++ if (arg3 != 20)
++ abort ();
++ if (arg4 != -3)
++ abort ();
++ if (arg5 != -4)
++ abort ();
++ if (arg6 != 26)
++ abort ();
++}
++
++DONT_SAVE_REGS2
++__attribute__ ((weak, __optimize__ ("-fomit-frame-pointer")))
++void
++entry (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
++{
++ /* Clobber frame pointer register. */
++ asm ("xor %%ebp, %%ebp" ::: "ebp");
++
++ if (arg1 != 17)
++ abort ();
++ if (arg2 != 8)
++ abort ();
++ if (arg3 != 20)
++ abort ();
++ if (arg4 != -3)
++ abort ();
++ if (arg5 != -4)
++ abort ();
++ if (arg6 != 26)
++ abort ();
++ continuation (arg1, arg2, arg3, arg4, arg5, arg6);
++}
++
++__attribute__ ((weak))
++void
++do_test (void)
++{
++ entry (17, 8, 20, -3, -4, 26);
++}
++
++int
++main (void)
++{
++ do_test ();
++ return 0;
++}
+diff --git a/gcc/testsuite/gcc.target/i386/pr120840-1b.c b/gcc/testsuite/gcc.target/i386/pr120840-1b.c
+new file mode 100644
+index 000000000000..a759e3402b5c
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr120840-1b.c
+@@ -0,0 +1,20 @@
++/* { dg-do run } */
++/* { dg-options "-save-temps -O2 -fno-omit-frame-pointer -mtune-ctrl=prologue_using_move,epilogue_using_move,use_leave" } */
++
++#define DONT_SAVE_REGS1 __attribute__((preserve_none))
++#define DONT_SAVE_REGS2 __attribute__((no_callee_saved_registers))
++
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target "*-*-linux*" } {^\t?\.} } } */
++
++/*
++**do_test:
++**.LFB[0-9]+:
++**...
++** leave
++**...
++** ret
++**...
++*/
++
++#include "pr120840-1a.c"
+diff --git a/gcc/testsuite/gcc.target/i386/pr120840-1c.c b/gcc/testsuite/gcc.target/i386/pr120840-1c.c
+new file mode 100644
+index 000000000000..84aa353d705b
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr120840-1c.c
+@@ -0,0 +1,20 @@
++/* { dg-do run } */
++/* { dg-options "-save-temps -O2 -fno-omit-frame-pointer -mtune-ctrl=prologue_using_move,epilogue_using_move,use_leave" } */
++
++#define DONT_SAVE_REGS1 __attribute__((no_callee_saved_registers))
++#define DONT_SAVE_REGS2 __attribute__((preserve_none))
++
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target "*-*-linux*" } {^\t?\.} } } */
++
++/*
++**do_test:
++**.LFB[0-9]+:
++**...
++** leave
++**...
++** ret
++**...
++*/
++
++#include "pr120840-1a.c"
+diff --git a/gcc/testsuite/gcc.target/i386/pr120840-1d.c b/gcc/testsuite/gcc.target/i386/pr120840-1d.c
+new file mode 100644
+index 000000000000..a6b38a6aff17
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr120840-1d.c
+@@ -0,0 +1,20 @@
++/* { dg-do run } */
++/* { dg-options "-save-temps -O2 -fno-omit-frame-pointer -mtune-ctrl=prologue_using_move,epilogue_using_move,use_leave" } */
++
++#define DONT_SAVE_REGS1 __attribute__((preserve_none))
++#define DONT_SAVE_REGS2 __attribute__((preserve_none))
++
++/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc'). */
++/* { dg-final { check-function-bodies "**" "" "" { target "*-*-linux*" } {^\t?\.} } } */
++
++/*
++**do_test:
++**.LFB[0-9]+:
++**...
++** leave
++**...
++** ret
++**...
++*/
++
++#include "pr120840-1a.c"
+diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-12.c b/gcc/testsuite/gcc.target/i386/preserve-none-12.c
+index 6960f6607972..b2fd0abcd065 100644
+--- a/gcc/testsuite/gcc.target/i386/preserve-none-12.c
++++ b/gcc/testsuite/gcc.target/i386/preserve-none-12.c
+@@ -17,7 +17,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
+@@ -34,7 +34,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-13.c b/gcc/testsuite/gcc.target/i386/preserve-none-13.c
+index 31b33201e852..d0f309979c64 100644
+--- a/gcc/testsuite/gcc.target/i386/preserve-none-13.c
++++ b/gcc/testsuite/gcc.target/i386/preserve-none-13.c
+@@ -18,7 +18,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
+@@ -35,7 +35,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-14.c b/gcc/testsuite/gcc.target/i386/preserve-none-14.c
+index 64a957ddf833..ca23b586fa16 100644
+--- a/gcc/testsuite/gcc.target/i386/preserve-none-14.c
++++ b/gcc/testsuite/gcc.target/i386/preserve-none-14.c
+@@ -17,7 +17,7 @@ foo (fn_t bar)
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
+@@ -34,7 +34,7 @@ foo (fn_t bar)
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-15.c b/gcc/testsuite/gcc.target/i386/preserve-none-15.c
+index 8af930bd9141..54527e3a8479 100644
+--- a/gcc/testsuite/gcc.target/i386/preserve-none-15.c
++++ b/gcc/testsuite/gcc.target/i386/preserve-none-15.c
+@@ -18,7 +18,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)cx" 1 } } */
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)dx" 1 } } */
+-/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)si" 1 } } */
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)di" 1 } } */
+ /* { dg-final { scan-assembler-times "pushq\[\\t \]*%r8" 1 { target { ! ia32 } } } } */
+@@ -33,7 +33,7 @@ foo (void)
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)cx" 1 } } */
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)dx" 1 } } */
+-/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)si" 1 } } */
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)di" 1 } } */
+ /* { dg-final { scan-assembler-times "popq\[\\t \]*%r8" 1 { target { ! ia32 } } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-23.c b/gcc/testsuite/gcc.target/i386/preserve-none-23.c
+index 8cc933f8aa8f..8e83879443fa 100644
+--- a/gcc/testsuite/gcc.target/i386/preserve-none-23.c
++++ b/gcc/testsuite/gcc.target/i386/preserve-none-23.c
+@@ -19,7 +19,7 @@ foo (uintptr_t p)
+ /* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "push(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "pushq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "pushl\[\\t \]*%edi" 1 { target ia32 } } } */
+@@ -36,7 +36,7 @@ foo (uintptr_t p)
+ /* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bx" 1 } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)cx" } } */
+ /* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)dx" } } */
+-/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-not "pop(?:l|q)\[\\t \]*%(?:e|r)bp" } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%esi" 1 { target ia32 } } } */
+ /* { dg-final { scan-assembler-not "popq\[\\t \]*%rsi" { target { ! ia32 } } } } */
+ /* { dg-final { scan-assembler-times "popl\[\\t \]*%edi" 1 { target ia32 } } } */
+diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-6.c b/gcc/testsuite/gcc.target/i386/preserve-none-6.c
+index 2606ea3bc198..037f9ecfa036 100644
+--- a/gcc/testsuite/gcc.target/i386/preserve-none-6.c
++++ b/gcc/testsuite/gcc.target/i386/preserve-none-6.c
+@@ -26,5 +26,7 @@ foo (void *frame)
+ }
+ }
+
+-/* { dg-final { scan-assembler-not "push" } } */
+-/* { dg-final { scan-assembler-not "pop" } } */
++/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*" 1 } } */
++/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*" 1 } } */
+diff --git a/gcc/testsuite/gcc.target/i386/preserve-none-7.c b/gcc/testsuite/gcc.target/i386/preserve-none-7.c
+index 79ce761eaf5c..2c80560887c2 100644
+--- a/gcc/testsuite/gcc.target/i386/preserve-none-7.c
++++ b/gcc/testsuite/gcc.target/i386/preserve-none-7.c
+@@ -26,5 +26,7 @@ foo (void *frame)
+ }
+ }
+
+-/* { dg-final { scan-assembler-not "push" } } */
+-/* { dg-final { scan-assembler-not "pop" } } */
++/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*%(?:e|r)bp" 1 } } */
++/* { dg-final { scan-assembler-times "push(?:l|q)\[\\t \]*" 1 } } */
++/* { dg-final { scan-assembler-times "pop(?:l|q)\[\\t \]*" 1 } } */
+
+base-commit: 8dcb922452516ebbf362e7c202b48d8ef547edce
+--
+2.50.0
+
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index b3cf833..1a556c2 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+4 ????
+
+ + 85_all_PR120840.patch
+
3 1 June 2025
+ 36_all_no-afdo-testing.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-19 16:59 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-19 16:59 UTC (permalink / raw
To: gentoo-commits
commit: 127aabd4d9cabfe7f6af572bade472d481a5bb67
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 19 16:59:16 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 16:59:16 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=127aabd4
16.0.0: drop merged bloat patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
...n-PARM_DECLs-again-to-at-least-BITS_PER_W.patch | 107 ---------------------
1 file changed, 107 deletions(-)
diff --git a/16.0.0/gentoo/86_all_PR120689-expand-Align-PARM_DECLs-again-to-at-least-BITS_PER_W.patch b/16.0.0/gentoo/86_all_PR120689-expand-Align-PARM_DECLs-again-to-at-least-BITS_PER_W.patch
deleted file mode 100644
index a173566..0000000
--- a/16.0.0/gentoo/86_all_PR120689-expand-Align-PARM_DECLs-again-to-at-least-BITS_PER_W.patch
+++ /dev/null
@@ -1,107 +0,0 @@
-https://inbox.sourceware.org/gcc-patches/aFMXyiQw8fBWE4jl@tucnak/
-
-From a483146d61698559fbe3adad9a536b3eb509ecaa Mon Sep 17 00:00:00 2001
-Message-ID: <a483146d61698559fbe3adad9a536b3eb509ecaa.1750281360.git.sam@gentoo.org>
-From: Jakub Jelinek <jakub@redhat.com>
-Date: Wed, 18 Jun 2025 21:47:22 +0200
-Subject: [PATCH] expand: Align PARM_DECLs again to at least BITS_PER_WORD if
- possible [PR120689]
-
-Hi!
-
-The following testcase shows a regression caused by the r10-577 change
-made for cris. Before that change, the MEM holding (in this case 3 byte)
-struct parameter was BITS_PER_WORD aligned, now it is just BITS_PER_UNIT
-aligned and that causes significantly worse generated code.
-So, the MAX (DECL_ALIGN (parm), BITS_PER_WORD) extra alignment clearly
-doesn't help just STRICT_ALIGNMENT targets, but other targets as well.
-Of course, it isn't worth doing stack realignment in the rare case of
-MAX_SUPPORTED_STACK_ALIGNMENT < BITS_PER_WORD targets like cris, so the
-patch only bumps the alignment if it won't go the
-> MAX_SUPPORTED_STACK_ALIGNMENT path because of that optimization.
-
-The change on the testcase is:
-bar:
-- movl %edi, %eax
-- movzbl %dil, %r8d
-- movl %esi, %ecx
-- movzbl %sil, %r10d
-- movl %edx, %r9d
-- movzbl %dl, %r11d
-- shrl $16, %edi
-- andl $65280, %ecx
-- shrl $16, %esi
-- shrl $16, %edx
-- andl $65280, %r9d
-- orq %r10, %rcx
-- movzbl %dl, %edx
-- movzbl %sil, %esi
-- andl $65280, %eax
-- movzbl %dil, %edi
-- salq $16, %rdx
-- orq %r11, %r9
-- salq $16, %rsi
-- orq %r8, %rax
-- salq $16, %rdi
-- orq %r9, %rdx
-- orq %rcx, %rsi
-- orq %rax, %rdi
- jmp foo
-
-Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
-
-2025-06-18 Jakub Jelinek <jakub@redhat.com>
-
- PR target/120689
- * function.cc (assign_parm_setup_block): Align parm to at least
- word alignment even on !STRICT_ALIGNMENT targets, as long as
- BITS_PER_WORD is not larger than MAX_SUPPORTED_STACK_ALIGNMENT.
-
- * gcc.target/i386/pr120689.c: New test.
----
- gcc/function.cc | 2 +-
- gcc/testsuite/gcc.target/i386/pr120689.c | 17 +++++++++++++++++
- 2 files changed, 18 insertions(+), 1 deletion(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/pr120689.c
-
-diff --git a/gcc/function.cc b/gcc/function.cc
-index a5b245a98e91..a3a74b44b916 100644
---- a/gcc/function.cc
-+++ b/gcc/function.cc
-@@ -2937,7 +2937,7 @@ assign_parm_setup_block (struct assign_parm_data_all *all,
- if (stack_parm == 0)
- {
- HOST_WIDE_INT parm_align
-- = (STRICT_ALIGNMENT
-+ = ((STRICT_ALIGNMENT || BITS_PER_WORD <= MAX_SUPPORTED_STACK_ALIGNMENT)
- ? MAX (DECL_ALIGN (parm), BITS_PER_WORD) : DECL_ALIGN (parm));
-
- SET_DECL_ALIGN (parm, parm_align);
-diff --git a/gcc/testsuite/gcc.target/i386/pr120689.c b/gcc/testsuite/gcc.target/i386/pr120689.c
-new file mode 100644
-index 000000000000..cd10cdb487df
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/pr120689.c
-@@ -0,0 +1,17 @@
-+/* PR target/120689 */
-+/* { dg-do compile { target lp64 } } */
-+/* { dg-options "-O2 -mtune=generic -fno-stack-protector -masm=att" } */
-+/* { dg-final { scan-assembler-not "\t\(movzbl\|shrl\|salq\|orq\)\t" } } */
-+
-+struct S { char a, b, c; };
-+
-+[[gnu::noipa]]
-+void foo (struct S x, struct S y, struct S z)
-+{
-+}
-+
-+void
-+bar (struct S x, struct S y, struct S z)
-+{
-+ [[gnu::musttail]] return foo (x, y, z);
-+}
-
-base-commit: 9cc6cfdca980a508f72865830a09b353140e738e
---
-2.50.0
-
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-19 0:58 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-19 0:58 UTC (permalink / raw
To: gentoo-commits
commit: 263a417f98b248f43e449689d3e04bf7dced1569
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 19 00:58:40 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 00:58:40 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=263a417f
16.0.0: add link to expand bloat patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
..._PR120689-expand-Align-PARM_DECLs-again-to-at-least-BITS_PER_W.patch | 2 ++
1 file changed, 2 insertions(+)
diff --git a/16.0.0/gentoo/86_all_PR120689-expand-Align-PARM_DECLs-again-to-at-least-BITS_PER_W.patch b/16.0.0/gentoo/86_all_PR120689-expand-Align-PARM_DECLs-again-to-at-least-BITS_PER_W.patch
index b160593..a173566 100644
--- a/16.0.0/gentoo/86_all_PR120689-expand-Align-PARM_DECLs-again-to-at-least-BITS_PER_W.patch
+++ b/16.0.0/gentoo/86_all_PR120689-expand-Align-PARM_DECLs-again-to-at-least-BITS_PER_W.patch
@@ -1,3 +1,5 @@
+https://inbox.sourceware.org/gcc-patches/aFMXyiQw8fBWE4jl@tucnak/
+
From a483146d61698559fbe3adad9a536b3eb509ecaa Mon Sep 17 00:00:00 2001
Message-ID: <a483146d61698559fbe3adad9a536b3eb509ecaa.1750281360.git.sam@gentoo.org>
From: Jakub Jelinek <jakub@redhat.com>
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-19 0:58 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-19 0:58 UTC (permalink / raw
To: gentoo-commits
commit: f4f4450c934bc6a5da4172c5a23c50f9a2459851
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 19 00:58:28 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 00:58:28 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=f4f4450c
16.0.0: drop merged shrink-wrap patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
...fstack-clash-protection-for-shrink-wrap-s.patch | 106 ---------------------
1 file changed, 106 deletions(-)
diff --git a/16.0.0/gentoo/85_all_PR120697-x86-Handle-fstack-clash-protection-for-shrink-wrap-s.patch b/16.0.0/gentoo/85_all_PR120697-x86-Handle-fstack-clash-protection-for-shrink-wrap-s.patch
deleted file mode 100644
index 803a74f..0000000
--- a/16.0.0/gentoo/85_all_PR120697-x86-Handle-fstack-clash-protection-for-shrink-wrap-s.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120697#c14
-
-From 73fe038b1974b8f2867a765e5cbf5846abae4a25 Mon Sep 17 00:00:00 2001
-From: Lili Cui <lili.cui@intel.com>
-Date: Tue, 17 Jun 2025 23:49:03 -0700
-Subject: [PATCH 12/12] x86: Fix shrink wrap separate ICE under
- -fstack-clash-protection [PR120697]
-
-gcc/ChangeLog:
-
- PR target/120697
- * config/i386/i386.cc (ix86_expand_prologue):
- Delete 3 assertions and related code.
-
-gcc/testsuite/ChangeLog:
-
- PR target/120697
- * gcc.target/i386/stack-clash-protection.c: New test.
----
- gcc/config/i386/i386.cc | 14 +-------------
- .../gcc.target/i386/stack-clash-protection.c | 19 +++++++++++++++++++
- 2 files changed, 20 insertions(+), 13 deletions(-)
- create mode 100644 gcc/testsuite/gcc.target/i386/stack-clash-protection.c
-
-diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
-index 3824b533989..6dce7cdfdcb 100644
---- a/gcc/config/i386/i386.cc
-+++ b/gcc/config/i386/i386.cc
-@@ -9234,10 +9234,9 @@ ix86_expand_prologue (void)
- the stack frame saving one cycle of the prologue. However, avoid
- doing this if we have to probe the stack; at least on x86_64 the
- stack probe can turn into a call that clobbers a red zone location. */
-- else if ((ix86_using_red_zone ()
-+ else if (ix86_using_red_zone ()
- && (! TARGET_STACK_PROBE
- || frame.stack_pointer_offset < CHECK_STACK_LIMIT))
-- || crtl->shrink_wrapped_separate)
- {
- HOST_WIDE_INT allocate_offset;
- if (crtl->shrink_wrapped_separate)
-@@ -9253,11 +9252,6 @@ ix86_expand_prologue (void)
-
- ix86_emit_save_regs_using_mov (frame.reg_save_offset);
- int_registers_saved = true;
--
-- if (ix86_using_red_zone ()
-- && (! TARGET_STACK_PROBE
-- || frame.stack_pointer_offset < CHECK_STACK_LIMIT))
-- cfun->machine->red_zone_used = true;
- }
- }
-
-@@ -9377,8 +9371,6 @@ ix86_expand_prologue (void)
- && flag_stack_clash_protection
- && !ix86_target_stack_probe ())
- {
-- gcc_assert (!crtl->shrink_wrapped_separate);
--
- ix86_adjust_stack_and_probe (allocate, int_registers_saved, false);
- allocate = 0;
- }
-@@ -9389,8 +9381,6 @@ ix86_expand_prologue (void)
- {
- const HOST_WIDE_INT probe_interval = get_probe_interval ();
-
-- gcc_assert (!crtl->shrink_wrapped_separate);
--
- if (STACK_CHECK_MOVING_SP)
- {
- if (crtl->is_leaf
-@@ -9447,8 +9437,6 @@ ix86_expand_prologue (void)
- else if (!ix86_target_stack_probe ()
- || frame.stack_pointer_offset < CHECK_STACK_LIMIT)
- {
-- gcc_assert (!crtl->shrink_wrapped_separate);
--
- pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
- GEN_INT (-allocate), -1,
- m->fs.cfa_reg == stack_pointer_rtx);
-diff --git a/gcc/testsuite/gcc.target/i386/stack-clash-protection.c b/gcc/testsuite/gcc.target/i386/stack-clash-protection.c
-new file mode 100644
-index 00000000000..5be28cb3ac7
---- /dev/null
-+++ b/gcc/testsuite/gcc.target/i386/stack-clash-protection.c
-@@ -0,0 +1,19 @@
-+/* { dg-do compile } */
-+/* { dg-options "-O2 -fstack-clash-protection" } */
-+
-+int flag;
-+void open();
-+int getChar();
-+typedef enum { QUOTE } CharType;
-+typedef enum { UNQ } State;
-+CharType getCharType();
-+void expand() {
-+ open();
-+ if (flag)
-+ return;
-+ int ch = getChar();
-+ State nextState = getCharType();
-+ if (nextState)
-+ while (ch)
-+ ;
-+}
---
-2.34.1
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-18 21:17 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-18 21:17 UTC (permalink / raw
To: gentoo-commits
commit: e97115ef72070c3d8de00572572f632aae9e94f0
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 18 21:16:43 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 18 21:17:16 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=e97115ef
16.0.0: add expand bloat fix
I need to rebuild for something else so may as well throw it in.
Bug: https://gcc.gnu.org/PR120689
Signed-off-by: Sam James <sam <AT> gentoo.org>
...n-PARM_DECLs-again-to-at-least-BITS_PER_W.patch | 105 +++++++++++++++++++++
1 file changed, 105 insertions(+)
diff --git a/16.0.0/gentoo/86_all_PR120689-expand-Align-PARM_DECLs-again-to-at-least-BITS_PER_W.patch b/16.0.0/gentoo/86_all_PR120689-expand-Align-PARM_DECLs-again-to-at-least-BITS_PER_W.patch
new file mode 100644
index 0000000..b160593
--- /dev/null
+++ b/16.0.0/gentoo/86_all_PR120689-expand-Align-PARM_DECLs-again-to-at-least-BITS_PER_W.patch
@@ -0,0 +1,105 @@
+From a483146d61698559fbe3adad9a536b3eb509ecaa Mon Sep 17 00:00:00 2001
+Message-ID: <a483146d61698559fbe3adad9a536b3eb509ecaa.1750281360.git.sam@gentoo.org>
+From: Jakub Jelinek <jakub@redhat.com>
+Date: Wed, 18 Jun 2025 21:47:22 +0200
+Subject: [PATCH] expand: Align PARM_DECLs again to at least BITS_PER_WORD if
+ possible [PR120689]
+
+Hi!
+
+The following testcase shows a regression caused by the r10-577 change
+made for cris. Before that change, the MEM holding (in this case 3 byte)
+struct parameter was BITS_PER_WORD aligned, now it is just BITS_PER_UNIT
+aligned and that causes significantly worse generated code.
+So, the MAX (DECL_ALIGN (parm), BITS_PER_WORD) extra alignment clearly
+doesn't help just STRICT_ALIGNMENT targets, but other targets as well.
+Of course, it isn't worth doing stack realignment in the rare case of
+MAX_SUPPORTED_STACK_ALIGNMENT < BITS_PER_WORD targets like cris, so the
+patch only bumps the alignment if it won't go the
+> MAX_SUPPORTED_STACK_ALIGNMENT path because of that optimization.
+
+The change on the testcase is:
+bar:
+- movl %edi, %eax
+- movzbl %dil, %r8d
+- movl %esi, %ecx
+- movzbl %sil, %r10d
+- movl %edx, %r9d
+- movzbl %dl, %r11d
+- shrl $16, %edi
+- andl $65280, %ecx
+- shrl $16, %esi
+- shrl $16, %edx
+- andl $65280, %r9d
+- orq %r10, %rcx
+- movzbl %dl, %edx
+- movzbl %sil, %esi
+- andl $65280, %eax
+- movzbl %dil, %edi
+- salq $16, %rdx
+- orq %r11, %r9
+- salq $16, %rsi
+- orq %r8, %rax
+- salq $16, %rdi
+- orq %r9, %rdx
+- orq %rcx, %rsi
+- orq %rax, %rdi
+ jmp foo
+
+Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
+
+2025-06-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/120689
+ * function.cc (assign_parm_setup_block): Align parm to at least
+ word alignment even on !STRICT_ALIGNMENT targets, as long as
+ BITS_PER_WORD is not larger than MAX_SUPPORTED_STACK_ALIGNMENT.
+
+ * gcc.target/i386/pr120689.c: New test.
+---
+ gcc/function.cc | 2 +-
+ gcc/testsuite/gcc.target/i386/pr120689.c | 17 +++++++++++++++++
+ 2 files changed, 18 insertions(+), 1 deletion(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/pr120689.c
+
+diff --git a/gcc/function.cc b/gcc/function.cc
+index a5b245a98e91..a3a74b44b916 100644
+--- a/gcc/function.cc
++++ b/gcc/function.cc
+@@ -2937,7 +2937,7 @@ assign_parm_setup_block (struct assign_parm_data_all *all,
+ if (stack_parm == 0)
+ {
+ HOST_WIDE_INT parm_align
+- = (STRICT_ALIGNMENT
++ = ((STRICT_ALIGNMENT || BITS_PER_WORD <= MAX_SUPPORTED_STACK_ALIGNMENT)
+ ? MAX (DECL_ALIGN (parm), BITS_PER_WORD) : DECL_ALIGN (parm));
+
+ SET_DECL_ALIGN (parm, parm_align);
+diff --git a/gcc/testsuite/gcc.target/i386/pr120689.c b/gcc/testsuite/gcc.target/i386/pr120689.c
+new file mode 100644
+index 000000000000..cd10cdb487df
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/pr120689.c
+@@ -0,0 +1,17 @@
++/* PR target/120689 */
++/* { dg-do compile { target lp64 } } */
++/* { dg-options "-O2 -mtune=generic -fno-stack-protector -masm=att" } */
++/* { dg-final { scan-assembler-not "\t\(movzbl\|shrl\|salq\|orq\)\t" } } */
++
++struct S { char a, b, c; };
++
++[[gnu::noipa]]
++void foo (struct S x, struct S y, struct S z)
++{
++}
++
++void
++bar (struct S x, struct S y, struct S z)
++{
++ [[gnu::musttail]] return foo (x, y, z);
++}
+
+base-commit: 9cc6cfdca980a508f72865830a09b353140e738e
+--
+2.50.0
+
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-18 9:53 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-18 9:53 UTC (permalink / raw
To: gentoo-commits
commit: 9fc60320b4ac6921dfe7d97972a86082f19e33ba
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 18 09:53:44 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 18 09:53:44 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=9fc60320
16.0.0: update patch to add testcase
Signed-off-by: Sam James <sam <AT> gentoo.org>
...fstack-clash-protection-for-shrink-wrap-s.patch | 57 ++++++++++++++--------
1 file changed, 37 insertions(+), 20 deletions(-)
diff --git a/16.0.0/gentoo/85_all_PR120697-x86-Handle-fstack-clash-protection-for-shrink-wrap-s.patch b/16.0.0/gentoo/85_all_PR120697-x86-Handle-fstack-clash-protection-for-shrink-wrap-s.patch
index 08e3c49..803a74f 100644
--- a/16.0.0/gentoo/85_all_PR120697-x86-Handle-fstack-clash-protection-for-shrink-wrap-s.patch
+++ b/16.0.0/gentoo/85_all_PR120697-x86-Handle-fstack-clash-protection-for-shrink-wrap-s.patch
@@ -1,23 +1,26 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120697#c12
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120697#c14
-From 4f80288ecb15195c8baa3e0081354c4cab78db36 Mon Sep 17 00:00:00 2001
+From 73fe038b1974b8f2867a765e5cbf5846abae4a25 Mon Sep 17 00:00:00 2001
From: Lili Cui <lili.cui@intel.com>
Date: Tue, 17 Jun 2025 23:49:03 -0700
-Subject: [PATCH] x86: Handle -fstack-clash-protection for shrink wrap separate
+Subject: [PATCH 12/12] x86: Fix shrink wrap separate ICE under
+ -fstack-clash-protection [PR120697]
gcc/ChangeLog:
- * config/i386/i386.cc (ix86_expand_prologue):
+ PR target/120697
+ * config/i386/i386.cc (ix86_expand_prologue):
Delete 3 assertions and related code.
gcc/testsuite/ChangeLog:
- * g++.target/i386/shrink_wrap_separate.C:
- Add -fstack-clash-protection into build options.
+ PR target/120697
+ * gcc.target/i386/stack-clash-protection.c: New test.
---
- gcc/config/i386/i386.cc | 14 +-------------
- .../g++.target/i386/shrink_wrap_separate.C | 2 +-
- 2 files changed, 2 insertions(+), 14 deletions(-)
+ gcc/config/i386/i386.cc | 14 +-------------
+ .../gcc.target/i386/stack-clash-protection.c | 19 +++++++++++++++++++
+ 2 files changed, 20 insertions(+), 13 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.target/i386/stack-clash-protection.c
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 3824b533989..6dce7cdfdcb 100644
@@ -74,16 +77,30 @@ index 3824b533989..6dce7cdfdcb 100644
pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
GEN_INT (-allocate), -1,
m->fs.cfa_reg == stack_pointer_rtx);
-diff --git a/gcc/testsuite/g++.target/i386/shrink_wrap_separate.C b/gcc/testsuite/g++.target/i386/shrink_wrap_separate.C
-index 294dccde5d3..a1772c3a396 100644
---- a/gcc/testsuite/g++.target/i386/shrink_wrap_separate.C
-+++ b/gcc/testsuite/g++.target/i386/shrink_wrap_separate.C
-@@ -1,5 +1,5 @@
- /* { dg-do compile } */
--/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue" } */
-+/* { dg-options "-O2 -fstack-clash-protection -fdump-rtl-pro_and_epilogue" } */
- typedef struct a b;
- typedef double c;
- struct a {
+diff --git a/gcc/testsuite/gcc.target/i386/stack-clash-protection.c b/gcc/testsuite/gcc.target/i386/stack-clash-protection.c
+new file mode 100644
+index 00000000000..5be28cb3ac7
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/i386/stack-clash-protection.c
+@@ -0,0 +1,19 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -fstack-clash-protection" } */
++
++int flag;
++void open();
++int getChar();
++typedef enum { QUOTE } CharType;
++typedef enum { UNQ } State;
++CharType getCharType();
++void expand() {
++ open();
++ if (flag)
++ return;
++ int ch = getChar();
++ State nextState = getCharType();
++ if (nextState)
++ while (ch)
++ ;
++}
--
2.34.1
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-18 9:06 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-18 9:06 UTC (permalink / raw
To: gentoo-commits
commit: 0368bcaaca6bc5c7d81426e5b69760063f808cad
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 18 09:05:47 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 18 09:05:47 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=0368bcaa
16.0.0: add patch for -fstack-clash-protection vs shrink wrapping
Bug: https://gcc.gnu.org/PR120697
Signed-off-by: Sam James <sam <AT> gentoo.org>
...fstack-clash-protection-for-shrink-wrap-s.patch | 89 ++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/16.0.0/gentoo/85_all_PR120697-x86-Handle-fstack-clash-protection-for-shrink-wrap-s.patch b/16.0.0/gentoo/85_all_PR120697-x86-Handle-fstack-clash-protection-for-shrink-wrap-s.patch
new file mode 100644
index 0000000..08e3c49
--- /dev/null
+++ b/16.0.0/gentoo/85_all_PR120697-x86-Handle-fstack-clash-protection-for-shrink-wrap-s.patch
@@ -0,0 +1,89 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120697#c12
+
+From 4f80288ecb15195c8baa3e0081354c4cab78db36 Mon Sep 17 00:00:00 2001
+From: Lili Cui <lili.cui@intel.com>
+Date: Tue, 17 Jun 2025 23:49:03 -0700
+Subject: [PATCH] x86: Handle -fstack-clash-protection for shrink wrap separate
+
+gcc/ChangeLog:
+
+ * config/i386/i386.cc (ix86_expand_prologue):
+ Delete 3 assertions and related code.
+
+gcc/testsuite/ChangeLog:
+
+ * g++.target/i386/shrink_wrap_separate.C:
+ Add -fstack-clash-protection into build options.
+---
+ gcc/config/i386/i386.cc | 14 +-------------
+ .../g++.target/i386/shrink_wrap_separate.C | 2 +-
+ 2 files changed, 2 insertions(+), 14 deletions(-)
+
+diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
+index 3824b533989..6dce7cdfdcb 100644
+--- a/gcc/config/i386/i386.cc
++++ b/gcc/config/i386/i386.cc
+@@ -9234,10 +9234,9 @@ ix86_expand_prologue (void)
+ the stack frame saving one cycle of the prologue. However, avoid
+ doing this if we have to probe the stack; at least on x86_64 the
+ stack probe can turn into a call that clobbers a red zone location. */
+- else if ((ix86_using_red_zone ()
++ else if (ix86_using_red_zone ()
+ && (! TARGET_STACK_PROBE
+ || frame.stack_pointer_offset < CHECK_STACK_LIMIT))
+- || crtl->shrink_wrapped_separate)
+ {
+ HOST_WIDE_INT allocate_offset;
+ if (crtl->shrink_wrapped_separate)
+@@ -9253,11 +9252,6 @@ ix86_expand_prologue (void)
+
+ ix86_emit_save_regs_using_mov (frame.reg_save_offset);
+ int_registers_saved = true;
+-
+- if (ix86_using_red_zone ()
+- && (! TARGET_STACK_PROBE
+- || frame.stack_pointer_offset < CHECK_STACK_LIMIT))
+- cfun->machine->red_zone_used = true;
+ }
+ }
+
+@@ -9377,8 +9371,6 @@ ix86_expand_prologue (void)
+ && flag_stack_clash_protection
+ && !ix86_target_stack_probe ())
+ {
+- gcc_assert (!crtl->shrink_wrapped_separate);
+-
+ ix86_adjust_stack_and_probe (allocate, int_registers_saved, false);
+ allocate = 0;
+ }
+@@ -9389,8 +9381,6 @@ ix86_expand_prologue (void)
+ {
+ const HOST_WIDE_INT probe_interval = get_probe_interval ();
+
+- gcc_assert (!crtl->shrink_wrapped_separate);
+-
+ if (STACK_CHECK_MOVING_SP)
+ {
+ if (crtl->is_leaf
+@@ -9447,8 +9437,6 @@ ix86_expand_prologue (void)
+ else if (!ix86_target_stack_probe ()
+ || frame.stack_pointer_offset < CHECK_STACK_LIMIT)
+ {
+- gcc_assert (!crtl->shrink_wrapped_separate);
+-
+ pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
+ GEN_INT (-allocate), -1,
+ m->fs.cfa_reg == stack_pointer_rtx);
+diff --git a/gcc/testsuite/g++.target/i386/shrink_wrap_separate.C b/gcc/testsuite/g++.target/i386/shrink_wrap_separate.C
+index 294dccde5d3..a1772c3a396 100644
+--- a/gcc/testsuite/g++.target/i386/shrink_wrap_separate.C
++++ b/gcc/testsuite/g++.target/i386/shrink_wrap_separate.C
+@@ -1,5 +1,5 @@
+ /* { dg-do compile } */
+-/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue" } */
++/* { dg-options "-O2 -fstack-clash-protection -fdump-rtl-pro_and_epilogue" } */
+ typedef struct a b;
+ typedef double c;
+ struct a {
+--
+2.34.1
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-13 12:03 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-13 12:03 UTC (permalink / raw
To: gentoo-commits
commit: 98a884c00e745bc079561290d535fab134afc7fb
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 13 12:03:37 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jun 13 12:03:37 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=98a884c0
16.0.0: drop now-upstream patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/85_all_PR120629.patch | 94 -------------------------------------
1 file changed, 94 deletions(-)
diff --git a/16.0.0/gentoo/85_all_PR120629.patch b/16.0.0/gentoo/85_all_PR120629.patch
deleted file mode 100644
index cc9c7bb..0000000
--- a/16.0.0/gentoo/85_all_PR120629.patch
+++ /dev/null
@@ -1,94 +0,0 @@
-https://inbox.sourceware.org/gcc-patches/aEsZqeAHpUtZMnED@tucnak/
-
-From 6acfe3c58453fada8ade14eb7b563a225ca44eff Mon Sep 17 00:00:00 2001
-Message-ID: <6acfe3c58453fada8ade14eb7b563a225ca44eff.1749760394.git.sam@gentoo.org>
-From: Jakub Jelinek <jakub@redhat.com>
-Date: Thu, 12 Jun 2025 20:17:13 +0200
-Subject: [PATCH] expand: Fix up edge splitting for ENTRY block during
- expansion if there are any PHIs [PR120629]
-
-Hi!
-
-Andrew ran some extra ranger checking during bootstrap and found one more
-case (though much rarer than the GIMPLE_COND case).
-
-Seems on fold-const.cc (native_encode_expr) we end up with bb 2, ENTRY
-bb successor, having PHI nodes (usually there is some bb in between, even if
-empty, in the native_encode_expr it is tail recursion but haven't managed
-to construct a test with such case by hand).
-So, we have in optimized dump
- <bb 2> [local count: 1089340384]:
- # expr_12 = PHI <expr_199(D)(0), part_93(51)>
- # ptr_13 = PHI <ptr_86(D)(0), ptr_13(51)>
- # len_14 = PHI <len_103(D)(0), _198(51)>
- # off_10 = PHI <off_102(D)(0), _207(51)>
- # add_acc_99 = PHI <0(0), add_acc_101(51)>
-where there are mostly default defs from the 0->2 edge (and one zero)
-and some other values from the other edge.
-construct_init_block inserts a BB_RTL basic block with the function start
-instructions and similarly to the GIMPLE_COND case it wants to insert that
-bb on the edge from ENTRY to its single successor.
-Now, without this patch redirect_edge_succ redirects the 0->2 edge to 0->52,
-so the 51->2 edge gets moved first by unordered_remove, and
-make_single_succ_edge adds a new 52->2 edge. So we end up with
- # expr_12 = PHI <expr_199(D)(51), part_93(52)>
- # ptr_13 = PHI <ptr_86(D)(51), ptr_13(52)>
- # len_14 = PHI <len_103(D)(51), _198(52)>
- # off_10 = PHI <off_102(D)(51), _207(52)>
- # add_acc_99 = PHI <0(51), add_acc_101(52)>
-which is not correct, the default definitions and zero are now from the edge
-from end of function and the other values from the edge from the new BB_RTL
-successor of ENTRY. With this patch we get
- # expr_12 = PHI <expr_199(D)(52), part_93(51)>
- # ptr_13 = PHI <ptr_86(D)(52), ptr_13(51)>
- # len_14 = PHI <len_103(D)(52), _198(51)>
- # off_10 = PHI <off_102(D)(52), _207(51)>
- # add_acc_99 = PHI <0(52), add_acc_101(51)>
-instead.
-
-Starting bootstrap/regtest now, ok for trunk if it passes on x86_64-linux
-and i686-linux?
-
-2025-06-12 Jakub Jelinek <jakub@redhat.com>
-
- * cfgexpand.cc (construct_init_block): If first_block isn't BB_RTL,
- has any PHI nodes and false_edge->dest_idx before redirection is
- different from make_single_succ_edge result's dest_idx, swap the
- latter with the former last pred edge and their dest_idx members.
----
- gcc/cfgexpand.cc | 15 ++++++++++++++-
- 1 file changed, 14 insertions(+), 1 deletion(-)
-
-diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
-index f288a5407346..2e6241d1e39a 100644
---- a/gcc/cfgexpand.cc
-+++ b/gcc/cfgexpand.cc
-@@ -6570,9 +6570,22 @@ construct_init_block (void)
- add_bb_to_loop (init_block, ENTRY_BLOCK_PTR_FOR_FN (cfun)->loop_father);
- if (e)
- {
-+ unsigned int dest_idx = e->dest_idx;
- first_block = e->dest;
- redirect_edge_succ (e, init_block);
-- make_single_succ_edge (init_block, first_block, flags);
-+ e = make_single_succ_edge (init_block, first_block, flags);
-+ if ((first_block->flags & BB_RTL) == 0
-+ && phi_nodes (first_block)
-+ && e->dest_idx != dest_idx)
-+ {
-+ /* If there are any PHI nodes on dest, swap the new succ edge
-+ with the one moved into false_edge's former position, so that
-+ PHI arguments don't need adjustment. */
-+ edge e2 = EDGE_PRED (first_block, dest_idx);
-+ std::swap (e->dest_idx, e2->dest_idx);
-+ std::swap (EDGE_PRED (first_block, e->dest_idx),
-+ EDGE_PRED (first_block, e2->dest_idx));
-+ }
- }
- else
- make_single_succ_edge (init_block, EXIT_BLOCK_PTR_FOR_FN (cfun),
-
-base-commit: 8804e5b5b127b27d099d0c361fa2161d0b13edef
---
-2.49.0
-
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-12 20:34 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-12 20:34 UTC (permalink / raw
To: gentoo-commits
commit: 4695541cd6d1de0770204f9000bd1087e597ba79
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 12 20:33:36 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 12 20:34:01 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=4695541c
16.0.0: add followup expand vs ranger patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/85_all_PR120629.patch | 94 +++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
diff --git a/16.0.0/gentoo/85_all_PR120629.patch b/16.0.0/gentoo/85_all_PR120629.patch
new file mode 100644
index 0000000..cc9c7bb
--- /dev/null
+++ b/16.0.0/gentoo/85_all_PR120629.patch
@@ -0,0 +1,94 @@
+https://inbox.sourceware.org/gcc-patches/aEsZqeAHpUtZMnED@tucnak/
+
+From 6acfe3c58453fada8ade14eb7b563a225ca44eff Mon Sep 17 00:00:00 2001
+Message-ID: <6acfe3c58453fada8ade14eb7b563a225ca44eff.1749760394.git.sam@gentoo.org>
+From: Jakub Jelinek <jakub@redhat.com>
+Date: Thu, 12 Jun 2025 20:17:13 +0200
+Subject: [PATCH] expand: Fix up edge splitting for ENTRY block during
+ expansion if there are any PHIs [PR120629]
+
+Hi!
+
+Andrew ran some extra ranger checking during bootstrap and found one more
+case (though much rarer than the GIMPLE_COND case).
+
+Seems on fold-const.cc (native_encode_expr) we end up with bb 2, ENTRY
+bb successor, having PHI nodes (usually there is some bb in between, even if
+empty, in the native_encode_expr it is tail recursion but haven't managed
+to construct a test with such case by hand).
+So, we have in optimized dump
+ <bb 2> [local count: 1089340384]:
+ # expr_12 = PHI <expr_199(D)(0), part_93(51)>
+ # ptr_13 = PHI <ptr_86(D)(0), ptr_13(51)>
+ # len_14 = PHI <len_103(D)(0), _198(51)>
+ # off_10 = PHI <off_102(D)(0), _207(51)>
+ # add_acc_99 = PHI <0(0), add_acc_101(51)>
+where there are mostly default defs from the 0->2 edge (and one zero)
+and some other values from the other edge.
+construct_init_block inserts a BB_RTL basic block with the function start
+instructions and similarly to the GIMPLE_COND case it wants to insert that
+bb on the edge from ENTRY to its single successor.
+Now, without this patch redirect_edge_succ redirects the 0->2 edge to 0->52,
+so the 51->2 edge gets moved first by unordered_remove, and
+make_single_succ_edge adds a new 52->2 edge. So we end up with
+ # expr_12 = PHI <expr_199(D)(51), part_93(52)>
+ # ptr_13 = PHI <ptr_86(D)(51), ptr_13(52)>
+ # len_14 = PHI <len_103(D)(51), _198(52)>
+ # off_10 = PHI <off_102(D)(51), _207(52)>
+ # add_acc_99 = PHI <0(51), add_acc_101(52)>
+which is not correct, the default definitions and zero are now from the edge
+from end of function and the other values from the edge from the new BB_RTL
+successor of ENTRY. With this patch we get
+ # expr_12 = PHI <expr_199(D)(52), part_93(51)>
+ # ptr_13 = PHI <ptr_86(D)(52), ptr_13(51)>
+ # len_14 = PHI <len_103(D)(52), _198(51)>
+ # off_10 = PHI <off_102(D)(52), _207(51)>
+ # add_acc_99 = PHI <0(52), add_acc_101(51)>
+instead.
+
+Starting bootstrap/regtest now, ok for trunk if it passes on x86_64-linux
+and i686-linux?
+
+2025-06-12 Jakub Jelinek <jakub@redhat.com>
+
+ * cfgexpand.cc (construct_init_block): If first_block isn't BB_RTL,
+ has any PHI nodes and false_edge->dest_idx before redirection is
+ different from make_single_succ_edge result's dest_idx, swap the
+ latter with the former last pred edge and their dest_idx members.
+---
+ gcc/cfgexpand.cc | 15 ++++++++++++++-
+ 1 file changed, 14 insertions(+), 1 deletion(-)
+
+diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
+index f288a5407346..2e6241d1e39a 100644
+--- a/gcc/cfgexpand.cc
++++ b/gcc/cfgexpand.cc
+@@ -6570,9 +6570,22 @@ construct_init_block (void)
+ add_bb_to_loop (init_block, ENTRY_BLOCK_PTR_FOR_FN (cfun)->loop_father);
+ if (e)
+ {
++ unsigned int dest_idx = e->dest_idx;
+ first_block = e->dest;
+ redirect_edge_succ (e, init_block);
+- make_single_succ_edge (init_block, first_block, flags);
++ e = make_single_succ_edge (init_block, first_block, flags);
++ if ((first_block->flags & BB_RTL) == 0
++ && phi_nodes (first_block)
++ && e->dest_idx != dest_idx)
++ {
++ /* If there are any PHI nodes on dest, swap the new succ edge
++ with the one moved into false_edge's former position, so that
++ PHI arguments don't need adjustment. */
++ edge e2 = EDGE_PRED (first_block, dest_idx);
++ std::swap (e->dest_idx, e2->dest_idx);
++ std::swap (EDGE_PRED (first_block, e->dest_idx),
++ EDGE_PRED (first_block, e2->dest_idx));
++ }
+ }
+ else
+ make_single_succ_edge (init_block, EXIT_BLOCK_PTR_FOR_FN (cfun),
+
+base-commit: 8804e5b5b127b27d099d0c361fa2161d0b13edef
+--
+2.49.0
+
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-12 14:05 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-12 14:05 UTC (permalink / raw
To: gentoo-commits
commit: 9b85c42b38d3e2964755e00ffb09c04177fafbf0
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 12 14:05:13 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 12 14:05:13 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=9b85c42b
16.0.0: drop now-upstream patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/75_all_PR120629.patch | 162 ------------------------------------
1 file changed, 162 deletions(-)
diff --git a/16.0.0/gentoo/75_all_PR120629.patch b/16.0.0/gentoo/75_all_PR120629.patch
deleted file mode 100644
index 5622107..0000000
--- a/16.0.0/gentoo/75_all_PR120629.patch
+++ /dev/null
@@ -1,162 +0,0 @@
-https://inbox.sourceware.org/gcc-patches/aEp6IPgAzLdU5pmi@tucnak/
-
-From 34ddeb4974ec668ee035735dcf57429c12b079b2 Mon Sep 17 00:00:00 2001
-Message-ID: <34ddeb4974ec668ee035735dcf57429c12b079b2.1749713239.git.sam@gentoo.org>
-From: Jakub Jelinek <jakub@redhat.com>
-Date: Thu, 12 Jun 2025 08:56:32 +0200
-Subject: [PATCH] expand: Fix up edge splitting for GIMPLE_COND expansion if
- there are any PHIs [PR120629]
-
-Hi!
-
-My r16-1398 PR120434 ranger during expansion change broke profiled lto
-bootstrap on x86_64-linux, the following testcase is reduced from that.
-
-The problem is during expand_gimple_cond, if we are unlucky that neither
-of edge_true and edge_false point to the next basic block, the code
-effectively attempts to split the false_edge and make the new bb BB_RTL
-with some extra instructions which just arranges to jump.
-It does it by creating a new bb, redirecting the false_edge and then
-creating a new edge from the new bb to the dest.
-Note, we don't have GIMPLE cfg hooks installed anymore and even if we
-would, the 3 calls aren't the same as one split_edge with transformation
-of the new bb into BB_RTL and adding it some BB_HEAD/BB_END. If
-false_edge->dest is BB_RTL or doesn't have PHI nodes (which before my
-patch was always the case because), then this works fine, but with
-PHI nodes on false_edge->dest redirect_edge_succ will remove the false_edge
-from dest->preds (unordered remove which moves into its place the last edge
-in the vector) and the new make_edge will then add the new edge as last
-in the vector. So, unless false_edge is the last edge in the dest->preds
-vector this effectively swaps the last edge in the vector with
-false_edge/its new replacement.
-gimple_split_edge solves this by temporarily clearing phi_nodes on dest
-(not needed when we don't have GIMPLE hooks), then making the new edge
-first and redirecting the old edge (plus restoring phi_nodes on dest).
-That way the redirection replaces the old edge with the new one and
-PHI arguments don't need adjustment. At the cost of temporarily needing
-one more edge in the vector and so if unlucky reallocation.
-Doing it like that is one of the options (i.e. just move the
-make_single_succ_edge call). This patch instead keeps doing what it did
-and just swaps two edges again if needed to restore the PHI behavior
-- remember edge_false->dest_idx first if there are PHI nodes in
-edge_false->dest and afterwards if new edge's dest_idx is different from
-the remembered one, swap the new edge with EDGE_PRED (dest, old_dest_idx).
-That way PHI arguments are maintained properly as well. Without this
-we sometimes just swap PHI arguments.
-
-Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
-
-2025-06-12 Jakub Jelinek <jakub@redhat.com>
-
- PR middle-end/120629
- * cfgexpand.cc (expand_gimple_cond): If dest bb isn't BB_RTL,
- has any PHI nodes and false_edge->dest_idx before redirection is
- different from make_single_succ_edge result's dest_idx, swap the
- latter with the former last pred edge and their dest_idx members.
-
- * g++.dg/opt/pr120629.C: New test.
----
- gcc/cfgexpand.cc | 17 ++++++++-
- gcc/testsuite/g++.dg/opt/pr120629.C | 53 +++++++++++++++++++++++++++++
- 2 files changed, 69 insertions(+), 1 deletion(-)
- create mode 100644 gcc/testsuite/g++.dg/opt/pr120629.C
-
-diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
-index 49b0b1404200..ce694add0e38 100644
---- a/gcc/cfgexpand.cc
-+++ b/gcc/cfgexpand.cc
-@@ -3013,6 +3013,9 @@ expand_gimple_cond (basic_block bb, gcond *stmt)
-
- new_bb = create_basic_block (NEXT_INSN (last), get_last_insn (), bb);
- dest = false_edge->dest;
-+ unsigned int dest_idx = 0;
-+ if ((dest->flags & BB_RTL) == 0 && phi_nodes (dest))
-+ dest_idx = false_edge->dest_idx;
- redirect_edge_succ (false_edge, new_bb);
- false_edge->flags |= EDGE_FALLTHRU;
- new_bb->count = false_edge->count ();
-@@ -3021,7 +3024,19 @@ expand_gimple_cond (basic_block bb, gcond *stmt)
- if (loop->latch == bb
- && loop->header == dest)
- loop->latch = new_bb;
-- make_single_succ_edge (new_bb, dest, 0);
-+ edge e = make_single_succ_edge (new_bb, dest, 0);
-+ if ((dest->flags & BB_RTL) == 0
-+ && phi_nodes (dest)
-+ && e->dest_idx != dest_idx)
-+ {
-+ /* If there are any PHI nodes on dest, swap the new succ edge
-+ with the one moved into false_edge's former position, so that
-+ PHI arguments don't need adjustment. */
-+ edge e2 = EDGE_PRED (dest, dest_idx);
-+ std::swap (e->dest_idx, e2->dest_idx);
-+ std::swap (EDGE_PRED (dest, e->dest_idx),
-+ EDGE_PRED (dest, e2->dest_idx));
-+ }
- if (BARRIER_P (BB_END (new_bb)))
- BB_END (new_bb) = PREV_INSN (BB_END (new_bb));
- update_bb_for_insn (new_bb);
-diff --git a/gcc/testsuite/g++.dg/opt/pr120629.C b/gcc/testsuite/g++.dg/opt/pr120629.C
-new file mode 100644
-index 000000000000..70a9cddcd3f2
---- /dev/null
-+++ b/gcc/testsuite/g++.dg/opt/pr120629.C
-@@ -0,0 +1,53 @@
-+// PR middle-end/120629
-+// { dg-do run }
-+// { dg-options "-O2 -fprofile-generate -fno-exceptions -fno-rtti" }
-+// { dg-require-profiling "-fprofile-generate" }
-+
-+__attribute__((noipa, noreturn, cold)) void
-+foo (const char *, int, const char *)
-+{
-+ __builtin_abort ();
-+}
-+
-+struct S
-+{
-+ __attribute__((noipa)) void bar (void *);
-+ static const int a = 8;
-+ unsigned int b[a + 1];
-+};
-+
-+__attribute__((noipa)) unsigned long
-+baz (void *)
-+{
-+ static int x = 8;
-+ return --x;
-+}
-+
-+__attribute__((noipa)) void
-+S::bar (void *x)
-+{
-+ unsigned int c;
-+ int k = 0;
-+
-+ do
-+ {
-+ ((void) (!(k <= a) ? foo ("foo", 42, __FUNCTION__), 0 : 0));
-+ c = b[k++] = baz (x);
-+ }
-+ while (c);
-+ while (k <= a)
-+ b[k++] = 0;
-+}
-+
-+int
-+main ()
-+{
-+ struct T { S a; unsigned int b; } s = {};
-+ s.b = 0x1234;
-+ s.a.bar (0);
-+ for (int i = 0; i < 9; ++i)
-+ if (s.a.b[i] != (i == 8 ? 0 : 7 - i))
-+ __builtin_abort ();
-+ if (s.b != 0x1234)
-+ __builtin_abort ();
-+}
-
-base-commit: ccfd4163970b1aef12b40f49b826bb49f3fc6f2b
---
-2.49.0
-
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-12 7:27 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-12 7:27 UTC (permalink / raw
To: gentoo-commits
commit: e45f688bab00f0d7af0a79e92c5bf114cbe58723
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 12 07:27:49 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 12 07:27:49 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=e45f688b
16.0.0: add more patch metadata
Now it got posted to the ML.
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/75_all_PR120629.patch | 75 +++++++++++++++++++++++++++++++++----
1 file changed, 68 insertions(+), 7 deletions(-)
diff --git a/16.0.0/gentoo/75_all_PR120629.patch b/16.0.0/gentoo/75_all_PR120629.patch
index 77b562a..5622107 100644
--- a/16.0.0/gentoo/75_all_PR120629.patch
+++ b/16.0.0/gentoo/75_all_PR120629.patch
@@ -1,4 +1,50 @@
-https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120629#c22
+https://inbox.sourceware.org/gcc-patches/aEp6IPgAzLdU5pmi@tucnak/
+
+From 34ddeb4974ec668ee035735dcf57429c12b079b2 Mon Sep 17 00:00:00 2001
+Message-ID: <34ddeb4974ec668ee035735dcf57429c12b079b2.1749713239.git.sam@gentoo.org>
+From: Jakub Jelinek <jakub@redhat.com>
+Date: Thu, 12 Jun 2025 08:56:32 +0200
+Subject: [PATCH] expand: Fix up edge splitting for GIMPLE_COND expansion if
+ there are any PHIs [PR120629]
+
+Hi!
+
+My r16-1398 PR120434 ranger during expansion change broke profiled lto
+bootstrap on x86_64-linux, the following testcase is reduced from that.
+
+The problem is during expand_gimple_cond, if we are unlucky that neither
+of edge_true and edge_false point to the next basic block, the code
+effectively attempts to split the false_edge and make the new bb BB_RTL
+with some extra instructions which just arranges to jump.
+It does it by creating a new bb, redirecting the false_edge and then
+creating a new edge from the new bb to the dest.
+Note, we don't have GIMPLE cfg hooks installed anymore and even if we
+would, the 3 calls aren't the same as one split_edge with transformation
+of the new bb into BB_RTL and adding it some BB_HEAD/BB_END. If
+false_edge->dest is BB_RTL or doesn't have PHI nodes (which before my
+patch was always the case because), then this works fine, but with
+PHI nodes on false_edge->dest redirect_edge_succ will remove the false_edge
+from dest->preds (unordered remove which moves into its place the last edge
+in the vector) and the new make_edge will then add the new edge as last
+in the vector. So, unless false_edge is the last edge in the dest->preds
+vector this effectively swaps the last edge in the vector with
+false_edge/its new replacement.
+gimple_split_edge solves this by temporarily clearing phi_nodes on dest
+(not needed when we don't have GIMPLE hooks), then making the new edge
+first and redirecting the old edge (plus restoring phi_nodes on dest).
+That way the redirection replaces the old edge with the new one and
+PHI arguments don't need adjustment. At the cost of temporarily needing
+one more edge in the vector and so if unlucky reallocation.
+Doing it like that is one of the options (i.e. just move the
+make_single_succ_edge call). This patch instead keeps doing what it did
+and just swaps two edges again if needed to restore the PHI behavior
+- remember edge_false->dest_idx first if there are PHI nodes in
+edge_false->dest and afterwards if new edge's dest_idx is different from
+the remembered one, swap the new edge with EDGE_PRED (dest, old_dest_idx).
+That way PHI arguments are maintained properly as well. Without this
+we sometimes just swap PHI arguments.
+
+Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2025-06-12 Jakub Jelinek <jakub@redhat.com>
@@ -9,10 +55,17 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120629#c22
latter with the former last pred edge and their dest_idx members.
* g++.dg/opt/pr120629.C: New test.
+---
+ gcc/cfgexpand.cc | 17 ++++++++-
+ gcc/testsuite/g++.dg/opt/pr120629.C | 53 +++++++++++++++++++++++++++++
+ 2 files changed, 69 insertions(+), 1 deletion(-)
+ create mode 100644 gcc/testsuite/g++.dg/opt/pr120629.C
---- a/gcc/cfgexpand.cc 2025-06-11 19:28:52.462056696 +0200
-+++ g/gcc/cfgexpand.cc 2025-06-12 00:05:27.524152553 +0200
-@@ -3013,6 +3013,9 @@ expand_gimple_cond (basic_block bb, gcon
+diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
+index 49b0b1404200..ce694add0e38 100644
+--- a/gcc/cfgexpand.cc
++++ b/gcc/cfgexpand.cc
+@@ -3013,6 +3013,9 @@ expand_gimple_cond (basic_block bb, gcond *stmt)
new_bb = create_basic_block (NEXT_INSN (last), get_last_insn (), bb);
dest = false_edge->dest;
@@ -22,7 +75,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120629#c22
redirect_edge_succ (false_edge, new_bb);
false_edge->flags |= EDGE_FALLTHRU;
new_bb->count = false_edge->count ();
-@@ -3021,7 +3024,19 @@ expand_gimple_cond (basic_block bb, gcon
+@@ -3021,7 +3024,19 @@ expand_gimple_cond (basic_block bb, gcond *stmt)
if (loop->latch == bb
&& loop->header == dest)
loop->latch = new_bb;
@@ -43,8 +96,11 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120629#c22
if (BARRIER_P (BB_END (new_bb)))
BB_END (new_bb) = PREV_INSN (BB_END (new_bb));
update_bb_for_insn (new_bb);
---- a/gcc/testsuite/g++.dg/opt/pr120629.C 2025-06-12 00:13:02.928211946 +0200
-+++ g/gcc/testsuite/g++.dg/opt/pr120629.C 2025-06-12 00:14:26.008117524 +0200
+diff --git a/gcc/testsuite/g++.dg/opt/pr120629.C b/gcc/testsuite/g++.dg/opt/pr120629.C
+new file mode 100644
+index 000000000000..70a9cddcd3f2
+--- /dev/null
++++ b/gcc/testsuite/g++.dg/opt/pr120629.C
@@ -0,0 +1,53 @@
+// PR middle-end/120629
+// { dg-do run }
@@ -99,3 +155,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120629#c22
+ if (s.b != 0x1234)
+ __builtin_abort ();
+}
+
+base-commit: ccfd4163970b1aef12b40f49b826bb49f3fc6f2b
+--
+2.49.0
+
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-12 5:46 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-12 5:46 UTC (permalink / raw
To: gentoo-commits
commit: 60c5a7be8bfe811a312076812624f30b8ff10cce
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 12 05:46:35 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 12 05:46:35 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=60c5a7be
16.0.0: add fix for profiledbootstrap
Bug: https://gcc.gnu.org/PR120629
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/75_all_PR120629.patch | 101 ++++++++++++++++++++++++++++++++++++
1 file changed, 101 insertions(+)
diff --git a/16.0.0/gentoo/75_all_PR120629.patch b/16.0.0/gentoo/75_all_PR120629.patch
new file mode 100644
index 0000000..77b562a
--- /dev/null
+++ b/16.0.0/gentoo/75_all_PR120629.patch
@@ -0,0 +1,101 @@
+https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120629#c22
+
+2025-06-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/120629
+ * cfgexpand.cc (expand_gimple_cond): If dest bb isn't BB_RTL,
+ has any PHI nodes and false_edge->dest_idx before redirection is
+ different from make_single_succ_edge result's dest_idx, swap the
+ latter with the former last pred edge and their dest_idx members.
+
+ * g++.dg/opt/pr120629.C: New test.
+
+--- a/gcc/cfgexpand.cc 2025-06-11 19:28:52.462056696 +0200
++++ g/gcc/cfgexpand.cc 2025-06-12 00:05:27.524152553 +0200
+@@ -3013,6 +3013,9 @@ expand_gimple_cond (basic_block bb, gcon
+
+ new_bb = create_basic_block (NEXT_INSN (last), get_last_insn (), bb);
+ dest = false_edge->dest;
++ unsigned int dest_idx = 0;
++ if ((dest->flags & BB_RTL) == 0 && phi_nodes (dest))
++ dest_idx = false_edge->dest_idx;
+ redirect_edge_succ (false_edge, new_bb);
+ false_edge->flags |= EDGE_FALLTHRU;
+ new_bb->count = false_edge->count ();
+@@ -3021,7 +3024,19 @@ expand_gimple_cond (basic_block bb, gcon
+ if (loop->latch == bb
+ && loop->header == dest)
+ loop->latch = new_bb;
+- make_single_succ_edge (new_bb, dest, 0);
++ edge e = make_single_succ_edge (new_bb, dest, 0);
++ if ((dest->flags & BB_RTL) == 0
++ && phi_nodes (dest)
++ && e->dest_idx != dest_idx)
++ {
++ /* If there are any PHI nodes on dest, swap the new succ edge
++ with the one moved into false_edge's former position, so that
++ PHI arguments don't need adjustment. */
++ edge e2 = EDGE_PRED (dest, dest_idx);
++ std::swap (e->dest_idx, e2->dest_idx);
++ std::swap (EDGE_PRED (dest, e->dest_idx),
++ EDGE_PRED (dest, e2->dest_idx));
++ }
+ if (BARRIER_P (BB_END (new_bb)))
+ BB_END (new_bb) = PREV_INSN (BB_END (new_bb));
+ update_bb_for_insn (new_bb);
+--- a/gcc/testsuite/g++.dg/opt/pr120629.C 2025-06-12 00:13:02.928211946 +0200
++++ g/gcc/testsuite/g++.dg/opt/pr120629.C 2025-06-12 00:14:26.008117524 +0200
+@@ -0,0 +1,53 @@
++// PR middle-end/120629
++// { dg-do run }
++// { dg-options "-O2 -fprofile-generate -fno-exceptions -fno-rtti" }
++// { dg-require-profiling "-fprofile-generate" }
++
++__attribute__((noipa, noreturn, cold)) void
++foo (const char *, int, const char *)
++{
++ __builtin_abort ();
++}
++
++struct S
++{
++ __attribute__((noipa)) void bar (void *);
++ static const int a = 8;
++ unsigned int b[a + 1];
++};
++
++__attribute__((noipa)) unsigned long
++baz (void *)
++{
++ static int x = 8;
++ return --x;
++}
++
++__attribute__((noipa)) void
++S::bar (void *x)
++{
++ unsigned int c;
++ int k = 0;
++
++ do
++ {
++ ((void) (!(k <= a) ? foo ("foo", 42, __FUNCTION__), 0 : 0));
++ c = b[k++] = baz (x);
++ }
++ while (c);
++ while (k <= a)
++ b[k++] = 0;
++}
++
++int
++main ()
++{
++ struct T { S a; unsigned int b; } s = {};
++ s.b = 0x1234;
++ s.a.bar (0);
++ for (int i = 0; i < 9; ++i)
++ if (s.a.b[i] != (i == 8 ? 0 : 7 - i))
++ __builtin_abort ();
++ if (s.b != 0x1234)
++ __builtin_abort ();
++}
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-11 5:05 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-11 5:05 UTC (permalink / raw
To: gentoo-commits
commit: d986f43364eb7a59fcb4e16caafaba46f9f0fcb8
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 11 05:05:41 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 11 05:05:41 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=d986f433
16.0.0: drop now-upstream patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
...ll_internal-fn-Fix-up-.POPCOUNT-expansion.patch | 61 ----------------------
1 file changed, 61 deletions(-)
diff --git a/16.0.0/gentoo/85_all_internal-fn-Fix-up-.POPCOUNT-expansion.patch b/16.0.0/gentoo/85_all_internal-fn-Fix-up-.POPCOUNT-expansion.patch
deleted file mode 100644
index 3a97e78..0000000
--- a/16.0.0/gentoo/85_all_internal-fn-Fix-up-.POPCOUNT-expansion.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-https://inbox.sourceware.org/gcc-patches/aEikagD%2FQXo+jH5H@tucnak/
-
-From a345b00cf30f9a10dfdb6be93287b4885fea68fd Mon Sep 17 00:00:00 2001
-Message-ID: <a345b00cf30f9a10dfdb6be93287b4885fea68fd.1749611907.git.sam@gentoo.org>
-From: Jakub Jelinek <jakub@redhat.com>
-Date: Tue, 10 Jun 2025 23:32:26 +0200
-Subject: [PATCH] internal-fn: Fix up .POPCOUNT expansion
-
-Hi!
-
-Apparently my ranger during expansion patch broke bootstrap on
-aarch64-linux, while building libsupc++, there is endless recursion
-on __builtin_popcountl (x) == 1 expansion.
-The hack to temporarily replace SSA_NAME_VAR of the lhs which replaced
-the earlier hack to temporarily change the gimple_call_lhs relies on
-the lhs being expanded with EXPAND_WRITE when expanding that ifn call.
-Unfortunately, in two spots I was using expand_normal (lhs) instead
-of expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE) which was used
-everywhere else in internal-fn.cc. This happened to work fine in the
-past, but doesn't anymore. git blame shows it was my patch using
-these incorrect calls.
-
-Fixed thusly, bootstrap/regtests on x86_64-linux, i686-linux and
-aarch64-linux are running, ok for trunk if it passes?
-
-2025-06-10 Jakub Jelinek <jakub@redhat.com>
-
- * internal-fn.cc (expand_POPCOUNT): Use
- expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE) instead of
- expand_normal (lhs).
----
- gcc/internal-fn.cc | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc
-index a0a73fefb906..3f4ac937367d 100644
---- a/gcc/internal-fn.cc
-+++ b/gcc/internal-fn.cc
-@@ -5561,7 +5561,7 @@ expand_POPCOUNT (internal_fn fn, gcall *stmt)
- expand_unary_optab_fn (fn, stmt, popcount_optab);
- rtx_insn *popcount_insns = end_sequence ();
- start_sequence ();
-- rtx plhs = expand_normal (lhs);
-+ rtx plhs = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
- rtx pcmp = emit_store_flag (NULL_RTX, EQ, plhs, const1_rtx, lhsmode, 0, 0);
- if (pcmp == NULL_RTX)
- {
-@@ -5603,7 +5603,7 @@ expand_POPCOUNT (internal_fn fn, gcall *stmt)
- {
- start_sequence ();
- emit_insn (cmp_insns);
-- plhs = expand_normal (lhs);
-+ plhs = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
- if (GET_MODE (cmp) != GET_MODE (plhs))
- cmp = convert_to_mode (GET_MODE (plhs), cmp, 1);
- /* For `<= 1`, we need to produce `2 - cmp` or `cmp ? 1 : 2` as that
-
-base-commit: 2c3ce07c568037a085bfcc438e2e823060980225
---
-2.49.0
-
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-11 3:19 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-11 3:19 UTC (permalink / raw
To: gentoo-commits
commit: eb54dc3c87cb5c11faff6dbd447641d13e6fdaf1
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 11 03:19:03 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 11 03:19:18 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=eb54dc3c
16.0.0: add ranger vs expand fixup patch
Signed-off-by: Sam James <sam <AT> gentoo.org>
...ll_internal-fn-Fix-up-.POPCOUNT-expansion.patch | 61 ++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/16.0.0/gentoo/85_all_internal-fn-Fix-up-.POPCOUNT-expansion.patch b/16.0.0/gentoo/85_all_internal-fn-Fix-up-.POPCOUNT-expansion.patch
new file mode 100644
index 0000000..3a97e78
--- /dev/null
+++ b/16.0.0/gentoo/85_all_internal-fn-Fix-up-.POPCOUNT-expansion.patch
@@ -0,0 +1,61 @@
+https://inbox.sourceware.org/gcc-patches/aEikagD%2FQXo+jH5H@tucnak/
+
+From a345b00cf30f9a10dfdb6be93287b4885fea68fd Mon Sep 17 00:00:00 2001
+Message-ID: <a345b00cf30f9a10dfdb6be93287b4885fea68fd.1749611907.git.sam@gentoo.org>
+From: Jakub Jelinek <jakub@redhat.com>
+Date: Tue, 10 Jun 2025 23:32:26 +0200
+Subject: [PATCH] internal-fn: Fix up .POPCOUNT expansion
+
+Hi!
+
+Apparently my ranger during expansion patch broke bootstrap on
+aarch64-linux, while building libsupc++, there is endless recursion
+on __builtin_popcountl (x) == 1 expansion.
+The hack to temporarily replace SSA_NAME_VAR of the lhs which replaced
+the earlier hack to temporarily change the gimple_call_lhs relies on
+the lhs being expanded with EXPAND_WRITE when expanding that ifn call.
+Unfortunately, in two spots I was using expand_normal (lhs) instead
+of expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE) which was used
+everywhere else in internal-fn.cc. This happened to work fine in the
+past, but doesn't anymore. git blame shows it was my patch using
+these incorrect calls.
+
+Fixed thusly, bootstrap/regtests on x86_64-linux, i686-linux and
+aarch64-linux are running, ok for trunk if it passes?
+
+2025-06-10 Jakub Jelinek <jakub@redhat.com>
+
+ * internal-fn.cc (expand_POPCOUNT): Use
+ expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE) instead of
+ expand_normal (lhs).
+---
+ gcc/internal-fn.cc | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc
+index a0a73fefb906..3f4ac937367d 100644
+--- a/gcc/internal-fn.cc
++++ b/gcc/internal-fn.cc
+@@ -5561,7 +5561,7 @@ expand_POPCOUNT (internal_fn fn, gcall *stmt)
+ expand_unary_optab_fn (fn, stmt, popcount_optab);
+ rtx_insn *popcount_insns = end_sequence ();
+ start_sequence ();
+- rtx plhs = expand_normal (lhs);
++ rtx plhs = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
+ rtx pcmp = emit_store_flag (NULL_RTX, EQ, plhs, const1_rtx, lhsmode, 0, 0);
+ if (pcmp == NULL_RTX)
+ {
+@@ -5603,7 +5603,7 @@ expand_POPCOUNT (internal_fn fn, gcall *stmt)
+ {
+ start_sequence ();
+ emit_insn (cmp_insns);
+- plhs = expand_normal (lhs);
++ plhs = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
+ if (GET_MODE (cmp) != GET_MODE (plhs))
+ cmp = convert_to_mode (GET_MODE (plhs), cmp, 1);
+ /* For `<= 1`, we need to produce `2 - cmp` or `cmp ? 1 : 2` as that
+
+base-commit: 2c3ce07c568037a085bfcc438e2e823060980225
+--
+2.49.0
+
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-06-01 22:39 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-06-01 22:39 UTC (permalink / raw
To: gentoo-commits
commit: 87ed5cf90a314ce99c862b1829203ad3d6f9b5f9
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 1 22:39:28 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun 1 22:39:28 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=87ed5cf9
16.0.0: cut patchset 3
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/README.history | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 189da71..b3cf833 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,4 +1,4 @@
-3 ????
+3 1 June 2025
+ 36_all_no-afdo-testing.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-05-31 18:48 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-05-31 18:48 UTC (permalink / raw
To: gentoo-commits
commit: e4dbf2424f80030489d714272de6c7317bedf5c3
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat May 31 18:47:34 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat May 31 18:47:34 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=e4dbf242
16.0.0: don't run afdo tests
Noticed by zen_deus after an abnormally high load on a machine I was
building GCC on. Seems to have started with 7b76965df10c47616c8f65e1c1134356d635f9ed
which is curious as it doesn't seem to have shown up for me before on
Intel machines, but I'm not so familiar with what it relies on yet.
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/36_all_no-afdo-testing.patch | 13 +++++++++++++
16.0.0/gentoo/README.history | 4 ++++
2 files changed, 17 insertions(+)
diff --git a/16.0.0/gentoo/36_all_no-afdo-testing.patch b/16.0.0/gentoo/36_all_no-afdo-testing.patch
new file mode 100644
index 0000000..9282804
--- /dev/null
+++ b/16.0.0/gentoo/36_all_no-afdo-testing.patch
@@ -0,0 +1,13 @@
+`perf` doesn't seem to work well in sandbox and this isn't so useful
+anyway for packaging testing purposes. These tests seemed to hang.
+--- a/gcc/testsuite/lib/target-supports.exp
++++ b/gcc/testsuite/lib/target-supports.exp
+@@ -799,7 +799,7 @@ proc check_profiling_available { test_what } {
+ }
+ puts $wrapper
+ global srcdir
+- set status [remote_exec host "$wrapper true -v >/dev/null"]
++ set status [remote_exec host "false >/dev/null"]
+ if { [lindex $status 0] != 0 } {
+ verbose "autofdo not supported because perf does not work"
+ return 0
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index a75f6c8..189da71 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+3 ????
+
+ + 36_all_no-afdo-testing.patch
+
2 11 May 2025
- 85_all_PR120080_Revert-gimple-Switch-bit-test-lowering-testcases-for.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-05-11 22:52 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-05-11 22:52 UTC (permalink / raw
To: gentoo-commits
commit: 931f2ec7eafda39ea33684e191c9e2e8b4239fdc
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 22:52:17 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun May 11 22:52:17 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=931f2ec7
16.0.0: cut patchset 2
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/README.history | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index afa3849..a75f6c8 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,4 +1,4 @@
-2 ????
+2 11 May 2025
- 85_all_PR120080_Revert-gimple-Switch-bit-test-lowering-testcases-for.patch
- 86_all_PR120080_Revert-gimple-Don-t-warn-about-using-different-algs-.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-05-10 15:28 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-05-10 15:28 UTC (permalink / raw
To: gentoo-commits
commit: 0f4b833b534f19465c433eabd4599de920bfc48d
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat May 10 15:27:38 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat May 10 15:27:58 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=0f4b833b
16.0.0: drop switch patch merged upstream
Signed-off-by: Sam James <sam <AT> gentoo.org>
...t-assert-that-switch-has-nondefault-cases.patch | 50 ----------------------
16.0.0/gentoo/README.history | 5 ++-
2 files changed, 4 insertions(+), 51 deletions(-)
diff --git a/16.0.0/gentoo/85_all_gimple-Don-t-assert-that-switch-has-nondefault-cases.patch b/16.0.0/gentoo/85_all_gimple-Don-t-assert-that-switch-has-nondefault-cases.patch
deleted file mode 100644
index 1d2eb1f..0000000
--- a/16.0.0/gentoo/85_all_gimple-Don-t-assert-that-switch-has-nondefault-cases.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-From bd8ccb7e0eefaac80028b4ffd16d09b91f3fe5f2 Mon Sep 17 00:00:00 2001
-Message-ID: <bd8ccb7e0eefaac80028b4ffd16d09b91f3fe5f2.1746833337.git.sam@gentoo.org>
-From: Filip Kastl <fkastl@suse.cz>
-Date: Fri, 9 May 2025 16:04:25 +0200
-Subject: [PATCH] gimple: Don't assert that switch has nondefault cases during
- lowering [PR120080]
-
-I have mistakenly assumed that switch lowering cannot encounter a switch
-with zero clusters. This patch removes the relevant assert and instead
-gives up bit-test lowering when this happens.
-
- PR tree-optimization/120080
-
-gcc/ChangeLog:
-
- * tree-switch-conversion.cc (bit_test_cluster::find_bit_tests):
- Replace assert with return.
-
-Signed-off-by: Filip Kastl <fkastl@suse.cz>
----
- gcc/tree-switch-conversion.cc | 8 +++++---
- 1 file changed, 5 insertions(+), 3 deletions(-)
-
-diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
-index dea217a01efb..bd4de966892c 100644
---- a/gcc/tree-switch-conversion.cc
-+++ b/gcc/tree-switch-conversion.cc
-@@ -1793,12 +1793,14 @@ bit_test_cluster::find_bit_tests (vec<cluster *> &clusters, int max_c)
- end up with as few clusters as possible. */
-
- unsigned l = clusters.length ();
-- auto_vec<min_cluster_item> min;
-- min.reserve (l + 1);
-
-- gcc_checking_assert (l > 0);
-+ if (l == 0)
-+ return clusters.copy ();
- gcc_checking_assert (l <= INT_MAX);
-
-+ auto_vec<min_cluster_item> min;
-+ min.reserve (l + 1);
-+
- int bits_in_word = GET_MODE_BITSIZE (word_mode);
-
- /* First phase: Compute the minimum number of clusters for each prefix of the
-
-base-commit: a470433732e77ae29a717cf79049ceeea3cbe979
---
-2.49.0
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index 4b20dc5..afa3849 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,6 +1,9 @@
2 ????
- + 85_all_gimple-Don-t-assert-that-switch-has-nondefault-cases.patch
+ - 85_all_PR120080_Revert-gimple-Switch-bit-test-lowering-testcases-for.patch
+ - 86_all_PR120080_Revert-gimple-Don-t-warn-about-using-different-algs-.patch
+ - 87_all_PR120080-Revert-gimple-Make-bit-test-switch-lowering-more-pow.patch
+ - 88_all_PR120080-Revert-gimple-Merge-slow-and-fast-bit-test-switch-lo.patch
1 5 May 2025
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-05-09 23:29 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-05-09 23:29 UTC (permalink / raw
To: gentoo-commits
commit: 5c57395235761f4b24fc2772879043a5f1d0156e
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri May 9 23:29:28 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 9 23:29:28 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=5c573952
16.0.0: drop switch reverts, use patch instead
Signed-off-by: Sam James <sam <AT> gentoo.org>
...le-Switch-bit-test-lowering-testcases-for.patch | 141 -----------
...t-assert-that-switch-has-nondefault-cases.patch | 50 ++++
...le-Don-t-warn-about-using-different-algs-.patch | 35 ---
...le-Make-bit-test-switch-lowering-more-pow.patch | 258 ---------------------
...le-Merge-slow-and-fast-bit-test-switch-lo.patch | 157 -------------
16.0.0/gentoo/README.history | 4 +
6 files changed, 54 insertions(+), 591 deletions(-)
diff --git a/16.0.0/gentoo/85_all_PR120080_Revert-gimple-Switch-bit-test-lowering-testcases-for.patch b/16.0.0/gentoo/85_all_PR120080_Revert-gimple-Switch-bit-test-lowering-testcases-for.patch
deleted file mode 100644
index a6df8d9..0000000
--- a/16.0.0/gentoo/85_all_PR120080_Revert-gimple-Switch-bit-test-lowering-testcases-for.patch
+++ /dev/null
@@ -1,141 +0,0 @@
-From 4c57a4d3c280b249649495e032682f5eea41752b Mon Sep 17 00:00:00 2001
-Message-ID: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
-From: Sam James <sam@gentoo.org>
-Date: Mon, 5 May 2025 14:02:03 +0100
-Subject: [PATCH 1/4] Revert "gimple: Switch bit-test lowering testcases for
- the more powerful alg"
-
-This reverts commit 8444c4cc7648f4396e2a3726677f909438e92c80.
----
- gcc/testsuite/gcc.dg/tree-ssa/switch-5.c | 60 ------------------------
- gcc/testsuite/gcc.dg/tree-ssa/switch-6.c | 51 --------------------
- 2 files changed, 111 deletions(-)
- delete mode 100644 gcc/testsuite/gcc.dg/tree-ssa/switch-5.c
- delete mode 100644 gcc/testsuite/gcc.dg/tree-ssa/switch-6.c
-
-diff --git a/gcc/testsuite/gcc.dg/tree-ssa/switch-5.c b/gcc/testsuite/gcc.dg/tree-ssa/switch-5.c
-deleted file mode 100644
-index b05742cf153c..000000000000
---- a/gcc/testsuite/gcc.dg/tree-ssa/switch-5.c
-+++ /dev/null
-@@ -1,60 +0,0 @@
--/* { dg-do compile { target { { x86_64-*-* aarch64-*-* ia64-*-* powerpc64-*-* } && lp64 } } } */
--/* { dg-options "-O2 -fdump-tree-switchlower1" } */
--
--int f0();
--int f1();
--int f2();
--int f3();
--int f4();
--
--int foo(int a)
--{
-- switch (a)
-- {
-- case 0:
-- case 2:
-- case 4:
-- case 6:
-- return f0();
-- case 8:
-- return f1();
-- case 10:
-- case 14:
-- case 16:
-- case 18:
-- return f2();
-- case 12:
-- return f3();
-- case 20:
-- return f4();
-- }
-- return -1;
--}
--
--/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: BT:0-8 BT:10-20" "switchlower1" } } */
--
--int bar(int a)
--{
-- switch (a)
-- {
-- case 20:
-- case 18:
-- case 16:
-- case 14:
-- return f0();
-- case 12:
-- return f1();
-- case 10:
-- case 6:
-- case 4:
-- case 2:
-- return f2();
-- case 8:
-- return f3();
-- case 0:
-- return f4();
-- }
-- return -1;
--}
--
--/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: BT:0-10 BT:12-20" "switchlower1" } } */
-diff --git a/gcc/testsuite/gcc.dg/tree-ssa/switch-6.c b/gcc/testsuite/gcc.dg/tree-ssa/switch-6.c
-deleted file mode 100644
-index bbbc87462c40..000000000000
---- a/gcc/testsuite/gcc.dg/tree-ssa/switch-6.c
-+++ /dev/null
-@@ -1,51 +0,0 @@
--/* { dg-do compile { target { { x86_64-*-* aarch64-*-* ia64-*-* powerpc64-*-* } && lp64 } } } */
--/* { dg-options "-O2 -fdump-tree-switchlower1 -fno-jump-tables" } */
--
--/* Test that bit-test switch lowering can create cluster of size 64 (there was
-- an of-by-one error causing it to only do 63 before). */
--
--int f();
--
--int foo(int a)
--{
-- switch (a)
-- {
-- case 0:
-- case 3:
-- case 5:
-- case 7:
-- case 9:
-- case 11:
-- case 13:
-- case 15:
-- case 17:
-- case 19:
-- case 21:
-- case 23:
-- case 25:
-- case 27:
-- case 29:
-- case 31:
-- case 33:
-- case 35:
-- case 37:
-- case 39:
-- case 41:
-- case 43:
-- case 45:
-- case 47:
-- case 49:
-- case 51:
-- case 53:
-- case 55:
-- case 57:
-- case 59:
-- case 61:
-- case 63:
-- return f();
-- default:
-- return -1;
-- }
--}
--
--/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: BT:0-63" "switchlower1" } } */
---
-2.49.0
-
diff --git a/16.0.0/gentoo/85_all_gimple-Don-t-assert-that-switch-has-nondefault-cases.patch b/16.0.0/gentoo/85_all_gimple-Don-t-assert-that-switch-has-nondefault-cases.patch
new file mode 100644
index 0000000..1d2eb1f
--- /dev/null
+++ b/16.0.0/gentoo/85_all_gimple-Don-t-assert-that-switch-has-nondefault-cases.patch
@@ -0,0 +1,50 @@
+From bd8ccb7e0eefaac80028b4ffd16d09b91f3fe5f2 Mon Sep 17 00:00:00 2001
+Message-ID: <bd8ccb7e0eefaac80028b4ffd16d09b91f3fe5f2.1746833337.git.sam@gentoo.org>
+From: Filip Kastl <fkastl@suse.cz>
+Date: Fri, 9 May 2025 16:04:25 +0200
+Subject: [PATCH] gimple: Don't assert that switch has nondefault cases during
+ lowering [PR120080]
+
+I have mistakenly assumed that switch lowering cannot encounter a switch
+with zero clusters. This patch removes the relevant assert and instead
+gives up bit-test lowering when this happens.
+
+ PR tree-optimization/120080
+
+gcc/ChangeLog:
+
+ * tree-switch-conversion.cc (bit_test_cluster::find_bit_tests):
+ Replace assert with return.
+
+Signed-off-by: Filip Kastl <fkastl@suse.cz>
+---
+ gcc/tree-switch-conversion.cc | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
+index dea217a01efb..bd4de966892c 100644
+--- a/gcc/tree-switch-conversion.cc
++++ b/gcc/tree-switch-conversion.cc
+@@ -1793,12 +1793,14 @@ bit_test_cluster::find_bit_tests (vec<cluster *> &clusters, int max_c)
+ end up with as few clusters as possible. */
+
+ unsigned l = clusters.length ();
+- auto_vec<min_cluster_item> min;
+- min.reserve (l + 1);
+
+- gcc_checking_assert (l > 0);
++ if (l == 0)
++ return clusters.copy ();
+ gcc_checking_assert (l <= INT_MAX);
+
++ auto_vec<min_cluster_item> min;
++ min.reserve (l + 1);
++
+ int bits_in_word = GET_MODE_BITSIZE (word_mode);
+
+ /* First phase: Compute the minimum number of clusters for each prefix of the
+
+base-commit: a470433732e77ae29a717cf79049ceeea3cbe979
+--
+2.49.0
+
diff --git a/16.0.0/gentoo/86_all_PR120080_Revert-gimple-Don-t-warn-about-using-different-algs-.patch b/16.0.0/gentoo/86_all_PR120080_Revert-gimple-Don-t-warn-about-using-different-algs-.patch
deleted file mode 100644
index eed3cdb..0000000
--- a/16.0.0/gentoo/86_all_PR120080_Revert-gimple-Don-t-warn-about-using-different-algs-.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From e11fc43562a4aaa15b757d5728dd5a514e128bee Mon Sep 17 00:00:00 2001
-Message-ID: <e11fc43562a4aaa15b757d5728dd5a514e128bee.1746450157.git.sam@gentoo.org>
-In-Reply-To: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
-References: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
-From: Sam James <sam@gentoo.org>
-Date: Mon, 5 May 2025 14:02:09 +0100
-Subject: [PATCH 2/4] Revert "gimple: Don't warn about using different algs for
- big switch lowering [PR117091]"
-
-This reverts commit c14560907a9586ad405f26ab937881eb08f39497.
----
- gcc/tree-switch-conversion.cc | 7 +++++++
- 1 file changed, 7 insertions(+)
-
-diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
-index dea217a01efb..4f0be8c43f07 100644
---- a/gcc/tree-switch-conversion.cc
-+++ b/gcc/tree-switch-conversion.cc
-@@ -2257,6 +2257,13 @@ switch_decision_tree::analyze_switch_statement ()
-
- reset_out_edges_aux (m_switch);
-
-+ if (l > (unsigned) param_switch_lower_slow_alg_max_cases)
-+ warning_at (gimple_location (m_switch), OPT_Wdisabled_optimization,
-+ "Using faster switch lowering algorithms. "
-+ "Number of switch cases (%d) exceeds "
-+ "%<--param=switch-lower-slow-alg-max-cases=%d%> limit.",
-+ l, param_switch_lower_slow_alg_max_cases);
-+
- /* Find bit-test clusters. */
- vec<cluster *> output = bit_test_cluster::find_bit_tests (clusters, max_c);
-
---
-2.49.0
-
diff --git a/16.0.0/gentoo/87_all_PR120080-Revert-gimple-Make-bit-test-switch-lowering-more-pow.patch b/16.0.0/gentoo/87_all_PR120080-Revert-gimple-Make-bit-test-switch-lowering-more-pow.patch
deleted file mode 100644
index bb246ad..0000000
--- a/16.0.0/gentoo/87_all_PR120080-Revert-gimple-Make-bit-test-switch-lowering-more-pow.patch
+++ /dev/null
@@ -1,258 +0,0 @@
-From 22f45f552e6dfe51256f4f1c423a51b831ab46d8 Mon Sep 17 00:00:00 2001
-Message-ID: <22f45f552e6dfe51256f4f1c423a51b831ab46d8.1746450157.git.sam@gentoo.org>
-In-Reply-To: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
-References: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
-From: Sam James <sam@gentoo.org>
-Date: Mon, 5 May 2025 14:02:17 +0100
-Subject: [PATCH 3/4] Revert "gimple: Make bit-test switch lowering more
- powerful"
-
-This reverts commit 1381a5114788a2e9234ff54e0cd7a3c810f0d02d.
----
- gcc/tree-switch-conversion.cc | 153 +++++++++++++++++++---------------
- gcc/tree-switch-conversion.h | 10 +++
- 2 files changed, 96 insertions(+), 67 deletions(-)
-
-diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
-index 4f0be8c43f07..a70274b03372 100644
---- a/gcc/tree-switch-conversion.cc
-+++ b/gcc/tree-switch-conversion.cc
-@@ -1783,98 +1783,58 @@ bit_test_cluster::find_bit_tests (vec<cluster *> &clusters, int max_c)
- if (!is_enabled () || max_c == 1)
- return clusters.copy ();
-
-- /* Dynamic programming algorithm.
--
-- In: List of simple clusters
-- Out: List of simple clusters and bit test clusters such that each bit test
-- cluster can_be_handled() and is_beneficial()
--
-- Tries to merge consecutive clusters into bigger (bit test) ones. Tries to
-- end up with as few clusters as possible. */
--
- unsigned l = clusters.length ();
- auto_vec<min_cluster_item> min;
- min.reserve (l + 1);
-
-- gcc_checking_assert (l > 0);
-- gcc_checking_assert (l <= INT_MAX);
--
-- int bits_in_word = GET_MODE_BITSIZE (word_mode);
-+ min.quick_push (min_cluster_item (0, 0, 0));
-
-- /* First phase: Compute the minimum number of clusters for each prefix of the
-- input list incrementally
-+ unsigned bits_in_word = GET_MODE_BITSIZE (word_mode);
-
-- min[i] = (count, j, _) means that the prefix ending with the (i-1)-th
-- element can be made to contain as few as count clusters and that in such
-- clustering the last cluster is made up of input clusters [j, i-1]
-- (inclusive). */
-- min.quick_push (min_cluster_item (0, 0, INT_MAX));
-- min.quick_push (min_cluster_item (1, 0, INT_MAX));
-- for (int i = 2; i <= (int) l; i++)
-+ for (unsigned i = 1; i <= l; i++)
- {
-- auto_vec<unsigned, m_max_case_bit_tests> unique_labels;
-+ /* Set minimal # of clusters with i-th item to infinite. */
-+ min.quick_push (min_cluster_item (INT_MAX, INT_MAX, INT_MAX));
-
- /* Since each cluster contains at least one case number and one bit test
- cluster can cover at most bits_in_word case numbers, we don't need to
- look farther than bits_in_word clusters back. */
-- for (int j = i - 1; j >= 0 && j >= i - bits_in_word; j--)
-+ unsigned j;
-+ if (i - 1 >= bits_in_word)
-+ j = i - 1 - bits_in_word;
-+ else
-+ j = 0;
-+ for (; j < i; j++)
- {
-- /* Consider creating a bit test cluster from input clusters [j, i-1]
-- (inclusive) */
--
-- simple_cluster *sc = static_cast<simple_cluster *> (clusters[j]);
-- unsigned label = sc->m_case_bb->index;
-- if (!unique_labels.contains (label))
-- {
-- if (unique_labels.length () >= m_max_case_bit_tests)
-- /* is_beneficial() will be false for this and the following
-- iterations. */
-- break;
-- unique_labels.quick_push (label);
-- }
--
-- unsigned new_count = min[j].m_count + 1;
--
-- if (j == i - 1)
-- {
-- min.quick_push (min_cluster_item (new_count, j, INT_MAX));
-- continue;
-- }
--
-- unsigned HOST_WIDE_INT range
-- = get_range (clusters[j]->get_low (), clusters[i-1]->get_high ());
-- if (new_count < min[i].m_count
-- && can_be_handled (range, unique_labels.length ())
-- && is_beneficial (i - j, unique_labels.length ()))
-- min[i] = min_cluster_item (new_count, j, INT_MAX);
-+ if (min[j].m_count + 1 < min[i].m_count
-+ && can_be_handled (clusters, j, i - 1))
-+ min[i] = min_cluster_item (min[j].m_count + 1, j, INT_MAX);
- }
-+
-+ gcc_checking_assert (min[i].m_count != INT_MAX);
- }
-
-+ /* No result. */
- if (min[l].m_count == l)
-- /* No bit test clustering opportunities. */
- return clusters.copy ();
-
- vec<cluster *> output;
- output.create (4);
-
-- /* Second phase: Find and build the bit test clusters by traversing min
-- array backwards. */
-+ /* Find and build the clusters. */
- for (unsigned end = l;;)
- {
-- unsigned start = min[end].m_start;
-- gcc_checking_assert (start < end);
--
-- /* This cluster will be made out of input clusters [start, end - 1]. */
-+ int start = min[end].m_start;
-
-- if (start == end - 1)
-- /* Let the cluster be a simple cluster. */
-- output.safe_push (clusters[start]);
-- else
-+ if (is_beneficial (clusters, start, end - 1))
- {
-- bool entire = start == 0 && end == l;
-+ bool entire = start == 0 && end == clusters.length ();
- output.safe_push (new bit_test_cluster (clusters, start, end - 1,
- entire));
- }
-+ else
-+ for (int i = end - 1; i >= start; i--)
-+ output.safe_push (clusters[i]);
-
- end = start;
-
-@@ -1897,25 +1857,84 @@ bit_test_cluster::can_be_handled (unsigned HOST_WIDE_INT range,
- if (range == 0)
- return false;
-
-- if (range > GET_MODE_BITSIZE (word_mode))
-+ if (range >= GET_MODE_BITSIZE (word_mode))
- return false;
-
- return uniq <= m_max_case_bit_tests;
- }
-
-+/* Return true when cluster starting at START and ending at END (inclusive)
-+ can build a bit test. */
-+
-+bool
-+bit_test_cluster::can_be_handled (const vec<cluster *> &clusters,
-+ unsigned start, unsigned end)
-+{
-+ auto_vec<int, m_max_case_bit_tests> dest_bbs;
-+ /* For algorithm correctness, bit test for a single case must return
-+ true. We bail out in is_beneficial if it's called just for
-+ a single case. */
-+ if (start == end)
-+ return true;
-+
-+ unsigned HOST_WIDE_INT range = get_range (clusters[start]->get_low (),
-+ clusters[end]->get_high ());
-+
-+ /* Make a guess first. */
-+ if (!can_be_handled (range, m_max_case_bit_tests))
-+ return false;
-+
-+ for (unsigned i = start; i <= end; i++)
-+ {
-+ simple_cluster *sc = static_cast<simple_cluster *> (clusters[i]);
-+ /* m_max_case_bit_tests is very small integer, thus the operation
-+ is constant. */
-+ if (!dest_bbs.contains (sc->m_case_bb->index))
-+ {
-+ if (dest_bbs.length () >= m_max_case_bit_tests)
-+ return false;
-+ dest_bbs.quick_push (sc->m_case_bb->index);
-+ }
-+ }
-+
-+ return true;
-+}
-+
- /* Return true when COUNT of cases of UNIQ labels is beneficial for bit test
- transformation. */
-
- bool
- bit_test_cluster::is_beneficial (unsigned count, unsigned uniq)
- {
-- /* NOTE: When modifying this, keep in mind the value of
-- m_max_case_bit_tests. */
- return (((uniq == 1 && count >= 3)
- || (uniq == 2 && count >= 5)
- || (uniq == 3 && count >= 6)));
- }
-
-+/* Return true if cluster starting at START and ending at END (inclusive)
-+ is profitable transformation. */
-+
-+bool
-+bit_test_cluster::is_beneficial (const vec<cluster *> &clusters,
-+ unsigned start, unsigned end)
-+{
-+ /* Single case bail out. */
-+ if (start == end)
-+ return false;
-+
-+ auto_bitmap dest_bbs;
-+
-+ for (unsigned i = start; i <= end; i++)
-+ {
-+ simple_cluster *sc = static_cast<simple_cluster *> (clusters[i]);
-+ bitmap_set_bit (dest_bbs, sc->m_case_bb->index);
-+ }
-+
-+ unsigned uniq = bitmap_count_bits (dest_bbs);
-+ unsigned count = end - start + 1;
-+ return is_beneficial (count, uniq);
-+}
-+
- /* Comparison function for qsort to order bit tests by decreasing
- probability of execution. */
-
-diff --git a/gcc/tree-switch-conversion.h b/gcc/tree-switch-conversion.h
-index b2b6ddc731fb..2ed7e1c7efc1 100644
---- a/gcc/tree-switch-conversion.h
-+++ b/gcc/tree-switch-conversion.h
-@@ -423,10 +423,20 @@ public:
- can build a bit test. */
- static bool can_be_handled (unsigned HOST_WIDE_INT range, unsigned uniq);
-
-+ /* Return true when cluster starting at START and ending at END (inclusive)
-+ can build a bit test. */
-+ static bool can_be_handled (const vec<cluster *> &clusters, unsigned start,
-+ unsigned end);
-+
- /* Return true when COUNT of cases of UNIQ labels is beneficial for bit test
- transformation. */
- static bool is_beneficial (unsigned count, unsigned uniq);
-
-+ /* Return true if cluster starting at START and ending at END (inclusive)
-+ is profitable transformation. */
-+ static bool is_beneficial (const vec<cluster *> &clusters, unsigned start,
-+ unsigned end);
-+
- /* Split the basic block at the statement pointed to by GSIP, and insert
- a branch to the target basic block of E_TRUE conditional on tree
- expression COND.
---
-2.49.0
-
diff --git a/16.0.0/gentoo/88_all_PR120080-Revert-gimple-Merge-slow-and-fast-bit-test-switch-lo.patch b/16.0.0/gentoo/88_all_PR120080-Revert-gimple-Merge-slow-and-fast-bit-test-switch-lo.patch
deleted file mode 100644
index ce952f0..0000000
--- a/16.0.0/gentoo/88_all_PR120080-Revert-gimple-Merge-slow-and-fast-bit-test-switch-lo.patch
+++ /dev/null
@@ -1,157 +0,0 @@
-From 3827851b3d589780a9dc072962a266bae18272ad Mon Sep 17 00:00:00 2001
-Message-ID: <3827851b3d589780a9dc072962a266bae18272ad.1746450157.git.sam@gentoo.org>
-In-Reply-To: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
-References: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
-From: Sam James <sam@gentoo.org>
-Date: Mon, 5 May 2025 14:02:25 +0100
-Subject: [PATCH 4/4] Revert "gimple: Merge slow and fast bit-test switch
- lowering [PR117091]"
-
-This reverts commit 5274db0c9b8c0e2d2879b237eb2ab576543b6c37.
----
- gcc/tree-switch-conversion.cc | 107 ++++++++++++++++++++++++++++------
- 1 file changed, 90 insertions(+), 17 deletions(-)
-
-diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
-index a70274b03372..39a8a893edde 100644
---- a/gcc/tree-switch-conversion.cc
-+++ b/gcc/tree-switch-conversion.cc
-@@ -1773,38 +1773,92 @@ jump_table_cluster::is_beneficial (const vec<cluster *> &,
- return end - start + 1 >= case_values_threshold ();
- }
-
--/* Find bit tests of given CLUSTERS, where all members of the vector
-- are of type simple_cluster. MAX_C is the approx max number of cases per
-- label. New clusters are returned. */
-+/* Find bit tests of given CLUSTERS, where all members of the vector are of
-+ type simple_cluster. Use a fast algorithm that might not find the optimal
-+ solution (minimal number of clusters on the output). New clusters are
-+ returned.
-+
-+ You should call find_bit_tests () instead of calling this function
-+ directly. */
-
- vec<cluster *>
--bit_test_cluster::find_bit_tests (vec<cluster *> &clusters, int max_c)
-+bit_test_cluster::find_bit_tests_fast (vec<cluster *> &clusters)
- {
-- if (!is_enabled () || max_c == 1)
-- return clusters.copy ();
-+ unsigned l = clusters.length ();
-+ vec<cluster *> output;
-+
-+ output.create (l);
-+
-+ /* Look at sliding BITS_PER_WORD sized windows in the switch value space
-+ and determine if they are suitable for a bit test cluster. Worst case
-+ this can examine every value BITS_PER_WORD-1 times. */
-+ unsigned k;
-+ for (unsigned i = 0; i < l; i += k)
-+ {
-+ hash_set<basic_block> targets;
-+ cluster *start_cluster = clusters[i];
-+
-+ /* Find the biggest k such that clusters i to i+k-1 can be turned into a
-+ one big bit test cluster. */
-+ k = 0;
-+ while (i + k < l)
-+ {
-+ cluster *end_cluster = clusters[i + k];
-+
-+ /* Does value range fit into the BITS_PER_WORD window? */
-+ HOST_WIDE_INT w = cluster::get_range (start_cluster->get_low (),
-+ end_cluster->get_high ());
-+ if (w == 0 || w > BITS_PER_WORD)
-+ break;
-+
-+ /* Check for max # of targets. */
-+ if (targets.elements () == m_max_case_bit_tests
-+ && !targets.contains (end_cluster->m_case_bb))
-+ break;
-+
-+ targets.add (end_cluster->m_case_bb);
-+ k++;
-+ }
-+
-+ if (is_beneficial (k, targets.elements ()))
-+ {
-+ output.safe_push (new bit_test_cluster (clusters, i, i + k - 1,
-+ i == 0 && k == l));
-+ }
-+ else
-+ {
-+ output.safe_push (clusters[i]);
-+ /* ??? Might be able to skip more. */
-+ k = 1;
-+ }
-+ }
-
-+ return output;
-+}
-+
-+/* Find bit tests of given CLUSTERS, where all members of the vector
-+ are of type simple_cluster. Use a slow (quadratic) algorithm that always
-+ finds the optimal solution (minimal number of clusters on the output). New
-+ clusters are returned.
-+
-+ You should call find_bit_tests () instead of calling this function
-+ directly. */
-+
-+vec<cluster *>
-+bit_test_cluster::find_bit_tests_slow (vec<cluster *> &clusters)
-+{
- unsigned l = clusters.length ();
- auto_vec<min_cluster_item> min;
- min.reserve (l + 1);
-
- min.quick_push (min_cluster_item (0, 0, 0));
-
-- unsigned bits_in_word = GET_MODE_BITSIZE (word_mode);
--
- for (unsigned i = 1; i <= l; i++)
- {
- /* Set minimal # of clusters with i-th item to infinite. */
- min.quick_push (min_cluster_item (INT_MAX, INT_MAX, INT_MAX));
-
-- /* Since each cluster contains at least one case number and one bit test
-- cluster can cover at most bits_in_word case numbers, we don't need to
-- look farther than bits_in_word clusters back. */
-- unsigned j;
-- if (i - 1 >= bits_in_word)
-- j = i - 1 - bits_in_word;
-- else
-- j = 0;
-- for (; j < i; j++)
-+ for (unsigned j = 0; j < i; j++)
- {
- if (min[j].m_count + 1 < min[i].m_count
- && can_be_handled (clusters, j, i - 1))
-@@ -1846,6 +1900,25 @@ bit_test_cluster::find_bit_tests (vec<cluster *> &clusters, int max_c)
- return output;
- }
-
-+/* Find bit tests of given CLUSTERS, where all members of the vector
-+ are of type simple_cluster. MAX_C is the approx max number of cases per
-+ label. New clusters are returned. */
-+
-+vec<cluster *>
-+bit_test_cluster::find_bit_tests (vec<cluster *> &clusters, int max_c)
-+{
-+ if (!is_enabled () || max_c == 1)
-+ return clusters.copy ();
-+
-+ unsigned l = clusters.length ();
-+
-+ /* Note: l + 1 is the number of cases of the switch. */
-+ if (l + 1 > (unsigned) param_switch_lower_slow_alg_max_cases)
-+ return find_bit_tests_fast (clusters);
-+ else
-+ return find_bit_tests_slow (clusters);
-+}
-+
- /* Return true when RANGE of case values with UNIQ labels
- can build a bit test. */
-
---
-2.49.0
-
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index df22676..4b20dc5 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -1,3 +1,7 @@
+2 ????
+
+ + 85_all_gimple-Don-t-assert-that-switch-has-nondefault-cases.patch
+
1 5 May 2025
+ 01_all_default-fortify-source.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-05-05 14:39 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-05-05 14:39 UTC (permalink / raw
To: gentoo-commits
commit: b8f2e705015c5742daa6f0c8ffba4574b145cc54
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon May 5 14:36:10 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon May 5 14:36:10 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=b8f2e705
16.0.0: cut first patchset
... to get out the switch reverts.
Signed-off-by: Sam James <sam <AT> gentoo.org>
16.0.0/gentoo/README.history | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/16.0.0/gentoo/README.history b/16.0.0/gentoo/README.history
index e69de29..df22676 100644
--- a/16.0.0/gentoo/README.history
+++ b/16.0.0/gentoo/README.history
@@ -0,0 +1,33 @@
+1 5 May 2025
+
+ + 01_all_default-fortify-source.patch
+ + 02_all_default-warn-format-security.patch
+ + 03_all_default-warn-trampolines.patch
+ + 04_all_nossp-on-nostdlib.patch
+ + 05_all_alpha-mieee-default.patch
+ + 06_all_ia64_note.GNU-stack.patch
+ + 08_all_libiberty-pic.patch
+ + 09_all_esysroot.patch
+ + 10_all_sh-drop-sysroot-suffix.patch
+ + 11_all_ia64-TEXTREL.patch
+ + 14_all_respect-build-cxxflags.patch
+ + 15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch
+ + 20_all_libstdcxx-no-vtv.patch
+ + 22_all_default_ssp-buffer-size.patch
+ + 23_all_DEF_GENTOO_ZNOW-z-now.patch
+ + 24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
+ + 26_all_enable-cet.patch
+ + 28_all_drop_CFLAGS_sed.patch
+ + 29_all_msgfmt-libstdc++-link.patch
+ + 30_all_tar_libstdc++-link.patch
+ + 31_all_testsuite-fortran-pass-Wcomplain-wrong-lang-where-ap.patch
+ + 32_all_time64.patch
+ + 33_all_PR80677-cross-limits.patch
+ + 34_all_time64_ssemath.patch
+ + 35_all_checking-gc-use-heuristics.patch
+ + 76_all_PR117854-config-nvptx-fix-bashisms-with-gen-copyright.sh-use.patch
+ + 84_all_PR116975-GDCFLAGS.patch
+ + 85_all_PR120080_Revert-gimple-Switch-bit-test-lowering-testcases-for.patch
+ + 86_all_PR120080_Revert-gimple-Don-t-warn-about-using-different-algs-.patch
+ + 87_all_PR120080-Revert-gimple-Make-bit-test-switch-lowering-more-pow.patch
+ + 88_all_PR120080-Revert-gimple-Merge-slow-and-fast-bit-test-switch-lo.patch
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/
@ 2025-05-05 13:05 Sam James
0 siblings, 0 replies; 88+ messages in thread
From: Sam James @ 2025-05-05 13:05 UTC (permalink / raw
To: gentoo-commits
commit: b6ea2bc8cb10601f270dfd82a9d1878862ebeffa
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon May 5 13:04:48 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon May 5 13:04:48 2025 +0000
URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=b6ea2bc8
16.0.0: revert switch conversion patches
Breaks building LLVM and workarounds aren't feasible (PR120115, PR120116).
Bug: https://gcc.gnu.org/PR120080
Bug: https://gcc.gnu.org/PR120115
Bug: https://gcc.gnu.org/PR120116
Signed-off-by: Sam James <sam <AT> gentoo.org>
...le-Switch-bit-test-lowering-testcases-for.patch | 141 +++++++++++
...le-Don-t-warn-about-using-different-algs-.patch | 35 +++
...le-Make-bit-test-switch-lowering-more-pow.patch | 258 +++++++++++++++++++++
...le-Merge-slow-and-fast-bit-test-switch-lo.patch | 157 +++++++++++++
4 files changed, 591 insertions(+)
diff --git a/16.0.0/gentoo/85_all_PR120080_Revert-gimple-Switch-bit-test-lowering-testcases-for.patch b/16.0.0/gentoo/85_all_PR120080_Revert-gimple-Switch-bit-test-lowering-testcases-for.patch
new file mode 100644
index 0000000..a6df8d9
--- /dev/null
+++ b/16.0.0/gentoo/85_all_PR120080_Revert-gimple-Switch-bit-test-lowering-testcases-for.patch
@@ -0,0 +1,141 @@
+From 4c57a4d3c280b249649495e032682f5eea41752b Mon Sep 17 00:00:00 2001
+Message-ID: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Mon, 5 May 2025 14:02:03 +0100
+Subject: [PATCH 1/4] Revert "gimple: Switch bit-test lowering testcases for
+ the more powerful alg"
+
+This reverts commit 8444c4cc7648f4396e2a3726677f909438e92c80.
+---
+ gcc/testsuite/gcc.dg/tree-ssa/switch-5.c | 60 ------------------------
+ gcc/testsuite/gcc.dg/tree-ssa/switch-6.c | 51 --------------------
+ 2 files changed, 111 deletions(-)
+ delete mode 100644 gcc/testsuite/gcc.dg/tree-ssa/switch-5.c
+ delete mode 100644 gcc/testsuite/gcc.dg/tree-ssa/switch-6.c
+
+diff --git a/gcc/testsuite/gcc.dg/tree-ssa/switch-5.c b/gcc/testsuite/gcc.dg/tree-ssa/switch-5.c
+deleted file mode 100644
+index b05742cf153c..000000000000
+--- a/gcc/testsuite/gcc.dg/tree-ssa/switch-5.c
++++ /dev/null
+@@ -1,60 +0,0 @@
+-/* { dg-do compile { target { { x86_64-*-* aarch64-*-* ia64-*-* powerpc64-*-* } && lp64 } } } */
+-/* { dg-options "-O2 -fdump-tree-switchlower1" } */
+-
+-int f0();
+-int f1();
+-int f2();
+-int f3();
+-int f4();
+-
+-int foo(int a)
+-{
+- switch (a)
+- {
+- case 0:
+- case 2:
+- case 4:
+- case 6:
+- return f0();
+- case 8:
+- return f1();
+- case 10:
+- case 14:
+- case 16:
+- case 18:
+- return f2();
+- case 12:
+- return f3();
+- case 20:
+- return f4();
+- }
+- return -1;
+-}
+-
+-/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: BT:0-8 BT:10-20" "switchlower1" } } */
+-
+-int bar(int a)
+-{
+- switch (a)
+- {
+- case 20:
+- case 18:
+- case 16:
+- case 14:
+- return f0();
+- case 12:
+- return f1();
+- case 10:
+- case 6:
+- case 4:
+- case 2:
+- return f2();
+- case 8:
+- return f3();
+- case 0:
+- return f4();
+- }
+- return -1;
+-}
+-
+-/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: BT:0-10 BT:12-20" "switchlower1" } } */
+diff --git a/gcc/testsuite/gcc.dg/tree-ssa/switch-6.c b/gcc/testsuite/gcc.dg/tree-ssa/switch-6.c
+deleted file mode 100644
+index bbbc87462c40..000000000000
+--- a/gcc/testsuite/gcc.dg/tree-ssa/switch-6.c
++++ /dev/null
+@@ -1,51 +0,0 @@
+-/* { dg-do compile { target { { x86_64-*-* aarch64-*-* ia64-*-* powerpc64-*-* } && lp64 } } } */
+-/* { dg-options "-O2 -fdump-tree-switchlower1 -fno-jump-tables" } */
+-
+-/* Test that bit-test switch lowering can create cluster of size 64 (there was
+- an of-by-one error causing it to only do 63 before). */
+-
+-int f();
+-
+-int foo(int a)
+-{
+- switch (a)
+- {
+- case 0:
+- case 3:
+- case 5:
+- case 7:
+- case 9:
+- case 11:
+- case 13:
+- case 15:
+- case 17:
+- case 19:
+- case 21:
+- case 23:
+- case 25:
+- case 27:
+- case 29:
+- case 31:
+- case 33:
+- case 35:
+- case 37:
+- case 39:
+- case 41:
+- case 43:
+- case 45:
+- case 47:
+- case 49:
+- case 51:
+- case 53:
+- case 55:
+- case 57:
+- case 59:
+- case 61:
+- case 63:
+- return f();
+- default:
+- return -1;
+- }
+-}
+-
+-/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: BT:0-63" "switchlower1" } } */
+--
+2.49.0
+
diff --git a/16.0.0/gentoo/86_all_PR120080_Revert-gimple-Don-t-warn-about-using-different-algs-.patch b/16.0.0/gentoo/86_all_PR120080_Revert-gimple-Don-t-warn-about-using-different-algs-.patch
new file mode 100644
index 0000000..eed3cdb
--- /dev/null
+++ b/16.0.0/gentoo/86_all_PR120080_Revert-gimple-Don-t-warn-about-using-different-algs-.patch
@@ -0,0 +1,35 @@
+From e11fc43562a4aaa15b757d5728dd5a514e128bee Mon Sep 17 00:00:00 2001
+Message-ID: <e11fc43562a4aaa15b757d5728dd5a514e128bee.1746450157.git.sam@gentoo.org>
+In-Reply-To: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
+References: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Mon, 5 May 2025 14:02:09 +0100
+Subject: [PATCH 2/4] Revert "gimple: Don't warn about using different algs for
+ big switch lowering [PR117091]"
+
+This reverts commit c14560907a9586ad405f26ab937881eb08f39497.
+---
+ gcc/tree-switch-conversion.cc | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
+index dea217a01efb..4f0be8c43f07 100644
+--- a/gcc/tree-switch-conversion.cc
++++ b/gcc/tree-switch-conversion.cc
+@@ -2257,6 +2257,13 @@ switch_decision_tree::analyze_switch_statement ()
+
+ reset_out_edges_aux (m_switch);
+
++ if (l > (unsigned) param_switch_lower_slow_alg_max_cases)
++ warning_at (gimple_location (m_switch), OPT_Wdisabled_optimization,
++ "Using faster switch lowering algorithms. "
++ "Number of switch cases (%d) exceeds "
++ "%<--param=switch-lower-slow-alg-max-cases=%d%> limit.",
++ l, param_switch_lower_slow_alg_max_cases);
++
+ /* Find bit-test clusters. */
+ vec<cluster *> output = bit_test_cluster::find_bit_tests (clusters, max_c);
+
+--
+2.49.0
+
diff --git a/16.0.0/gentoo/87_all_PR120080-Revert-gimple-Make-bit-test-switch-lowering-more-pow.patch b/16.0.0/gentoo/87_all_PR120080-Revert-gimple-Make-bit-test-switch-lowering-more-pow.patch
new file mode 100644
index 0000000..bb246ad
--- /dev/null
+++ b/16.0.0/gentoo/87_all_PR120080-Revert-gimple-Make-bit-test-switch-lowering-more-pow.patch
@@ -0,0 +1,258 @@
+From 22f45f552e6dfe51256f4f1c423a51b831ab46d8 Mon Sep 17 00:00:00 2001
+Message-ID: <22f45f552e6dfe51256f4f1c423a51b831ab46d8.1746450157.git.sam@gentoo.org>
+In-Reply-To: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
+References: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Mon, 5 May 2025 14:02:17 +0100
+Subject: [PATCH 3/4] Revert "gimple: Make bit-test switch lowering more
+ powerful"
+
+This reverts commit 1381a5114788a2e9234ff54e0cd7a3c810f0d02d.
+---
+ gcc/tree-switch-conversion.cc | 153 +++++++++++++++++++---------------
+ gcc/tree-switch-conversion.h | 10 +++
+ 2 files changed, 96 insertions(+), 67 deletions(-)
+
+diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
+index 4f0be8c43f07..a70274b03372 100644
+--- a/gcc/tree-switch-conversion.cc
++++ b/gcc/tree-switch-conversion.cc
+@@ -1783,98 +1783,58 @@ bit_test_cluster::find_bit_tests (vec<cluster *> &clusters, int max_c)
+ if (!is_enabled () || max_c == 1)
+ return clusters.copy ();
+
+- /* Dynamic programming algorithm.
+-
+- In: List of simple clusters
+- Out: List of simple clusters and bit test clusters such that each bit test
+- cluster can_be_handled() and is_beneficial()
+-
+- Tries to merge consecutive clusters into bigger (bit test) ones. Tries to
+- end up with as few clusters as possible. */
+-
+ unsigned l = clusters.length ();
+ auto_vec<min_cluster_item> min;
+ min.reserve (l + 1);
+
+- gcc_checking_assert (l > 0);
+- gcc_checking_assert (l <= INT_MAX);
+-
+- int bits_in_word = GET_MODE_BITSIZE (word_mode);
++ min.quick_push (min_cluster_item (0, 0, 0));
+
+- /* First phase: Compute the minimum number of clusters for each prefix of the
+- input list incrementally
++ unsigned bits_in_word = GET_MODE_BITSIZE (word_mode);
+
+- min[i] = (count, j, _) means that the prefix ending with the (i-1)-th
+- element can be made to contain as few as count clusters and that in such
+- clustering the last cluster is made up of input clusters [j, i-1]
+- (inclusive). */
+- min.quick_push (min_cluster_item (0, 0, INT_MAX));
+- min.quick_push (min_cluster_item (1, 0, INT_MAX));
+- for (int i = 2; i <= (int) l; i++)
++ for (unsigned i = 1; i <= l; i++)
+ {
+- auto_vec<unsigned, m_max_case_bit_tests> unique_labels;
++ /* Set minimal # of clusters with i-th item to infinite. */
++ min.quick_push (min_cluster_item (INT_MAX, INT_MAX, INT_MAX));
+
+ /* Since each cluster contains at least one case number and one bit test
+ cluster can cover at most bits_in_word case numbers, we don't need to
+ look farther than bits_in_word clusters back. */
+- for (int j = i - 1; j >= 0 && j >= i - bits_in_word; j--)
++ unsigned j;
++ if (i - 1 >= bits_in_word)
++ j = i - 1 - bits_in_word;
++ else
++ j = 0;
++ for (; j < i; j++)
+ {
+- /* Consider creating a bit test cluster from input clusters [j, i-1]
+- (inclusive) */
+-
+- simple_cluster *sc = static_cast<simple_cluster *> (clusters[j]);
+- unsigned label = sc->m_case_bb->index;
+- if (!unique_labels.contains (label))
+- {
+- if (unique_labels.length () >= m_max_case_bit_tests)
+- /* is_beneficial() will be false for this and the following
+- iterations. */
+- break;
+- unique_labels.quick_push (label);
+- }
+-
+- unsigned new_count = min[j].m_count + 1;
+-
+- if (j == i - 1)
+- {
+- min.quick_push (min_cluster_item (new_count, j, INT_MAX));
+- continue;
+- }
+-
+- unsigned HOST_WIDE_INT range
+- = get_range (clusters[j]->get_low (), clusters[i-1]->get_high ());
+- if (new_count < min[i].m_count
+- && can_be_handled (range, unique_labels.length ())
+- && is_beneficial (i - j, unique_labels.length ()))
+- min[i] = min_cluster_item (new_count, j, INT_MAX);
++ if (min[j].m_count + 1 < min[i].m_count
++ && can_be_handled (clusters, j, i - 1))
++ min[i] = min_cluster_item (min[j].m_count + 1, j, INT_MAX);
+ }
++
++ gcc_checking_assert (min[i].m_count != INT_MAX);
+ }
+
++ /* No result. */
+ if (min[l].m_count == l)
+- /* No bit test clustering opportunities. */
+ return clusters.copy ();
+
+ vec<cluster *> output;
+ output.create (4);
+
+- /* Second phase: Find and build the bit test clusters by traversing min
+- array backwards. */
++ /* Find and build the clusters. */
+ for (unsigned end = l;;)
+ {
+- unsigned start = min[end].m_start;
+- gcc_checking_assert (start < end);
+-
+- /* This cluster will be made out of input clusters [start, end - 1]. */
++ int start = min[end].m_start;
+
+- if (start == end - 1)
+- /* Let the cluster be a simple cluster. */
+- output.safe_push (clusters[start]);
+- else
++ if (is_beneficial (clusters, start, end - 1))
+ {
+- bool entire = start == 0 && end == l;
++ bool entire = start == 0 && end == clusters.length ();
+ output.safe_push (new bit_test_cluster (clusters, start, end - 1,
+ entire));
+ }
++ else
++ for (int i = end - 1; i >= start; i--)
++ output.safe_push (clusters[i]);
+
+ end = start;
+
+@@ -1897,25 +1857,84 @@ bit_test_cluster::can_be_handled (unsigned HOST_WIDE_INT range,
+ if (range == 0)
+ return false;
+
+- if (range > GET_MODE_BITSIZE (word_mode))
++ if (range >= GET_MODE_BITSIZE (word_mode))
+ return false;
+
+ return uniq <= m_max_case_bit_tests;
+ }
+
++/* Return true when cluster starting at START and ending at END (inclusive)
++ can build a bit test. */
++
++bool
++bit_test_cluster::can_be_handled (const vec<cluster *> &clusters,
++ unsigned start, unsigned end)
++{
++ auto_vec<int, m_max_case_bit_tests> dest_bbs;
++ /* For algorithm correctness, bit test for a single case must return
++ true. We bail out in is_beneficial if it's called just for
++ a single case. */
++ if (start == end)
++ return true;
++
++ unsigned HOST_WIDE_INT range = get_range (clusters[start]->get_low (),
++ clusters[end]->get_high ());
++
++ /* Make a guess first. */
++ if (!can_be_handled (range, m_max_case_bit_tests))
++ return false;
++
++ for (unsigned i = start; i <= end; i++)
++ {
++ simple_cluster *sc = static_cast<simple_cluster *> (clusters[i]);
++ /* m_max_case_bit_tests is very small integer, thus the operation
++ is constant. */
++ if (!dest_bbs.contains (sc->m_case_bb->index))
++ {
++ if (dest_bbs.length () >= m_max_case_bit_tests)
++ return false;
++ dest_bbs.quick_push (sc->m_case_bb->index);
++ }
++ }
++
++ return true;
++}
++
+ /* Return true when COUNT of cases of UNIQ labels is beneficial for bit test
+ transformation. */
+
+ bool
+ bit_test_cluster::is_beneficial (unsigned count, unsigned uniq)
+ {
+- /* NOTE: When modifying this, keep in mind the value of
+- m_max_case_bit_tests. */
+ return (((uniq == 1 && count >= 3)
+ || (uniq == 2 && count >= 5)
+ || (uniq == 3 && count >= 6)));
+ }
+
++/* Return true if cluster starting at START and ending at END (inclusive)
++ is profitable transformation. */
++
++bool
++bit_test_cluster::is_beneficial (const vec<cluster *> &clusters,
++ unsigned start, unsigned end)
++{
++ /* Single case bail out. */
++ if (start == end)
++ return false;
++
++ auto_bitmap dest_bbs;
++
++ for (unsigned i = start; i <= end; i++)
++ {
++ simple_cluster *sc = static_cast<simple_cluster *> (clusters[i]);
++ bitmap_set_bit (dest_bbs, sc->m_case_bb->index);
++ }
++
++ unsigned uniq = bitmap_count_bits (dest_bbs);
++ unsigned count = end - start + 1;
++ return is_beneficial (count, uniq);
++}
++
+ /* Comparison function for qsort to order bit tests by decreasing
+ probability of execution. */
+
+diff --git a/gcc/tree-switch-conversion.h b/gcc/tree-switch-conversion.h
+index b2b6ddc731fb..2ed7e1c7efc1 100644
+--- a/gcc/tree-switch-conversion.h
++++ b/gcc/tree-switch-conversion.h
+@@ -423,10 +423,20 @@ public:
+ can build a bit test. */
+ static bool can_be_handled (unsigned HOST_WIDE_INT range, unsigned uniq);
+
++ /* Return true when cluster starting at START and ending at END (inclusive)
++ can build a bit test. */
++ static bool can_be_handled (const vec<cluster *> &clusters, unsigned start,
++ unsigned end);
++
+ /* Return true when COUNT of cases of UNIQ labels is beneficial for bit test
+ transformation. */
+ static bool is_beneficial (unsigned count, unsigned uniq);
+
++ /* Return true if cluster starting at START and ending at END (inclusive)
++ is profitable transformation. */
++ static bool is_beneficial (const vec<cluster *> &clusters, unsigned start,
++ unsigned end);
++
+ /* Split the basic block at the statement pointed to by GSIP, and insert
+ a branch to the target basic block of E_TRUE conditional on tree
+ expression COND.
+--
+2.49.0
+
diff --git a/16.0.0/gentoo/88_all_PR120080-Revert-gimple-Merge-slow-and-fast-bit-test-switch-lo.patch b/16.0.0/gentoo/88_all_PR120080-Revert-gimple-Merge-slow-and-fast-bit-test-switch-lo.patch
new file mode 100644
index 0000000..ce952f0
--- /dev/null
+++ b/16.0.0/gentoo/88_all_PR120080-Revert-gimple-Merge-slow-and-fast-bit-test-switch-lo.patch
@@ -0,0 +1,157 @@
+From 3827851b3d589780a9dc072962a266bae18272ad Mon Sep 17 00:00:00 2001
+Message-ID: <3827851b3d589780a9dc072962a266bae18272ad.1746450157.git.sam@gentoo.org>
+In-Reply-To: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
+References: <4c57a4d3c280b249649495e032682f5eea41752b.1746450157.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Mon, 5 May 2025 14:02:25 +0100
+Subject: [PATCH 4/4] Revert "gimple: Merge slow and fast bit-test switch
+ lowering [PR117091]"
+
+This reverts commit 5274db0c9b8c0e2d2879b237eb2ab576543b6c37.
+---
+ gcc/tree-switch-conversion.cc | 107 ++++++++++++++++++++++++++++------
+ 1 file changed, 90 insertions(+), 17 deletions(-)
+
+diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
+index a70274b03372..39a8a893edde 100644
+--- a/gcc/tree-switch-conversion.cc
++++ b/gcc/tree-switch-conversion.cc
+@@ -1773,38 +1773,92 @@ jump_table_cluster::is_beneficial (const vec<cluster *> &,
+ return end - start + 1 >= case_values_threshold ();
+ }
+
+-/* Find bit tests of given CLUSTERS, where all members of the vector
+- are of type simple_cluster. MAX_C is the approx max number of cases per
+- label. New clusters are returned. */
++/* Find bit tests of given CLUSTERS, where all members of the vector are of
++ type simple_cluster. Use a fast algorithm that might not find the optimal
++ solution (minimal number of clusters on the output). New clusters are
++ returned.
++
++ You should call find_bit_tests () instead of calling this function
++ directly. */
+
+ vec<cluster *>
+-bit_test_cluster::find_bit_tests (vec<cluster *> &clusters, int max_c)
++bit_test_cluster::find_bit_tests_fast (vec<cluster *> &clusters)
+ {
+- if (!is_enabled () || max_c == 1)
+- return clusters.copy ();
++ unsigned l = clusters.length ();
++ vec<cluster *> output;
++
++ output.create (l);
++
++ /* Look at sliding BITS_PER_WORD sized windows in the switch value space
++ and determine if they are suitable for a bit test cluster. Worst case
++ this can examine every value BITS_PER_WORD-1 times. */
++ unsigned k;
++ for (unsigned i = 0; i < l; i += k)
++ {
++ hash_set<basic_block> targets;
++ cluster *start_cluster = clusters[i];
++
++ /* Find the biggest k such that clusters i to i+k-1 can be turned into a
++ one big bit test cluster. */
++ k = 0;
++ while (i + k < l)
++ {
++ cluster *end_cluster = clusters[i + k];
++
++ /* Does value range fit into the BITS_PER_WORD window? */
++ HOST_WIDE_INT w = cluster::get_range (start_cluster->get_low (),
++ end_cluster->get_high ());
++ if (w == 0 || w > BITS_PER_WORD)
++ break;
++
++ /* Check for max # of targets. */
++ if (targets.elements () == m_max_case_bit_tests
++ && !targets.contains (end_cluster->m_case_bb))
++ break;
++
++ targets.add (end_cluster->m_case_bb);
++ k++;
++ }
++
++ if (is_beneficial (k, targets.elements ()))
++ {
++ output.safe_push (new bit_test_cluster (clusters, i, i + k - 1,
++ i == 0 && k == l));
++ }
++ else
++ {
++ output.safe_push (clusters[i]);
++ /* ??? Might be able to skip more. */
++ k = 1;
++ }
++ }
+
++ return output;
++}
++
++/* Find bit tests of given CLUSTERS, where all members of the vector
++ are of type simple_cluster. Use a slow (quadratic) algorithm that always
++ finds the optimal solution (minimal number of clusters on the output). New
++ clusters are returned.
++
++ You should call find_bit_tests () instead of calling this function
++ directly. */
++
++vec<cluster *>
++bit_test_cluster::find_bit_tests_slow (vec<cluster *> &clusters)
++{
+ unsigned l = clusters.length ();
+ auto_vec<min_cluster_item> min;
+ min.reserve (l + 1);
+
+ min.quick_push (min_cluster_item (0, 0, 0));
+
+- unsigned bits_in_word = GET_MODE_BITSIZE (word_mode);
+-
+ for (unsigned i = 1; i <= l; i++)
+ {
+ /* Set minimal # of clusters with i-th item to infinite. */
+ min.quick_push (min_cluster_item (INT_MAX, INT_MAX, INT_MAX));
+
+- /* Since each cluster contains at least one case number and one bit test
+- cluster can cover at most bits_in_word case numbers, we don't need to
+- look farther than bits_in_word clusters back. */
+- unsigned j;
+- if (i - 1 >= bits_in_word)
+- j = i - 1 - bits_in_word;
+- else
+- j = 0;
+- for (; j < i; j++)
++ for (unsigned j = 0; j < i; j++)
+ {
+ if (min[j].m_count + 1 < min[i].m_count
+ && can_be_handled (clusters, j, i - 1))
+@@ -1846,6 +1900,25 @@ bit_test_cluster::find_bit_tests (vec<cluster *> &clusters, int max_c)
+ return output;
+ }
+
++/* Find bit tests of given CLUSTERS, where all members of the vector
++ are of type simple_cluster. MAX_C is the approx max number of cases per
++ label. New clusters are returned. */
++
++vec<cluster *>
++bit_test_cluster::find_bit_tests (vec<cluster *> &clusters, int max_c)
++{
++ if (!is_enabled () || max_c == 1)
++ return clusters.copy ();
++
++ unsigned l = clusters.length ();
++
++ /* Note: l + 1 is the number of cases of the switch. */
++ if (l + 1 > (unsigned) param_switch_lower_slow_alg_max_cases)
++ return find_bit_tests_fast (clusters);
++ else
++ return find_bit_tests_slow (clusters);
++}
++
+ /* Return true when RANGE of case values with UNIQ labels
+ can build a bit test. */
+
+--
+2.49.0
+
^ permalink raw reply related [flat|nested] 88+ messages in thread
end of thread, other threads:[~2025-09-17 18:41 UTC | newest]
Thread overview: 88+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-07 22:42 [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/ Sam James
-- strict thread matches above, loose matches on Subject: below --
2025-09-17 18:41 Sam James
2025-09-17 3:04 Sam James
2025-09-16 19:23 Sam James
2025-09-14 11:26 Sam James
2025-09-13 13:16 Sam James
2025-09-06 2:42 Sam James
2025-09-05 12:44 Sam James
2025-09-01 8:04 Sam James
2025-08-31 22:43 Sam James
2025-08-30 14:06 Sam James
2025-08-30 8:05 Sam James
2025-08-30 6:57 Sam James
2025-08-30 0:12 Sam James
2025-08-29 21:26 Sam James
2025-08-29 21:02 Sam James
2025-08-29 20:24 Sam James
2025-08-29 20:18 Sam James
2025-08-29 18:38 Sam James
2025-08-29 12:15 Sam James
2025-08-28 17:57 Sam James
2025-08-28 5:27 Sam James
2025-08-27 4:19 Sam James
2025-08-26 23:42 Sam James
2025-08-26 4:48 Sam James
2025-08-26 0:56 Sam James
2025-08-25 3:55 Sam James
2025-08-24 23:42 Sam James
2025-08-21 16:11 Sam James
2025-08-20 20:45 Sam James
2025-08-20 14:10 Sam James
2025-08-20 1:16 Sam James
2025-08-20 1:10 Sam James
2025-08-19 16:30 Sam James
2025-08-18 23:52 Sam James
2025-08-18 23:08 Sam James
2025-08-17 22:45 Sam James
2025-08-17 21:01 Sam James
2025-08-17 16:30 Sam James
2025-08-17 15:44 Sam James
2025-08-17 15:10 Sam James
2025-08-16 23:06 Sam James
2025-08-05 0:23 Sam James
2025-07-30 22:35 Sam James
2025-07-30 0:44 Sam James
2025-07-30 0:44 Sam James
2025-07-25 18:49 Sam James
2025-07-23 11:22 Sam James
2025-07-22 23:56 Sam James
2025-07-21 14:02 Sam James
2025-07-21 1:12 Sam James
2025-07-14 16:03 Sam James
2025-07-14 4:09 Sam James
2025-07-14 2:55 Sam James
2025-07-14 2:55 Sam James
2025-07-14 2:40 Sam James
2025-07-13 23:11 Sam James
2025-07-13 1:09 Sam James
2025-07-12 15:24 Sam James
2025-07-12 15:23 Sam James
2025-07-10 12:34 Sam James
2025-07-10 1:22 Sam James
2025-07-10 0:50 Sam James
2025-07-07 20:49 Sam James
2025-07-06 22:41 Sam James
2025-07-03 1:29 Sam James
2025-06-30 6:26 Sam James
2025-06-29 0:29 Sam James
2025-06-19 16:59 Sam James
2025-06-19 0:58 Sam James
2025-06-19 0:58 Sam James
2025-06-18 21:17 Sam James
2025-06-18 9:53 Sam James
2025-06-18 9:06 Sam James
2025-06-13 12:03 Sam James
2025-06-12 20:34 Sam James
2025-06-12 14:05 Sam James
2025-06-12 7:27 Sam James
2025-06-12 5:46 Sam James
2025-06-11 5:05 Sam James
2025-06-11 3:19 Sam James
2025-06-01 22:39 Sam James
2025-05-31 18:48 Sam James
2025-05-11 22:52 Sam James
2025-05-10 15:28 Sam James
2025-05-09 23:29 Sam James
2025-05-05 14:39 Sam James
2025-05-05 13:05 Sam James
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox