From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CFFF43858C36; Mon, 27 Nov 2023 22:30:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CFFF43858C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701124236; bh=kwcj7Q5ZQTNbBKI/BPxJeJmcDaWsaDaCP+L3NNGEFhA=; h=From:To:Subject:Date:From; b=ducKH2/wRJ75wrWsg/EVu64x+ReNNV9ofY/F7x01A5idm9ZpEz5yAdSDnwNRb+cJC DdhzbUqf+WOyGzm/a8F/L+IWeGD5I2KJxTZpTygTSpxLekUMcbLSZNmGshrK1+tUm+ FNw2vWfE3CyBfGXonEgWPr74LH5vkUZA7iYvvrjQ= From: "kristerw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112736] New: vectorizer is introducing out of bounds memory access Date: Mon, 27 Nov 2023 22:30:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kristerw 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D112736 Bug ID: 112736 Summary: vectorizer is introducing out of bounds memory access Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: kristerw at gcc dot gnu.org Target Milestone: --- The following function (from gcc.dg/torture/pr68379.c) int a, b[3], c[3][5]; void fn1 () { int e; for (a =3D 2; a >=3D 0; a--) for (e =3D 0; e < 4; e++) c[a][e] =3D b[a]; } generates out of bound memory access (where the three movdqu instructions r= ead 1, 2, and 3 elements before b) when compiled as -O3 for x86_64: fn1: movdqu b-4(%rip), %xmm1 movdqu b-8(%rip), %xmm2 movl $-1, a(%rip) movdqu b-12(%rip), %xmm3 pshufd $255, %xmm1, %xmm0 movups %xmm0, c+40(%rip) pshufd $255, %xmm2, %xmm0 movups %xmm0, c+20(%rip) pshufd $255, %xmm3, %xmm0 movaps %xmm0, c(%rip) ret The vector operations were introduced by the "vect" pass.=