mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-29 07:39:27 +00:00
Move isTrueWhenEqual to ICmpInst.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51215 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1f7580c5eb
commit
fc1efbbfbc
@ -741,6 +741,22 @@ public:
|
|||||||
/// @brief Determine if the predicate is signed.
|
/// @brief Determine if the predicate is signed.
|
||||||
static bool isSignedPredicate(Predicate pred);
|
static bool isSignedPredicate(Predicate pred);
|
||||||
|
|
||||||
|
/// @returns true if the specified compare predicate is
|
||||||
|
/// true when both operands are equal...
|
||||||
|
/// @brief Determine if the icmp is true when both operands are equal
|
||||||
|
static bool isTrueWhenEqual(ICmpInst::Predicate pred) {
|
||||||
|
return pred == ICmpInst::ICMP_EQ || pred == ICmpInst::ICMP_UGE ||
|
||||||
|
pred == ICmpInst::ICMP_SGE || pred == ICmpInst::ICMP_ULE ||
|
||||||
|
pred == ICmpInst::ICMP_SLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @returns true if the specified compare instruction is
|
||||||
|
/// true when both operands are equal...
|
||||||
|
/// @brief Determine if the ICmpInst returns true when both operands are equal
|
||||||
|
bool isTrueWhenEqual() {
|
||||||
|
return isTrueWhenEqual(getPredicate());
|
||||||
|
}
|
||||||
|
|
||||||
/// Initialize a set of values that all satisfy the predicate with C.
|
/// Initialize a set of values that all satisfy the predicate with C.
|
||||||
/// @brief Make a ConstantRange for a relation with a constant value.
|
/// @brief Make a ConstantRange for a relation with a constant value.
|
||||||
static ConstantRange makeConstantRange(Predicate pred, const APInt &C);
|
static ConstantRange makeConstantRange(Predicate pred, const APInt &C);
|
||||||
|
@ -2056,22 +2056,6 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, uint64_t DemandedElts,
|
|||||||
return MadeChange ? I : 0;
|
return MadeChange ? I : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @returns true if the specified compare predicate is
|
|
||||||
/// true when both operands are equal...
|
|
||||||
/// @brief Determine if the icmp Predicate is true when both operands are equal
|
|
||||||
static bool isTrueWhenEqual(ICmpInst::Predicate pred) {
|
|
||||||
return pred == ICmpInst::ICMP_EQ || pred == ICmpInst::ICMP_UGE ||
|
|
||||||
pred == ICmpInst::ICMP_SGE || pred == ICmpInst::ICMP_ULE ||
|
|
||||||
pred == ICmpInst::ICMP_SLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @returns true if the specified compare instruction is
|
|
||||||
/// true when both operands are equal...
|
|
||||||
/// @brief Determine if the ICmpInst returns true when both operands are equal
|
|
||||||
static bool isTrueWhenEqual(ICmpInst &ICI) {
|
|
||||||
return isTrueWhenEqual(ICI.getPredicate());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// AssociativeOpt - Perform an optimization on an associative operator. This
|
/// AssociativeOpt - Perform an optimization on an associative operator. This
|
||||||
/// function is designed to check a chain of associative operators for a
|
/// function is designed to check a chain of associative operators for a
|
||||||
/// potential to apply a certain optimization. Since the optimization may be
|
/// potential to apply a certain optimization. Since the optimization may be
|
||||||
@ -5204,7 +5188,7 @@ Instruction *InstCombiner::FoldGEPICmp(User *GEPLHS, Value *RHS,
|
|||||||
if (NumDifferences == 0) // SAME GEP?
|
if (NumDifferences == 0) // SAME GEP?
|
||||||
return ReplaceInstUsesWith(I, // No comparison is needed here.
|
return ReplaceInstUsesWith(I, // No comparison is needed here.
|
||||||
ConstantInt::get(Type::Int1Ty,
|
ConstantInt::get(Type::Int1Ty,
|
||||||
isTrueWhenEqual(Cond)));
|
ICmpInst::isTrueWhenEqual(Cond)));
|
||||||
|
|
||||||
else if (NumDifferences == 1) {
|
else if (NumDifferences == 1) {
|
||||||
Value *LHSV = GEPLHS->getOperand(DiffOperand);
|
Value *LHSV = GEPLHS->getOperand(DiffOperand);
|
||||||
@ -5321,7 +5305,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
// icmp X, X
|
// icmp X, X
|
||||||
if (Op0 == Op1)
|
if (Op0 == Op1)
|
||||||
return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty,
|
return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty,
|
||||||
isTrueWhenEqual(I)));
|
I.isTrueWhenEqual()));
|
||||||
|
|
||||||
if (isa<UndefValue>(Op1)) // X icmp undef -> undef
|
if (isa<UndefValue>(Op1)) // X icmp undef -> undef
|
||||||
return ReplaceInstUsesWith(I, UndefValue::get(Type::Int1Ty));
|
return ReplaceInstUsesWith(I, UndefValue::get(Type::Int1Ty));
|
||||||
@ -5333,7 +5317,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
(isa<GlobalValue>(Op1) || isa<AllocaInst>(Op1) ||
|
(isa<GlobalValue>(Op1) || isa<AllocaInst>(Op1) ||
|
||||||
isa<ConstantPointerNull>(Op1)))
|
isa<ConstantPointerNull>(Op1)))
|
||||||
return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty,
|
return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty,
|
||||||
!isTrueWhenEqual(I)));
|
!I.isTrueWhenEqual()));
|
||||||
|
|
||||||
// icmp's with boolean values can always be turned into bitwise operations
|
// icmp's with boolean values can always be turned into bitwise operations
|
||||||
if (Ty == Type::Int1Ty) {
|
if (Ty == Type::Int1Ty) {
|
||||||
@ -5614,7 +5598,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
if (LHSI->hasOneUse() && isa<ConstantPointerNull>(RHSC)) {
|
if (LHSI->hasOneUse() && isa<ConstantPointerNull>(RHSC)) {
|
||||||
AddToWorkList(LHSI);
|
AddToWorkList(LHSI);
|
||||||
return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty,
|
return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty,
|
||||||
!isTrueWhenEqual(I)));
|
!I.isTrueWhenEqual()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user