[llvm] [Arm] Control forced unrolling of small loops (PR #170127)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 1 04:40:17 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-arm
Author: Vladi Krapp (VladiKrapp-Arm)
<details>
<summary>Changes</summary>
* Add flag to control cost threshold for forced unrolling of loops. Existing value preserved as default.
* Document flag in release notes, along with equivalent Aarch64 flag.
---
Full diff: https://github.com/llvm/llvm-project/pull/170127.diff
2 Files Affected:
- (modified) llvm/docs/ReleaseNotes.md (+4)
- (modified) llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp (+5-1)
``````````diff
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index c6c527d1ae964..1ec700047ced5 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -111,12 +111,16 @@ Changes to the AArch64 Backend
* `FEAT_TME` support has been removed, as it has been withdrawn from
all future versions of the A-profile architecture.
+* Allow forced unrolling of small loops. Threshold controlled by flag `aarch64-force-unroll-threshold`
+
Changes to the AMDGPU Backend
-----------------------------
Changes to the ARM Backend
--------------------------
+* Allow forced unrolling of small loops. Threshold controlled by flag `arm-force-unroll-threshold` (existing default preserved)
+
Changes to the AVR Backend
--------------------------
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
index fdb0ec40cb41f..b5749bf51ce08 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -66,6 +66,10 @@ extern cl::opt<bool> EnableMaskedGatherScatters;
extern cl::opt<unsigned> MVEMaxSupportedInterleaveFactor;
+static cl::opt<int> ArmForceUnrollThreshold(
+ "arm-force-unroll-threshold", cl::init(12), cl::Hidden,
+ cl::desc("Threshold for forced unrolling of small loops in Arm architecture"));
+
/// Convert a vector load intrinsic into a simple llvm load instruction.
/// This is beneficial when the underlying object being addressed comes
/// from a constant, since we get constant-folding for free.
@@ -2731,7 +2735,7 @@ void ARMTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
// Force unrolling small loops can be very useful because of the branch
// taken cost of the backedge.
- if (Cost < 12)
+ if (Cost < ArmForceUnrollThreshold)
UP.Force = true;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/170127
More information about the llvm-commits
mailing list