From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E744A385841E; Fri, 4 Nov 2022 19:45:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E744A385841E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667591107; bh=GvF6e4D995IImL9BQqKae4YPSWChB9g2Qphq0jvprcM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CqwHyjPEyqW5s6zu7oJy55r8/irWA/VwqnNmWf/ZqPlYN2XLDprty7V5zr8vVMqdL PnK0M7KC8kDSkwpPDOSwI9M526WYu2FUKwTDsOJ41Io8dNG9Qs8zF3N3iMX/gK/NbP 578gUM9Np+W/DGxB1BjA0ts+qVJITiPPORSf1oZQ= From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/55157] Missed VRP with != 0 and multiply Date: Fri, 04 Nov 2022 19:45:06 +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: 4.8.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: aldyh at gcc dot gnu.org X-Bugzilla-Status: NEW 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=3D55157 --- Comment #9 from Aldy Hernandez --- (In reply to Aldy Hernandez from comment #7) > (In reply to Andrew Macleod from comment #6) > > (In reply to Aldy Hernandez from comment #4) > > 3) It also seems to me that you then only need to add the zero/union if= f the > > trailing bit has zeros. ie, if the are no trailing zeros, then just set= the > > lb to 0, and calculate the UB based on the clz. >=20 > That actually made it slightly worse. I did some more testing. Your suggestions actually improved the original c= ode from 3.3% to 2.5%, but I added: + if (!wi::neg_p (mask, TYPE_SIGN (type ())) && prec > 1) instead of: + if (TYPE_UNSIGNED (type ()) && prec > 1) because we can still perform the optimization for signed positive numbers. = And that brought the slowdown back to 3.6%. But ISTM that we're gonna do it, m= ight as well do it for signed numbers as well. Hmmmm... I think we really should do our best to represent masks as ranges = as it makes other optimizations possible across the ranger ecosystem. But I'm= not ecstatic about the 3.6% drop (even though overall compilation is unaffected= ).=