aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2020-11-12 16:15:46 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2020-11-12 16:16:04 +0000
commit89967427412489e10b3625bf1563a804fe5f2be2 (patch)
treef838f93ad9ae924f18e7fe64e0249a0489bffaa1 /llvm/lib/Analysis/ValueTracking.cpp
parenta20b3620bb7c943080ce1c791f0b0bc36916735f (diff)
downloadllvm-89967427412489e10b3625bf1563a804fe5f2be2.zip
llvm-89967427412489e10b3625bf1563a804fe5f2be2.tar.gz
llvm-89967427412489e10b3625bf1563a804fe5f2be2.tar.bz2
[KnownBits] Add KnownBits::makeConstant helper. NFCI.
Helper for cases where we need to create a KnownBits from a (fully known) constant value.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index a7aee65..8568a23 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1223,10 +1223,7 @@ static void computeKnownBitsFromOperator(const Operator *I,
case Instruction::Shl: {
bool NSW = Q.IIQ.hasNoSignedWrap(cast<OverflowingBinaryOperator>(I));
auto KF = [NSW](const KnownBits &KnownShiftVal, unsigned ShiftAmt) {
- APInt ShiftAmtV(KnownShiftVal.getBitWidth(), ShiftAmt);
- KnownBits KnownShiftAmt;
- KnownShiftAmt.One = ShiftAmtV;
- KnownShiftAmt.Zero = ~ShiftAmtV;
+ KnownBits KnownShiftAmt = KnownBits::makeConstant(APInt(32, ShiftAmt));
KnownBits Result = KnownBits::shl(KnownShiftVal, KnownShiftAmt);
// If this shift has "nsw" keyword, then the result is either a poison
// value or has the same sign bit as the first operand.
@@ -1244,10 +1241,7 @@ static void computeKnownBitsFromOperator(const Operator *I,
}
case Instruction::LShr: {
auto KF = [](const KnownBits &KnownShiftVal, unsigned ShiftAmt) {
- APInt ShiftAmtV(KnownShiftVal.getBitWidth(), ShiftAmt);
- KnownBits KnownShiftAmt;
- KnownShiftAmt.One = ShiftAmtV;
- KnownShiftAmt.Zero = ~ShiftAmtV;
+ KnownBits KnownShiftAmt = KnownBits::makeConstant(APInt(32, ShiftAmt));
return KnownBits::lshr(KnownShiftVal, KnownShiftAmt);
};
computeKnownBitsFromShiftOperator(I, DemandedElts, Known, Known2, Depth, Q,
@@ -1256,10 +1250,7 @@ static void computeKnownBitsFromOperator(const Operator *I,
}
case Instruction::AShr: {
auto KF = [](const KnownBits &KnownShiftVal, unsigned ShiftAmt) {
- APInt ShiftAmtV(KnownShiftVal.getBitWidth(), ShiftAmt);
- KnownBits KnownShiftAmt;
- KnownShiftAmt.One = ShiftAmtV;
- KnownShiftAmt.Zero = ~ShiftAmtV;
+ KnownBits KnownShiftAmt = KnownBits::makeConstant(APInt(32, ShiftAmt));
return KnownBits::ashr(KnownShiftVal, KnownShiftAmt);
};
computeKnownBitsFromShiftOperator(I, DemandedElts, Known, Known2, Depth, Q,