[llvm] [VPlan] Make VPInstruction::AnyOf poison-safe. (PR #154156)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 19 07:47:36 PDT 2025


david-arm wrote:

Yeah that's my understanding of @llvm.experimental.cttz.elts as well. My point was more that we repeatedly use the comparison in the early exit block every time we want to calculate the last index in order to know which element to extract. Suppose the comparison was genuinely poison, then we'll end up using poison many times without freezing it. Suppose you had a loop like this:

```
  unsigned i = 0;
  memcpy(tmp, v, n * sizeof(int));
  for (; i < n; i++) {
    if (v[i] >> i)
      break;
  }
  if (v[i] != tmp[i])
    abort();
```

An arithmetic shift right of `v[i]` could lead to poison and we may or may not trigger the early exit. However, even if poison does lead to an early exit then `v[i]` should still always equal `tmp[i]`, but the vectoriser effectively recalculates the indices for `v[i]` and `tmp[i]` using the unfrozen vector comparison `v[i] >> i != 0`. My point is that after vectorising this loop we may abort.

https://github.com/llvm/llvm-project/pull/154156


More information about the llvm-commits mailing list