From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 78E82385DC10; Thu, 9 Apr 2020 22:28:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78E82385DC10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586471332; bh=NmLRNzwDZKPwSdeoKLAr1CFn3AcCJl8fAb1ISGNpZEM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OuVB5/Vizz1+qVTMw/uvJ5MZsPPibktbaXCIORzJE5/ufQJGfAr4uHvwTyI8uk5Nz PUYQQk7C18wFp/PIQjn5W7cm2heqS7d3f9K8v+P/lznDYOlQLGu0tT/LlazAKtsEQa Aae1pQycGkPYJ8GW4xoWh7Dazw6/D98Sl1DTCN+o= From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/94541] [8/9/10 Regression] -mx32 gcc produces wrong code passing structs by value Date: Thu, 09 Apr 2020 22:28:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: Thu, 09 Apr 2020 22:28:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94541 --- Comment #12 from H.J. Lu --- (In reply to Andrew Pinski from comment #11) > (In reply to H.J. Lu from comment #10) > > (In reply to Andrew Pinski from comment #8) > > > (In reply to H.J. Lu from comment #7) > > > > After 284r.ira: > > >=20 > > > That is fine according to the rules as long as TARGET_TRULY_NOOP_TRUN= CATION=20 > > > is true. > >=20 > > We can't turn > >=20 > > (insn 13 12 14 3 (set (reg:SI 4 si) > > (subreg:SI (reg/v:DI 85 [ b ]) 0)) "y.i":14:14 67 {*movsi_inter= nal} > > (expr_list:REG_DEAD (reg/v:DI 85 [ b ]) > > (nil))) > >=20 > > into > >=20 > >=20 > > (insn 13 12 14 3 (set (reg:SI 4 si) > > (reg:SI 4 si [orig:85 b ] [85])) "y.i":14:14 67 {*movsi_interna= l} > > (expr_list:REG_DEAD (reg/v:DI 4 si [orig:85 b ] [85]) > > (nil))) > >=20 > > This is simple wrong. >=20 > How is that wrong? What register was 85 assigned to? 4? > Then is fully correct as TARGET_TRULY_NOOP_TRUNCATION is true for those > sizes.=20=20 >=20 > On MIPS, TARGET_TRULY_NOOP_TRUNCATION is false for SI/DI truncation. > You need TARGET_TRULY_NOOP_TRUNCATION to be false for those sizes and you > get a truncate RTL instead of the subreg. subreg means the upper bits of > the register are undefined. In this case, upper bits in 85 are undefined: (insn 13 12 14 3 (set (reg:SI 4 si) (subreg:SI (reg/v:DI 4 si [orig:85 b ] [85]) 0)) "y.i":14:14 67 {*movsi_internal} (expr_list:REG_DEAD (reg/v:DI 4 si [orig:85 b ] [85]) (nil))) LRA has: for (i =3D id->insn_static_data->n_operands - 1; i >=3D 0; i--) if ((DEBUG_INSN_P (insn) || ! static_id->operand[i].is_operator) && alter_subregs (id->operand_loc[i], ! DEBUG_INSN_P (insn)= )) { lra_update_dup (id, i); insn_change_p =3D true; } if (insn_change_p) lra_update_operator_dups (id); if ((set =3D single_set (insn)) !=3D NULL && REG_P (SET_SRC (set)) && REG_P (SET_DEST (set)) && REGNO (SET_SRC (set)) =3D=3D REGNO (SET_DEST (set))) { /* Remove an useless move insn. IRA can generate move insns involving pseudos. It is better remove them earlier to speed up compiler a bit. It is also better to do it here as they might not pass final RTL check in LRA, (e.g. insn moving a control register into itself). */ lra_invalidate_insn_data (insn); delete_insn (insn); } But (insn 13 12 14 3 (set (reg:SI 4 si) (subreg:SI (reg/v:DI 4 si [orig:85 b ] [85]) 0)) "y.i":14:14 67 {*movsi_internal} (expr_list:REG_DEAD (reg/v:DI 4 si [orig:85 b ] [85]) (nil))) isn't useless and shouldn't be removed.=