diff options
author | Huihui Zhang <huihuiz@quicinc.com> | 2020-05-07 13:03:26 -0700 |
---|---|---|
committer | Huihui Zhang <huihuiz@quicinc.com> | 2020-05-07 13:03:52 -0700 |
commit | 1ec0cc0f02432ef640173b319a9c3b13fc850d33 (patch) | |
tree | a49b96045afb5517f2d07bdd3556240f5bdf9124 /llvm/lib/Analysis/VectorUtils.cpp | |
parent | d03838343f2199580a1942eb353901add38af909 (diff) | |
download | llvm-1ec0cc0f02432ef640173b319a9c3b13fc850d33.zip llvm-1ec0cc0f02432ef640173b319a9c3b13fc850d33.tar.gz llvm-1ec0cc0f02432ef640173b319a9c3b13fc850d33.tar.bz2 |
[InstCombine][SVE] Fix visitExtractElementInst for scalable type.
Summary:
This patch fix the following issues with visitExtractElementInst:
1. Restrict VectorUtils::findScalarElement to fixed-length vector.
For scalable type, the number of elements in shuffle mask is
unknown at compile-time.
2. Fix out-of-range calculation for fixed-length vector.
3. Skip scalable type when analysis rely on fixed number of elements.
4. Add unit tests to check functionality of extractelement for scalable type.
Reviewers: sdesmalen, efriedma, spatel, nikic
Reviewed By: efriedma
Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D78267
Diffstat (limited to 'llvm/lib/Analysis/VectorUtils.cpp')
-rw-r--r-- | llvm/lib/Analysis/VectorUtils.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp index a96686a..f16b04e 100644 --- a/llvm/lib/Analysis/VectorUtils.cpp +++ b/llvm/lib/Analysis/VectorUtils.cpp @@ -288,9 +288,11 @@ Value *llvm::findScalarElement(Value *V, unsigned EltNo) { return findScalarElement(III->getOperand(0), EltNo); } - if (ShuffleVectorInst *SVI = dyn_cast<ShuffleVectorInst>(V)) { + ShuffleVectorInst *SVI = dyn_cast<ShuffleVectorInst>(V); + // Restrict the following transformation to fixed-length vector. + if (SVI && isa<FixedVectorType>(SVI->getType())) { unsigned LHSWidth = - cast<VectorType>(SVI->getOperand(0)->getType())->getNumElements(); + cast<FixedVectorType>(SVI->getOperand(0)->getType())->getNumElements(); int InEl = SVI->getMaskValue(EltNo); if (InEl < 0) return UndefValue::get(VTy->getElementType()); |