From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7F2BB3858C2D; Sun, 28 Jan 2024 06:23:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F2BB3858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706423011; bh=qlvd9eNK10cru47ttcj6QYNHSORrt7eGRLEJCgdx5yg=; h=From:To:Subject:Date:From; b=I5lRVMX9Rijnwa82vJ2jP3sd4SFrCrtxd9t0ET4w1hSR5gSDrMCp9I0tUAjFfh1Lj bQszPCNV4Hd8vqgMKxVNhm35v8bK52FwFfRgwirgRhfQGnX7WrxArYkY3lfcS+e+1v VGlV0ZAIPG3od2w8i/TeHSybJZyRwMf2KhaBH2es= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113632] New: Range info for a^CST could be improved Date: Sun, 28 Jan 2024 06:23:30 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal 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=3D113632 Bug ID: 113632 Summary: Range info for a^CST could be improved Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` void dummy(); _Bool f(unsigned long a) { _Bool cmp =3D a > 8192; if (cmp) goto then; else goto e; then: unsigned long t =3D __builtin_clzl(a); // [0,50]=20 t^=3D63; // [13,63] return t >=3D 13; e: dummy(); return 0; } ``` Currently after the t^=3D63; we get: ``` # RANGE [irange] int [1, 63] MASK 0x3f VALUE 0x0 _7 =3D _1 ^ 63; ``` But this could/should be improved to [13,63]. If we change to using minus instead: ``` t =3D 63 - t; ``` We get the better range and the comparison (t >=3D 13) is optimized away. ``` Folding statement: t_10 =3D 63 - t_9; Global Exported: t_10 =3D [irange] long unsigned int [13, 63] MASK 0x3f VAL= UE 0x0 Not folded ``` Yes this should up in real code, see the LLVM issue for more information on that.=