From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 191FF3858414; Mon, 28 Nov 2022 17:26:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 191FF3858414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669656416; bh=o0E07BD8q8bYRz+TePb7ZFDgDOd8UPc8sp4i6qqf58c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=A1zSGYdCSuj+aCl/NItJDTlBlkEXGWaAk0qrP+Lfj88SEIntkGzcCipipYbY9Ef2M hbd+UzyIJUPhfRc3UAHHcg98tzIE/+AhuGYc/lkbG/8p6dZVKFn9Fq8s8veD+DJB9X DAtvRyPBig6cNcM8IyuDLmPsOZ4pSeaRjPNfumco= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107888] [12/13 Regression] Missed min/max transformation in phiopt due to VRP Date: Mon, 28 Nov 2022 17:26:55 +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: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal 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: 12.3 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=3D107888 --- Comment #2 from Andrew Pinski --- (In reply to Richard Biener from comment #1) > which means we fail to optimize a > b ? 1 : b as well, no? Yes that is correct. Even for max, "a >=3D b ? a : 6;" would need to be "reverted" 6 back to b. [local count: 1073741824]: if (ab_2(D) >=3D bb_3(D)) goto ; [65.00%] else goto ; [35.00%] [local count: 697932184]: [local count: 1073741824]: # c_1 =3D PHI The min/max patterns inside match needs to handle CST if the ranges of the = two operands overlap with one/two values. Even though this is a regression, I don't know if this shows up in real code and is a small optimization really so I would suspect a P4 for this really = as it requires a bigger change that most likely won't be backported. I filed i= t as it was showing up while I was working on the patch for PR 101805 (which won= 't be submitted until GCC 14 anyways).=