[PATCH] D101533: [TTI] NFC: Change getTypeLegalizationCost to return InstructionCost.

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 30 08:20:30 PDT 2021


sdesmalen added a comment.

Thanks for your effort to revert the `auto` changes. Just have two nits, other than that the patch looks good to me!



================
Comment at: llvm/include/llvm/CodeGen/BasicTTIImpl.h:360
   unsigned getRegUsageForType(Type *Ty) {
-    return getTLI()->getTypeLegalizationCost(DL, Ty).first;
+    return *getTLI()->getTypeLegalizationCost(DL, Ty).first.getValue();
   }
----------------
nit: given that InstructionCost is signed (it uses `int` as the CostType), would it be an idea to add an assert that the value is >= 0?


================
Comment at: llvm/lib/Target/X86/X86TargetTransformInfo.cpp:3162
         // Case#3: inserting into 4,5,6,7 index needs 4*vpinsrd + inserti128.
-        unsigned Num128Lanes = LT.second.getSizeInBits() / 128 * LT.first;
-        unsigned NumElts = LT.second.getVectorNumElements() * LT.first;
+        const InstructionCost::CostType CostValue = *LT.first.getValue();
+        unsigned Num128Lanes = LT.second.getSizeInBits() / 128 * CostValue;
----------------
nit: Maybe just use `int` instead of `const InstructionCost::CostType`? (+ assert that the value is >= 0)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101533



More information about the llvm-commits mailing list