Skip to content

Conversation

@VladiKrapp-Arm
Copy link
Contributor

  • 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.
@llvmbot
Copy link
Member

llvmbot commented Dec 1, 2025

@llvm/pr-subscribers-backend-arm

Author: Vladi Krapp (VladiKrapp-Arm)

Changes
  • 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 --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; } 
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@jthackray jthackray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

* Add flag to control cost threshold for forced unrolling of loops. Existing value preserved as default.
Copy link
Collaborator

@davemgreen davemgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK thanks. LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants