From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5C18A3858D37; Fri, 1 Sep 2023 16:26:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C18A3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693585598; bh=pKMtw+2slvLHOoweAX5WnmSOeSsbPgvAK+9G9EnXySc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MwyLIq8dAYIlVQ0TYpKBY0L1VJdJsUqtlXIbKuHjezkVLSjfgZlcp7tmQFjiTUYMr hbTwhCTf4y09JM96wj6j326o5WJcyqVEXKbbtfh7CCGDFBTv4XTTdWxCQtn9WwZNHs tu2T557o1MGP0Qmamdxk3i/9BC6ucaY010ghodLg= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107137] (unsigned)-(int)(bool_var) should be optimized to -(unsigned)bool_var Date: Fri, 01 Sep 2023 16:26:37 +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, patch 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=3D107137 --- Comment #4 from Andrew Pinski --- Solving this one is easier, just going with: /* (nop_outer_cast)-(inner_cast)var -> -(outer_cast)(var) if var is smaller in precision. */ (simplify (convert (negate:s@1 (convert:s @0))) (if (INTEGRAL_TYPE_P (type) && tree_nop_conversion_p (type, TREE_TYPE (@1)) && TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (@0))) (negate (convert @0))))=