From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C1352385B832; Mon, 6 Apr 2020 08:44:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1352385B832 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586162678; bh=J8kdrvIkAfymfE30Jlo0F+2N9FpUjyU33HWTCCLyl6U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cbXkL2RwZodJhVT8ZTOBwBM2BVHTUuz2ILPBkE2d49C7hEKPWVpxVnhTfXj/RTuHz R2RCwD+/MM+oNR+QWeC+q2fjr4H7snMLb75YJx6RYsb+nUw//rPtV4lktIk0bnPLld lOPpA3hPAKWdTJtmcLXvlfvU1zkRuhQbiePRtAsE= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/94482] [8/9/10 Regression] Inserting into vector with optimization enabled on x86 generates incorrect result Date: Mon, 06 Apr 2020 08:44:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 9.3.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org 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: 8.5 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: Mon, 06 Apr 2020 08:44:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94482 --- Comment #17 from Richard Biener --- This: if (write) { gassign *stmt; if (access->grp_partial_lhs) ref =3D force_gimple_operand_gsi (gsi, ref, true, NULL_TREE, false, GSI_NEW_STMT); stmt =3D gimple_build_assign (repl, ref); gimple_set_location (stmt, loc); gsi_insert_after (gsi, stmt, GSI_NEW_STMT); is definitely wrong. And in the else case grp_partial_lhs is never true. The whole bfr path looks fisy, too. The following fixes the testcase: diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index b2056b58750..e16b641c9bb 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -3737,36 +3737,8 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *g= si, bool write) type conversion (see PR42196) and when scalarized unions are invo= lved in assembler statements (see PR42398). */ if (!useless_type_conversion_p (type, access->type)) - { - tree ref; - - ref =3D build_ref_for_model (loc, orig_expr, 0, access, gsi, fals= e); - - if (write) - { - gassign *stmt; - - if (access->grp_partial_lhs) - ref =3D force_gimple_operand_gsi (gsi, ref, true, NULL_TREE, - false, GSI_NEW_STMT); - stmt =3D gimple_build_assign (repl, ref); - gimple_set_location (stmt, loc); - gsi_insert_after (gsi, stmt, GSI_NEW_STMT); - } - else - { - gassign *stmt; - - if (access->grp_partial_lhs) - repl =3D force_gimple_operand_gsi (gsi, repl, true, NULL_TR= EE, - true, GSI_SAME_STMT); - stmt =3D gimple_build_assign (ref, repl); - gimple_set_location (stmt, loc); - gsi_insert_before (gsi, stmt, GSI_SAME_STMT); - } - } - else - *expr =3D repl; + repl =3D build1 (VIEW_CONVERT_EXPR, type, repl); + *expr =3D repl; sra_stats.exprs++; } else if (write && access->grp_to_be_debug_replaced)=