[PATCH] D79053: [SVE] Fix invalid use of VectorType::getNumElements() in Value Tracking
Christopher Tetreault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 16:45:52 PDT 2020
ctetreau created this revision.
Herald added subscribers: llvm-commits, psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a reviewer: efriedma.
Herald added a project: LLVM.
ctetreau added reviewers: sdesmalen, c-rhodes.
Remove invalid usage of VectorType::getNumElements in computeKnownBits
identified by test Clang::CodeGen/aarch64-sve-intrinsics/acle_sve_ext.c.
It is not possible to know at compile time the bits of a scalable
vector, so we cast to fixed width and do not call it if the vector is
scalable
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79053
Files:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/Analysis/ValueTracking.cpp
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -207,10 +207,11 @@
static void computeKnownBits(const Value *V, KnownBits &Known, unsigned Depth,
const Query &Q) {
Type *Ty = V->getType();
+ assert(!isa<ScalableVectorType>(Ty) &&
+ "Cannot compute known bits of scalable vector");
+ auto *FVTy = dyn_cast<FixedVectorType>(Ty);
APInt DemandedElts =
- Ty->isVectorTy()
- ? APInt::getAllOnesValue(cast<VectorType>(Ty)->getNumElements())
- : APInt(1, 1);
+ FVTy ? APInt::getAllOnesValue(FVTy->getNumElements()) : APInt(1, 1);
computeKnownBits(V, DemandedElts, Known, Depth, Q);
}
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5622,7 +5622,8 @@
// In general, it is possible for computeKnownBits to determine all bits in a
// value even when the operands are not all constants.
- if (!Result && I->getType()->isIntOrIntVectorTy()) {
+ if (!Result && I->getType()->isIntOrIntVectorTy() &&
+ !isa<ScalableVectorType>(I->getType())) {
KnownBits Known = computeKnownBits(I, Q.DL, /*Depth*/ 0, Q.AC, I, Q.DT, ORE);
if (Known.isConstant())
Result = ConstantInt::get(I->getType(), Known.getConstant());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79053.260794.patch
Type: text/x-patch
Size: 1517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200428/5fe1db02/attachment.bin>
More information about the llvm-commits
mailing list