/*========================== begin_copyright_notice ============================ Copyright (C) 2021 Intel Corporation SPDX-License-Identifier: MIT ============================= end_copyright_notice ===========================*/ /*========================== begin_copyright_notice ============================ Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. See https://llvm.org/LICENSE.txt for license information. SPDX-License-Identifier: Apache-2.0 with LLVM-exception ============================= end_copyright_notice ===========================*/ diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index 1b974576a3cc..8324662aadd5 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -810,7 +810,7 @@ bool llvm::computeUnrollCount( // In addition we only unroll small upper bounds. unsigned FullUnrollMaxTripCount = MaxTripCount; if (!(UP.UpperBound || MaxOrZero) || - FullUnrollMaxTripCount > UnrollMaxUpperBound) + FullUnrollMaxTripCount > std::max(16U, UnrollMaxUpperBound.getValue())) FullUnrollMaxTripCount = 0; // UnrollByMaxCount and ExactTripCount cannot both be non zero since we only @@ -941,7 +941,8 @@ bool llvm::computeUnrollCount( } // Don't unroll a small upper bound loop unless user or TTI asked to do so. - if (MaxTripCount && !UP.Force && MaxTripCount < UnrollMaxUpperBound) { + if (MaxTripCount && !UP.Force && + MaxTripCount < std::max(16U, UnrollMaxUpperBound.getValue())) { UP.Count = 0; return false; }