From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3E78C3857400; Thu, 1 Jun 2023 03:49:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E78C3857400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685591349; bh=+EAwaGOeTX9e9G8iW+piyOqAAivC0Y2O3NPhk0uo6Z8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QYWXGt/UF6Tfqmrmk3Qr6SAfkIoh6e/YX7DUucr05lnkEhQHMc+6FVEe3ggk5cCbj cjC446opT/ToxF5Tzs6rcxzUAUHBMcxfh8gSiv+IUeVRQgN2QN6ZxAbD3yu8f32elC L/ga2Pt7See52S+d03UM+uyXcCr3zn/H+GlH3sZs= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110068] missing min detection Date: Thu, 01 Jun 2023 03:49:09 +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=3D110068 --- Comment #1 from Andrew Pinski --- here is another one: ``` unsigned f5 (unsigned x) { bool t =3D x >=3D 1U<<(sizeof(x)*8-1); if (!t) ; else x =3D 1U<<(sizeof(x)*8-1); return x; } ``` this time LLVM does not detect it either. easy way to see that out is by using riscv and -march=3Drv32gc_zba_zbb_zbc_= zbs. You should get for all 5 functions: li a5,-2147483648 minu a0,a0,a5 ret Or: lui a1, 524288 minu a0, a0, a1 ret Both are execute the same in the end.=