From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 70BAD3858401; Wed, 5 Jun 2024 19:02:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70BAD3858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1717614161; bh=lBb2qkrLihfVg/awdVgaxJhpcDwU0oQYPt2jbAWVR44=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XrgApowuqb1d7cs/vlbrfoH+fgzuapL7yjzBf+xuuXHig+BfDG5dkSBzRBC4f2SM1 WufQA38Bp4ct/D9SkoKjzAnaDtJswuADQhnlhG9/3bXnPKKXEplSLqE7ryKVPdf0Sl 7onu10Ggr/g8blDlY5o4GGgTVHSicenjh/G9Ybrs= From: "tnfchris at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114932] IVopts inefficient handling of signed IV used for addressing. Date: Wed, 05 Jun 2024 19:02:40 +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: tnfchris at gcc dot gnu.org 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 #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 wi= th > one IV? >=20 > That's where I'd look into. It looks like this is because of a subtle difference in the expressions. In get_loop_invariant_expr IVOPTs first tries to strip away all casts with STRIP_NOPS. 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...) So the first one becomes: (unsigned long) (stride.3_27 * 4) -> stride.3_27 * 4 and second one: ((unsigned long) stride.3_27) * 4 -> ((unsigned long) stride.3_27) * 4 since we don't care about overflow here, it looks like the stripping should be recursive as long as it's a NOP expression between two integral types. That would get them to hash to the same IV expression. Trying now..=