From nobody Sat Dec 25 11:56:27 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2AE2018F4380; Sat, 25 Dec 2021 11:56:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JLj7x24h2z4lbj; Sat, 25 Dec 2021 11:56:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7823816CD6; Sat, 25 Dec 2021 11:56:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BPBuRk2007523; Sat, 25 Dec 2021 11:56:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BPBuRhp007522; Sat, 25 Dec 2021 11:56:27 GMT (envelope-from git) Date: Sat, 25 Dec 2021 11:56:27 GMT Message-Id: <202112251156.1BPBuRhp007522@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 471c6e3367a1 - stable/12 - Apply fix for LLVM PR51957 (Miscompilation in Botan's SHA3) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 471c6e3367a11d2d8a9bf49ca98faa1a452f77ac Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640433390; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9QVTghRpVtbgwP0iUS9C39rO52OabBbFZkOsfmPlhBE=; b=mqUuBJOnhCHP0TlCFEXMpn/dOgAMyYRPgfjN1m5yI4n3zYQ+l/LF2Hood4Jow8dCsu7m7z Ow59o0X/bvm4ur2a4nGgEacM7FWISGbPv1lkBS3ykVW59yzD+pXuXbzmlIe7VxpAtAEAnP 1i0aqI1T1rjn5MC7a+ODCZMy4HFMSoRwHt9r1f5WuxQ9bmIyNDM8kfinYmSsMbhzJ+kyPg /Nz+1zAh26kQiIOLNrdQ4ktsxTwHx07e66hLKkj+zkLRQkp+a7GQQ/Y8xFry2cZGuVtYKo c8IumSBwS+izu36XV1AAzJAm+Jx/z7CCpRCfcgeqp5Z7dwKT6jpJYgLQx9G9Aw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640433390; a=rsa-sha256; cv=none; b=X+SaMxyshVeeG1KNwjqdSK5hBOXREyrMD+3fj5EEnMWcSGRUTcw0xukrKyEt6FFjpviqsI ijM4tlKFHQKxeLUYkY/dKba570x0w9CEGTGWlmyrFL9xmzHoudCOKOX9mCH+x9JOYseOEB mAjRPzgemGQts69GBph1zRHJfNsITgS1lP5uEP2PmRBXrkiiJgdtqyXHwSXPcv8ku5/lU7 VSeMLqw3jdd/OTLsIXVY/+DH8nY/P/lKhAW+eUPzizdBNtUrR4rJHHwfTQVOdD8i3zGEjX T8+nHI3MxVSZx6TPhzowL+8vB5gaSYJSbT7WrXtCsu30j9+M6v1Qp4TTpLPedA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=471c6e3367a11d2d8a9bf49ca98faa1a452f77ac commit 471c6e3367a11d2d8a9bf49ca98faa1a452f77ac Author: Dimitry Andric AuthorDate: 2021-11-10 18:38:23 +0000 Commit: Dimitry Andric CommitDate: 2021-12-25 11:51:41 +0000 Apply fix for LLVM PR51957 (Miscompilation in Botan's SHA3) Merge commit e27a6db5298f from llvm git (by Jameson Nash): Bad SLPVectorization shufflevector replacement, resulting in write to wrong memory location We see that it might otherwise do: %10 = getelementptr {}**, <2 x {}***> %9, <2 x i32> %11 = bitcast <2 x {}***> %10 to <2 x i64*> ... %27 = extractelement <2 x i64*> %11, i32 0 %28 = bitcast i64* %27 to <2 x i64>* store <2 x i64> %22, <2 x i64>* %28, align 4, !tbaa !2 Which is an out-of-bounds store (the extractelement got offset 10 instead of offset 4 as intended). With the fix, we correctly generate extractelement for i32 1 and generate correct code. Differential Revision: https://reviews.llvm.org/D106613 (cherry picked from commit 397a8ba05313cc3815d219c9d1b2de1372fcb561) --- .../lib/Transforms/Vectorize/SLPVectorizer.cpp | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index cc3f5c7d4b48..1d06bc7d79a7 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -5430,8 +5430,11 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) { // The pointer operand uses an in-tree scalar so we add the new BitCast // to ExternalUses list to make sure that an extract will be generated // in the future. - if (getTreeEntry(PO)) - ExternalUses.emplace_back(PO, cast(VecPtr), 0); + if (TreeEntry *Entry = getTreeEntry(PO)) { + // Find which lane we need to extract. + unsigned FoundLane = Entry->findLaneForValue(PO); + ExternalUses.emplace_back(PO, cast(VecPtr), FoundLane); + } NewLI = Builder.CreateAlignedLoad(VecTy, VecPtr, LI->getAlign()); } else { @@ -5474,8 +5477,12 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) { // The pointer operand uses an in-tree scalar, so add the new BitCast to // ExternalUses to make sure that an extract will be generated in the // future. - if (getTreeEntry(ScalarPtr)) - ExternalUses.push_back(ExternalUser(ScalarPtr, cast(VecPtr), 0)); + if (TreeEntry *Entry = getTreeEntry(ScalarPtr)) { + // Find which lane we need to extract. + unsigned FoundLane = Entry->findLaneForValue(ScalarPtr); + ExternalUses.push_back( + ExternalUser(ScalarPtr, cast(VecPtr), FoundLane)); + } Value *V = propagateMetadata(ST, E->Scalars); @@ -5577,8 +5584,14 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) { // The scalar argument uses an in-tree scalar so we add the new vectorized // call to ExternalUses list to make sure that an extract will be // generated in the future. - if (ScalarArg && getTreeEntry(ScalarArg)) - ExternalUses.push_back(ExternalUser(ScalarArg, cast(V), 0)); + if (ScalarArg) { + if (TreeEntry *Entry = getTreeEntry(ScalarArg)) { + // Find which lane we need to extract. + unsigned FoundLane = Entry->findLaneForValue(ScalarArg); + ExternalUses.push_back( + ExternalUser(ScalarArg, cast(V), FoundLane)); + } + } propagateIRFlags(V, E->Scalars, VL0); ShuffleBuilder.addMask(E->ReuseShuffleIndices);