From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3D3C33858C74; Mon, 3 Oct 2022 19:40:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D3C33858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664826006; bh=3a+50FTT9hp3bmvydVv/s5I6y4MHPaWPl4pCo3JR7Qo=; h=From:To:Subject:Date:From; b=ictxK3evc78nzBamU8cGSUPitcZhfahXfSAxrmyFdBTWMvayKC91iPzX3RejEmZ8m AGMAENCdKMLTJ+VGvPoS5Bmm3f+tq+JizSs+G8Zwk4pNbq0EZLje7ol7vJb/sjiRym l8gYU/5DVk0flkUfH5vbaaZR/BpA/Lr/XlD25nrQ= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107137] New: (unsigned)-(int)(bool_var) should be optimized to -(unsigned)bool_var Date: Mon, 03 Oct 2022 19:40:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 Bug ID: 107137 Summary: (unsigned)-(int)(bool_var) should be optimized to -(unsigned)bool_var Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` unsigned f(_Bool a) { int t =3D a; t =3D -t; return t; } ``` Currently we get: ``` t_2 =3D (int) a_1(D); t_3 =3D -t_2; _4 =3D (unsigned int) t_3; ``` But we can do better than that with just: ``` _ =3D (unsigned int) a_1(D); _4 =3D -_; ``` Noticed that while looking into https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107131. Note even bool_var could be an unsigned type or a type which whos size is bigger than the outer type really.=