[PATCH] D81619: [NFC] Bail out for scalable vectors before calling getNumElements
Christopher Tetreault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 10 16:08:27 PDT 2020
ctetreau created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Move the bail out logic to before constructing the Result and Lane
vectors. This is both potentially faster, and avoids calling
getNumElements on a potentially scalable vector
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81619
Files:
llvm/lib/Analysis/ConstantFolding.cpp
Index: llvm/lib/Analysis/ConstantFolding.cpp
===================================================================
--- llvm/lib/Analysis/ConstantFolding.cpp
+++ llvm/lib/Analysis/ConstantFolding.cpp
@@ -2689,15 +2689,16 @@
const DataLayout &DL,
const TargetLibraryInfo *TLI,
const CallBase *Call) {
- SmallVector<Constant *, 4> Result(VTy->getNumElements());
- SmallVector<Constant *, 4> Lane(Operands.size());
- Type *Ty = VTy->getElementType();
-
// Do not iterate on scalable vector. The number of elements is unknown at
// compile-time.
if (isa<ScalableVectorType>(VTy))
return nullptr;
+ SmallVector<Constant *, 4> Result(
+ cast<FixedVectorType>(VTy)->getNumElements());
+ SmallVector<Constant *, 4> Lane(Operands.size());
+ Type *Ty = VTy->getElementType();
+
if (IntrinsicID == Intrinsic::masked_load) {
auto *SrcPtr = Operands[0];
auto *Mask = Operands[2];
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81619.269988.patch
Type: text/x-patch
Size: 1027 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200610/a595973f/attachment.bin>
More information about the llvm-commits
mailing list