https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123312
Bug ID: 123312
Summary: [16 Regression] `c ? a & b : a` has extra instructions
after ifcvt changes
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: pinskia at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: aarch64 x86_64
For:
```
int f(int a, int b, int c)
{
if (c) a &= b;
return a;
}
```
We now get:
```
f:
xorl %eax, %eax
testl %edx, %edx
cmove %edi, %eax
andl %esi, %edi
orl %edi, %eax
ret
```
While we used to get:
```
f:
andl %edi, %esi
movl %edi, %eax
testl %edx, %edx
cmovne %esi, %eax
ret
```
Notice how there is and andl and orl while before we just had an andl.
Though maybe we should get:
```
testl %edx, %edx
movl $-1, %eax
cmovne %esi, %eax
andl %edi, %eax
ret
```
That is:
b = c ? b : -1;
return a & b;