Debian Codegraph @

external/llvm/releases/22.0.0/patches_external/alter-unroll-max-upperbound-command-line-option-value.patch

raw
1 /*========================== begin_copyright_notice ============================
2
3 Copyright (C) 2026 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 This comes from patches of LLVM 14 (copy-pasted from there)
18
19 diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
20 index 9beb2281c..a3cc73ca5 100644
21 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
22 +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
23 @@ -1003,7 +1003,7 @@ bool llvm::computeUnrollCount(
24 // cost of exact full unrolling. As such, if we have an exact count and
25 // found it unprofitable, we'll never chose to bounded unroll.
26 if (!TripCount && MaxTripCount && (UP.UpperBound || MaxOrZero) &&
27 - MaxTripCount <= UP.MaxUpperBound) {
28 + MaxTripCount < std::max(16U, UP.MaxUpperBound)) {
29 UP.Count = MaxTripCount;
30 if (auto UnrollFactor = shouldFullUnroll(L, TTI, DT, SE, EphValues,
31 MaxTripCount, UCE, UP)) {
32 @@ -1077,7 +1077,8 @@ bool llvm::computeUnrollCount(
33 }
34
35 // Don't unroll a small upper bound loop unless user or TTI asked to do so.
36 - if (MaxTripCount && !UP.Force && MaxTripCount < UP.MaxUpperBound) {
37 + if (MaxTripCount && !UP.Force &&
38 + MaxTripCount < std::max(16U, UP.MaxUpperBound)) {
39 UP.Count = 0;
40 return false;
41 }
42 --
43 2.43.0