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

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 23:37:37 PDT 2017


Ayal added inline comments.


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2922
           VectorType *OtherVTy = VectorType::get(Member->getType(), VF);
           StridedVec = Builder.CreateBitOrPointerCast(StridedVec, OtherVTy);
         }
----------------
Ayal wrote:
> Same floating-point-vs-pointer type casting issue may hold for interleaved loads here as well, right?
Thanks. This interleaved loads case requires a test.


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:2956
+          // StoredVec cannot be directly casted to SubVT type.
+          // May happen when StoredVec is Floating point vector but SubVT is a
+          // pointer type.
----------------
Ayal wrote:
> Or the other way around, when the last appearing store marking the insertion position of the final wide store has SubVT type of floating point, and another member has StoredVec type of a pointer. E.g., when the fields are swapped within the struct.
This swapped case requires a test.


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:3322
+  Value *CastVal = nullptr;
+  if (VectorType *SrcVecTy = dyn_cast<VectorType>(V->getType())) {
+    Type *SrcElemTy = SrcVecTy->getElementType();
----------------
This function assumes V has vector type, having same number of elements as VTy, and both have elements of same size in bits. These properties can be asserted upfront.

Suffice to check once if direct cast works and exit early if so.
If not, assert one is a pointer and the other a floating point.
Suffice to have only one copy of the code creating the two casts.

Explain (in method declaration above) that we're bit casting from V to VTy, and/or use more informative variable names.


https://reviews.llvm.org/D35498





More information about the llvm-commits mailing list