Issue 140100
Summary Missed VRP with __builtin_popcount() when bitshift with __builtin_{ctzg, clzg}
Labels
Assignees
Reporter BreadTom
    [Godbolt](https://godbolt.org/z/Ybco775zT)
[GCC bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120296)
```
extern void f0_unreachable(void);

void f0(unsigned int arg0, unsigned char arg1){
 int tmp0;
    unsigned int tmp1;
    int tmp2[2];
    if(arg1){
 tmp0 = __builtin_ctzg(arg0, 0);
        tmp1 = arg0 >> tmp0;
    } else {
 tmp0 = __builtin_clzg(arg0, 0);
        tmp1 = arg0 << tmp0;
    }
 tmp2[0] = __builtin_popcount(arg0);
    tmp2[1] = __builtin_popcount(tmp1);
    if(tmp2[0] != tmp2[1])
 f0_unreachable();
}
```
When bitshifting ARG0 till it reaches one (or zero if it is zero), popcount should remain same and should not execute f0_unreachable() 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

Reply via email to