https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114712
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.