[LLVMdev] First attempt at recognizing pointer reduction

Renato Golin renato.golin at linaro.org
Mon Oct 21 08:23:50 PDT 2013


Hi Nadav, Arnold,

I managed to find some time to work on the pointer reduction, and I got a
patch that can make "canVectorize()" pass.

Basically what I do is to teach AddReductionVar() about pointers, saying
they don't really have an exit instructions, and that (maybe) the final
store is a good candidate (is it?).

This makes it recognize the writes and reads, but then
"canVectorizeMemory()" bails because it can't find the array bounds. This
will be my next step, but I'd like to know if I'm in the right direction,
with the right assumptions about the reduction detection, before proceeding
into more complicated bits.

An example of the debug output I get for my earlier example:

LV: Checking a loop in "fn1"
LV: Found a loop: for.body

== Induction ==

LV: Found an induction variable.

== Our write reduction ==

LV: Found a pointer add reduction PHI.  %WRITE913 = phi i8* [
%incdec.ptr18, %for.body ], [ %WRITE, %for.body.preheader ]

== Not sure what this is... Will check. ==

LV: Found an non-int non-pointer PHI.

== Our read reduction ==

LV: Found a pointer add reduction PHI.  %READ1012 = phi i8* [ %incdec.ptr2,
%for.body ], [ %READ, %for.body.preheader ]

== Below are the memory operations's validation, which I'll deal with later
==

LV: Found an unidentified write ptr: i8* %WRITE
LV: Found an unidentified write ptr: i8* %WRITE
LV: Found an unidentified write ptr: i8* %WRITE
LV: Found an unidentified read ptr: i8* %READ
LV: Found an unidentified read ptr: i8* %READ
LV: Found an unidentified read ptr: i8* %READ
LV: Found a runtime check ptr:  %WRITE913 = phi i8* [ %incdec.ptr18,
%for.body ], [ %WRITE, %for.body.preheader ]
LV: Found a runtime check ptr:  %incdec.ptr16 = getelementptr inbounds i8*
%WRITE913, i64 1
LV: Found a runtime check ptr:  %incdec.ptr17 = getelementptr inbounds i8*
%WRITE913, i64 2
LV: Found a runtime check ptr:  %READ1012 = phi i8* [ %incdec.ptr2,
%for.body ], [ %READ, %for.body.preheader ]
LV: Found a runtime check ptr:  %incdec.ptr = getelementptr inbounds i8*
%READ1012, i64 1
LV: Found a runtime check ptr:  %incdec.ptr1 = getelementptr inbounds i8*
%READ1012, i64 2
LV: We need to do 18 pointer comparisons.
LV: We can't vectorize because we can't find the array bounds.

cheers,
--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131021/9dbace7c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pointer-reduction.patch
Type: application/octet-stream
Size: 3694 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131021/9dbace7c/attachment.obj>


More information about the llvm-dev mailing list