diff options
author | Philip Reames <preames@rivosinc.com> | 2022-11-01 09:22:24 -0700 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2022-11-01 09:29:42 -0700 |
commit | 2e999b7dd1934a44d38c3a753460f1e5a217e9a5 (patch) | |
tree | d115e68da16235d3276443fcebfada825bdfbe0e /llvm/lib/Analysis/ValueTracking.cpp | |
parent | a715b1bde91077b313b9c36d9ecbc0c83a0edac2 (diff) | |
download | llvm-2e999b7dd1934a44d38c3a753460f1e5a217e9a5.zip llvm-2e999b7dd1934a44d38c3a753460f1e5a217e9a5.tar.gz llvm-2e999b7dd1934a44d38c3a753460f1e5a217e9a5.tar.bz2 |
Allow scalable vectors in ComputeNumSignBits and isKnownNonNull
This is a follow up to D136470 which extends the same scheme used there to ComputeNumSignBits and isKnownNonNull. As a reminder, for scalable vectors we track a single bit which is implicitly broadcast to all lanes. We do not know how many lanes there are statically, and thus have to be conservative along paths which require exact sizes.
Differential Revision: https://reviews.llvm.org/D137046
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 0606ce7..be00950 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -375,11 +375,6 @@ static unsigned ComputeNumSignBits(const Value *V, const APInt &DemandedElts, static unsigned ComputeNumSignBits(const Value *V, unsigned Depth, const Query &Q) { - // FIXME: We currently have no way to represent the DemandedElts of a scalable - // vector - if (isa<ScalableVectorType>(V->getType())) - return 1; - auto *FVTy = dyn_cast<FixedVectorType>(V->getType()); APInt DemandedElts = FVTy ? APInt::getAllOnes(FVTy->getNumElements()) : APInt(1, 1); @@ -2449,10 +2444,6 @@ static bool isNonZeroRecurrence(const PHINode *PN) { /// Supports values with integer or pointer type and vectors of integers. bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth, const Query &Q) { - // FIXME: We currently have no way to represent the DemandedElts of a scalable - // vector - if (isa<ScalableVectorType>(V->getType())) - return false; #ifndef NDEBUG Type *Ty = V->getType(); @@ -2574,14 +2565,18 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth, // Note that we have to take special care to avoid looking through // truncating casts, e.g., int2ptr/ptr2int with appropriate sizes, as well // as casts that can alter the value, e.g., AddrSpaceCasts. - if (Q.DL.getTypeSizeInBits(I->getOperand(0)->getType()).getFixedSize() <= + if (!isa<ScalableVectorType>(I->getOperand(0)->getType()) && + !isa<ScalableVectorType>(I->getType()) && + Q.DL.getTypeSizeInBits(I->getOperand(0)->getType()).getFixedSize() <= Q.DL.getTypeSizeInBits(I->getType()).getFixedSize()) return isKnownNonZero(I->getOperand(0), Depth, Q); break; case Instruction::PtrToInt: // Similar to int2ptr above, we can look through ptr2int here if the cast // is a no-op or an extend and not a truncate. - if (Q.DL.getTypeSizeInBits(I->getOperand(0)->getType()).getFixedSize() <= + if (!isa<ScalableVectorType>(I->getOperand(0)->getType()) && + !isa<ScalableVectorType>(I->getType()) && + Q.DL.getTypeSizeInBits(I->getOperand(0)->getType()).getFixedSize() <= Q.DL.getTypeSizeInBits(I->getType()).getFixedSize()) return isKnownNonZero(I->getOperand(0), Depth, Q); break; @@ -2740,11 +2735,6 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth, } bool isKnownNonZero(const Value* V, unsigned Depth, const Query& Q) { - // FIXME: We currently have no way to represent the DemandedElts of a scalable - // vector - if (isa<ScalableVectorType>(V->getType())) - return false; - auto *FVTy = dyn_cast<FixedVectorType>(V->getType()); APInt DemandedElts = FVTy ? APInt::getAllOnes(FVTy->getNumElements()) : APInt(1, 1); @@ -3096,12 +3086,6 @@ static unsigned ComputeNumSignBitsImpl(const Value *V, const APInt &DemandedElts, unsigned Depth, const Query &Q) { Type *Ty = V->getType(); - - // FIXME: We currently have no way to represent the DemandedElts of a scalable - // vector - if (isa<ScalableVectorType>(Ty)) - return 1; - #ifndef NDEBUG assert(Depth <= MaxAnalysisRecursionDepth && "Limit Search Depth"); |