From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 304A2385355B; Tue, 16 May 2023 02:55:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 304A2385355B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684205711; bh=SBc0AIMt2J93Xsn4ylYGQLTYKekOd0VVT8MJSvXONnE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vGhW+h+2XP566a79iLR+bsVdkLN0XBfnUL8ZRTl2yireStT9bmrMBNxGqhE1Wz4bJ keL4IGnyE0+JT0TWccsGDW75mPSnJbyokYlRntnhaXLEQ6lnWy6aMFdCeuYkyz0l5n Tdsnlq4Lkim8SjmRN0TyixqYY3jC0GE/xVY4kmOo= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/90087] Suboptimal codegen for x < 0 ? x - INT_MIN : x Date: Tue, 16 May 2023 02:55:10 +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: 9.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=3D90087 --- Comment #3 from Andrew Pinski --- THis way with type_min and type_max filled out correctly. (simplify (cond (lt @0 integer_zero_p) (minus @0 INTEGER_CST@1) @0) (if (TYPE_SIGNED (type) && wi::to_widest(@0) =3D=3D type_min(@0)) (bit_ior @0 { build_int_cst (type_max(type), type); } ))) Note I think TYPE_PRECISION needs to be a power of 2 but I could be wrong .= ..=