Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I have updated the whole method CastInst::castISValid to correctly
support scalable vectors.
llvm/lib/IR/Instructions.cpp | ||
---|---|---|
3240–3245 | Nit: While doing some of the modification you have asked me, I got confused by the fact that the variables [Src|Dst]BitSize are referring to the size of the scalars, not of the whole [Src|Dst]Ty. Is it OK if I rename them to [Src|Dst]ScalarBitSize? | |
3241 | getScalarSizeInBits implicitly casts the TypeSize of getScalarType()->getPrimitiveSizeInBits() into an integer, an operation that we have agreed to mark as deprecated. I probably should have mentioned this in the commit message. getScalarSizeInBits is implemented as follows: unsigned Type::getScalarSizeInBits() const { return getScalarType()->getPrimitiveSizeInBits(); } Given that we don't expect "scalar" values to be scalable, I can revert this change to use unsigned values, and maybe submit a separate patch that adds an assertion inside getScalarSizeInBits that makes sure to check that the TypeSize retrieved by getPrimitiveSizeInBits is not a scalable TypeSize. The method will look like this after the change (disclaimer, I didn't compile it!): unsigned Type::getScalarSizeInBits() const { TypeSize TS = getScalarType()->getPrimitiveSizeInBits(); assert(!TS.isScalable() && "Invalid type.") return TS.getKnownMinSize(); } Please let me know which of the following you want me to do:
| |
3285–3286 |
Yes, on it. How about also creating two boolean vars that hold the isa<VectorType>([Src|Dst]Ty) and use them instead of the isa<VectorType>([Src|Dst]Ty) or dyn_cast<VectorType>([Src|Dst]Ty).? |
Hi @efriedma,
thank you for your review!
I have addressed all your comments, and applied the following changes:
- restored the use of unsigned for the size in bits. I have created a
separate patch that updated the unsigned Type::getScalarSizeInBits()
to use TypeSize::getFixedSize(): https://reviews.llvm.org/D76892
- I have fixed the tests that were refusing to bitcast fixed size
vectors to scalable vectors (and viceversa). In the previous patch I
erroneusly used scalable vectors everywhere, just with different
lanes.
- I have replaced the use of getVectorElementCount with variables
that are set at the beginning of the method.
- I have renamed [Src|Dst]BitSize to [Src|Dst]ScalarBitSize, to
avoid confusion when dealing with vector types instead of scalars.
Kind regards,
Francesco
Last but not least, I have renamed [Src|Dst]Length into [Src|Dst]EC as the variables now hold ElementCount and not unsigned.
What's wrong with getScalarSizeInBits()?