diff options
author | Huihui Zhang <huihuiz@quicinc.com> | 2019-12-05 13:38:07 -0800 |
---|---|---|
committer | Huihui Zhang <huihuiz@quicinc.com> | 2019-12-05 19:43:19 -0800 |
commit | 381d3c5c45c55c00f8d561eaff03b460953ca5c0 (patch) | |
tree | 9d8ec244bdce72abf21afc2c3903909802f0132a /llvm/lib/IR | |
parent | 759909506c2b557b9bc5cd3883970dea48e0b86b (diff) | |
download | bcm5719-llvm-381d3c5c45c55c00f8d561eaff03b460953ca5c0.tar.gz bcm5719-llvm-381d3c5c45c55c00f8d561eaff03b460953ca5c0.zip |
[ConstantFold][SVE] Skip scalable vectors in ConstantFoldInsertElementInstruction.
Summary:
Should not constant fold insertelement instruction for scalable vector type.
Reviewers: huntergr, sdesmalen, spatel, levedev.ri, apazos, efriedma, willlovett
Reviewed By: efriedma, spatel
Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70985
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index f6dbe9b5ea9..bf01f9f2ae6 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -833,6 +833,12 @@ Constant *llvm::ConstantFoldInsertElementInstruction(Constant *Val, ConstantInt *CIdx = dyn_cast<ConstantInt>(Idx); if (!CIdx) return nullptr; + // Do not iterate on scalable vector. The num of elements is unknown at + // compile-time. + VectorType *ValTy = cast<VectorType>(Val->getType()); + if (ValTy->isScalable()) + return nullptr; + unsigned NumElts = Val->getType()->getVectorNumElements(); if (CIdx->uge(NumElts)) return UndefValue::get(Val->getType()); |