[Bug rtl-optimization/109866] New: Sometimes using sub/test instead just test
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon May 15 18:44:19 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109866
Bug ID: 109866
Summary: Sometimes using sub/test instead just test
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
int g(void); int h(void); int t(void);
int f(int a, int b)
{
int c = a - b;
if(c == 0)
return g();
if (c > 0)
return h();
return t();
}
```
This is reduced from bzip2 in spec 2006, though I am not so sure any more.
On x86_64 GCC produces:
```
subl %esi, %edi
testl %edi, %edi
je .L5
jle .L3
jmp h()
.L3:
jmp t()
.L5:
jmp g()
```
But GCC should produce (likes clang/LLVM does):
```
cmpl %esi, %edi
je .L5
jle .L3
jmp h()
.L3:
jmp t()
.L5:
jmp g()
```
Note a similar thing happens with aarch64 target too.
More information about the Gcc-bugs
mailing list