[PATCH] D108699: [LAA] Analyze pointers forked by a select
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 23 16:19:20 PST 2021
fhahn added a comment.
In D108699#3150041 <https://reviews.llvm.org/D108699#3150041>, @fhahn wrote:
> I just realized how this may be a bit similar to how we handle pointers that are phi nodes. Currently those are handled by adding accesses for both incoming values (see D109381 <https://reviews.llvm.org/D109381>). Unfortunately the same approach cannot be directly used for selects, because we need to create 2 pointers that do not exist in the IR.
>
> But if `MemAccessInfo`/ would also carry the pointer SCEV directly, I think it would be possible to avoid adding another dimension to `RuntimePointerChecking::PointerInfo`. Instead we would add 2 PointerInfo entries with separate translated pointer SCEVs. I put up a rough sketch of what this may look like in D114480 <https://reviews.llvm.org/D114480>, D114479 <https://reviews.llvm.org/D114479> to see how this may look like
I also put up a sketch of a stripped down variant that only supports runtime check generation by adding multiple `PointerInfos` with different associated pointer SCEVs: D114487 <https://reviews.llvm.org/D114487>.
The variant that also extends `MemAccessInfo` should also be able to determine that certain loops are safe without runtime checks, e.g. like the one below I think:
%s1 = type { [32000 x float], [32000 x float], [32000 x float] }
define dso_local void @foo(%s1 * nocapture readonly %Base, i32* nocapture readonly %Preds) {
entry:
br label %for.body
for.cond.cleanup:
ret void
for.body:
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
%arrayidx = getelementptr inbounds i32, i32* %Preds, i64 %indvars.iv
%0 = load i32, i32* %arrayidx, align 4
%cmp1.not = icmp eq i32 %0, 0
%gep.1 = getelementptr inbounds %s1, %s1* %Base, i64 0, i32 1, i32 0
%gep.2 = getelementptr inbounds %s1, %s1* %Base, i64 0, i32 2, i32 0
%spec.select = select i1 %cmp1.not, float* %gep.1, float* %gep.2
%.sink.in = getelementptr inbounds float, float* %spec.select, i64 %indvars.iv
%.sink = load float, float* %.sink.in, align 4
%1= getelementptr inbounds %s1, %s1 * %Base, i64 0, i32 0, i64 %indvars.iv
store float %.sink, float* %1, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.not = icmp eq i64 %indvars.iv.next, 100
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
}
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108699/new/
https://reviews.llvm.org/D108699
More information about the llvm-commits
mailing list