From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9D9D0398E43F; Thu, 6 Jun 2024 06:17:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D9D0398E43F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1717654633; bh=lJD2dcLsLBSBvFyydSu9REZWtDemDU2st14kU283MCY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ov7v+5hWrQMXI/Qc0XzKPEk3luJzWM70DO3oMZ1u2CwsSGW4xRoHu8OetKm2s9cqP lJzCGIjR5H9smPXgnni33tKlCLX0+C3K0y5viouwPnu60oAGMlwZP+8DmORFKpIwGl hsihzCL0KSDvrA4CBivvl+pfJLIIJO+XARrG4RyM= From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114932] IVopts inefficient handling of signed IV used for addressing. Date: Thu, 06 Jun 2024 06:17:10 +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: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: tnfchris 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=3D114932 --- Comment #12 from rguenther at suse dot de --- On Wed, 5 Jun 2024, tnfchris at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114932 >=20 > --- Comment #11 from Tamar Christina --- > (In reply to Richard Biener from comment #10) > > I think the question is why IVOPTs ends up using both the signed and > > unsigned variant of the same IV instead of expressing all uses of both = with > > one IV? > >=20 > > That's where I'd look into. >=20 > It looks like this is because of a subtle difference in the expressions. >=20 > In get_loop_invariant_expr IVOPTs first tries to strip away all casts with > STRIP_NOPS. >=20 > The first expression is (unsigned long) (stride.3_27 * 4) and the second > expression is ((unsigned long) stride.3_27) * 4 (The pretty printing here= is > pretty bad...) >=20 > So the first one becomes: > (unsigned long) (stride.3_27 * 4) -> stride.3_27 * 4 >=20 > and second one: > ((unsigned long) stride.3_27) * 4 -> ((unsigned long) stride.3_27) * 4 >=20 > since we don't care about overflow here, it looks like the stripping shou= ld > be recursive as long as it's a NOP expression between two integral types. >=20 > That would get them to hash to the same IV expression. Trying now.. Note tree-affine is a tool that's used for this kind of "weak" equalities. Convert both to affine, subtract them and if that's zero they are equal.=