From 4a13fd07bb89ef80702ab0db50eaddce1356877a Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Wed, 27 Aug 2025 08:07:50 -0400 Subject: [PATCH] Fix ICE in rebuild_jump_labels on aarch64-linux-gnu Resolves: RHEL-106790 --- gcc.spec | 11 ++++++- gcc14-pr118892-1.patch | 39 ++++++++++++++++++++++++ gcc14-pr118892-2.patch | 67 ++++++++++++++++++++++++++++++++++++++++++ gcc14-pr118892-3.patch | 62 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 gcc14-pr118892-1.patch create mode 100644 gcc14-pr118892-2.patch create mode 100644 gcc14-pr118892-3.patch diff --git a/gcc.spec b/gcc.spec index 9a1f0dc..2614d9f 100644 --- a/gcc.spec +++ b/gcc.spec @@ -11,7 +11,7 @@ BuildRequires: scl-utils-build %global gcc_major 14 # 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 10 +%global gcc_release 11 %global nvptx_tools_gitrev 87ce9dc5999e5fca2e1d3478a30888d9864c9804 %global newlib_cygwin_gitrev d45261f62a15f8abd94a1031020b9a9f455e4eed %global isl_version 0.24 @@ -362,6 +362,9 @@ Patch3017: 0020-more-fixes.patch Patch3018: 0021-libstdc++-disable-tests.patch Patch4000: gcc14-RHEL-90244.patch +Patch4001: gcc14-pr118892-1.patch +Patch4002: gcc14-pr118892-2.patch +Patch4003: gcc14-pr118892-3.patch %if 0%{?rhel} == 9 %global nonsharedver 110 @@ -728,6 +731,9 @@ touch -r isl-0.24/m4/ax_prog_cxx_for_build.m4 isl-0.24/m4/ax_prog_cc_for_build.m # Bugfix backports. %patch -P4000 -p1 -b .RHEL-90244~ +%patch -P4001 -p1 -b .RHEL-pr118892-1~ +%patch -P4002 -p1 -b .RHEL-pr118892-2~ +%patch -P4003 -p1 -b .RHEL-pr118892-3~ find gcc/testsuite -name \*.pr96939~ | xargs rm -f @@ -2794,6 +2800,9 @@ fi %endif %changelog +* Wed Aug 27 2025 Siddhesh Poyarekar 14.2.1-11 +- Fix ICE in rebuild_jump_labels on aarch64-linux-gnu (RHEL-106790) + * Wed May 28 2025 Siddhesh Poyarekar 14.2.1-10 - Put the libstdc++ AS_NEEDED in the right places (RHEL-84679) diff --git a/gcc14-pr118892-1.patch b/gcc14-pr118892-1.patch new file mode 100644 index 0000000..f8f77fc --- /dev/null +++ b/gcc14-pr118892-1.patch @@ -0,0 +1,39 @@ +From 021ccf9dee0c14455a205f2555326e027e9047d8 Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Wed, 16 Apr 2025 13:20:25 +0100 +Subject: [PATCH] Make force_subreg emit nothing on failure + +While adding more uses of force_subreg, I realised that it should +be more careful to emit no instructions on failure. This kind of +failure should be very rare, so I don't think it's a case worth +optimising for. + +gcc/ + * explow.cc (force_subreg): Emit no instructions on failure. + +(cherry picked from commit 01044471ea39f9be4803c583ef2a946abc657f99) +--- + gcc/explow.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/gcc/explow.cc b/gcc/explow.cc +index f6843398c4b..bd93c878064 100644 +--- a/gcc/explow.cc ++++ b/gcc/explow.cc +@@ -756,8 +756,12 @@ force_subreg (machine_mode outermode, rtx op, + if (x) + return x; + ++ auto *start = get_last_insn (); + op = copy_to_mode_reg (innermode, op); +- return simplify_gen_subreg (outermode, op, innermode, byte); ++ rtx res = simplify_gen_subreg (outermode, op, innermode, byte); ++ if (!res) ++ delete_insns_since (start); ++ return res; + } + + /* If X is a memory ref, copy its contents to a new temp reg and return +-- +2.50.1 + diff --git a/gcc14-pr118892-2.patch b/gcc14-pr118892-2.patch new file mode 100644 index 0000000..a03fd5b --- /dev/null +++ b/gcc14-pr118892-2.patch @@ -0,0 +1,67 @@ +From b33e9eb8d404475a45a53afa3e3cc0ff742d75ec Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Wed, 16 Apr 2025 13:20:26 +0100 +Subject: [PATCH] Add force_lowpart_subreg + +optabs had a local function called lowpart_subreg_maybe_copy +that is very similar to the lowpart version of force_subreg. +This patch adds a force_lowpart_subreg wrapper around +force_subreg. + +The only difference between the old and new functions is that +the old one asserted success while the new one doesn't. +It's common not to assert elsewhere when taking subregs; +normally a null result is enough. + +Later patches will make more use of the new function. + +gcc/ + * explow.h (force_lowpart_subreg): Declare. + * explow.cc (force_lowpart_subreg): New function. + +(cherry picked from commit 5f40d1c0cc6ce91ef28d326b8707b3f05e6f239c) +--- + gcc/explow.cc | 14 ++++++++++++++ + gcc/explow.h | 1 + + 2 files changed, 15 insertions(+) + +diff --git a/gcc/explow.cc b/gcc/explow.cc +index bd93c878064..2a91cf76ea6 100644 +--- a/gcc/explow.cc ++++ b/gcc/explow.cc +@@ -764,6 +764,20 @@ force_subreg (machine_mode outermode, rtx op, + return res; + } + ++/* Try to return an rvalue expression for the OUTERMODE lowpart of OP, ++ which has mode INNERMODE. Allow OP to be forced into a new register ++ if necessary. ++ ++ Return null on failure. */ ++ ++rtx ++force_lowpart_subreg (machine_mode outermode, rtx op, ++ machine_mode innermode) ++{ ++ auto byte = subreg_lowpart_offset (outermode, innermode); ++ return force_subreg (outermode, op, innermode, byte); ++} ++ + /* If X is a memory ref, copy its contents to a new temp reg and return + that reg. Otherwise, return X. */ + +diff --git a/gcc/explow.h b/gcc/explow.h +index cbd1fcb7eb3..dd654649b06 100644 +--- a/gcc/explow.h ++++ b/gcc/explow.h +@@ -43,6 +43,7 @@ extern rtx copy_to_suggested_reg (rtx, rtx, machine_mode); + extern rtx force_reg (machine_mode, rtx); + + extern rtx force_subreg (machine_mode, rtx, machine_mode, poly_uint64); ++extern rtx force_lowpart_subreg (machine_mode, rtx, machine_mode); + + /* Return given rtx, copied into a new temp reg if it was in memory. */ + extern rtx force_not_mem (rtx); +-- +2.50.1 + diff --git a/gcc14-pr118892-3.patch b/gcc14-pr118892-3.patch new file mode 100644 index 0000000..e5b52de --- /dev/null +++ b/gcc14-pr118892-3.patch @@ -0,0 +1,62 @@ +From 9ce381170ed40874230db05111f8837475634e4b Mon Sep 17 00:00:00 2001 +From: Tamar Christina +Date: Mon, 28 Apr 2025 12:58:37 +0100 +Subject: [PATCH] aarch64: force operand to fresh register to avoid subreg + issues [PR118892] + +When the input is already a subreg and we try to make a paradoxical +subreg out of it for copysign this can fail if it violates the subreg +relationship. + +Use force_lowpart_subreg instead of lowpart_subreg to then force the +results to a register instead of ICEing. + +gcc/ChangeLog: + + PR target/118892 + * config/aarch64/aarch64.md (copysign3): Use + force_lowpart_subreg instead of lowpart_subreg. + +gcc/testsuite/ChangeLog: + + PR target/118892 + * gcc.target/aarch64/copysign-pr118892.c: New test. +--- + gcc/config/aarch64/aarch64.md | 2 +- + gcc/testsuite/gcc.target/aarch64/copysign-pr118892.c | 11 +++++++++++ + 2 files changed, 12 insertions(+), 1 deletion(-) + create mode 100644 gcc/testsuite/gcc.target/aarch64/copysign-pr118892.c + +diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md +index 95577b325ce..6a481059bf0 100644 +--- a/gcc/config/aarch64/aarch64.md ++++ b/gcc/config/aarch64/aarch64.md +@@ -7210,7 +7210,7 @@ (define_expand "copysign3" + + emit_insn (gen_iorv23 ( + lowpart_subreg (V2mode, operands[0], mode), +- lowpart_subreg (V2mode, operands[1], mode), ++ force_lowpart_subreg (V2mode, operands[1], mode), + v_bitmask)); + DONE; + } +diff --git a/gcc/testsuite/gcc.target/aarch64/copysign-pr118892.c b/gcc/testsuite/gcc.target/aarch64/copysign-pr118892.c +new file mode 100644 +index 00000000000..adfa30dc3e2 +--- /dev/null ++++ b/gcc/testsuite/gcc.target/aarch64/copysign-pr118892.c +@@ -0,0 +1,11 @@ ++/* { dg-do compile } */ ++/* { dg-options "-Ofast" } */ ++ ++double l(); ++double f() ++{ ++ double t6[2] = {l(), l()}; ++ double t7[2]; ++ __builtin_memcpy(&t7, &t6, sizeof(t6)); ++ return -__builtin_fabs(t7[1]); ++} +-- +2.50.1 +