From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F066F3858C52; Wed, 22 Mar 2023 17:16:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F066F3858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679505398; bh=ZTf++Idn1n/XmXpCku4InzjwcSwmKeyHcfG6DoWCN14=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LM7zeqE9z02+VUzj9K30jJ99XobrPVpNKYVg/Sp5RTaTEAtI/hyJ+R6LRrfadGX5Z 012xyM6rHwQn5NFeERjVlvyPNVFKicZLqIquHiwWy8NsojaJck5YTBmIvp10H6Pezs UzH53A/mj2nKtYW/N4QXXxu+xRHzeIpZ9p1MyikA= From: "amacleod at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBjLzEwOTIzM10gWzEyLzEzIFJlZ3Jlc3Npb25dIHdhcm5p?= =?UTF-8?B?bmc6IGFycmF5IHN1YnNjcmlwdCA1IGlzIGFib3ZlIGFycmF5IGJvdW5kcyBv?= =?UTF-8?B?ZiDigJhzdHJ1Y3QgdGczX25hcGlbNV3igJkgc2luY2UgcjEyLTI1OTE=?= Date: Wed, 22 Mar 2023 17:16:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: amacleod at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 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=3D109233 --- Comment #11 from Andrew Macleod --- (In reply to Aldy Hernandez from comment #10) > (In reply to Jakub Jelinek from comment #8) >=20 > > And on the ranger side why we have determined the [0, 5] range rather t= han > > [0, 4], whether it is related to inaccurate number of iterations estima= tion, > > or ranger using it incorrectly, ... >=20 > The [0, 5] is actually coming from SCEV, which ranger is using to refine = the > range. Presumably, ranger is doing worse than SCEV, because it doesn't > improve it. >=20 > $ grep 'Loops range fo' a.c.*evrp > Loops range found for i_3: [irange] int [0, 5] NONZERO 0x7 and calcula= ted > range :[irange] int [-2147483647, +INF] > Loops range found for i_3: [irange] int [0, 5] NONZERO 0x7 and calcula= ted > range :[irange] int [0, 6] NONZERO 0x7 >=20 > Perhaps Andrew can pontificate on the recalculations / iterations / etc. Im not sure what to add.=20 SCEV tells us its [0,5] . Statement MEM [(struct S *)t_9(D)].f[i_3].y =3D 1; is executed at most 4 (bounded by 4) + 1 times in loop 1. Induction variable (int) 0 + 1 * iteration does not wrap in statement MEM [(struct S *)t_9(D)].f[i_3].z =3D 2; in loop 1. Statement MEM [(struct S *)t_9(D)].f[i_3].z =3D 2; is executed at most 4 (bounded by 4) + 1 times in loop 1. Induction variable (int) 0 + 1 * iteration does not wrap in statement MEM [(struct S *)t_9(D)].f[i_3].x =3D 3; in loop 1. Statement MEM [(struct S *)t_9(D)].f[i_3].x =3D 3; is executed at most 4 (bounded by 4) + 1 times in loop 1. Induction variable (int) 0 + 1 * iteration does not wrap in statement MEM [(struct S *)t_9(D)].f[i_3].z =3D 2; in loop 1. Statement MEM [(struct S *)t_9(D)].f[i_3].z =3D 2; is executed at most 4 (bounded by 4) + 1 times in loop 1. Trying to walk loop body to reduce the bound. Found better loop bound 5 I see nothing else in the IL to help ranger make any other decision, so it defers to SCEV, and the transformtion to rewrite the array index to [5] see= ms spot on, its the only possible value that can be there... THe branch condi= tion is: _1 =3D t_9(D)->h; i.0_2 =3D (unsigned int) i_3; if (_1 > i.0_2) goto ; Ranger knows nothing of the value of _1, and with i_3 being [0,5] there is nothing that I can see that ranger could do Why does scev decide 5 is a better bound?=