public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114047] New: `(cast)(cast)a != a` for large unsigned _BitInt should be produce better code
@ 2024-02-22  8:49 pinskia at gcc dot gnu.org
  2024-02-22  9:23 ` [Bug tree-optimization/114047] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-22  8:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114047
           Summary: `(cast)(cast)a != a` for large unsigned _BitInt should
                    be produce better code
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
unsigned
foo (unsigned _BitInt(512) ub512_0)
{
  unsigned _BitInt(255) t;
  return __builtin_sub_overflow (ub512_0, 0, &t);
}

unsigned
foo1 (unsigned _BitInt(512) ub512_0)
{
  unsigned _BitInt(255) t = ub512_0;
  return t != ub512_0;
}
```

Currently foo produces decent code but foo1 does not even though they are
equivalent.

Noticed while looking into PR 114040.

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

* [Bug tree-optimization/114047] `(cast)(cast)a != a` for large unsigned _BitInt should be produce better code
  2024-02-22  8:49 [Bug tree-optimization/114047] New: `(cast)(cast)a != a` for large unsigned _BitInt should be produce better code pinskia at gcc dot gnu.org
@ 2024-02-22  9:23 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-22  9:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note there is a generic (non _BitInt) issue with __builtin_sub_overflow  vs the
other comparison too; on some targets using a bit mask is better while on
others using the `<=` test is better.

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

end of thread, other threads:[~2024-02-22  9:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-22  8:49 [Bug tree-optimization/114047] New: `(cast)(cast)a != a` for large unsigned _BitInt should be produce better code pinskia at gcc dot gnu.org
2024-02-22  9:23 ` [Bug tree-optimization/114047] " pinskia 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).