mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-16 00:33:10 +00:00
Remove a bunch of duplicated code. Among other things, this fixes
constant folding of signed comparisons of bool. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33134 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f6e7bb4a5e
commit
d333d90673
@ -554,21 +554,6 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
|
||||
// so look at directly computing the value.
|
||||
if (const ConstantInt *CI1 = dyn_cast<ConstantInt>(C1)) {
|
||||
if (const ConstantInt *CI2 = dyn_cast<ConstantInt>(C2)) {
|
||||
if (CI1->getType() == Type::Int1Ty && CI2->getType() == Type::Int1Ty) {
|
||||
switch (Opcode) {
|
||||
default:
|
||||
break;
|
||||
case Instruction::And:
|
||||
return ConstantInt::get(Type::Int1Ty,
|
||||
CI1->getZExtValue() & CI2->getZExtValue());
|
||||
case Instruction::Or:
|
||||
return ConstantInt::get(Type::Int1Ty,
|
||||
CI1->getZExtValue() | CI2->getZExtValue());
|
||||
case Instruction::Xor:
|
||||
return ConstantInt::get(Type::Int1Ty,
|
||||
CI1->getZExtValue() ^ CI2->getZExtValue());
|
||||
}
|
||||
} else {
|
||||
uint64_t C1Val = CI1->getZExtValue();
|
||||
uint64_t C2Val = CI2->getZExtValue();
|
||||
switch (Opcode) {
|
||||
@ -620,7 +605,6 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
|
||||
CI1->getSExtValue() >> C2Val);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (const ConstantFP *CFP1 = dyn_cast<ConstantFP>(C1)) {
|
||||
if (const ConstantFP *CFP2 = dyn_cast<ConstantFP>(C2)) {
|
||||
double C1Val = CFP1->getValue();
|
||||
@ -1059,34 +1043,7 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred,
|
||||
return ConstantInt::getTrue();
|
||||
}
|
||||
|
||||
if (isa<ConstantInt>(C1) && isa<ConstantInt>(C2) &&
|
||||
C1->getType() == Type::Int1Ty && C2->getType() == Type::Int1Ty) {
|
||||
bool C1Val = cast<ConstantInt>(C1)->getZExtValue();
|
||||
bool C2Val = cast<ConstantInt>(C2)->getZExtValue();
|
||||
switch (pred) {
|
||||
default: assert(0 && "Invalid ICmp Predicate"); return 0;
|
||||
case ICmpInst::ICMP_EQ:
|
||||
return ConstantInt::get(Type::Int1Ty, C1Val == C2Val);
|
||||
case ICmpInst::ICMP_NE:
|
||||
return ConstantInt::get(Type::Int1Ty, C1Val != C2Val);
|
||||
case ICmpInst::ICMP_ULT:
|
||||
return ConstantInt::get(Type::Int1Ty, C1Val < C2Val);
|
||||
case ICmpInst::ICMP_UGT:
|
||||
return ConstantInt::get(Type::Int1Ty, C1Val > C2Val);
|
||||
case ICmpInst::ICMP_ULE:
|
||||
return ConstantInt::get(Type::Int1Ty, C1Val <= C2Val);
|
||||
case ICmpInst::ICMP_UGE:
|
||||
return ConstantInt::get(Type::Int1Ty, C1Val >= C2Val);
|
||||
case ICmpInst::ICMP_SLT:
|
||||
return ConstantInt::get(Type::Int1Ty, C1Val < C2Val);
|
||||
case ICmpInst::ICMP_SGT:
|
||||
return ConstantInt::get(Type::Int1Ty, C1Val > C2Val);
|
||||
case ICmpInst::ICMP_SLE:
|
||||
return ConstantInt::get(Type::Int1Ty, C1Val <= C2Val);
|
||||
case ICmpInst::ICMP_SGE:
|
||||
return ConstantInt::get(Type::Int1Ty, C1Val >= C2Val);
|
||||
}
|
||||
} else if (isa<ConstantInt>(C1) && isa<ConstantInt>(C2)) {
|
||||
if (isa<ConstantInt>(C1) && isa<ConstantInt>(C2)) {
|
||||
if (ICmpInst::isSignedPredicate(ICmpInst::Predicate(pred))) {
|
||||
int64_t V1 = cast<ConstantInt>(C1)->getSExtValue();
|
||||
int64_t V2 = cast<ConstantInt>(C2)->getSExtValue();
|
||||
|
Loading…
x
Reference in New Issue
Block a user