public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114737] New: Missed optimization : fail to optimize load with select clobber
@ 2024-04-16  7:55 xxs_chy at outlook dot com
  2024-04-16 10:47 ` [Bug tree-optimization/114737] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: xxs_chy at outlook dot com @ 2024-04-16  7:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114737
           Summary: Missed optimization : fail to optimize load with
                    select clobber
           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/3e5sfvfKj

```
char src(void** p, char* p1, bool c) {
    char* tostore1 = p1 + 1;
    char* tostore2 = p1 + 4;
    *p = tostore1;
    *p1 = 0;

    char* tostore = (c ? tostore1 : tostore2) + 1;
    *tostore = 1;
    return *p1;
}
```

"return *p1" can be optimized into "return 0" here.

```
char tgt(void** p, char* p1, bool c) {
    char* tostore1 = p1 + 1;
    char* tostore2 = p1 + 4;
    *p = tostore1;
    *p1 = 0;

    char* tostore = (c ? tostore1 : tostore2) + 1;
    *tostore = 1;
    return 0;
}
```

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

* [Bug tree-optimization/114737] Missed optimization : fail to optimize load with select clobber
  2024-04-16  7:55 [Bug tree-optimization/114737] New: Missed optimization : fail to optimize load with select clobber xxs_chy at outlook dot com
@ 2024-04-16 10:47 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-04-16 10:47 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-04-16
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |alias, missed-optimization
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  points-to analysis does not track pointer offsets for the final
points-to sets, so tostore and p1 point to the same object.  Specifically
pointer offset gathering when setting up the ao_ref for *to_store_1
doesn't look through PHIs:

  <bb 3> :
  # PT = nonlocal null
  tostore_11 = p1_2(D) + 2;
  goto <bb 5>; [INV]

  <bb 4> :
  # PT = nonlocal null
  tostore_10 = p1_2(D) + 5;

  <bb 5> :
  # PT = nonlocal null
  # tostore_1 = PHI <tostore_11(3), tostore_10(4)>
  *tostore_1 = 1;

what in this case would help a little bit is if this were

  <bb 3> :
  goto <bb 5>; [INV]

  <bb 4> :

  <bb 5> :
  # PT = nonlocal null
  # offset_3 = PHI <2(3), 5(4)>
  # PT = nonlocal null
  tostore_1 = p1_2(D) + offset_3;
  *tostore_1 = 1;

then eventually range-info for offset_3 could be used to constrain the
ao_ref.

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

end of thread, other threads:[~2024-04-16 10:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16  7:55 [Bug tree-optimization/114737] New: Missed optimization : fail to optimize load with select clobber xxs_chy at outlook dot com
2024-04-16 10:47 ` [Bug tree-optimization/114737] " 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).