From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 70329385DC26; Fri, 11 Jun 2021 04:00:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70329385DC26 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101024] New: Missed min expression at phiopt1 Date: Fri, 11 Jun 2021 04:00:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jun 2021 04:00:26 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101024 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 =3D 32 / (8); unsigned int chunk_nunits =3D ((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 whil= e 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 phi= opt2 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_replace= ment to match-and-simplify.=