PATCH: SelectionDAG: Use MVT::i32 for vector indices

Duncan Sands duncan.sands at gmail.com
Mon Jul 29 05:41:11 PDT 2013


Hi Tom,

> The attached patch ensures that the SelectionDAG always uses MVT::i32
> for the index operands of EXTRACT_VECTOR_ELT, INSERT_VECTOR_ELT,
> INSERT_SUBVECTOR, and EXTRACT_SUBVECTOR.  MVT::i32 was chosen because
> the LLVM IR specification uses i32 for all its vector instructions that
> take an index arguement.

I think this is a bad idea since it assumes that the i32 type is legal for
all platforms.

> The previous code was using TargetLowering::getPointerTy() for vector
> indices.  I think the reason for this was to make it easier to handle
> non-constant vector indices, which required that the vector be
> stored in memory.

I think the real reason is that an integer type with the same size as a pointer
is required to be a legal type on all platforms.

>
> Using TargetLowering::getPointerTy() can be a problem for targets with
> pointer sizes that differ across address spaces, since the address space
> used to store the vector may have a different pointer size than the
> 'zero' address space which is what TargetLowering::getPointerTy() uses.

I think this is a different issue to the one of always using an integer type
that is guaranteed to be legal.

Ciao, Duncan.

>
> There are two motivations for this patch, the first is to clean
> up some bad code that is generated when using dynamic indexing
> of vectors in the R600 target.  The second is to reduce the use of
> TargetLowering::getPointerTy() in the SelectionDAG code which will help
> anyone who is trying to improve support for targets with pointer sizes
> that differ across address spaces.
>
> Please Review.
>
> Thanks,
> Tom
>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list