From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5457E3858C52; Fri, 9 Jun 2023 15:25:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5457E3858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686324312; bh=GcPYGe0BXGyLvrA+XS1n46q2K6IzRO5mDVu0e3fPigE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WerbHDE/m11Ad6VF/GJNB7dROfWYbw6cywEcde8BmAP8zB3K/2CuogQ91tHBv7TQB ijjzhbWxQu5lJhIx1EdhQ298Q684dVR3eBrVU9hO0Y/dauhg0HFOv08++YG9VgfICY HBRWRe9lf45d2KqARh5vyyIjc3nNqxzOcQbZRdWM= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/95906] Failure to recognize max pattern with mask Date: Fri, 09 Jun 2023 15:25:11 +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: 11.0 X-Bugzilla-Keywords: easyhack, missed-optimization 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: bug_status assigned_to 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=3D95906 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot = gnu.org --- Comment #4 from Andrew Pinski --- For the scalar we have: _1 =3D a_5(D) > b_6(D); _9 =3D _2 + -1; _4 =3D b_6(D) & _9; Where _2 is zero_one_valued_p. So we could match that: /* ((m1 CMP m2) + -1) & d -> (m1 CMP m2) ? 0 : d */ (simplify (bit_and:c (plus (convert (cmp@0 @1 @2)) integer_minus_onep) @3) (if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (@0))) (cond @0 { build_zero_cst (type); } @3))) Like we do already for `(-(m1 CMP m2)) & d -> (m1 CMP m2) ? d : 0`. This should get us: _3 =3D _1 ? a_5(D) : 0; _4 =3D _1 ? 0 : b_6(D); _7 =3D _3 | _4; Which then can be reduced to: _7 =3D _1 ? a_5(D) : b_6(D) via (maybe a new pattern): (simplify (bit_ior:c (cond @0 @1 integer_zerop) (cond @0 integer_zerop @2)) (cond @0 @1 @2)) Which then will match. Let me see if I can implement the above.=