From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CB3983861869; Fri, 15 Dec 2023 09:24:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB3983861869 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702632297; bh=cfxXBD8Zn7HKNdkQPkFWcJNwU8r2uTigXRVb59WtwVs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HDvfOYJd751YHSk6bBbs62a+qzDHdZnQEHCnACjfk8EaJRPzEkgEenk6qqiqGvdSO zuZwhOoWnsRLEsSOS5Q/+CXzNo9QPmB8npFkz3dhPbR9HBWQ0e1+3+8DazH8GjL49g xG/Zh4VMwPoUtquMEOfU+wXXcTvvqwOzY91XjSHE= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113026] Bogus -Wstringop-overflow warning on simple memcpy type loop Date: Fri, 15 Dec 2023 09:24:57 +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: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to everconfirmed keywords bug_status cf_reconfirmed_on 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=3D113026 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot = gnu.org Ever confirmed|0 |1 Keywords| |missed-optimization Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2023-12-15 --- Comment #2 from Richard Biener --- We are diagnosing the scalar store in the epilogue of the vectorized "loop" where we somehow optimized the vector loop to terminate immediately (based on dst[] size I guess) and also peeled the epilogue but failed to eliminate that completely (but then -Wstringop-overflow correctly figures the access would be out-of-bounds). A bit reduced (interestingly when avoiding versioning for aliasing we manage to avoid the diagnostic because of the way we re-use the epilog when n < 16 char dst[16]; void foo (char *src, long n) { for (long i =3D 0; i < n; i++) dst[i] =3D src[i]; } in the end this is a missed optimization. We do know an upper bound for the loop so we should have disabled epilog peeling based on that. The peeling code assumes the vector loop can be skipped (niter < vf) only when we either vectorize the epilogue or do not version the loop while the code computing wheter we need peeling takes into account the versioning cost model threshold only.=