From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BE13C3858CDB; Fri, 12 Apr 2024 10:12:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE13C3858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712916774; bh=BCJcG9qNrqQbwh9AV82qdLDfF/bWuGY6R/6fF0XrjyU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OQNqTGkcgphmAszVArR09oS6leHdAIqAKNMmi7RW7NBhgfPhAX0vYXV0cEadTOLSW 79qpTYAHIMy3k9JHbDaNITy70sVZLrodV4wOaO4RY36gp4LxeNK2S6/7c/sas5JGgH syNKO/AIi0z5gy+tVTXOyurQHld69Bi+1Qired04= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114403] [14 regression] LLVM miscompiled with -O3 -march=znver2 -fno-vect-cost-model since r14-6822-g01f4251b8775c8 Date: Fri, 12 Apr 2024 10:12:51 +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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: tnfchris at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 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=3D114403 --- Comment #23 from Richard Biener --- Maybe easier to understand testcase: long x[9]; long a[20]; struct { long x; long b[40]; } b; int __attribute__((noipa)) foo (int n) { int i =3D 0; int k =3D 0; do { if (x[k++]) // early exit, loop upper bound is 8 because of this break; a[i] =3D b.b[2*i]; // the misaligned 2*i access causes peeling for ga= ps } while (++i < n); return i; } int main() { x[8] =3D 1; if (foo (20) !=3D 8) __builtin_abort (); return 0; } with -O3 -msse4.1 -fno-vect-cost-model we return 20 instead of 8. Adding -fdisable-tree-cunroll avoids the issue. The upper bound we set on the vector loop causes us to force taking the IV exit which continues with i =3D=3D (niter - 1) / VF * VF, but 'niter' is 20 here.=