[LLVMdev] vectorize a def-use chain

Jason thesurprises at gmail.com
Wed Jul 8 15:48:38 PDT 2015


Two ways I've done this:
1. Create a ReplaceAllUsesWithUnsafe() function that does the same as
ReplaceAllUsesWith except without the check for compatible types, knowing
that eventually you will end up with a fully compatible instruction
eventually.
2. Do a recursive traversal up the use-def chain from the store back
through all the args.  This will ensure that at every instruction, all the
args will have been vectorized through the recursion, and all you really
need to do at that point is call Instruction::mutateType() to ensure the
return type of the instruction matches the vector args.

Thanks
Jason

On Wed, Jul 8, 2015 at 3:18 PM, Frank Winter <fwinter at jlab.org> wrote:

> I'd like to replace scalar instructions with vector instructions such that
> the code corresponding to following tree would be vectorized:
>
> load0  load1
>   \     /
>    \   /
>     add/sub/mul
>      |
>      |
>    store
>
> I had unsuccessful encounters with load0->replaceAllUsesWith(vec_load0)
> complaining about mismatching type (makes sense, add's other operand is
> still scalar at that time..)
>
> Is the only way to create a vectorized version of this tree by
>
> 1) creating the vector loads vec_load0 AND vec_load1
> 2) retrieving the opcode of the arithmetic instruction and create a new
> one according to the opcode
>
> How is step 2) in donepractice? Cloning the instruction and replacing the
> operands? (would that bypass the type checking for a moment?)
>
> Thanks,
> Frank
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150708/4b747382/attachment.html>


More information about the llvm-dev mailing list