diff options
author | Christopher Tetreault <ctetreau@quicinc.com> | 2020-11-17 12:25:21 -0800 |
---|---|---|
committer | Christopher Tetreault <ctetreau@quicinc.com> | 2020-11-17 12:45:31 -0800 |
commit | 792f8e1114afa7f40227eee2820c6e425ee07c3b (patch) | |
tree | 5f729f0d502384e1766a67fc9b9313a4608cfddb /llvm/lib/IR/ConstantFold.cpp | |
parent | 44a11c342caa70efe9f9d07db3e66dd48f701aca (diff) | |
download | llvm-792f8e1114afa7f40227eee2820c6e425ee07c3b.zip llvm-792f8e1114afa7f40227eee2820c6e425ee07c3b.tar.gz llvm-792f8e1114afa7f40227eee2820c6e425ee07c3b.tar.bz2 |
[SVE] Take constant fold fast path for splatted vscale vectors
This should be a perfectly reasonable operation for scalable vectors.
Currently, it only works for zeroinitializer values of
ScalableVectorType, but the fundamental operation is sound and it should
be possible to make it work for other splats
Reviewed By: david-arm
Differential Revision: https://reviews.llvm.org/D77442
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 968742b..b850267 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -2042,11 +2042,6 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, } } else if (auto *C1VTy = dyn_cast<VectorType>(C1->getType())) { - // Do not iterate on scalable vector. The number of elements is unknown at - // compile-time. - if (isa<ScalableVectorType>(C1VTy)) - return nullptr; - // Fast path for splatted constants. if (Constant *C1Splat = C1->getSplatValue()) if (Constant *C2Splat = C2->getSplatValue()) @@ -2054,6 +2049,11 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, C1VTy->getElementCount(), ConstantExpr::getCompare(pred, C1Splat, C2Splat)); + // Do not iterate on scalable vector. The number of elements is unknown at + // compile-time. + if (isa<ScalableVectorType>(C1VTy)) + return nullptr; + // If we can constant fold the comparison of each element, constant fold // the whole vector comparison. SmallVector<Constant*, 4> ResElts; |