From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 46F9839A183E; Fri, 6 Aug 2021 13:59:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 46F9839A183E From: "stefansf at linux dot ibm.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/101260] [10/11/12 Regression] Backport 27381e78925 to GCC 11 Date: Fri, 06 Aug 2021 13:59:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: stefansf at linux dot ibm.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2021 13:59:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101260 --- Comment #10 from Stefan Schulze Frielinghaus --- In regcprop we call find_oldest_value_reg which itself calls maybe_mode_change (TImode, TImode, DImode, 10, 18) where we have regno +=3D subreg_regno_offset (regno, orig_mode, offset, new_mode); The call is made where offset equals 8 which is wrong since we are interest= ed in the high part which is contained in r10 and not r11. The following patch fixes this: diff --git a/gcc/regcprop.c b/gcc/regcprop.c index d2a01130fe1..0e1ac12458a 100644 --- a/gcc/regcprop.c +++ b/gcc/regcprop.c @@ -414,9 +414,14 @@ maybe_mode_change (machine_mode orig_mode, machine_mode copy_mode, copy_nregs, &bytes_per_reg)) return NULL_RTX; poly_uint64 copy_offset =3D bytes_per_reg * (copy_nregs - use_nregs); - poly_uint64 offset - =3D subreg_size_lowpart_offset (GET_MODE_SIZE (new_mode) + copy_off= set, - GET_MODE_SIZE (orig_mode)); + poly_uint64 offset =3D +#if WORDS_BIG_ENDIAN + subreg_size_highpart_offset +#else + subreg_size_lowpart_offset +#endif + (GET_MODE_SIZE (new_mode) + copy_offset, + GET_MODE_SIZE (orig_mode)); regno +=3D subreg_regno_offset (regno, orig_mode, offset, new_mode); if (targetm.hard_regno_mode_ok (regno, new_mode)) return gen_raw_REG (new_mode, regno); With the patch (insn 234 222 235 14 (set (reg:DI 10 %r10 [ a ]) (reg:DI 18 %f4)) 1376 {*movdi_64} (nil)) is first modified into a noop (insn 234 222 235 14 (set (reg:DI 10 %r10 [ a ]) (reg:DI 10 %r10 [18])) 1376 {*movdi_64} (nil)) and then deleted within regcprop.=