[PATCH] D77259: Clean up usages of asserting vector getters in Type

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 09:00:41 PDT 2020


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


================
Comment at: llvm/lib/Transforms/Vectorize/VectorCombine.cpp:281
   // TODO: Handle bitcast from narrow element type to wide element type.
-  assert(SrcTy->isVectorTy() && "Shuffle of non-vector type?");
-  unsigned DestNumElts = DestTy->getVectorNumElements();
-  unsigned SrcNumElts = SrcTy->getVectorNumElements();
+  assert(SrcTy && "Shuffle of non-vector type?");
+  unsigned DestNumElts = DestTy->getNumElements();
----------------
sdesmalen wrote:
> Now that SrcTy is of type VectorType because of the `cast<>`, this assert can be removed.
I agree and will fix it, but for the record: whenever this happens, I did it so that the assert message wouldn't change.

It might be nice if cast() had an overload that took a message that was used for the assert, but that's a problem for another day. Something like:

```
auto *t = cast<Foo>(bar, "This is guaranteed to be a Foo becasue it's the return value of a BarInst");
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77259





More information about the llvm-commits mailing list