From nobody Mon Dec 06 16:33:26 2021 X-Original-To: dev-commits-src-all@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 E2ACD18B3CB2; Mon, 6 Dec 2021 16:33:29 +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 4J78BH52FNz3Bqw; Mon, 6 Dec 2021 16:33:27 +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 62105729F; Mon, 6 Dec 2021 16:33:26 +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 1B6GXQcX087690; Mon, 6 Dec 2021 16:33:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B6GXQST087689; Mon, 6 Dec 2021 16:33:26 GMT (envelope-from git) Date: Mon, 6 Dec 2021 16:33:26 GMT Message-Id: <202112061633.1B6GXQST087689@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: 1aaf10a91c8f - stable/13 - Apply fix for LLVM PR51957 (Miscompilation in Botan's SHA3) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/13 X-Git-Reftype: branch X-Git-Commit: 1aaf10a91c8f8e225c71c32d5b7d507fb1f4bf9d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638808408; 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=mTv4TmqXVu+uKRd3YkkcpfYEnjeMtv2Zt5iDBnx2JsM=; b=LTSbPv3yCZPlZg55wI/rnYJRocjDCFSTukRGpxzSGH4P6GfbLu1OqM5tB3soFzpHhcDoAD 9QSI1nCm8Rv5uc5PYIAEDD+WCmp45ulswH0UWfr+4JwLYXbF7VHxjc6ygrQRv5GA4Kn+oI cbryHI/4QrJS9RVJt3uK5ccVGi9Qi/Bm49dfaDv6XnhfSeVj/r5g39mp4dlz9XYBn5DD6v hTayic1bF9gU4HQDOR5RjfI0iOS3Uf39XKSWzZ+aeXBBYn5uYhC/kpusumYyisNm8iff63 jBUt09tvZ1XbgI5Im8849ZgVbpbHc17NLZuipUGrn5PfbZUKm4LTxrgbgIicMA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638808408; a=rsa-sha256; cv=none; b=HrJf5MWCg6/B17Is7iRVKtbiW21TY29DhujiTRV6pWf1nwWrp4iQGpXsQ0JPbDhZrRWtNK +7ywJF58gZ3kYnfypklrNfAFEdC8riSDhqC3A91w9CidtkxB7lDSGURqVui5mjd3xqBkP5 uHv+nVDkY3m200JxQ0U7mJg3QiDv2vaY89Chbg6/TK5UkMjKHwucTIwo/frkJMBumgFDUy ed2VEkzSkCDjSPWv00O7pqVSN6jLVTQd5LBR0k3TIIJUGR+Ffzlk8MWSbJAFMbiLhlqmmC uWP4a4VDLNcHmm3YG4b8ttNf2rSbJrPd8KsVFQO9sezXk2G0BpuBz0AlejjMQQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=1aaf10a91c8f8e225c71c32d5b7d507fb1f4bf9d commit 1aaf10a91c8f8e225c71c32d5b7d507fb1f4bf9d Author: Dimitry Andric AuthorDate: 2021-11-10 18:38:23 +0000 Commit: Dimitry Andric CommitDate: 2021-12-06 16:30:10 +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);