public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/101024] New: Missed min expression at phiopt1
@ 2021-06-11  4:00 pinskia at gcc dot gnu.org
  2021-06-11  4:01 ` [Bug tree-optimization/101024] " pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-11  4:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101024
           Summary: Missed min expression at phiopt1
           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:
unsigned f(int nunits)
{
  int units_per = 32 / (8);


  unsigned int chunk_nunits = ((nunits) < (units_per) ? (nunits) :
(units_per));
  return chunk_nunits;
}
-------- CUT ------
Compile with the C++ front-end and -O2 (note C++ is needed as fold won't
convert ?: into min/max expression due to lvalue requirements).
You will notice this is not caught by phiopt1 even though it should be while it
is caught now (on the trunk) by phiopt2 (match-and-simplify).  That is the
minmax_replacement does not handle the above case but match does.

Note this shows up in read code (GCC) in assemble_real (varasm.c). There are
two cases of this in assemble_real but only one of the two is caught in phiopt2
though because there looks like some jump threading that had happened before
that causes other issues.

I am filing this as a bug only so I can keep track of moving minmax_replacement
to match-and-simplify.

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

end of thread, other threads:[~2023-06-01  2:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11  4:00 [Bug tree-optimization/101024] New: Missed min expression at phiopt1 pinskia at gcc dot gnu.org
2021-06-11  4:01 ` [Bug tree-optimization/101024] " pinskia at gcc dot gnu.org
2021-06-11 11:44 ` pinskia at gcc dot gnu.org
2021-07-06  7:28 ` pinskia at gcc dot gnu.org
2021-07-09  7:22 ` pinskia at gcc dot gnu.org
2021-07-20 21:20 ` pinskia at gcc dot gnu.org
2023-04-05 19:33 ` pinskia at gcc dot gnu.org
2023-05-07 23:44 ` pinskia at gcc dot gnu.org
2023-05-08  1:52 ` pinskia at gcc dot gnu.org
2023-05-08  2:17 ` pinskia at gcc dot gnu.org
2023-05-30 16:26 ` pinskia at gcc dot gnu.org
2023-06-01  2: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).