[PATCH] D79202: [SVE] Fix invalid usages of getNumElements() in ValueTracking

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 17:15:40 PDT 2020


ctetreau marked an inline comment as done.
ctetreau added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:378
   APInt DemandedElts =
-      Ty->isVectorTy()
-          ? APInt::getAllOnesValue(cast<VectorType>(Ty)->getNumElements())
-          : APInt(1, 1);
+      FVTy ? APInt::getAllOnesValue(FVTy->getNumElements()) : APInt(1, 1);
   return ComputeNumSignBits(V, DemandedElts, Depth, Q);
----------------
sdesmalen wrote:
> By checking the result of `dyn_cast<FixedVectorType>`, this switch will select APInt(1, 1) when Ty is a `ScalableVectorType`.
> I guess this should just bail out when the type is a scalable vector.
I did this on purpose for the same reasoning as in D79053.

Though I'm no longer convinced that it will work for that commit either. I'm thinking these might need a bigger rework that I was hoping to do today. Some sort of scalable APInt? Or maybe we just need a polynomial type?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79202





More information about the llvm-commits mailing list