Issue 71429
Summary need a way to report branch removed due to poison values
Labels new issue
Assignees
Reporter yxsamliu
    https://godbolt.org/z/bb3We4ozP

the following code results in an empty function:

`int foo(int *x) {
 int sum = 0;
  for (int i = 0; i < 19; i++) {
    unsigned mask = 1U << (i - 1);
    sum += x[i & mask];
  }
  return sum;
}`

This is because when i is 0, `1U << (i - 1)` is poison. BDCEPass will remove the branches with poison conditions.

However, clang is unable to diagnose this. Since only after loop unrolling the compiler knows `mask` is poison. We cannot simply diagnose any `unsigned << signed` by default since such uses are too common.

This kind of error is pretty common and is difficult for users to debug. Therefore better have a way to let LLVM mid-end to report it. Maybe by some -R options.


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

Reply via email to