[Bug middle-end/122519] New: Extra cset with movcc expansion due to ccmp depending on ter
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Nov 1 20:00:06 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122519
Bug ID: 122519
Summary: Extra cset with movcc expansion due to ccmp depending
on ter
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: aarch64
```
int __GIMPLE extra_cset (int a, int b, int c, int d)
{
int t;
bool bb;
bool bb1;
bb = a == 3;
bb1 = b == 100;
bb = bb & bb1;
t = bb ? c : d;
return t;
}
int __GIMPLE ccmpok (int a, int b, int c, int d)
{
int t;
bool bb;
bool bb2;
bool bb1;
bb2 = a == 3;
bb1 = b == 100;
bb = bb2 & bb1;
t = bb ? c : d;
return t;
}
```
With `-O1 -fgimple`
These 2 functions should produce the same code but since ccmp depends on ter
and ter in the extra_cset decides not to combine in the bb assignment, we get
an extra cset.
To fix this, we need to recognize ccmp outside of expand and not depend on TER.
More information about the Gcc-bugs
mailing list