[Bug tree-optimization/123103] missed optimization for redundant conditional
652023330028 at smail dot nju.edu.cn
gcc-bugzilla@gcc.gnu.org
Sun Dec 14 13:26:14 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123103
--- Comment #4 from Yi <652023330028 at smail dot nju.edu.cn> ---
(In reply to Andrew Pinski from comment #3)
> You definitely reduced this testcase too much because you introduced
> possible undefined behavior due to the return value being possible not being
> have a value.
Thanks for the feedback.
reduced code:
https://godbolt.org/z/KGW5bfrcn
int t1, t2;
int ab() {
int e=t1, f=t2;
if (!e && !f) return 1;
else{
if (e)
return 0;
if (f)
return 1;
}
}
GCC -O3:
ab:
movl t2(%rip), %ecx
movl t1(%rip), %esi
orl %ecx, %esi
je .L2
movl t1(%rip), %eax
xorl %edx, %edx
testl %eax, %eax
jne .L1
testl %ecx, %ecx
jne .L2
.L1:
movl %edx, %eax
ret
.L2:
movl $1, %edx
movl %edx, %eax
ret
Expected (Clang -O3):
ab:
xor eax, eax
cmp dword ptr [rip + t1], 0
sete al
ret
More information about the Gcc-bugs
mailing list