Consistently apply Vector Length (VF) cap in AArch64 cost model.
AArch64 cost model now uniformly applies vector length caps for better loop optimization accuracy.
The AArch64 backend ensures that the Vector Length (VF) cap is applied consistently across both the statement body cost adjustment and the main loop comparison logic. This resolves discrepancies where the compiler might have ranked the same loop differently due to uncapped VF in one part of the cost model and capped in another, leading to more accurate optimization decisions for fixed-trip loops.
In Details
This commit unifies the application of the Vector Length (VF) cap in aarch64.cc. A new helper function aarch64_vect_vf_for_cost is introduced to determine the capped VF. This function is used by both aarch64_vector_costs::adjust_body_cost and aarch64_vector_costs::better_main_loop_than_p, ensuring that the cost model consistently accounts for loops that may execute fewer lanes than the architectural VF, thus improving the accuracy of loop optimization choices.
- VF
- Vector Length. In the context of ARM's SVE (Scalable Vector Extension), this refers to the number of elements in a vector register, which can vary.
- AArch64
- The 64-bit ARM architecture.
- cost model
- A component of the compiler that estimates the performance cost of different code sequences or instructions to guide optimization decisions.
- fixed-trip loops
- Loops whose number of iterations is known at compile time.