From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 93EB73858D3C; Mon, 24 Apr 2023 19:06:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93EB73858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682363213; bh=PTl51e27xO9+PC8cSth1r6muRM/Vc/YtAGzc+c7UpCE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XeK0pofDVqyXm/g3CtJcs3HtD1kvMJzubKm0muJLgW+E1xf31Yyw+M71Gkh7cAto4 4g4Xf6ZHvjGWvoFXkpqpJrEpAmeUlLptOYHBG0VPw9hwnsANBXpJQpXB4UYfuuPUdD q723a0fMgEmUq7QoDeQFHbN5yae4sWr3fBg831lk= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/68894] Recognition min/max pattern with multiple arguments. Date: Mon, 24 Apr 2023 19:06:53 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: missed-optimization, TREE X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D68894 --- Comment #12 from Andrew Pinski --- Just a quick note on this part of the bug report: (In reply to Richard Biener from comment #3) > Doing this in a classical way in phi-opt might end up being slightly > convoluted. > So I'd propose to try to utilize match-and-simplify by adding >=20 >=20 > (cond (ge @0 @1) (max:s @0 @2) (max:s @1 @2)) > -> (max (max @0 @1) @2) I am going to submit patches for the above later today or tomorrow. >=20 > kind patterns and from phiopt doing exploded queries of this simplificati= on > by seeding the cond expr from the dominating condition plus the PHI opera= nds. >=20 > res =3D gimple_simplify (COND_EXPR, build2 /* Ick */ (cond-code, > boolean_type, cond-op0, cond-op1), true-phi-arg, false-phi-arg, &seq, > follow_single_use_edges); >=20 > of course you need more than a single pattern or consider swapped ops 2 a= nd 3 > (not yet supported). In the end explicit pattern explosion might make a > manual > implementation in phiopt easier (who knows). This part is fully implemented in r14-204-gf1f5cbaa3f716fcb472dee5 (there w= as a few pieces of the match-and-simplify phiopt implemented in GCC 12).=20 Note phiopt already does "a ? b : c" -> "!a ? c : b" (where !a folds) (implemented in r12-2040-ga50cecb20a10) specifically because of the explosi= on issue.=