public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/115034] New: Missed optimization: reduntant store of identical value in the slot
@ 2024-05-10 14:34 xxs_chy at outlook dot com
  2024-05-10 14:43 ` [Bug tree-optimization/115034] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: xxs_chy at outlook dot com @ 2024-05-10 14:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115034

            Bug ID: 115034
           Summary: Missed optimization: reduntant store of identical
                    value in the slot
           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/fdxKaxGoj

```
int src(int* outl, bool c1, bool c2) {
    int a;
    *outl = 0;
    if (c1)
        if (c2) {
            dummy();
            return 0;
        } else {
            a = 1;
        }
    else {
        // we don't need to assign a = 0
        a = 0;
    }
    *outl = a;
    return 0;
}
```

can be transformed into:

```
int tgt(int* outl, bool c1, bool c2) {
    int a;
    *outl = 0;
    if (c1) {
        if (c2) {
            dummy();
            return 0;
        } else {
            a = 1;
        }
    } else {
        return 0;
    }
    *outl = 1;
    return 0;
}
```

Because "*outl = 0" is known at the entry, the path "a = 0 -> *outl = 0" can be
cut off. That is, we can move "*outl = 1" into the path where c1 is true.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-13  9:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-10 14:34 [Bug tree-optimization/115034] New: Missed optimization: reduntant store of identical value in the slot xxs_chy at outlook dot com
2024-05-10 14:43 ` [Bug tree-optimization/115034] " pinskia at gcc dot gnu.org
2024-05-10 15:32 ` xxs_chy at outlook dot com
2024-05-13  9:33 ` rguenth at gcc dot gnu.org

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).