mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-29 13:37:15 +00:00
Add variants of ult, ule, etc. which take a uint64_t RHS, for convenience.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100824 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
287df1bc03
commit
e056781323
include/llvm/ADT
lib
Analysis
CodeGen/SelectionDAG
Transforms
@ -870,12 +870,28 @@ public:
|
|||||||
/// @brief Unsigned less than comparison
|
/// @brief Unsigned less than comparison
|
||||||
bool ult(const APInt& RHS) const;
|
bool ult(const APInt& RHS) const;
|
||||||
|
|
||||||
|
/// Regards both *this as an unsigned quantity and compares it with RHS for
|
||||||
|
/// the validity of the less-than relationship.
|
||||||
|
/// @returns true if *this < RHS when considered unsigned.
|
||||||
|
/// @brief Unsigned less than comparison
|
||||||
|
bool ult(uint64_t RHS) const {
|
||||||
|
return ult(APInt(getBitWidth(), RHS));
|
||||||
|
}
|
||||||
|
|
||||||
/// Regards both *this and RHS as signed quantities and compares them for
|
/// Regards both *this and RHS as signed quantities and compares them for
|
||||||
/// validity of the less-than relationship.
|
/// validity of the less-than relationship.
|
||||||
/// @returns true if *this < RHS when both are considered signed.
|
/// @returns true if *this < RHS when both are considered signed.
|
||||||
/// @brief Signed less than comparison
|
/// @brief Signed less than comparison
|
||||||
bool slt(const APInt& RHS) const;
|
bool slt(const APInt& RHS) const;
|
||||||
|
|
||||||
|
/// Regards both *this as a signed quantity and compares it with RHS for
|
||||||
|
/// the validity of the less-than relationship.
|
||||||
|
/// @returns true if *this < RHS when considered signed.
|
||||||
|
/// @brief Signed less than comparison
|
||||||
|
bool slt(uint64_t RHS) const {
|
||||||
|
return slt(APInt(getBitWidth(), RHS));
|
||||||
|
}
|
||||||
|
|
||||||
/// Regards both *this and RHS as unsigned quantities and compares them for
|
/// Regards both *this and RHS as unsigned quantities and compares them for
|
||||||
/// validity of the less-or-equal relationship.
|
/// validity of the less-or-equal relationship.
|
||||||
/// @returns true if *this <= RHS when both are considered unsigned.
|
/// @returns true if *this <= RHS when both are considered unsigned.
|
||||||
@ -884,6 +900,14 @@ public:
|
|||||||
return ult(RHS) || eq(RHS);
|
return ult(RHS) || eq(RHS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Regards both *this as an unsigned quantity and compares it with RHS for
|
||||||
|
/// the validity of the less-or-equal relationship.
|
||||||
|
/// @returns true if *this <= RHS when considered unsigned.
|
||||||
|
/// @brief Unsigned less or equal comparison
|
||||||
|
bool ule(uint64_t RHS) const {
|
||||||
|
return ule(APInt(getBitWidth(), RHS));
|
||||||
|
}
|
||||||
|
|
||||||
/// Regards both *this and RHS as signed quantities and compares them for
|
/// Regards both *this and RHS as signed quantities and compares them for
|
||||||
/// validity of the less-or-equal relationship.
|
/// validity of the less-or-equal relationship.
|
||||||
/// @returns true if *this <= RHS when both are considered signed.
|
/// @returns true if *this <= RHS when both are considered signed.
|
||||||
@ -892,6 +916,14 @@ public:
|
|||||||
return slt(RHS) || eq(RHS);
|
return slt(RHS) || eq(RHS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Regards both *this as a signed quantity and compares it with RHS for
|
||||||
|
/// the validity of the less-or-equal relationship.
|
||||||
|
/// @returns true if *this <= RHS when considered signed.
|
||||||
|
/// @brief Signed less or equal comparison
|
||||||
|
bool sle(uint64_t RHS) const {
|
||||||
|
return sle(APInt(getBitWidth(), RHS));
|
||||||
|
}
|
||||||
|
|
||||||
/// Regards both *this and RHS as unsigned quantities and compares them for
|
/// Regards both *this and RHS as unsigned quantities and compares them for
|
||||||
/// the validity of the greater-than relationship.
|
/// the validity of the greater-than relationship.
|
||||||
/// @returns true if *this > RHS when both are considered unsigned.
|
/// @returns true if *this > RHS when both are considered unsigned.
|
||||||
@ -900,6 +932,14 @@ public:
|
|||||||
return !ult(RHS) && !eq(RHS);
|
return !ult(RHS) && !eq(RHS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Regards both *this as an unsigned quantity and compares it with RHS for
|
||||||
|
/// the validity of the greater-than relationship.
|
||||||
|
/// @returns true if *this > RHS when considered unsigned.
|
||||||
|
/// @brief Unsigned greater than comparison
|
||||||
|
bool ugt(uint64_t RHS) const {
|
||||||
|
return ugt(APInt(getBitWidth(), RHS));
|
||||||
|
}
|
||||||
|
|
||||||
/// Regards both *this and RHS as signed quantities and compares them for
|
/// Regards both *this and RHS as signed quantities and compares them for
|
||||||
/// the validity of the greater-than relationship.
|
/// the validity of the greater-than relationship.
|
||||||
/// @returns true if *this > RHS when both are considered signed.
|
/// @returns true if *this > RHS when both are considered signed.
|
||||||
@ -908,6 +948,14 @@ public:
|
|||||||
return !slt(RHS) && !eq(RHS);
|
return !slt(RHS) && !eq(RHS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Regards both *this as a signed quantity and compares it with RHS for
|
||||||
|
/// the validity of the greater-than relationship.
|
||||||
|
/// @returns true if *this > RHS when considered signed.
|
||||||
|
/// @brief Signed greater than comparison
|
||||||
|
bool sgt(uint64_t RHS) const {
|
||||||
|
return sgt(APInt(getBitWidth(), RHS));
|
||||||
|
}
|
||||||
|
|
||||||
/// Regards both *this and RHS as unsigned quantities and compares them for
|
/// Regards both *this and RHS as unsigned quantities and compares them for
|
||||||
/// validity of the greater-or-equal relationship.
|
/// validity of the greater-or-equal relationship.
|
||||||
/// @returns true if *this >= RHS when both are considered unsigned.
|
/// @returns true if *this >= RHS when both are considered unsigned.
|
||||||
@ -916,6 +964,14 @@ public:
|
|||||||
return !ult(RHS);
|
return !ult(RHS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Regards both *this as an unsigned quantity and compares it with RHS for
|
||||||
|
/// the validity of the greater-or-equal relationship.
|
||||||
|
/// @returns true if *this >= RHS when considered unsigned.
|
||||||
|
/// @brief Unsigned greater or equal comparison
|
||||||
|
bool uge(uint64_t RHS) const {
|
||||||
|
return uge(APInt(getBitWidth(), RHS));
|
||||||
|
}
|
||||||
|
|
||||||
/// Regards both *this and RHS as signed quantities and compares them for
|
/// Regards both *this and RHS as signed quantities and compares them for
|
||||||
/// validity of the greater-or-equal relationship.
|
/// validity of the greater-or-equal relationship.
|
||||||
/// @returns true if *this >= RHS when both are considered signed.
|
/// @returns true if *this >= RHS when both are considered signed.
|
||||||
@ -924,6 +980,14 @@ public:
|
|||||||
return !slt(RHS);
|
return !slt(RHS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Regards both *this as a signed quantity and compares it with RHS for
|
||||||
|
/// the validity of the greater-or-equal relationship.
|
||||||
|
/// @returns true if *this >= RHS when considered signed.
|
||||||
|
/// @brief Signed greater or equal comparison
|
||||||
|
bool sge(uint64_t RHS) const {
|
||||||
|
return sge(APInt(getBitWidth(), RHS));
|
||||||
|
}
|
||||||
|
|
||||||
/// This operation tests if there are any pairs of corresponding bits
|
/// This operation tests if there are any pairs of corresponding bits
|
||||||
/// between this APInt and RHS that are both set.
|
/// between this APInt and RHS that are both set.
|
||||||
bool intersects(const APInt &RHS) const {
|
bool intersects(const APInt &RHS) const {
|
||||||
|
@ -4065,7 +4065,7 @@ ScalarEvolution::getConstantEvolutionLoopExitValue(PHINode *PN,
|
|||||||
if (I != ConstantEvolutionLoopExitValue.end())
|
if (I != ConstantEvolutionLoopExitValue.end())
|
||||||
return I->second;
|
return I->second;
|
||||||
|
|
||||||
if (BEs.ugt(APInt(BEs.getBitWidth(),MaxBruteForceIterations)))
|
if (BEs.ugt(MaxBruteForceIterations))
|
||||||
return ConstantEvolutionLoopExitValue[PN] = 0; // Not going to evaluate it.
|
return ConstantEvolutionLoopExitValue[PN] = 0; // Not going to evaluate it.
|
||||||
|
|
||||||
Constant *&RetVal = ConstantEvolutionLoopExitValue[PN];
|
Constant *&RetVal = ConstantEvolutionLoopExitValue[PN];
|
||||||
|
@ -1614,7 +1614,7 @@ bool SelectionDAGBuilder::handleJTSwitchCase(CaseRec& CR,
|
|||||||
I!=E; ++I)
|
I!=E; ++I)
|
||||||
TSize += I->size();
|
TSize += I->size();
|
||||||
|
|
||||||
if (!areJTsAllowed(TLI) || TSize.ult(APInt(First.getBitWidth(), 4)))
|
if (!areJTsAllowed(TLI) || TSize.ult(4))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
APInt Range = ComputeRange(First, Last);
|
APInt Range = ComputeRange(First, Last);
|
||||||
@ -1868,7 +1868,7 @@ bool SelectionDAGBuilder::handleBitTestsSwitchCase(CaseRec& CR,
|
|||||||
<< "Low bound: " << minValue << '\n'
|
<< "Low bound: " << minValue << '\n'
|
||||||
<< "High bound: " << maxValue << '\n');
|
<< "High bound: " << maxValue << '\n');
|
||||||
|
|
||||||
if (cmpRange.uge(APInt(cmpRange.getBitWidth(), IntPtrBits)) ||
|
if (cmpRange.uge(IntPtrBits) ||
|
||||||
(!(Dests.size() == 1 && numCmps >= 3) &&
|
(!(Dests.size() == 1 && numCmps >= 3) &&
|
||||||
!(Dests.size() == 2 && numCmps >= 5) &&
|
!(Dests.size() == 2 && numCmps >= 5) &&
|
||||||
!(Dests.size() >= 3 && numCmps >= 6)))
|
!(Dests.size() >= 3 && numCmps >= 6)))
|
||||||
@ -1880,8 +1880,7 @@ bool SelectionDAGBuilder::handleBitTestsSwitchCase(CaseRec& CR,
|
|||||||
// Optimize the case where all the case values fit in a
|
// Optimize the case where all the case values fit in a
|
||||||
// word without having to subtract minValue. In this case,
|
// word without having to subtract minValue. In this case,
|
||||||
// we can optimize away the subtraction.
|
// we can optimize away the subtraction.
|
||||||
if (minValue.isNonNegative() &&
|
if (minValue.isNonNegative() && maxValue.slt(IntPtrBits)) {
|
||||||
maxValue.slt(APInt(maxValue.getBitWidth(), IntPtrBits))) {
|
|
||||||
cmpRange = maxValue;
|
cmpRange = maxValue;
|
||||||
} else {
|
} else {
|
||||||
lowBound = minValue;
|
lowBound = minValue;
|
||||||
|
@ -1325,7 +1325,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||||||
// If we have a signed (X % (2^c)) == 0, turn it into an unsigned one.
|
// If we have a signed (X % (2^c)) == 0, turn it into an unsigned one.
|
||||||
if (RHSV == 0 && isa<ConstantInt>(BO->getOperand(1)) &&BO->hasOneUse()){
|
if (RHSV == 0 && isa<ConstantInt>(BO->getOperand(1)) &&BO->hasOneUse()){
|
||||||
const APInt &V = cast<ConstantInt>(BO->getOperand(1))->getValue();
|
const APInt &V = cast<ConstantInt>(BO->getOperand(1))->getValue();
|
||||||
if (V.sgt(APInt(V.getBitWidth(), 1)) && V.isPowerOf2()) {
|
if (V.sgt(1) && V.isPowerOf2()) {
|
||||||
Value *NewRem =
|
Value *NewRem =
|
||||||
Builder->CreateURem(BO->getOperand(0), BO->getOperand(1),
|
Builder->CreateURem(BO->getOperand(0), BO->getOperand(1),
|
||||||
BO->getName());
|
BO->getName());
|
||||||
|
@ -2447,7 +2447,7 @@ void LSRInstance::GenerateCrossUseConstantOffsets() {
|
|||||||
if (C->getValue()->getValue().isNegative() !=
|
if (C->getValue()->getValue().isNegative() !=
|
||||||
(NewF.AM.BaseOffs < 0) &&
|
(NewF.AM.BaseOffs < 0) &&
|
||||||
(C->getValue()->getValue().abs() * APInt(BitWidth, F.AM.Scale))
|
(C->getValue()->getValue().abs() * APInt(BitWidth, F.AM.Scale))
|
||||||
.ule(APInt(BitWidth, NewF.AM.BaseOffs).abs()))
|
.ule(abs64(NewF.AM.BaseOffs)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// OK, looks good.
|
// OK, looks good.
|
||||||
@ -2475,7 +2475,7 @@ void LSRInstance::GenerateCrossUseConstantOffsets() {
|
|||||||
if (C->getValue()->getValue().isNegative() !=
|
if (C->getValue()->getValue().isNegative() !=
|
||||||
(NewF.AM.BaseOffs < 0) &&
|
(NewF.AM.BaseOffs < 0) &&
|
||||||
C->getValue()->getValue().abs()
|
C->getValue()->getValue().abs()
|
||||||
.ule(APInt(BitWidth, NewF.AM.BaseOffs).abs()))
|
.ule(abs64(NewF.AM.BaseOffs)))
|
||||||
goto skip_formula;
|
goto skip_formula;
|
||||||
|
|
||||||
// Ok, looks good.
|
// Ok, looks good.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user