[PATCH] D35498: [LoopVectorizer] Use two step casting for float to pointer type.

Manoj Gupta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 17 15:24:36 PDT 2017


manojgupta added a comment.

In https://reviews.llvm.org/D35498#811867, @mkuper wrote:

> In https://reviews.llvm.org/D35498#811759, @rengolin wrote:
>
> > Setting aside from the fact that no one should ever be casting floating point to pointers, perhaps we shouldn't be even trying to do this transformation here, as I'm not sure this could have a guaranteed semantics in this case, and probably better to just bail the vectorisation?
>
>
> I'm not sure about this. What's happening here, if I understand correctly, is that we have a struct:
>
>   typedef struct CvNode1D
>   {
>       float val;
>       struct CvNode1D *next;
>   }
>   CvNode1D;
>
>
> And we're trying to vectorize code that loads these structs. Since the pointer and the float have the same width, we can load four of the structs as, e.g. 2 * <4 x float>, and then use shuffles to get a vector of 4 floats and a vectors of 4 pointers.
>
> Anyway, I agree this isn't the right fix, but my gut feeling is that the right fix is to actually allow the builder to create a bitcast between a pointer and a pointer-sized float.


Should I update the Builder's CreateBitOrPointerCast function to handle float to pointer casts using float -> int and int -> pointer casts? I can do that or I can create a local pass specific casting function to handle  float -> ptr + other CreateBitOrPointerCast routines used here.

> I don't see anything in the langref that makes the semantics of this undefined. Renato, what kind of semantic issues do you see here?
> 
>> Also, tests, etc. please.
> 
> +1

I am trying to create a reduced test case but no success so far.


https://reviews.llvm.org/D35498





More information about the llvm-commits mailing list