[PATCH] D79202: [SVE] Fix invalid usages of getNumElements() in ValueTracking
Sander de Smalen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 1 17:15:01 PDT 2020
sdesmalen added a comment.
Is there a way we can test/guard this?
================
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);
----------------
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.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:2698
+ DemandedElts.getBitWidth()) ||
+ (!isa<FixedVectorType>(Ty) && DemandedElts == APInt(1, 1))) &&
"Unexpected vector size");
----------------
This should be `!isa<VectorType>`, because APInt(1, 1) doesn't work for scalable vectors.
Should this function also bail out early when the type is a scalablevector?
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