https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122018
--- Comment #15 from uis <uis9936 at gmail dot com> ---
There are still some missed cases. Consider this:
int j(int);
int f4p(int a, int b) {
bool t = false;
t = (a >> b) & 1;
int c = a | (1 << b);
if(!t)
return j(c);
return a;
}
It produces following:
.globl f4p
.type f4p, @function
f4p:
.LFB4:
.cfi_startproc
btl %esi, %edi
jnc .L38
movl %edi, %eax
ret
.p2align 4,,10
.p2align 3
.L38:
btsl %esi, %edi
jmp j
It would make sense for btsl here to replace btl, since if the branch will not
be taken(if flag was already set), there will be no observable change to the
value of register.
On the other hand, if I remove negation of variable t, output will be same, but
jnc will be replaced with jc, but btsl will stay, regardless of it setting flag
that was just confirmed to be set. Probably unrelated.