[PATCH] D103378: [VectorCombine] Freeze index unless it is known to be non-poison.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 14 09:07:22 PDT 2021
efriedma added inline comments.
================
Comment at: llvm/test/Transforms/VectorCombine/AArch64/load-extractelement-scalarization.ll:153
+; CHECK-NEXT: [[R:%.*]] = load i32, i32* [[TMP1]], align 4
; CHECK-NEXT: ret i32 [[R]]
;
----------------
fhahn wrote:
> efriedma wrote:
> > This is still not right. See https://alive2.llvm.org/ce/z/dqg8HF
> Thanks Eli, I thought I ran Alive2 on the test after the changes but something went wrong. I limited the transform to non-poison indices only for now in 96ca03493ae5.
>
> Not sure if there's much else we can do to make this save using freeze, if we cannot rely on the constrained range.
The following is legal, in general:
```
define i32 @src(<4 x i32>* %x, i4 %idx) {
entry:
%lv = load <4 x i32>, <4 x i32>* %x
%r = extractelement <4 x i32> %lv, i4 %idx
ret i32 %r
}
define i32 @tgt(<4 x i32>* %x, i4 %idx) {
entry:
%idx.freeze = freeze i4 %idx
%idx.clamped = and i4 %idx.freeze, 3
%gep = getelementptr inbounds <4 x i32>, <4 x i32>* %x, i32 0, i4 %idx.clamped
%r = load i32, i32* %gep
ret i32 %r
}
```
I haven't thought about when it's profitable.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103378/new/
https://reviews.llvm.org/D103378
More information about the llvm-commits
mailing list