[PATCH] D77258: 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:07 PDT 2020


sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM!



================
Comment at: mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp:1597
           auto splatAttr = SplatElementsAttr::get(
-              mlir::VectorType::get(
-                  {llvmVectorTy.getUnderlyingType()->getVectorNumElements()},
-                  floatType),
+              mlir::VectorType::get({(unsigned)cast<llvm::VectorType>(
+                                         llvmVectorTy.getUnderlyingType())
----------------
ctetreau wrote:
> efriedma wrote:
> > ctetreau wrote:
> > > sdesmalen wrote:
> > > > is the cast to `unsigned` needed?
> > > VectorType::getNumElements() returns uint64_t, where Type::getVectorNumElements() returned unsigned. At least in visual studio, this results in an error due to a narrowing conversion.
> > > 
> > > I have no idea why this is, I can't imagine that we'd need 64 bits to express the number of vector lanes.
> > Actually, I'm pretty sure it's actually "SequentalType::getNumElements()" returns a uint64_t.
> > 
> > We could consider changing that once I land the patch to kill SequentialType.
> I added D77763 to change it. Most of the calls to this were through getVectorNumElements() anyways, which did the cast.
Thanks for that!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77258





More information about the llvm-commits mailing list