From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 057E0385842D; Sat, 13 Apr 2024 18:19:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 057E0385842D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713032365; bh=KdWRqcEXW+0/nSMzjkF/gd01Jbir6YWJi9Hqc68Fe50=; h=From:To:Subject:Date:From; b=BY6ZMDtcrw5F8bNqodzwWSO/oVclZYaAbA2NkSpFIWSnhj6JJ83AbJBbwj/1+4bR+ TmxY0CSjeY0VrC+M1M9Uacde/fbpGjaJ8IN3XGtOLnHgfWIOWNFqh9nn/cuf0AXNDq CndjTpuGYsLj2WwiYUY9znWvCLh3bXDv0LSTf3Vw= From: "xxs_chy at outlook dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114712] New: Missed optimization: simplify if-else basic blocks that share common destinations Date: Sat, 13 Apr 2024 18:19:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xxs_chy at outlook dot com X-Bugzilla-Status: UNCONFIRMED 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_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D114712 Bug ID: 114712 Summary: Missed optimization: simplify if-else basic blocks that share common destinations Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: xxs_chy at outlook dot com Target Milestone: --- Godbolt link: https://godbolt.org/z/hY6Eaj8fj ``` void dummy(); void dummy1(); void src(bool c1, bool c2){ if(c1) { if(c2) goto bb1; else goto bb2; } else { if(c2) goto bb2; else goto bb1; } bb1: dummy(); return; bb2: dummy1(); return; } ``` can be folded to: ``` void tgt(bool c1, bool c2){ if (c1 ^ c2) { dummy1(); } else { dummy(); } } ``` It saves unnecessary branches.=