From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6520B384D15E; Thu, 6 Oct 2022 09:44:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6520B384D15E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665049494; bh=CrbpHNODdT5Rcbx0oJBlnTIX2kdMZn6JXexvC1OU2OU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CNTLydhsA/gtnZ2vWfMtT/zVtA1s1ZUn3tLIXdzhPo33pk8TGDWIV4G87rhzjfSrZ B957asfM2e68lG2f/nfzIbm9ev1xb07dSdZIOS2pYHvt2ScTWVBUkcRRITL1rBJsUC MI8KE0WBzt6vw7mEaH85dC3bDkBgcOQROSmskuRA= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/107115] Wrong codegen from TBAA under stores that change effective type? Date: Thu, 06 Oct 2022 09:44: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: 13.0 X-Bugzilla-Keywords: alias, 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107115 --- Comment #3 from Richard Biener --- So possibly expand_assignment is eliding the store somewhere downthread (it's operand_equal_p check shouldn't fire). It's rtx store_expr (tree exp, rtx target, int call_param_p, bool nontemporal, bool reverse) { ... if ((! rtx_equal_p (temp, target) || (temp !=3D target && (side_effects_p (temp) || side_effects_p (target)))) which doesn't fire. We have (gdb) p debug_rtx (temp) (mem:DI (reg/f:DI 87 [ _11 ]) [2 *_11+0 S8 A64]) (gdb) p debug_rtx (target) (mem:DI (reg/f:DI 87 [ _11 ]) [1 MEM[(long int *)_11]+0 S8 A64]) Note that even just matching up MEM_ALIAS_SET isn't enough. I'd call the above optimization premature at least. (gdb) p mems_same_for_tbaa_p (temp, target) $13 =3D false so diff --git a/gcc/expr.cc b/gcc/expr.cc index 80bb1b8a4c5..71a7fc19c42 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -6207,7 +6207,8 @@ store_expr (tree exp, rtx target, int call_param_p, if ((! rtx_equal_p (temp, target) || (temp !=3D target && (side_effects_p (temp) - || side_effects_p (target)))) + || side_effects_p (target) + || !mems_same_for_tbaa_p (temp, target)))) && TREE_CODE (exp) !=3D ERROR_MARK /* If store_expr stores a DECL whose DECL_RTL(exp) =3D=3D TARGET, but TARGET is not valid memory reference, TEMP will differ fixes this mistake. But then we run into the sched issue which -fno-schedule-insns2 "fixes".=