public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110262] New: `t < 0 ? 1 : min(t, 1)` is not simplified down to just `t != 0`
@ 2023-06-15  3:18 pinskia at gcc dot gnu.org
  2023-11-12 21:48 ` [Bug tree-optimization/110262] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-15  3:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110262
           Summary: `t < 0 ? 1 : min(t, 1)` is not simplified down to just
                    `t != 0`
           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 g(int min_need_stall)
{
  return  min_need_stall < 0 ? 1 : ((min_need_stall) < (1) ? (min_need_stall) :
(1));
}
```
This should just be the same as `min_need_stall != 0` but currently is not.

Yes this code does shows up in real code, it is from sel-sched.cc:
          min_need_stall = min_need_stall < 0 ? 1 : MIN (min_need_stall, 1);

Note we currently miscompile it but that is due to PR 110252 (which I have a
fix).

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

* [Bug tree-optimization/110262] `t < 0 ? 1 : min(t, 1)` is not simplified down to just `t != 0`
  2023-06-15  3:18 [Bug tree-optimization/110262] New: `t < 0 ? 1 : min(t, 1)` is not simplified down to just `t != 0` pinskia at gcc dot gnu.org
@ 2023-11-12 21:48 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-12 21:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=104296
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2023-11-12
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So basically:
min(t, 1) -> `t != 0` if we know at this point t is nonnegative ...
and that is how it gets simplified.

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

end of thread, other threads:[~2023-11-12 21:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-15  3:18 [Bug tree-optimization/110262] New: `t < 0 ? 1 : min(t, 1)` is not simplified down to just `t != 0` pinskia at gcc dot gnu.org
2023-11-12 21:48 ` [Bug tree-optimization/110262] " 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).