From 46ce913ce6b1c3c05edc42b705e09e764692506c Mon Sep 17 00:00:00 2001
From: Jakub Jelinek
Date: Fri, 19 Aug 2022 19:30:52 +0200
Subject: [PATCH] 12.2.1-1
---
.gitignore | 1 +
gcc.spec | 21 ++++-
gcc12-libstdc++-docs.patch | 4 +-
gcc12-p2327r1.patch | 135 +++++++++++++++++++++++++++++++
gcc12-pr106590.patch | 159 +++++++++++++++++++++++++++++++++++++
sources | 2 +-
update-gcc.sh | 2 +-
7 files changed, 316 insertions(+), 8 deletions(-)
create mode 100644 gcc12-p2327r1.patch
create mode 100644 gcc12-pr106590.patch
diff --git a/.gitignore b/.gitignore
index cdb4494..0efc72e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,3 +74,4 @@
/gcc-12.1.1-20220507.tar.xz
/gcc-12.1.1-20220628.tar.xz
/gcc-12.1.1-20220810.tar.xz
+/gcc-12.2.1-20220819.tar.xz
diff --git a/gcc.spec b/gcc.spec
index f53ed6a..7fffb7f 100644
--- a/gcc.spec
+++ b/gcc.spec
@@ -1,10 +1,10 @@
-%global DATE 20220810
-%global gitrev c66b9ee42a4ecd9d14f9724bf0a26019326edf0a
-%global gcc_version 12.1.1
+%global DATE 20220819
+%global gitrev 12a206c28987ada47b447ebd200d1fd9639c8edd
+%global gcc_version 12.2.1
%global gcc_major 12
# Note, gcc_release must be integer, if you want to add suffixes to
# %%{release}, append them after %%{gcc_release} on Release: line.
-%global gcc_release 4
+%global gcc_release 1
%global nvptx_tools_gitrev 5f6f343a302d620b0868edab376c00b15741e39e
%global newlib_cygwin_gitrev 50e2a63b04bdd018484605fbb954fd1bd5147fa0
%global _unpackaged_files_terminate_build 0
@@ -275,6 +275,8 @@ Patch8: gcc12-no-add-needed.patch
Patch9: gcc12-Wno-format-security.patch
Patch10: gcc12-rh1574936.patch
Patch11: gcc12-d-shared-libphobos.patch
+Patch12: gcc12-p2327r1.patch
+Patch13: gcc12-pr106590.patch
Patch100: gcc12-fortran-fdec-duplicates.patch
Patch101: gcc12-fortran-flogical-as-integer.patch
@@ -802,6 +804,8 @@ so that there cannot be any synchronization problems.
%patch10 -p0 -b .rh1574936~
%endif
%patch11 -p0 -b .d-shared-libphobos~
+%patch12 -p0 -b .p2327r1~
+%patch13 -p0 -b .pr106590~
%if 0%{?rhel} >= 9
%patch100 -p1 -b .fortran-fdec-duplicates~
@@ -3213,6 +3217,15 @@ end
%endif
%changelog
+* Fri Aug 19 2022 Jakub Jelinek 12.2.1-1
+- update from releases/gcc-12 branch
+ - GCC 12.1 release
+ - PRs c++/67048, c++/106369, c/106016, d/106623, d/106638, lto/106334,
+ lto/106540, middle-end/106492, tree-optimization/106513
+- fix an if-conversion wrong-code bug (PR rtl-optimization/106590)
+- implement C++23 P2327R1 - de-deprecating volatile compound operations - as
+ a DR
+
* Wed Aug 8 2022 Jakub Jelinek 12.1.1-4
- update from releases/gcc-12 branch
- PRs analyzer/105285, analyzer/106204, analyzer/106225, c++/53164,
diff --git a/gcc12-libstdc++-docs.patch b/gcc12-libstdc++-docs.patch
index 5a27a5d..b6c2d50 100644
--- a/gcc12-libstdc++-docs.patch
+++ b/gcc12-libstdc++-docs.patch
@@ -4,7 +4,7 @@
FSF
-+ Release 12.1.1
++ Release 12.2.1
+
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation
@@ -17,7 +17,7 @@
- The API documentation, rendered into HTML, can be viewed online
+ The API documentation, rendered into HTML, can be viewed locally
-+ for the 12.1.1 release,
++ for the 12.2.1 release,
+ online
for each GCC release
and
diff --git a/gcc12-p2327r1.patch b/gcc12-p2327r1.patch
new file mode 100644
index 0000000..4c6e695
--- /dev/null
+++ b/gcc12-p2327r1.patch
@@ -0,0 +1,135 @@
+2022-08-16 Jakub Jelinek
+
+ * typeck.cc (cp_build_modify_expr): Implement
+ P2327R1 - De-deprecating volatile compound operations. Don't warn
+ for |=, &= or ^= with volatile lhs.
+ * expr.cc (mark_use) : Adjust warning wording,
+ leave out simple.
+
+ * g++.dg/cpp2a/volatile1.C: Adjust for de-deprecation of volatile
+ compound |=, &= and ^= operations.
+ * g++.dg/cpp2a/volatile3.C: Likewise.
+ * g++.dg/cpp2a/volatile5.C: Likewise.
+
+--- gcc/cp/expr.cc
++++ gcc/cp/expr.cc
+@@ -220,7 +220,7 @@ mark_use (tree expr, bool rvalue_p, bool read_p,
+ case MODIFY_EXPR:
+ {
+ tree lhs = TREE_OPERAND (expr, 0);
+- /* [expr.ass] "A simple assignment whose left operand is of
++ /* [expr.ass] "An assignment whose left operand is of
+ a volatile-qualified type is deprecated unless the assignment
+ is either a discarded-value expression or appears in an
+ unevaluated context." */
+@@ -230,7 +230,7 @@ mark_use (tree expr, bool rvalue_p, bool read_p,
+ && !TREE_THIS_VOLATILE (expr))
+ {
+ if (warning_at (location_of (expr), OPT_Wvolatile,
+- "using value of simple assignment with "
++ "using value of assignment with "
+ "%-qualified left operand is "
+ "deprecated"))
+ /* Make sure not to warn about this assignment again. */
+--- gcc/cp/typeck.cc
++++ gcc/cp/typeck.cc
+@@ -9136,10 +9136,14 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
+
+ /* An expression of the form E1 op= E2. [expr.ass] says:
+ "Such expressions are deprecated if E1 has volatile-qualified
+- type." We warn here rather than in cp_genericize_r because
++ type and op is not one of the bitwise operators |, &, ^."
++ We warn here rather than in cp_genericize_r because
+ for compound assignments we are supposed to warn even if the
+ assignment is a discarded-value expression. */
+- if (TREE_THIS_VOLATILE (lhs) || CP_TYPE_VOLATILE_P (lhstype))
++ if (modifycode != BIT_AND_EXPR
++ && modifycode != BIT_IOR_EXPR
++ && modifycode != BIT_XOR_EXPR
++ && (TREE_THIS_VOLATILE (lhs) || CP_TYPE_VOLATILE_P (lhstype)))
+ warning_at (loc, OPT_Wvolatile,
+ "compound assignment with %-qualified left "
+ "operand is deprecated");
+--- gcc/testsuite/g++.dg/cpp2a/volatile1.C
++++ gcc/testsuite/g++.dg/cpp2a/volatile1.C
+@@ -56,6 +56,9 @@ fn2 ()
+ vi = i;
+ vi = i = 42;
+ i = vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
++ i = vi |= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
++ i = vi &= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
++ i = vi ^= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
+ &(vi = i); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
+ (vi = 42, 45);
+ (i = vi = 42, 10); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
+@@ -74,8 +77,9 @@ fn2 ()
+ vi += i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
+ vi -= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
+ vi %= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
+- vi ^= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
+- vi |= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
++ vi ^= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
++ vi |= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
++ vi &= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
+ vi /= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
+ vi = vi += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
+ vi += vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
+@@ -131,7 +135,8 @@ void raccoon ()
+ volatile T t, u;
+ t = 42;
+ u = t = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
+- t &= 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
++ t += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } }
++ t &= 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
+ }
+
+ void
+--- gcc/testsuite/g++.dg/cpp2a/volatile3.C
++++ gcc/testsuite/g++.dg/cpp2a/volatile3.C
+@@ -57,6 +57,9 @@ fn2 ()
+ vi = i;
+ vi = i = 42;
+ i = vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
++ i = vi |= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" }
++ i = vi &= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" }
++ i = vi ^= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" }
+ &(vi = i); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+ (vi = 42, 45);
+ (i = vi = 42, 10); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+@@ -75,8 +78,9 @@ fn2 ()
+ vi += i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+ vi -= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+ vi %= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+- vi ^= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+- vi |= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
++ vi ^= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
++ vi |= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
++ vi &= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
+ vi /= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+ vi = vi += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+ vi += vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+@@ -132,7 +136,8 @@ void raccoon ()
+ volatile T t, u;
+ t = 42;
+ u = t = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+- t &= 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
++ t += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
++ t &= 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
+ }
+
+ void
+--- gcc/testsuite/g++.dg/cpp2a/volatile5.C
++++ gcc/testsuite/g++.dg/cpp2a/volatile5.C
+@@ -8,8 +8,8 @@ f (bool b)
+ {
+ (b ? x : y) = 1;
+ (b ? x : y) += 1; // { dg-warning "compound assignment" "" { target c++20 } }
+- z = (b ? x : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
+- ((z = 2) ? x : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
+- (b ? (x = 2) : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
+- (b ? x : (y = 5)) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
++ z = (b ? x : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } }
++ ((z = 2) ? x : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } }
++ (b ? (x = 2) : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } }
++ (b ? x : (y = 5)) = 1; // { dg-warning "using value of assignment" "" { target c++20 } }
+ }
diff --git a/gcc12-pr106590.patch b/gcc12-pr106590.patch
new file mode 100644
index 0000000..11e0cd4
--- /dev/null
+++ b/gcc12-pr106590.patch
@@ -0,0 +1,159 @@
+2022-08-15 Jakub Jelinek
+
+ PR rtl-optimization/106590
+ * ifcvt.cc (check_for_cc_cmp_clobbers): New function.
+ (noce_convert_multiple_sets_1): If SEQ sets or clobbers any regs
+ mentioned in cc_cmp or rev_cc_cmp, don't consider seq2 for any
+ further conditional moves.
+
+ * gcc.dg/torture/pr106590.c: New test.
+
+--- gcc/ifcvt.cc
++++ gcc/ifcvt.cc
+@@ -3369,6 +3369,20 @@ noce_convert_multiple_sets (struct noce_if_info *if_info)
+ return TRUE;
+ }
+
++/* Helper function for noce_convert_multiple_sets_1. If store to
++ DEST can affect P[0] or P[1], clear P[0]. Called via note_stores. */
++
++static void
++check_for_cc_cmp_clobbers (rtx dest, const_rtx, void *p0)
++{
++ rtx *p = (rtx *) p0;
++ if (p[0] == NULL_RTX)
++ return;
++ if (reg_overlap_mentioned_p (dest, p[0])
++ || (p[1] && reg_overlap_mentioned_p (dest, p[1])))
++ p[0] = NULL_RTX;
++}
++
+ /* This goes through all relevant insns of IF_INFO->then_bb and tries to
+ create conditional moves. In case a simple move sufficis the insn
+ should be listed in NEED_NO_CMOV. The rewired-src cases should be
+@@ -3519,7 +3533,7 @@ noce_convert_multiple_sets_1 (struct noce_if_info *if_info,
+
+ as min/max and emit an insn, accordingly. */
+ unsigned cost1 = 0, cost2 = 0;
+- rtx_insn *seq, *seq1, *seq2;
++ rtx_insn *seq, *seq1, *seq2 = NULL;
+ rtx temp_dest = NULL_RTX, temp_dest1 = NULL_RTX, temp_dest2 = NULL_RTX;
+ bool read_comparison = false;
+
+@@ -3531,9 +3545,10 @@ noce_convert_multiple_sets_1 (struct noce_if_info *if_info,
+ as well. This allows the backend to emit a cmov directly without
+ creating an additional compare for each. If successful, costing
+ is easier and this sequence is usually preferred. */
+- seq2 = try_emit_cmove_seq (if_info, temp, cond,
+- new_val, old_val, need_cmov,
+- &cost2, &temp_dest2, cc_cmp, rev_cc_cmp);
++ if (cc_cmp)
++ seq2 = try_emit_cmove_seq (if_info, temp, cond,
++ new_val, old_val, need_cmov,
++ &cost2, &temp_dest2, cc_cmp, rev_cc_cmp);
+
+ /* The backend might have created a sequence that uses the
+ condition. Check this. */
+@@ -3588,6 +3603,24 @@ noce_convert_multiple_sets_1 (struct noce_if_info *if_info,
+ return FALSE;
+ }
+
++ if (cc_cmp)
++ {
++ /* Check if SEQ can clobber registers mentioned in
++ cc_cmp and/or rev_cc_cmp. If yes, we need to use
++ only seq1 from that point on. */
++ rtx cc_cmp_pair[2] = { cc_cmp, rev_cc_cmp };
++ for (walk = seq; walk; walk = NEXT_INSN (walk))
++ {
++ note_stores (walk, check_for_cc_cmp_clobbers, cc_cmp_pair);
++ if (cc_cmp_pair[0] == NULL_RTX)
++ {
++ cc_cmp = NULL_RTX;
++ rev_cc_cmp = NULL_RTX;
++ break;
++ }
++ }
++ }
++
+ /* End the sub sequence and emit to the main sequence. */
+ emit_insn (seq);
+
+--- gcc/testsuite/gcc.dg/torture/pr106590.c
++++ gcc/testsuite/gcc.dg/torture/pr106590.c
+@@ -0,0 +1,75 @@
++/* PR rtl-optimization/106590 } */
++/* { dg-do run } */
++/* { dg-additional-options "-mtune=skylake" { target { i?86-*-* x86_64-*-* } } } */
++
++typedef struct A { short a; } A;
++typedef A *B;
++typedef struct C { int c, d; } C;
++typedef C *D;
++
++B
++foo (void)
++{
++ static A r = { .a = 1 };
++ return &r;
++}
++
++D
++bar (void)
++{
++ static C r = { .c = 1, .d = 23 };
++ return &r;
++}
++
++static inline int __attribute__((always_inline))
++baz (short a)
++{
++ int e = 1, f;
++ short g;
++ D h;
++
++ switch (a)
++ {
++ case 1:
++ f = 23;
++ g = 1;
++ break;
++ case 2:
++ f = 20;
++ g = 2;
++ break;
++ }
++
++ h = bar ();
++
++ if (h->d != f || h->c != g)
++ __builtin_abort ();
++ return e;
++}
++
++int
++qux (void)
++{
++ B i = foo ();
++ int e = 1;
++
++ switch (i->a)
++ {
++ case 1:
++ case 2:
++ e = baz (i->a);
++ break;
++ case 3:
++ e = 0;
++ break;
++ }
++
++ return e;
++}
++
++int
++main ()
++{
++ qux ();
++ return 0;
++}
diff --git a/sources b/sources
index 2495567..20c9d7c 100644
--- a/sources
+++ b/sources
@@ -1,4 +1,4 @@
-SHA512 (gcc-12.1.1-20220810.tar.xz) = dffb7d9b2de89a47ad29533d0b467ffc26d094b1e6eab0b019c5ea5cd06f7766f912a7c38ca8e046516c5bcb50424d6b51b47e5b4f93ef4fc8cec56e37f1d6f5
+SHA512 (gcc-12.2.1-20220819.tar.xz) = 40464b6c544edd91ea744354a38bb2ec075d021b3bece7997b40b462dbca5a7b86105ae157fa081b1a6bd1c9f4813a51eec245b56a2bd2eb171e90ce048c0f25
SHA512 (isl-0.18.tar.bz2) = 85d0b40f4dbf14cb99d17aa07048cdcab2dc3eb527d2fbb1e84c41b2de5f351025370e57448b63b2b8a8cf8a0843a089c3263f9baee1542d5c2e1cb37ed39d94
SHA512 (newlib-cygwin-50e2a63b04bdd018484605fbb954fd1bd5147fa0.tar.xz) = 002a48a7b689a81abbf16161bcaec001a842e67dfbe372e9e109092703bfc666675f16198f60ca429370e8850d564547dc505df81bc3aaca4ce6defbc014ad6c
SHA512 (nvptx-tools-5f6f343a302d620b0868edab376c00b15741e39e.tar.xz) = f6d10db94fa1570ae0f94df073fa3c73c8e5ee16d59070b53d94f7db0de8a031bc44d7f3f1852533da04b625ce758e022263855ed43cfc6867e0708d001e53c7
diff --git a/update-gcc.sh b/update-gcc.sh
index 5b0572c..d34d6ce 100755
--- a/update-gcc.sh
+++ b/update-gcc.sh
@@ -3,5 +3,5 @@
git clone --depth 1 git://gcc.gnu.org/git/gcc.git gcc-dir.tmp
git --git-dir=gcc-dir.tmp/.git fetch --depth 1 origin $1
d=`date --iso | sed 's/-//g'`
-git --git-dir=gcc-dir.tmp/.git archive --prefix=gcc-12.1.1-$d/ $1 | xz -9e > gcc-12.1.1-$d.tar.xz
+git --git-dir=gcc-dir.tmp/.git archive --prefix=gcc-12.2.1-$d/ $1 | xz -9e > gcc-12.2.1-$d.tar.xz
rm -rf gcc-dir.tmp