From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1BA0B3858D32; Mon, 8 May 2023 01:52:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BA0B3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683510721; bh=BNsodyIgySQV+G259rnD4IaMVzLa5xQmAPQQJSXhMWg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HmGGIfmbygvcU2iFts5ZU7s/sTnhssAn66euTZY1VczlE0SYIPxirwH+qp8Pt8OXH 5xj6bmTMisQ5q4gGhLdbDZoMJi5NgjTFZw2BtsIfgjLrz1ZVAKe8XW8MGs2gMbHUSd 52j1SdQJSRymW/InlohfdL6VfoPUoHvwfQktsspk= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101024] Missed min expression at phiopt1 Date: Mon, 08 May 2023 01:52:00 +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: 12.0 X-Bugzilla-Keywords: 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: 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=3D101024 --- Comment #8 from Andrew Pinski --- (In reply to Andrew Pinski from comment #7) > After https://gcc.gnu.org/pipermail/gcc-patches/2023-May/617758.html, the= se > are testcases that fail if we remove minmax_replacement : > FAIL: gcc.dg/tree-ssa/phi-opt-20.c scan-tree-dump-times phiopt1 "MAX_EXPR= " 2 > FAIL: gcc.dg/tree-ssa/phi-opt-20.c scan-tree-dump-times phiopt1 "MIN_EXPR= " 2 >=20 > phiopt match-simplify trying: > num_2(D) !=3D 0 ? num_2(D) : 1 > num_2(D) !=3D 4294967295 ? num_2(D) : 4294967294 > num_2(D) !=3D -2147483648 ? num_2(D) : -2147483647 > num_2(D) !=3D 2147483647 ? num_2(D) : 2147483646 >=20 > This should be reasonable to handle minmax_from_comparison and handle eq/= ne > for the cases where that is called. I have a patch which also handles when we know the range of non-constant. Like this: ``` int f(int num) { if (num < 3) __builtin_unreachable(); return num !=3D 3 ? num : 4; } ``` That should get a MAX_EXPR(num, 4);=