Issue |
139944
|
Summary |
Missed DCE for __builtin_{clzg,ctzg} when bitshift
|
Labels |
new issue
|
Assignees |
|
Reporter |
BreadTom
|
[Godbolt](https://godbolt.org/z/G89zK5brd) and [GCC bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120279)
```
unsigned long f0(unsigned long arg0, int arg1){
int tmp1;
if(arg1){
tmp1 = __builtin_ctzg(arg0, 0);
return (arg0 >> tmp1);
}
tmp1 = __builtin_clzg(arg0, 0);
return (arg0 << tmp1);
}
unsigned long f1(unsigned long arg0, int arg1){
int tmp1;
if(arg1){
tmp1 = __builtin_clzg(arg0, 0);
arg0 <<= tmp1;
tmp1 = __builtin_ctzg(arg0, 0);
arg0 >>= tmp1;
return arg0;
}
tmp1 = __builtin_ctzg(arg0, 0);
arg0 >>= tmp1;
tmp1 = __builtin_clzg(arg0, 0);
arg0 <<= tmp1;
return arg0;
}
```
f1() uses __builtin_ctzg() then __builtin_clzg() for returning ARG0 when it could instead use __builtin_clzg() in f0() (Vice versa) with flags -O3 -march=icelake-client.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs