From 181b5e81642163a54ebcbb37d91b0da06564260a Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Fri, 30 Mar 2018 16:55:44 +0000 Subject: [PATCH] Revert "peel loops with runtime small trip counts" This reverts commit r328854, it breaks some Hexagon tests. llvm-svn: 328875 --- .../Hexagon/HexagonTargetTransformInfo.cpp | 8 ---- lib/Transforms/Utils/LoopUnrollPeel.cpp | 7 +--- .../LoopUnroll/Hexagon/peel-small-loop.ll | 37 ------------------- 3 files changed, 1 insertion(+), 51 deletions(-) delete mode 100644 test/Transforms/LoopUnroll/Hexagon/peel-small-loop.ll diff --git a/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp b/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp index 51aab0b635a..3290b5931ad 100644 --- a/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp +++ b/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp @@ -44,14 +44,6 @@ HexagonTTIImpl::getPopcntSupport(unsigned IntTyWidthInBit) const { void HexagonTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP) { UP.Runtime = UP.Partial = true; - // Only try to peel innermost loops with small runtime trip counts. - if (L && L->empty() && - SE.getSmallConstantTripCount(L) == 0 && - SE.getSmallConstantMaxTripCount(L) > 0 && - SE.getSmallConstantMaxTripCount(L) <= 5) { - UP.PeelCount = 2; - UP.AllowPeeling = true; - } } bool HexagonTTIImpl::shouldFavorPostInc() const { diff --git a/lib/Transforms/Utils/LoopUnrollPeel.cpp b/lib/Transforms/Utils/LoopUnrollPeel.cpp index cfbecd59af3..5f465f328b0 100644 --- a/lib/Transforms/Utils/LoopUnrollPeel.cpp +++ b/lib/Transforms/Utils/LoopUnrollPeel.cpp @@ -221,9 +221,6 @@ void llvm::computePeelCount(Loop *L, unsigned LoopSize, TargetTransformInfo::UnrollingPreferences &UP, unsigned &TripCount, ScalarEvolution &SE) { assert(LoopSize > 0 && "Zero loop size is not allowed!"); - // Save the UP.PeelCount value set by the target in - // TTI.getUnrollingPreferences or by the flag -unroll-peel-count. - unsigned TargetPeelCount = UP.PeelCount; UP.PeelCount = 0; if (!canPeel(L)) return; @@ -243,9 +240,7 @@ void llvm::computePeelCount(Loop *L, unsigned LoopSize, SmallDenseMap IterationsToInvariance; // Now go through all Phis to calculate their the number of iterations they // need to become invariants. - // Start the max computation with the UP.PeelCount value set by the target - // in TTI.getUnrollingPreferences or by the flag -unroll-peel-count. - unsigned DesiredPeelCount = TargetPeelCount; + unsigned DesiredPeelCount = 0; BasicBlock *BackEdge = L->getLoopLatch(); assert(BackEdge && "Loop is not in simplified form?"); for (auto BI = L->getHeader()->begin(); isa(&*BI); ++BI) { diff --git a/test/Transforms/LoopUnroll/Hexagon/peel-small-loop.ll b/test/Transforms/LoopUnroll/Hexagon/peel-small-loop.ll deleted file mode 100644 index 45c2553a70a..00000000000 --- a/test/Transforms/LoopUnroll/Hexagon/peel-small-loop.ll +++ /dev/null @@ -1,37 +0,0 @@ -; RUN: opt -loop-unroll -mtriple=hexagon -S < %s | FileCheck %s -; Check that the loop is peeled twice for Hexagon. -; CHECK: while.body.peel -; CHECK: while.body.peel2 - -%struct.STREAM = type { %union.anon, i32, i32 } -%union.anon = type { i32* } - -define void @function(%struct.STREAM* nocapture readonly %b) local_unnamed_addr { -entry: - %bitPtr3 = getelementptr inbounds %struct.STREAM, %struct.STREAM* %b, i32 0, i32 2 - %0 = load i32, i32* %bitPtr3, align 4 - %cmp11 = icmp ult i32 %0, 32 - br i1 %cmp11, label %while.body.preheader, label %do.end - -while.body.preheader: - %value2 = getelementptr inbounds %struct.STREAM, %struct.STREAM* %b, i32 0, i32 1 - %1 = load i32, i32* %value2, align 4 - %w = getelementptr inbounds %struct.STREAM, %struct.STREAM* %b, i32 0, i32 0, i32 0 - %2 = load i32*, i32** %w, align 4 - br label %while.body - -while.body: - %bitPtr.014 = phi i32 [ %add, %while.body ], [ %0, %while.body.preheader ] - %value.013 = phi i32 [ %shl, %while.body ], [ %1, %while.body.preheader ] - %ptr.012 = phi i32* [ %incdec.ptr, %while.body ], [ %2, %while.body.preheader ] - %add = add nuw i32 %bitPtr.014, 8 - %shr = lshr i32 %value.013, 24 - %incdec.ptr = getelementptr inbounds i32, i32* %ptr.012, i32 1 - store i32 %shr, i32* %ptr.012, align 4 - %shl = shl i32 %value.013, 8 - %cmp = icmp ult i32 %add, 17 - br i1 %cmp, label %while.body, label %do.end - -do.end: - ret void -}