This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking][SVE] Fix getOffsetFromIndex for scalable vector.
ClosedPublic

Authored by huihuiz on Mar 19 2020, 4:50 PM.

Details

Summary

Return None if GEP index type is scalable vector. Size of scalable vectors
are multiplied by a runtime constant.

Avoid transforming:

%a = bitcast i8* %p to <vscale x 16 x i8>*
%tmp0 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i64 0
store <vscale x 16 x i8> zeroinitializer, <vscale x 16 x i8>* %tmp0
%tmp1 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i64 1
store <vscale x 16 x i8> zeroinitializer, <vscale x 16 x i8>* %tmp1

into:

%a = bitcast i8* %p to <vscale x 16 x i8>*
%tmp0 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i64 0
%1 = bitcast <vscale x 16 x i8>* %tmp0 to i8*
call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 32, i1 false)

Diff Detail

Event Timeline

huihuiz created this revision.Mar 19 2020, 4:50 PM
efriedma added inline comments.Mar 19 2020, 6:13 PM
llvm/lib/Analysis/ValueTracking.cpp
6157

If we're calling getTypeAllocSize anyway, can we just check whether it returns a scalable TypeSize?

huihuiz updated this revision to Diff 251679.Mar 20 2020, 9:47 AM
huihuiz marked 2 inline comments as done.

Address review comments.

llvm/lib/Analysis/ValueTracking.cpp
6157

Thanks Eli for the feedback! Yes, that sounds better.

sdesmalen accepted this revision.Mar 20 2020, 10:30 AM

Thanks for this patch! Looks good to me.

This revision is now accepted and ready to land.Mar 20 2020, 10:30 AM
This revision was automatically updated to reflect the committed changes.