From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1599C3858D28; Sun, 9 Apr 2023 23:50:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1599C3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681084215; bh=80ZJ7LBiNcKU7HJW51Y27HRuzn2XrTmzm9be2929Dsk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IGtLwNDW4I8xAwMA/tAf60gS3cHgtyUW5F6kFPo0qW1EhFjrVujRygbKrqOs6OCXK Fw91Hy6L3+HmJTLx9m8wFGWnarNQq0wAoZGcn37EoRkNiprvuSG0bzTRQTHDHqRyj4 8pbsLHpu4Dgvpi6iY0YgqyNhmYgih238FEt1GbiY= 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: Sun, 09 Apr 2023 23:50:14 +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 #8 from Andrew Pinski --- (In reply to Andrew Pinski from comment #7) > Mine, working on improving phi-opt here; though the hoisting of the load = is > something which needs to be looked into further. >=20 > I have the match.pd pattern for what is mentioned in comment #3: > /* These was part of minmax phiopt. */ > /* Optimize (a CMP b) ? minmax : minmax > to minmax, c> */ > (for minmax (min max) > (for cmp (lt le gt ge) > (simplify > (cond (cmp @1 @3) (minmax:c @1 @4) (minmax:c @2 @4)) > (with > { > tree_code code =3D minmax_from_comparison (cmp, @1, @2, @1, @3); > } > (if (code =3D=3D MIN_EXPR) > (minmax (min @1 @2) @4) > (if (code =3D=3D MAX_EXPR) > (minmax (max @1 @2) @4))))))) >=20 > I also have the improvements to match_simplify_replacement which are need= ed > to use those patterns too. I will be submitting them for GCC 14. Note these patterns are enough for the ifcvt pass for the vectorizer to generate: pretmp_24 =3D a3D.2740[i_20]; _35 =3D MIN_EXPR <_1, _2>; d_9 =3D MIN_EXPR ; Rather than the current: d_14 =3D MIN_EXPR <_1, pretmp_24>; _23 =3D _1 < _2; d_13 =3D MIN_EXPR <_2, pretmp_24>; d_9 =3D _23 ? d_14 : d_13;=