https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77499
--- Comment #11 from avieira at gcc dot gnu.org --- (In reply to Segher Boessenkool from comment #10) > That is what nonzero_bits etc. is about. We could do much better nowadays > with the generic DF framework. > I am not familiar with the generic DF framework, could you point me to it? > Is code hoisting making the code better at all here? (At RTL level) Not as is, but I was hoping that if the zero_extend gets removed, we could end up with: movw r6, #45345 .L4: smull r5, r4, r7, r1 lsrs r0, r0, #1 sub r4, r4, r1, asr #31 - eor r5, r0, r6 add r4, r4, r4, lsl #1 cmp r1, r4 sub r1, r1, r3 it ne - uxthne r0, r5 + eorne r0, r0, r6 cmp r2, r1 blt .L4 So compared to the no-code-hoisting case it would realize it needs to do the same shift in both cases and only do it once.