[PATCH] D35498: [LoopVectorizer] Use two step casting for float to pointer type.
Renato Golin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 09:13:38 PDT 2017
rengolin added a comment.
In https://reviews.llvm.org/D35498#811867, @mkuper wrote:
> 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.
Right, sorry, I missed the bug reference.
> 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.
> 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?
I agree the vectorizer can "safely" assume this case is ok because we know the original datatype was a pointer anyway and this is part of a strided load, but I feel we'd be opening a can of worms if we start allowing any float<->pointer conversion by default.
For example, a different case would be pointer->float->double->pointer. C has automatic promotions, and some corner cases may slip and create that sequence, which would destroy the bit-pattern and therefore the memory address.
So, if we can do this in this specific case, Manoj's current fix is "better" than moving it up `CreateBitOrPointerCast`, because we know what the semantics is. Or maybe we just load them as "data" (i32/i64?) and then bitcast safely?
Makes sense?
https://reviews.llvm.org/D35498
More information about the llvm-commits
mailing list