public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/115555] New: [Ranger] deduce 'a >= 0' from  'b << a'
@ 2024-06-20  7:50 burnus at gcc dot gnu.org
  2024-06-20 16:06 ` [Bug middle-end/115555] " pinskia at gcc dot gnu.org
  2024-06-20 16:07 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2024-06-20  7:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115555
           Summary: [Ranger] deduce 'a >= 0' from  'b << a'
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: aldyh at gcc dot gnu.org
  Target Milestone: ---

Stumbled over this when looking at PR 115551.

C has for the bitwise shift operators:

"If the value of the right operand is negative or is greater than or equal to
the
width of the promoted left operand, the behavior is undefined."

Thus, it seems as if the ranger should be able to deduce 'a >= 0' in the
following, such that both conditions can be optimized away:

int f (int a, float *b) {
   *b = a >= 0 ? 1.0 : 2.0;
   int mask1 = 1U << a;  // 'a' must be >= 0 → '*b=1.0' above and 'return -1'
below
   if (a >= 0)
     return -1;
   return mask1;
}

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

* [Bug middle-end/115555] [Ranger] deduce 'a >= 0' from  'b << a'
  2024-06-20  7:50 [Bug middle-end/115555] New: [Ranger] deduce 'a >= 0' from 'b << a' burnus at gcc dot gnu.org
@ 2024-06-20 16:06 ` pinskia at gcc dot gnu.org
  2024-06-20 16:07 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-20 16:06 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this might be a dup.

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

* [Bug middle-end/115555] [Ranger] deduce 'a >= 0' from  'b << a'
  2024-06-20  7:50 [Bug middle-end/115555] New: [Ranger] deduce 'a >= 0' from 'b << a' burnus at gcc dot gnu.org
  2024-06-20 16:06 ` [Bug middle-end/115555] " pinskia at gcc dot gnu.org
@ 2024-06-20 16:07 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-06-20 16:07 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yes it is a dup.

*** This bug has been marked as a duplicate of bug 31178 ***

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

end of thread, other threads:[~2024-06-20 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-20  7:50 [Bug middle-end/115555] New: [Ranger] deduce 'a >= 0' from 'b << a' burnus at gcc dot gnu.org
2024-06-20 16:06 ` [Bug middle-end/115555] " pinskia at gcc dot gnu.org
2024-06-20 16:07 ` 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).