From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 13961384475E; Tue, 25 Jun 2024 09:41:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 13961384475E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1719308480; bh=o5SxFxXceCALHSuGAfNfhGW3tNn6e8EoRPdeNSwVX8w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CQBUwZU3SK1ix/9v6KpAkvOqTWEhrHX89Zgw1auq6i5NwmQVtkfck0DxEpk3nHzOX vPT8sPKHYfGoBfHlKaVnTHA2zL3kpCESFQqXTGTmXXjNuxNk/tE/zUsPCk1qg2c7cl N88nz3TK4Uy7bp1ajsQs6Vlf9DarGG3V+Fz7Ts2c= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115629] Inefficient if-convert of masked conditionals Date: Tue, 25 Jun 2024 09:41:17 +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: 15.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement 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: bug_status cf_reconfirmed_on everconfirmed 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=3D115629 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2024-06-25 Ever confirmed|0 |1 --- Comment #1 from Richard Biener --- I think the transform is profitable for scalar for all cases as well. Now, if-conversion records BB predicates and uses those to predicate stmts/PHIs, I'm not sure how to go optimize it on that level. It's more a CFG transform of a if (A) x; else { if (B) x; else y; } to if (A || B) x; else y; with the downside that in this case evaluating 'B' has side-effects (memory dereference which can trap). Due to the trapping this needs to be somehow done in if-conversion where you also need to determine that x =3D=3D x' (both copies of x evaluate to the same code). Some scalar GIMPLE opt could have de-duplicated the BB with 'x' (tail-merging to the rescue? it considers the cands but somehow doesn't merge - I think the PHI node isn't supported).=