From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4E2DE3858409; Tue, 28 Nov 2023 23:01:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E2DE3858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701212462; bh=1uj7G0k4s2SUbvW9gtGuKxy+tOEJBD2JwNb8Z1/qZBU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XjO1lGQCSl/VGYPoojN+scivRjO7lPOf3ME8Qe3GIkg5NbKC06SVM80TnbYdOV6Rw 87JHI7cUGk+F7RBRdNEa/Uu6NLJJTFZ1k2t9+IJhVS1GMFDXwjM0DFrgo9sMHnRINZ ie34HQwTh973Utj92hYOh7opx3OF8FRTnjpqbxkw= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112752] `~a - MIN, ~c>` is not optimized to `MAX,c> - a` Date: Tue, 28 Nov 2023 23:01:02 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement 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: --- 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=3D112752 --- Comment #2 from Andrew Pinski --- Here is a semi-reduced testcase: ``` #define byte unsigned char #define MIN(a, b) ((a) > (b)?(b):(a)) byte hh(byte r, byte g, byte b) { byte c =3D 255 - r; byte m =3D 255 - g; byte y =3D 255 - b; byte tmp =3D MIN(m, y); byte k =3D MIN(c, tmp); return m - k; } ``` Note matching this directly, the above might not fix the original testcase.=