[PATCH] D77264: Clean up usages of asserting vector getters in Type

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 07:24:05 PDT 2020


sdesmalen added inline comments.


================
Comment at: llvm/lib/Target/X86/X86TargetTransformInfo.cpp:935
                                       LT.second.getVectorNumElements());
-        Type *SubTy = VectorType::get(Tp->getVectorElementType(),
+        Type *SubTy = VectorType::get(cast<VectorType>(Tp)->getElementType(),
                                       SubLT.second.getVectorNumElements());
----------------
This code calls `cast<VectorType>(Tp)` several times, so it's probably worth putting that in a separate `VectorType *VTp`.
A quick scan through the codebase leads me to believe that Tp is always a VectorType.


================
Comment at: llvm/lib/Target/X86/X86TargetTransformInfo.cpp:2721
   if (LT.first != 1 && MTy.isVector() &&
-      MTy.getVectorNumElements() < ValTy->getVectorNumElements()) {
+      MTy.getVectorNumElements() < cast<VectorType>(ValTy)->getNumElements()) {
     // Type needs to be split. We need LT.first - 1 arithmetic ops.
----------------
cast<VectorType>(ValTy) could also fit into a separate variable. I expect ValTy is always of type VectorType.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77264/new/

https://reviews.llvm.org/D77264





More information about the llvm-commits mailing list