On 1/10/2026 6:44 AM, Andrew Pinski wrote:
After the current improvements to ifcvt, on some targets for
cmp?a&b:a it is better to produce `(cmp?b:-1) & a` rather than
`(!cmp?a:0)|(a & b)`. So this extends noce_try_cond_zero_arith (with
a rename to noce_try_cond_arith) to see if `cmp ? a : -1` is cheaper than
`!cmp?a:0`.
Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* ifcvt.cc (noce_try_cond_zero_arith): Rename to ...
(noce_try_cond_arith): This. For AND try `cmp ? a : -1`
also to see which one cost less.
(noce_process_if_block): Handle the rename.
Signed-off-by: Andrew Pinski <[email protected]>
So on a testing note, I threw this into my tester overnight, so it's
been bootstrapped and regression tested on riscv and tested on most of
our embedded platforms without any regressions. I was briefly concerned
about the store-merging failures, but those were from a different patch
that went onto the trunk and were expected to flip behavior.
Some of the sequence juggling is annoying, but likely unavoidable to a
large extent. But I'm happy with the overall approach of just costing
the two approaches and selecting one.
OK for the trunk.
Thanks again for picking this up -- I had expected to cover it myself.
Jeff