public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114711] New: Missed optimization: fold load of global constant array if there is obivous pattern
@ 2024-04-13 17:42 xxs_chy at outlook dot com
  2024-04-13 17:48 ` [Bug tree-optimization/114711] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: xxs_chy at outlook dot com @ 2024-04-13 17:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114711
           Summary: Missed optimization: fold load of global constant
                    array if there is obivous pattern
           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/MMxoGaj9T

```
static char* const names[3] = {"abc", "cdf", "dsadsa"};
char** const id2name[3] = {names, names + 1, names + 2};

void* src(size_t idx){
    return id2name[idx];
}

```

can be folded to:

```
static char* const names[3] = {"abc", "cdf", "dsadsa"};
void* tgt(size_t idx){
    return names + idx;
}
```

This is a real pattern from openssl.

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

end of thread, other threads:[~2024-04-15  8:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-13 17:42 [Bug tree-optimization/114711] New: Missed optimization: fold load of global constant array if there is obivous pattern xxs_chy at outlook dot com
2024-04-13 17:48 ` [Bug tree-optimization/114711] " pinskia at gcc dot gnu.org
2024-04-13 17:50 ` pinskia at gcc dot gnu.org
2024-04-13 17:57 ` xxs_chy at outlook dot com
2024-04-15  8:15 ` 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).