From nobody Sat Dec 25 11:55:49 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 1915F18F3344; Sat, 25 Dec 2021 11:55:54 +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 4JLj7B0XGfz4lD3; Sat, 25 Dec 2021 11:55:50 +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 6C3AB1686E; Sat, 25 Dec 2021 11:55:49 +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 1BPBtnNH006833; Sat, 25 Dec 2021 11:55:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BPBtnnQ006832; Sat, 25 Dec 2021 11:55:49 GMT (envelope-from git) Date: Sat, 25 Dec 2021 11:55:49 GMT Message-Id: <202112251155.1BPBtnnQ006832@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: 8a95c6332bfc - stable/12 - llvm: Revert "[HardwareLoops] Change order of SCEV expression construction for InitLoopCount." 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/12 X-Git-Reftype: branch X-Git-Commit: 8a95c6332bfc9b45a30bde15e306ccdccc33a1db Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640433351; 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=o2jLGlcC6zgIkV6Hqkhq6V5E3cBaZlDl4cLIMhYjOac=; b=v3+qYTIbe6iWeOtwFOPhmPPf1tJKS6AWLLiBVI3OE/0JRBBHRbUL0i8eNMHvmmGhlFi8qL kDlkFAxSAPb68j4L0N3ikBGrGDRtCEOu33LA1jAWwm3WuZznZQtKhSUsVcBjMmZXRHyPqe 6iArQhoWJkCr9TDBoXG6yo87V+NU302OivsVCAqhJD1mMpYCclGa7iptppMeEryaIT0JlC tSR/NJgJm0I465NFjUUNMB2AACRFMiGcktcv9930SWP0cw2zl3AM94YAVUePCIS23qbeLm E1lDavgH/5JD+mhZcBevZfB8cgW7fHiGb84QzPTO3kFjYYkJp4UqwDwpKSxvbg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640433351; a=rsa-sha256; cv=none; b=CPmD8FWJiyCheCQIpDjvG/MJqXr4KmVBBf/yyOqs2VsNzTVPFIKgpMzGJHr32KxdSKnz8H 0owO9856yCoupH0C+Zc0/QqwFa4UVmyG7aa8K3NWUbqkCmm5gZQ8qlx4rmznIbbB1xdkw8 fSc2qMpeTamTGab+F1e4F2tOsc7oIlBIs/jCCtG6EVaKbhKq++UqoqXmzSCZ8EnBSEqG8H lmfIX/L25hC8UHMbkDLHt9Asfyge3wReI18hura4z2/WfX1RR5L0UwK8NXQDMoAR/dmMwc yfVdoft8Ru953WJ6eVbDtrqJqCn1dztZpETm2fYciw4f2baupAfvjvOL+WjvKg== 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=8a95c6332bfc9b45a30bde15e306ccdccc33a1db commit 8a95c6332bfc9b45a30bde15e306ccdccc33a1db Author: Alfredo Dal'Ava Junior AuthorDate: 2021-09-02 17:54:31 +0000 Commit: Dimitry Andric CommitDate: 2021-12-25 11:51:21 +0000 llvm: Revert "[HardwareLoops] Change order of SCEV expression construction for InitLoopCount." Reverts llvm commit 42eaf4fe0adef3344adfd9fbccd49f325cb549ef, pointed from bisect as source of regression that causes liblzma to compress/ uncompress incorrectly. It's know to affect powerpc64 BE only. The patch unbreaks FreeBSD powerpc64 installation media, since bsdinstall can't uncompress the *.txz produced by FreeBSD CI. It's probably miscompiling other software bas well. Upstream PR: https://bugs.llvm.org/show_bug.cgi?id=51714 Reviewed by: dim MFC after: 2 days Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D31804 (cherry picked from commit f21fcae487026987f44154de981c03b69efbc945) --- .../include/llvm/Analysis/TargetTransformInfo.h | 1 + .../llvm/lib/Analysis/TargetTransformInfo.cpp | 5 +---- .../llvm/lib/CodeGen/HardwareLoops.cpp | 26 +++++++++++++--------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h b/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h index cdfb04424e56..4dc442e1ed56 100644 --- a/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/contrib/llvm-project/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -94,6 +94,7 @@ struct HardwareLoopInfo { Loop *L = nullptr; BasicBlock *ExitBlock = nullptr; BranchInst *ExitBranch = nullptr; + const SCEV *ExitCount = nullptr; const SCEV *TripCount = nullptr; IntegerType *CountType = nullptr; Value *LoopDecrement = nullptr; // Decrement the loop counter by this diff --git a/contrib/llvm-project/llvm/lib/Analysis/TargetTransformInfo.cpp b/contrib/llvm-project/llvm/lib/Analysis/TargetTransformInfo.cpp index e498401eb8b5..43cc90aedbc9 100644 --- a/contrib/llvm-project/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/contrib/llvm-project/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -217,10 +217,7 @@ bool HardwareLoopInfo::isHardwareLoopCandidate(ScalarEvolution &SE, // Note that this block may not be the loop latch block, even if the loop // has a latch block. ExitBlock = BB; - TripCount = SE.getAddExpr(EC, SE.getOne(EC->getType())); - - if (!EC->getType()->isPointerTy() && EC->getType() != CountType) - TripCount = SE.getZeroExtendExpr(TripCount, CountType); + ExitCount = EC; break; } diff --git a/contrib/llvm-project/llvm/lib/CodeGen/HardwareLoops.cpp b/contrib/llvm-project/llvm/lib/CodeGen/HardwareLoops.cpp index 810b10c9c82a..354e50b4844d 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/HardwareLoops.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/HardwareLoops.cpp @@ -187,7 +187,7 @@ namespace { const DataLayout &DL, OptimizationRemarkEmitter *ORE) : SE(SE), DL(DL), ORE(ORE), L(Info.L), M(L->getHeader()->getModule()), - TripCount(Info.TripCount), + ExitCount(Info.ExitCount), CountType(Info.CountType), ExitBranch(Info.ExitBranch), LoopDecrement(Info.LoopDecrement), @@ -202,7 +202,7 @@ namespace { OptimizationRemarkEmitter *ORE = nullptr; Loop *L = nullptr; Module *M = nullptr; - const SCEV *TripCount = nullptr; + const SCEV *ExitCount = nullptr; Type *CountType = nullptr; BranchInst *ExitBranch = nullptr; Value *LoopDecrement = nullptr; @@ -298,7 +298,7 @@ bool HardwareLoops::TryConvertLoop(HardwareLoopInfo &HWLoopInfo) { } assert( - (HWLoopInfo.ExitBlock && HWLoopInfo.ExitBranch && HWLoopInfo.TripCount) && + (HWLoopInfo.ExitBlock && HWLoopInfo.ExitBranch && HWLoopInfo.ExitCount) && "Hardware Loop must have set exit info."); BasicBlock *Preheader = L->getLoopPreheader(); @@ -384,12 +384,18 @@ Value *HardwareLoop::InitLoopCount() { SCEVExpander SCEVE(SE, DL, "loopcnt"); + if (!ExitCount->getType()->isPointerTy() && + ExitCount->getType() != CountType) + ExitCount = SE.getZeroExtendExpr(ExitCount, CountType); + + ExitCount = SE.getAddExpr(ExitCount, SE.getOne(CountType)); + // If we're trying to use the 'test and set' form of the intrinsic, we need // to replace a conditional branch that is controlling entry to the loop. It // is likely (guaranteed?) that the preheader has an unconditional branch to // the loop header, so also check if it has a single predecessor. - if (SE.isLoopEntryGuardedByCond(L, ICmpInst::ICMP_NE, TripCount, - SE.getZero(TripCount->getType()))) { + if (SE.isLoopEntryGuardedByCond(L, ICmpInst::ICMP_NE, ExitCount, + SE.getZero(ExitCount->getType()))) { LLVM_DEBUG(dbgs() << " - Attempting to use test.set counter.\n"); UseLoopGuard |= ForceGuardLoopEntry; } else @@ -401,19 +407,19 @@ Value *HardwareLoop::InitLoopCount() { BasicBlock *Predecessor = BB->getSinglePredecessor(); // If it's not safe to create a while loop then don't force it and create a // do-while loop instead - if (!isSafeToExpandAt(TripCount, Predecessor->getTerminator(), SE)) + if (!isSafeToExpandAt(ExitCount, Predecessor->getTerminator(), SE)) UseLoopGuard = false; else BB = Predecessor; } - if (!isSafeToExpandAt(TripCount, BB->getTerminator(), SE)) { - LLVM_DEBUG(dbgs() << "- Bailing, unsafe to expand TripCount " - << *TripCount << "\n"); + if (!isSafeToExpandAt(ExitCount, BB->getTerminator(), SE)) { + LLVM_DEBUG(dbgs() << "- Bailing, unsafe to expand ExitCount " + << *ExitCount << "\n"); return nullptr; } - Value *Count = SCEVE.expandCodeFor(TripCount, CountType, + Value *Count = SCEVE.expandCodeFor(ExitCount, CountType, BB->getTerminator()); // FIXME: We've expanded Count where we hope to insert the counter setting