[AArch64] Reuse SUBS results for conditional subtraction (#223391)
For C++ code such as:
uint64_t conditional_subtract(uint64_t x, uint64_t q) {
return x - (x >= q ? q : 0);
}
AArch64 currently uses three instructions for the conditional
subtraction (omitting the return):
cmp x0, x1
csel x8, x1, xzr, hs
sub x0, x0, x8
The comparison already computes x - q to set the condition flags, but
its arithmetic result is discarded. Preserve that result with SUBS and
select between it and x, reducing the sequence to two instructions:
subs x8, x0, x1
csel x0, x8, x0, hs
Apply this combine to i32 and i64 single-use selects with zero in either
arm. Keep the original flags and condition code, allowing signed,
unsigned, equality, and overflow conditions while preserving other users
of the comparison.
This gives an approximately 3% performance improvement in the
750.sealcrypto_r benchmark from SPEC CPU 2026.