Issue 76085
Summary Switch default destination not eliminated despite known value range
Labels new issue
Assignees
Reporter mattiase
    A fully populated switch with known value range (but no explicit `default` clause) will still generate a conditional jump to the default destination:
```C
void canthappen(void);
int g(int);

int f(int x) {
  if (x >= 0 && x <= 3) {
    switch (x) {
    case 0: return g(2);
    case 1: return g(3);
    case 2: return g(4);
    case 3: return g(5);
    }
    canthappen();
 }
  return -23;
}
```
results in a never-taken conditional branch to code that calls `canthappen`.
llvm 18.0.0git (9f74e6e6157bc4d63a28385c7c0a50506bb8a737).

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to