| 1 |
/*========================== begin_copyright_notice ============================ |
| 2 |
|
| 3 |
Copyright (C) 2021 Intel Corporation |
| 4 |
|
| 5 |
SPDX-License-Identifier: MIT |
| 6 |
|
| 7 |
============================= end_copyright_notice ===========================*/ |
| 8 |
|
| 9 |
/*========================== begin_copyright_notice ============================ |
| 10 |
|
| 11 |
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 12 |
See https://llvm.org/LICENSE.txt for license information. |
| 13 |
SPDX-License-Identifier: Apache-2.0 with LLVM-exception |
| 14 |
|
| 15 |
============================= end_copyright_notice ===========================*/ |
| 16 |
|
| 17 |
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp |
| 18 |
index 2fa7436213dd..c5db1f6eb876 100644 |
| 19 |
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp |
| 20 |
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp |
| 21 |
@@ -1082,7 +1082,7 @@ static LoopUnrollResult tryToUnrollLoop( |
| 22 |
// number of loop tests goes up which may end up being worse on targets with |
| 23 |
// constrained branch predictor resources so is controlled by an option.) |
| 24 |
// In addition we only unroll small upper bounds. |
| 25 |
- if (!(UP.UpperBound || MaxOrZero) || MaxTripCount > UnrollMaxUpperBound) { |
| 26 |
+ if (!(UP.UpperBound || MaxOrZero) || MaxTripCount > std::max(16U, UnrollMaxUpperBound.getValue())) { |
| 27 |
MaxTripCount = 0; |
| 28 |
} |
| 29 |
} |