public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111766] New: Missed optimization with __builtin_unreachable and ands
@ 2023-10-11  1:55 pinskia at gcc dot gnu.org
  2023-10-11 14:00 ` [Bug tree-optimization/111766] " amacleod at redhat dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-11  1:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111766
           Summary: Missed optimization with __builtin_unreachable and
                    ands
           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:
```
int
foo3n(int c, int bb)
{
  if ((bb & ~3)!=0) __builtin_unreachable(); // bb = [0,3]
  if ((bb & 1)==0) __builtin_unreachable(); // bb&1 == 0 // [0],[3]
  if(bb == 2) __builtin_trap();
  return bb;
}
```

The condition `bb == 2` is never true as (bb&1) has to be zero.

I Noticed this while looking into PR 111432.  Note clang/LLVM is able to
optimize this ...

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

end of thread, other threads:[~2023-11-03 17:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-11  1:55 [Bug tree-optimization/111766] New: Missed optimization with __builtin_unreachable and ands pinskia at gcc dot gnu.org
2023-10-11 14:00 ` [Bug tree-optimization/111766] " amacleod at redhat dot com
2023-11-03 17:14 ` cvs-commit at gcc dot gnu.org
2023-11-03 17:15 ` amacleod at redhat dot com
2023-11-03 17:15 ` amacleod at redhat dot com
2023-11-03 17:29 ` sjames 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).