[LLVMdev] Auto-vectorization and phi nodes

Vesa Norilo vnorilo at siba.fi
Tue Feb 19 10:33:17 PST 2013


19.2.2013 20:16, Nadav Rotem kirjoitti:
>
> On Feb 19, 2013, at 10:09 AM, Vesa Norilo <vnorilo at siba.fi> wrote:
>
>> LV: Found an unidentified PHI.  %a.ptr = phi float* [ %a, %Top ], [ %a.next, %Loop ]
>>
> Yes. SCEV does not identify this PHI. You can add a breakpoint in "isInductionVariable" to verify this.  How are you generating this code ? Do you have a  C example for it ?
>
> Thanks,
> Nadav
>
>

Sorry, no C example. I'm writing a frontend for a functional language 
that generates a bunch of tail calls that iterate through arrays by 
passing incremented pointers and a decrementing induction var as 
arguments to tail recursion. LLVM makes very neat scalar loop code out 
of this, but fails to vectorize.

I wrote the IR I posted by hand to get a minimal example. The reason why 
it's quite tricky for me to emit [baseptr+indvar] style IR is that base 
pointer isn't local to the function body until after tail call 
optimization. Any suggestions are welcome!

I actually wrote a quick pass that moves those phi nodes out of a loop 
body and replaces them with base+index, but the resulting machine code 
is rather bad (full of gather/scatter), probably because I needed to 
screw with the order of llvm optimization passes without a deep enough 
understanding of how they interact.

All the best,
Vesa



More information about the llvm-dev mailing list