[PATCH] D132477: Improve cost model for some 128-bit vector operations that use SVE

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 23 09:23:59 PDT 2022


sdesmalen added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:2044
       // expanded into scalar divisions of each pair of elements.
-      Cost += getArithmeticInstrCost(Instruction::ExtractElement, Ty, CostKind,
-                                     Op1Info, Op2Info);
-      Cost += getArithmeticInstrCost(Instruction::InsertElement, Ty, CostKind,
-                                     Op1Info, Op2Info);
+      if (OverrideNEON || (isa<ScalableVectorType>(Ty))) {
+        bool IsFloat = Ty->isFPOrFPVectorTy();
----------------
hassnaa-arm wrote:
> @sdesmalen 
> I noticed something here,
> is using that **isa** for Ty is correct, give that Ty is a ptr of "Type" ?
> I thought about using Ty.isVectorTy(), but it returns true for both scalable and fixed vectors, so it doesn't work here.
`class ScalableVectorType` subclasses from `class VectorType`, which in turn subclasses from `class Type`.
`class FixedVectorType` also subclasses from `class VectorType`.

If `Ty` is a `Type*`, you can ask at runtime if `Ty` is actually an object of class `ScalableVectorType` using `isa<ScalableVectorType>(Ty)`.

If you ask `Ty->isVectorTy()` it will return true if it is either a `FixedVectorType` or a `ScalableVectorType`, which means that is synonymous with `isa<VectorType>(Ty)`.

So yes, if you want to check if a `Type *` is actually a `ScalableVectorType*`, then using `isa` seems correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132477



More information about the llvm-commits mailing list