https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114331
Bug ID: 114331
Summary: Missed optimization: indicate knownbits from
dominating condition switch(trunc(a))
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: xxs_chy at outlook dot com
Target Milestone: ---
Godbolt link: https://godbolt.org/z/dso53ndTo
For code like:
int src(int num) {
switch((short)num){
case 111:
return num & 0xfffe;
case 267:
case 204:
case 263:
return 0;
default:
dummy();
return 0;
}
}
"num & 0xfffe" can be folded to "110". But both LLVM and GCC fail to fold it.