mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
Revert "Ensure that InstructionCost actually implements a total ordering"
This reverts commit b481cd519e07b3ad2bd3e81c89b0dd8efd68d6bc.
This commit is contained in:
parent
3594bb4c1b
commit
74267eec45
@ -146,30 +146,31 @@ public:
|
|||||||
return Copy;
|
return Copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For the comparison operators we have chosen to use lexicographical
|
|
||||||
/// ordering where valid costs are always considered to be less than invalid
|
|
||||||
/// costs. This avoids having to add asserts to the comparison operators that
|
|
||||||
/// the states are valid and users can test for validity of the cost
|
|
||||||
/// explicitly.
|
|
||||||
bool operator<(const InstructionCost &RHS) const {
|
|
||||||
return State < RHS.State || Value < RHS.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implement in terms of operator< to ensure that the two comparisons stay in
|
|
||||||
// sync
|
|
||||||
bool operator==(const InstructionCost &RHS) const {
|
bool operator==(const InstructionCost &RHS) const {
|
||||||
return !(*this < RHS) && !(RHS < *this);
|
return State == RHS.State && Value == RHS.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const InstructionCost &RHS) const { return !(*this == RHS); }
|
bool operator!=(const InstructionCost &RHS) const { return !(*this == RHS); }
|
||||||
|
|
||||||
bool operator==(const CostType RHS) const {
|
bool operator==(const CostType RHS) const {
|
||||||
InstructionCost RHS2(RHS);
|
return State == Valid && Value == RHS;
|
||||||
return *this == RHS2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const CostType RHS) const { return !(*this == RHS); }
|
bool operator!=(const CostType RHS) const { return !(*this == RHS); }
|
||||||
|
|
||||||
|
/// For the comparison operators we have chosen to use total ordering with
|
||||||
|
/// the following rules:
|
||||||
|
/// 1. If either of the states != Valid then a lexicographical order is
|
||||||
|
/// applied based upon the state.
|
||||||
|
/// 2. If both states are valid then order based upon value.
|
||||||
|
/// This avoids having to add asserts the comparison operators that the states
|
||||||
|
/// are valid and users can test for validity of the cost explicitly.
|
||||||
|
bool operator<(const InstructionCost &RHS) const {
|
||||||
|
if (State != Valid || RHS.State != Valid)
|
||||||
|
return State < RHS.State;
|
||||||
|
return Value < RHS.Value;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator>(const InstructionCost &RHS) const { return RHS < *this; }
|
bool operator>(const InstructionCost &RHS) const { return RHS < *this; }
|
||||||
|
|
||||||
bool operator<=(const InstructionCost &RHS) const { return !(RHS < *this); }
|
bool operator<=(const InstructionCost &RHS) const { return !(RHS < *this); }
|
||||||
|
@ -25,7 +25,6 @@ TEST_F(CostTest, Operators) {
|
|||||||
InstructionCost VSix = 6;
|
InstructionCost VSix = 6;
|
||||||
InstructionCost IThreeA = InstructionCost::getInvalid(3);
|
InstructionCost IThreeA = InstructionCost::getInvalid(3);
|
||||||
InstructionCost IThreeB = InstructionCost::getInvalid(3);
|
InstructionCost IThreeB = InstructionCost::getInvalid(3);
|
||||||
InstructionCost ITwo = InstructionCost::getInvalid(2);
|
|
||||||
InstructionCost TmpCost;
|
InstructionCost TmpCost;
|
||||||
|
|
||||||
EXPECT_NE(VThree, VNegTwo);
|
EXPECT_NE(VThree, VNegTwo);
|
||||||
@ -38,9 +37,6 @@ TEST_F(CostTest, Operators) {
|
|||||||
EXPECT_EQ(VThree - VNegTwo, 5);
|
EXPECT_EQ(VThree - VNegTwo, 5);
|
||||||
EXPECT_EQ(VThree * VNegTwo, -6);
|
EXPECT_EQ(VThree * VNegTwo, -6);
|
||||||
EXPECT_EQ(VSix / VThree, 2);
|
EXPECT_EQ(VSix / VThree, 2);
|
||||||
EXPECT_NE(IThreeA, ITwo);
|
|
||||||
EXPECT_LT(ITwo, IThreeA);
|
|
||||||
EXPECT_GT(IThreeA, ITwo);
|
|
||||||
|
|
||||||
EXPECT_FALSE(IThreeA.isValid());
|
EXPECT_FALSE(IThreeA.isValid());
|
||||||
EXPECT_EQ(IThreeA.getState(), InstructionCost::Invalid);
|
EXPECT_EQ(IThreeA.getState(), InstructionCost::Invalid);
|
||||||
|
Loading…
Reference in New Issue
Block a user