From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D676B3858284; Thu, 25 Aug 2022 07:48:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D676B3858284 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661413684; bh=TyDtkUQj1LTUIAbKCvMxiI28L3xWwCYJPE5nX4L8Kmk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gfZTbl6bawLUlOrVNFdRj5geNO5ny01mVP2WIMgQNdBBXMoR6/0GU/xKTOC26fRpz NxN0ZNr58t0qXMfiJy2Ao8/maAQpup1IOO3ZsPxNo6uhv7Czr0EKvcVpAH37DR8R96 wOc83rlIlZuUJZ8ovX3oDBexTEa20Jp380sfZyWA= From: "guihaoc at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/102316] Unexpected stringop-overflow Warnings on POWER CPU Date: Thu, 25 Aug 2022 07:48:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: guihaoc 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: cc 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=3D102316 HaoChen Gui changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |guihaoc at gcc dot gnu.org, | |rguenth at gcc dot gnu.org --- Comment #4 from HaoChen Gui --- #define LEN 4 struct { char c[LEN] } d; extern int a; extern char* b; int p() { for (int i =3D 0; i < a; i++) { d.c[i] =3D b[i]; } return 0; } Above codes cause the same errors on x86. When setting the LEN to 8, it can= be also reproduced on aarch64. It's a common problem. The iteration number of reset loop after vectorization should not only deci= ded by variable "a" but also by the length of array. If the len is 5 and vector size is 4, the reset loop should be only executed once. Currently iteration number only depends on variable "a". Then it is complete unrolled 3 times if vector size is 4. That causes the warning. [local count: 398179264]: # i_30 =3D PHI _32 =3D (sizetype) i_30; _33 =3D b.0_1 + _32; _34 =3D *_33; d.c[i_30] =3D _34; i_36 =3D i_30 + 1; if (i_36 < a.1_13) // iterations depend on "a" only, the length of arra= y is not take into consideration goto ; [89.00%] else goto ; [11.00%]=