https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121240
--- Comment #8 from Dhruv Chawla <dhruvc at gcc dot gnu.org> --- I tried doing some analysis with an AI agent (which ended up being quite wordy), so this may be wrong but it seems to make sense to me. ====== The commit b67918fddab causes a ~6% regression in GROMACS 2025 on Neoverse V2 (Arm Grace). The hot kernel is nbnxmKernelSimd< KernelLayout::r4xM, KernelCoulombType::EwaldAnalytical, VdwCutoffCheck::No, LJCombinationRule::GeomComb, InteractionModifiers::ForceSwitch, LJEwald::None, EnergyOutput::None>, consuming ~70% of total cycles. The new DUP expansion and force_const_mem paths replace ADRP+LDR Q (constant pool load) with MOV/MOVK/DUP (scalar materialization + broadcast) for broadcast vector constants. This adds ~130 instructions to the kernel (+99 ADRP removed, but +117 MOV, +83 MOVK, +108 DUP added) and increases integer pipeline pressure in a loop dominated by SIMD floating-point work. This kernel does not have high register pressure in the baseline, so the freed ADRP base registers provide no benefit. The regression was surgically confirmed by replacing only this kernel's object file (compiled with the pre-commit compiler) in an otherwise post-commit build and relinking — performance fully recovers from 24.4 to 25.9 ns/day. However, the same commit produces a ~6% speedup on a different GROMACS kernel: nbnxmKernelSimd<..., InteractionModifiers::PotentialShift, ...> (~84% of cycles). This kernel has significantly higher register pressure in the baseline — the pre-commit build emits 246 stores vs 190 in the post-commit build, indicating heavy spilling. Here, the DUP expansion frees registers that were previously pinned to ADRP base addresses, eliminating ~56 spill stores and shrinking the function from 12576 to 12252 bytes. The register pressure relief outweighs the extra integer instructions. The root issue is that the DUP expansion in aarch64-simd.md is unconditional — it always prefers MOV/MOVK/DUP over a constant pool load for all const_vec_duplicate_p constants, regardless of whether the freed registers actually relieve pressure. For constants requiring MOV+MOVK (arbitrary 32-bit floats that aren't FMOV immediates), the 3-instruction materialization sequence is only profitable when register pressure is high enough that eliminating the ADRP base register saves spills. When pressure is already low (as in the ForceSwitch kernel), the extra instructions are pure overhead. A full revert recovers the regression but loses the speedup, confirming this is a trade-off rather than a clear-cut improvement.
