https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63783
--- Comment #13 from Oleg Endo <olegendo at gcc dot gnu.org> --- (In reply to Michael Karcher from comment #12) > Further digging into this showed that there actually is a pass that would > merge the two "tst r1,r1" instructions - the jump2 pass in cfgclenup.c. > > The optimization is called "crossjumping" in gcc, also known as tail > merging. For some reason[1], gcc is reluctant to perform crossjumping on > small common parts. In this case, the common part is just one instruction, > and the parameter min-crossjump-insns is five by default unless optimizing > for size. With "-fparam-min-crossjump-insns=1" or "-Os", my first patch > removing all the special-casing of zero compares produces the same result as > the patch fixing the logical negations. In the current situation, I see no > advantage of not cross-jumping in this case, so the minimally invasive > solution is definitely the second patch to fix logical negation, but still > it somehow feels ugly to me to have a limited reimplementation of > crossjumping in the sh-treg-combine pass. Replacing stuff of that pass by > improving other optimizations is IMHO beyond the scope of this bug, though. Thanks for digging into that. One possible way to evaluate the crossjumping optimization in ths case: - disable/don't register sh_treg_combine pass in sh.c - set default param -fparam-min-crossjump-insns=1 somehow - run sh.exp tests - compare CSiBE code sizes (or similar larger code bases) If you're interested in doing that, please post your findings in PR 51244.