[llvm] r365520 - Revert "[HardwareLoops] NFC - move hardware loop checking code to isHardwareLoopProfitable()"
Jinsong Ji via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 15:33:25 PDT 2019
Sure, thanks for reminding, will include why next time.
For this revert, it was breaking several build.
See discussion in https://reviews.llvm.org/D64197 for more details if interested.
Philip Reames --- [EXTERNAL] Re: [llvm] r365520 - Revert "[HardwareLoops] NFC - move hardware loop checking code to isHardwareLoopProfitable()" ---
From:"Philip Reames" <listmail at philipreames.com>To:"Jinsong Ji" <jji at us.ibm.com>, llvm-commits at lists.llvm.orgDate:Tue, Jul 9, 2019 6:09 PMSubject:[EXTERNAL] Re: [llvm] r365520 - Revert "[HardwareLoops] NFC - move hardware loop checking code to isHardwareLoopProfitable()"
When revert, please say why.PhilipOn 7/9/19 10:53 AM, Jinsong Ji via llvm-commits wrote:> Author: jsji> Date: Tue Jul 9 10:53:09 2019> New Revision: 365520>> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D365520-26view-3Drev&d=DwICaQ&c=jf_iaSHvJObTbx-siA1ZOg&r=DvnnfavFQBGT2CDyHzTr_Q&m=5n5rA3XF6uGi268QFmwK9CN1EZ1gNuuz1wxJVEy64qY&s=Oq9deT9bXxH0NHPyOfs3B-rMYCEZ7SBNkpKzJTyV4fI&e= > Log:> Revert "[HardwareLoops] NFC - move hardware loop checking code to isHardwareLoopProfitable()">> This reverts commit d95557306585404893d610784edb3e32f1bfce18.>> Modified:> llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h> llvm/trunk/lib/Analysis/TargetTransformInfo.cpp> llvm/trunk/lib/CodeGen/HardwareLoops.cpp>> Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_Analysis_TargetTransformInfo.h-3Frev-3D365520-26r1-3D365519-26r2-3D365520-26view-3Ddiff&d=DwICaQ&c=jf_iaSHvJObTbx-siA1ZOg&r=DvnnfavFQBGT2CDyHzTr_Q&m=5n5rA3XF6uGi268QFmwK9CN1EZ1gNuuz1wxJVEy64qY&s=vKu87OjQPNP_J6XkL7GufJagShSUznzaSkhiq1j7bLI&e= > ==============================================================================> --- llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h (original)> +++ llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h Tue Jul 9 10:53:09 2019> @@ -99,8 +99,7 @@ struct HardwareLoopInfo {> // produces an i1 to guard the loop entry.> bool isHardwareLoopCandidate(ScalarEvolution &SE, LoopInfo &LI,> DominatorTree &DT, bool ForceNestedLoop = false,> - bool ForceHardwareLoopPHI = false,> - bool ForceGuardLoopEntry = false);> + bool ForceHardwareLoopPHI = false);> bool canAnalyze(LoopInfo &LI);> };> >> Modified: llvm/trunk/lib/Analysis/TargetTransformInfo.cpp> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Analysis_TargetTransformInfo.cpp-3Frev-3D365520-26r1-3D365519-26r2-3D365520-26view-3Ddiff&d=DwICaQ&c=jf_iaSHvJObTbx-siA1ZOg&r=DvnnfavFQBGT2CDyHzTr_Q&m=5n5rA3XF6uGi268QFmwK9CN1EZ1gNuuz1wxJVEy64qY&s=VYoUKwZ8m-SvEz_DoDtim8yKnQ2CXYt6fJ3G3aRbeL4&e= > ==============================================================================> --- llvm/trunk/lib/Analysis/TargetTransformInfo.cpp (original)> +++ llvm/trunk/lib/Analysis/TargetTransformInfo.cpp Tue Jul 9 10:53:09 2019> @@ -20,9 +20,6 @@> #include "llvm/Support/ErrorHandling.h"> #include "llvm/Analysis/CFG.h"> #include "llvm/Analysis/LoopIterator.h"> -#include "llvm/Transforms/Utils.h"> -#include "llvm/Transforms/Utils/LoopUtils.h"> -#include "llvm/Analysis/ScalarEvolutionExpander.h"> #include <utility>> > using namespace llvm;> @@ -58,8 +55,7 @@ bool HardwareLoopInfo::canAnalyze(LoopIn> bool HardwareLoopInfo::isHardwareLoopCandidate(ScalarEvolution &SE,> LoopInfo &LI, DominatorTree &DT,> bool ForceNestedLoop,> - bool ForceHardwareLoopPHI,> - bool ForceGuardLoopEntry) {> + bool ForceHardwareLoopPHI) {> SmallVector<BasicBlock *, 4> ExitingBlocks;> L->getExitingBlocks(ExitingBlocks);> > @@ -138,33 +134,6 @@ bool HardwareLoopInfo::isHardwareLoopCan> > if (!ExitBlock)> return false;> -> - BasicBlock *Preheader = L->getLoopPreheader();> -> - // If we don't have a preheader, then insert one.> - if (!Preheader)> - Preheader = InsertPreheaderForLoop(L, &DT, &LI, nullptr, true);> - if (!Preheader)> - return false;> -> - // Make sure we have a valid Loop Count> - if (!ExitCount->getType()->isPointerTy() &&ExitCount->getType() != CountType)> - ExitCount = SE.getZeroExtendExpr(ExitCount, CountType);> -> - ExitCount = SE.getAddExpr(ExitCount, SE.getOne(CountType));> -> - BasicBlock *BB = L->getLoopPreheader();> -> - if (ForceGuardLoopEntry &&BB->getSinglePredecessor() &&> - cast<BranchInst>(BB->getTerminator())->isUnconditional())> - BB = BB->getSinglePredecessor();> -> - if (!isSafeToExpandAt(ExitCount, BB->getTerminator(), SE)) {> - LLVM_DEBUG(dbgs() << "Not a Hardware Loop: unsafe to expand ExitCount "> - << *ExitCount << "\n");> - return false;> - }> -> return true;> }> >> Modified: llvm/trunk/lib/CodeGen/HardwareLoops.cpp> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_HardwareLoops.cpp-3Frev-3D365520-26r1-3D365519-26r2-3D365520-26view-3Ddiff&d=DwICaQ&c=jf_iaSHvJObTbx-siA1ZOg&r=DvnnfavFQBGT2CDyHzTr_Q&m=5n5rA3XF6uGi268QFmwK9CN1EZ1gNuuz1wxJVEy64qY&s=RjYspxycuwL1Xme86I9nA1Q_eT7ObjKQ-JP1mxiowS4&e= > ==============================================================================> --- llvm/trunk/lib/CodeGen/HardwareLoops.cpp (original)> +++ llvm/trunk/lib/CodeGen/HardwareLoops.cpp Tue Jul 9 10:53:09 2019> @@ -15,6 +15,7 @@> ///> //===----------------------------------------------------------------------===//> > +#include "llvm/Pass.h"> #include "llvm/PassRegistry.h"> #include "llvm/PassSupport.h"> #include "llvm/ADT/Statistic.h"> @@ -35,8 +36,10 @@> #include "llvm/IR/Value.h"> #include "llvm/Support/Debug.h"> #include "llvm/Transforms/Scalar.h"> +#include "llvm/Transforms/Utils.h"> #include "llvm/Transforms/Utils/BasicBlockUtils.h"> #include "llvm/Transforms/Utils/Local.h"> +#include "llvm/Transforms/Utils/LoopUtils.h"> > #define DEBUG_TYPE "hardware-loops"> > @@ -109,6 +112,7 @@ namespace {> const DataLayout *DL = nullptr;> const TargetTransformInfo *TTI = nullptr;> DominatorTree *DT = nullptr;> + bool PreserveLCSSA = false;> AssumptionCache *AC = nullptr;> TargetLibraryInfo *LibInfo = nullptr;> Module *M = nullptr;> @@ -180,6 +184,7 @@ bool HardwareLoops::runOnFunction(Functi> DL = &F.getParent()->getDataLayout();> auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();> LibInfo = TLIP ? &TLIP->getTLI() : nullptr;> + PreserveLCSSA = mustPreserveAnalysisID(LCSSAID);> AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);> M = F.getParent();> > @@ -225,19 +230,25 @@ bool HardwareLoops::TryConvertLoop(Loop> > bool HardwareLoops::TryConvertLoop(HardwareLoopInfo &HWLoopInfo) {> > - LLVM_DEBUG(dbgs() << "HWLoops: Try to convert profitable loop: "> - << *HWLoopInfo.L);> + Loop *L = HWLoopInfo.L;> + LLVM_DEBUG(dbgs() << "HWLoops: Try to convert profitable loop: " << *L);> > if (!HWLoopInfo.isHardwareLoopCandidate(*SE, *LI, *DT, ForceNestedLoop,> - ForceHardwareLoopPHI,> - ForceGuardLoopEntry))> + ForceHardwareLoopPHI))> return false;> > assert(> (HWLoopInfo.ExitBlock &&HWLoopInfo.ExitBranch &&HWLoopInfo.ExitCount) &&> "Hardware Loop must have set exit info.");> > - // Now start to converting...> + BasicBlock *Preheader = L->getLoopPreheader();> +> + // If we don't have a preheader, then insert one.> + if (!Preheader)> + Preheader = InsertPreheaderForLoop(L, DT, LI, nullptr, PreserveLCSSA);> + if (!Preheader)> + return false;> +> HardwareLoop HWLoop(HWLoopInfo, *SE, *DL);> HWLoop.Create();> ++NumHWLoops;> @@ -246,10 +257,10 @@ bool HardwareLoops::TryConvertLoop(Hardw> > void HardwareLoop::Create() {> LLVM_DEBUG(dbgs() << "HWLoops: Converting loop..\n");> -> +> Value *LoopCountInit = InitLoopCount();> -> - assert(LoopCountInit &&"Hardware Loop must have a loop count");> + if (!LoopCountInit)> + return;> > InsertIterationSetup(LoopCountInit);> > @@ -309,22 +320,32 @@ Value *HardwareLoop::InitLoopCount() {> // loop counter and tests that is not zero?> > 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, ExitCount,> - SE.getZero(ExitCount->getType())))> + SE.getZero(ExitCount->getType()))) {> + LLVM_DEBUG(dbgs() << " - Attempting to use test.set counter.\n");> UseLoopGuard |= ForceGuardLoopEntry;> - else> + } else> UseLoopGuard = false;> > BasicBlock *BB = L->getLoopPreheader();> if (UseLoopGuard &&BB->getSinglePredecessor() &&> - cast<BranchInst>(BB->getTerminator())->isUnconditional()) {> - LLVM_DEBUG(dbgs() << " - Attempting to use test.set counter.\n");> + cast<BranchInst>(BB->getTerminator())->isUnconditional())> BB = BB->getSinglePredecessor();> +> + if (!isSafeToExpandAt(ExitCount, BB->getTerminator(), SE)) {> + LLVM_DEBUG(dbgs() << "- Bailing, unsafe to expand ExitCount "> + << *ExitCount << "\n");> + return nullptr;> }> > Value *Count = SCEVE.expandCodeFor(ExitCount, CountType,>>> _______________________________________________> llvm-commits mailing list> llvm-commits at lists.llvm.org> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=DwICaQ&c=jf_iaSHvJObTbx-siA1ZOg&r=DvnnfavFQBGT2CDyHzTr_Q&m=5n5rA3XF6uGi268QFmwK9CN1EZ1gNuuz1wxJVEy64qY&s=_3ZaFmu5fpyyYWG5LZ_-V5_iljWLVpi_YcVZdKzRr3k&e=
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190709/089e8372/attachment.html>
More information about the llvm-commits
mailing list