From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 498283858422; Thu, 18 Nov 2021 17:08:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 498283858422 From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103266] [12 regression] llvm-13 miscompilation: __builtin_assume_aligned causes over-aggressive dce Date: Thu, 18 Nov 2021 17:08:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: hubicka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 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, 18 Nov 2021 17:08:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103266 --- Comment #7 from Jan Hubicka --- I am testing diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c index c94f0589d44..e5d2b11025a 100644 --- a/gcc/ipa-modref.c +++ b/gcc/ipa-modref.c @@ -2033,10 +2033,7 @@ modref_eaf_analysis::merge_call_lhs_flags (gcall *ca= ll, int arg, bool indirect) { int index =3D SSA_NAME_VERSION (name); - - /* If value is not returned at all, do nothing. */ - if (!direct && !indirect) - return; + bool returned_directly =3D false; /* If there is no return value, no flags are affected. */ if (!gimple_call_lhs (call)) @@ -2047,10 +2044,23 @@ modref_eaf_analysis::merge_call_lhs_flags (gcall *c= all, int arg, if (arg >=3D 0) { int flags =3D gimple_call_return_flags (call); - if ((flags & ERF_RETURNS_ARG) - && (flags & ERF_RETURN_ARG_MASK) !=3D arg) - return; + if (flags & ERF_RETURNS_ARG) + { + if ((flags & ERF_RETURN_ARG_MASK) =3D=3D arg) + returned_directly =3D true; + else + return; + } + } + /* Make ERF_RETURNS_ARG overwrite EAF_UNUSED. */ + if (returned_directly) + { + direct =3D true; + indirect =3D false; } + /* If value is not returned at all, do nothing. */ + else if (!direct && !indirect) + return; /* If return value is SSA name determine its flags. */ if (TREE_CODE (gimple_call_lhs (call)) =3D=3D SSA_NAME) @@ -2273,11 +2283,13 @@ modref_eaf_analysis::analyze_ssa_name (tree name) if (gimple_call_arg (call, i) =3D=3D name) { int call_flags =3D gimple_call_arg_flags (call, i); - if (!ignore_retval && !(call_flags & EAF_UNUSED)) + if (!ignore_retval) merge_call_lhs_flags (call, i, name, - !(call_flags & EAF_NOT_RETURNED_DIRECTLY), - !(call_flags & EAF_NOT_RETURNED_INDIRECTLY)); + !(call_flags & (EAF_NOT_RETURNED_DIRECTLY + | EAF_UNUSED)), + !(call_flags & (EAF_NOT_RETURNED_INDIRECTLY + | EAF_UNUSED))); if (!(ecf_flags & (ECF_CONST | ECF_NOVOPS))) { call_flags =3D callee_to_caller_flags=