From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9D04F3948A77; Mon, 5 Dec 2022 20:35:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D04F3948A77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670272509; bh=5uUz61SjH+zL+T2mxZvRUJKM7AVwWht2JJoBj2X3ZLc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sfH25fcexbi0qiRpIHSyexf5poxpzVNdoLGTNqmctZp6s0QFcsPEVfFBYx1N5Z25P GuRcEW6PWL7C/SCT6QC+XKuB5efdXFS1iu4TeMZtWuJFH0hyCv6dns9w8EuNbzy6/s MWxFixKOSy8DA8LSQfPB8niHjsVAAs9bMw8wulMA= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106757] [12/13 Regression] Incorrect "writing 1 byte into a region of size 0" on a vectorized loop Date: Mon, 05 Dec 2022 20:35:08 +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: 12.2.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org 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: keywords 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=3D106757 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization --- Comment #4 from Richard Biener --- (In reply to Peter Bergner from comment #3) > Is this the same bug, so just a simpler test case? >=20 > bergner@fowler:LTC193379$ cat bug.c > int len =3D 16; > extern char *src; > char dst[16]; >=20 > void > foo (void) > { > #ifdef OK > for (int i =3D 0; i < 16; i++) > #else > for (int i =3D 0; i < len; i++) > #endif > dst[i] =3D src[i]; > } >=20 > bergner@fowler:LTC193379$ > /home/bergner/gcc/build/gcc-fsf-mainline-ltc193379-debug/gcc/xgcc > -B/home/bergner/gcc/build/gcc-fsf-mainline-ltc193379-debug/gcc -S -O3 -DOK > -ftree-vectorize bug.c >=20 > bergner@fowler:LTC193379$ > /home/bergner/gcc/build/gcc-fsf-mainline-ltc193379-debug/gcc/xgcc > -B/home/bergner/gcc/build/gcc-fsf-mainline-ltc193379-debug/gcc -S -O3 -UOK > -fno-tree-vectorize bug.c >=20 > bergner@fowler:LTC193379$ > /home/bergner/gcc/build/gcc-fsf-mainline-ltc193379-debug/gcc/xgcc > -B/home/bergner/gcc/build/gcc-fsf-mainline-ltc193379-debug/gcc -S -O3 -UOK > -ftree-vectorize bug.c > bug.c: In function =E2=80=98foo=E2=80=99: > bug.c:13:12: warning: writing 1 byte into a region of size 0 > [-Wstringop-overflow=3D] > 13 | dst[i] =3D src[i]; > | ~~~~~~~^~~~~~~~ > bug.c:3:6: note: at offset 16 into destination object =E2=80=98dst=E2=80= =99 of size 16 > 3 | char dst[16]; > | ^~~ > bug.c:13:12: warning: writing 1 byte into a region of size 0 > [-Wstringop-overflow=3D] > 13 | dst[i] =3D src[i]; > | ~~~~~~~^~~~~~~~ > bug.c:3:6: note: at offset 17 into destination object =E2=80=98dst=E2=80= =99 of size 16 > 3 | char dst[16]; > | ^~~ >=20 > I'll note that -fno-unroll-loops doesn't affect anything. It looks similar. Note the code we warn is isolated by DOM threading after loop opts here. The unrolling done is also a bit excessive but that's because we estimate an upper bound on the epilogue based on the array size accessed. The IL we diagnose is definitely bogus but unreachable at runtime which we don't see so it's also a code size issue.=