[PATCH] D81619: [NFC] Bail out for scalable vectors before calling getNumElements
Christopher Tetreault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 15 13:14:26 PDT 2020
ctetreau updated this revision to Diff 270838.
ctetreau added a comment.
address code review issues
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81619/new/
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,24 +2689,26 @@
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;
+ auto *FVTy = cast<FixedVectorType>(VTy);
+
+ SmallVector<Constant *, 4> Result(FVTy->getNumElements());
+ SmallVector<Constant *, 4> Lane(Operands.size());
+ Type *Ty = FVTy->getElementType();
+
if (IntrinsicID == Intrinsic::masked_load) {
auto *SrcPtr = Operands[0];
auto *Mask = Operands[2];
auto *Passthru = Operands[3];
- Constant *VecData = ConstantFoldLoadFromConstPtr(SrcPtr, VTy, DL);
+ Constant *VecData = ConstantFoldLoadFromConstPtr(SrcPtr, FVTy, DL);
SmallVector<Constant *, 32> NewElements;
- for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
+ for (unsigned I = 0, E = FVTy->getNumElements(); I != E; ++I) {
auto *MaskElt = Mask->getAggregateElement(I);
if (!MaskElt)
break;
@@ -2732,12 +2734,12 @@
return nullptr;
}
}
- if (NewElements.size() != VTy->getNumElements())
+ if (NewElements.size() != FVTy->getNumElements())
return nullptr;
return ConstantVector::get(NewElements);
}
- for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
+ for (unsigned I = 0, E = FVTy->getNumElements(); I != E; ++I) {
// Gather a column of constants.
for (unsigned J = 0, JE = Operands.size(); J != JE; ++J) {
// Some intrinsics use a scalar type for certain arguments.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81619.270838.patch
Type: text/x-patch
Size: 2053 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200615/266a9e3a/attachment.bin>
More information about the llvm-commits
mailing list