[llvm] [VPlan] Make VPInstruction::AnyOf poison-safe. (PR #154156)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 19 06:34:45 PDT 2025
david-arm wrote:
Isn't there still a bug here? I think the freezes for any-of are only partially fixing the problem, since there is the issue of outside use of the compares too. Consider
```
vector.body: ; preds = %vector.body, %vector.ph
...
%6 = icmp ne <4 x i32> %4, zeroinitializer
%7 = icmp ne <4 x i32> %5, zeroinitializer
...
%8 = freeze <4 x i1> %6
%9 = freeze <4 x i1> %7
%10 = or <4 x i1> %8, %9
%11 = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> %10)
...
vector.early.exit: ; preds = %middle.split
...
%idx1 = call i64 @llvm.experimental.cttz.elts.i64.v4i1(<4 x i1> %6, i1 true)
%extract1 = extractelement <4 x i32> %some_val1, i32 %idx1
...
%idx2 = call i64 @llvm.experimental.cttz.elts.i64.v4i1(<4 x i1> %6, i1 true)
%extract2 = extractelement <4 x i32> %some_val2, i32 %idx2
```
We're calculating the lane to extract multiple times for each outside use, so if we don't freeze `%6` we're potentially going to get different lane indices each time if `%6` happens to be something like <0, 0, poison, 0>.
https://github.com/llvm/llvm-project/pull/154156
More information about the llvm-commits
mailing list