| Issue |
238297
|
| Summary |
[LAA] Missing runtime check for unknown dependences through non-header pointer phis (miscompile)
|
| Labels |
miscompilation,
vectorizers,
llvm:transforms
|
| Assignees |
|
| Reporter |
SavchenkoValeriy
|
LAA drops the runtime check between two accesses with an unknown dependence when both pointers go through non-header phis. LV then vectorizes a loop-carried dependence. This miscompiles at plain -O3. [Godbolt](https://llvm.godbolt.org/z/eb9xrz46G).
In that reproducer it prints `a[8]: scalar 2, vectorized 1`.
### Analysis
LAA requires only d vs {p0, p1} and d vs {q0, q1}. It omits {p0, p1} vs {q0, q1}, although p and q access a at a runtime distance of 4*k.
The reason for that is that `visitPointers` expands the non-header phis `%p`/`%q` into their incoming pointers, so `DepCands` holds `%p0`, `%p1`, `%q0`, `%q1`. The dependence checker records the p<->q unknown dependences against the load/store instructions. On the retry, `AccessAnalysis::canCheckPtrAtRT erases classes` by `getPointerOperand(I)`, i.e. the phi. The phi is not in `DepCands`, so `eraseClass` is a no-op and the class survives. All four pointers then share a dependence set and get no check against each other.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs