[PATCH] Allow loop vectorization with llvm.lifetime calls

Arnold Schwaighofer aschwaighofer at apple.com
Wed Jul 31 12:08:54 PDT 2013


On Jul 31, 2013, at 1:34 PM, Jessome, Marc <marc.jessome at intel.com> wrote:

> Hi Arnold,
> 
> I've attached an updated patch, however I do have a quick question about one of your comments.
> 
> Your comment about the need to use getVectorValue() rather than getArgOperand() is spot on. I am wondering, however, if we want to do this only for the first element of the vector, or if it should be done for each element?
> In the latter case, a simple scalarizeInstruction() would suffice, rather than manually extracting the arguments and rebuilding lifetime.* calls.

I was (probably mistakenly) assuming that we cannot have loop variant pointers as argument to lifetime intrinsic calls. For example: 

+for.body:
+  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+  %0 = getelementptr [1024 x i32]* %arr, 0, indvars.iv
+  %1 = bitcast [1024 x i32]* %0 to i8*
+  call void @llvm.lifetime.start(i64 4, i8* %1) #1


If we can have a construct like the one above (which I don’t see why we shouldn’t) then yes you need to scalarize the elements of getVectorValue() individually like done by scalarizeInstruction.

The question then remains whether to subsequent calls to a lifetime intrinsic are legal. I don’t see anything in "http://llvm.org/docs/LangRef.html#llvm-lifetime-start-intrinsic” that leads me to believe it would not be.

+  %0 = bitcast [1024 x i32]* % arr to i8*
+  call void @llvm.lifetime.start(i64 4, i8* %0) #1
+  call void @llvm.lifetime.start(i64 4, i8* %0) #1

Maybe Nadav knows?



More information about the llvm-commits mailing list