public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/103509] New: ((-1u >> t) & b) != 0 is not optimized to b != 0
@ 2021-11-30 23:35 pinskia at gcc dot gnu.org
  2021-11-30 23:43 ` [Bug tree-optimization/103509] " navidrahimi at microsoft dot com
  0 siblings, 1 reply; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-30 23:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103509
           Summary: ((-1u >> t) & b) != 0 is not optimized to b != 0
           Product: gcc
           Version: 12.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:
bool f1(bool a, int t)
{
    unsigned tt = -1;
    tt >>= t;
    return (a&tt) != 0;
}

bool f2(bool a, int t)
{
    unsigned tt = -1;
    tt >>= t;
    return (tt) != 0;
}
As shown by the above, we know that (-1u>>t)!=0 is always true Therefore we
should be able to optimize f1 to just a!=0

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

* [Bug tree-optimization/103509] ((-1u >> t) & b) != 0 is not optimized to b != 0
  2021-11-30 23:35 [Bug tree-optimization/103509] New: ((-1u >> t) & b) != 0 is not optimized to b != 0 pinskia at gcc dot gnu.org
@ 2021-11-30 23:43 ` navidrahimi at microsoft dot com
  0 siblings, 0 replies; 2+ messages in thread
From: navidrahimi at microsoft dot com @ 2021-11-30 23:43 UTC (permalink / raw)
  To: gcc-bugs

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

Navid Rahimi <navidrahimi at microsoft dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |navidrahimi at microsoft dot com

--- Comment #1 from Navid Rahimi <navidrahimi at microsoft dot com> ---
Thanks Andrew. How about we close [1] in favor of this, to make sure we have
only single place to track this issue. Previous discussion about this was here
[2].

1) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98956
2) https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585783.html

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

end of thread, other threads:[~2021-11-30 23:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 23:35 [Bug tree-optimization/103509] New: ((-1u >> t) & b) != 0 is not optimized to b != 0 pinskia at gcc dot gnu.org
2021-11-30 23:43 ` [Bug tree-optimization/103509] " navidrahimi at microsoft dot com

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