[Bug target/105338] [12 Regression] Regression: jump or cmove generated for pattern (x ? CST : 0)

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Apr 26 08:21:58 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105338

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to denis.campredon from comment #13)
> Thanks a lots.
> 
> I have a question though: foo and bar are similar, foo produces a branchless
> code whereas bar uses a jump.
> 
> int foo(int i) {
>     return !i ? 0 : -2;
> }
> 
> int bar(int i) {
>     return i ? -2 : 0;
> }
> 
> If I'm readding correctly in the two functions the probabilities are the
> same. Is this "normal" or worth a new ticket ?

There is the bug where cond_move_process_if_block ignores the costs and another
where if the cost checks are added, it might be worth for the destination
overlap with comparison operand case force the comparison operand or
destination into a new temporary and add one more first or last instead of
giving up.  The costs comparison would then catch that.
So yes, it is worth a new PR, but not something that will be addressed for GCC
12.


More information about the Gcc-bugs mailing list