public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xxs_chy at outlook dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-114712-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2024-04-13 18:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-13 18:19 xxs_chy at outlook dot com [this message]
2024-04-13 18:25 ` [Bug tree-optimization/114712] " pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-114712-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).