mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-24 13:18:17 +00:00
Commit r185909 was a misapplied patch, fix it
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185910 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1564,13 +1564,23 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
||||
}
|
||||
}
|
||||
|
||||
// X-C1 <u 2 -> (X & -2) == C1
|
||||
// iff C1 & 1 == 0
|
||||
// X-C1 <u C2 -> (X & -C2) == C1
|
||||
// iff C1 & (C2-1) == 0
|
||||
// C2 is a power of 2
|
||||
if (ICI.getPredicate() == ICmpInst::ICMP_ULT && LHSI->hasOneUse() &&
|
||||
LHSV[0] == 0 && RHSV == 2)
|
||||
RHSV.isPowerOf2() && (LHSV & (RHSV - 1)) == 0)
|
||||
return new ICmpInst(ICmpInst::ICMP_EQ,
|
||||
Builder->CreateAnd(LHSI->getOperand(0), -RHSV),
|
||||
ConstantExpr::getNeg(LHSC));
|
||||
|
||||
// X-C1 >u C2 -> (X & ~C2) == C1
|
||||
// iff C1 & C2 == 0
|
||||
// C2+1 is a power of 2
|
||||
if (ICI.getPredicate() == ICmpInst::ICMP_UGT && LHSI->hasOneUse() &&
|
||||
(RHSV + 1).isPowerOf2() && (LHSV & RHSV) == 0)
|
||||
return new ICmpInst(ICmpInst::ICMP_NE,
|
||||
Builder->CreateAnd(LHSI->getOperand(0), ~RHSV),
|
||||
ConstantExpr::getNeg(LHSC));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1732,24 +1742,6 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// X-C1 <u C2 -> (X & -C2) == C1
|
||||
// iff C1 & (C2-1) == 0
|
||||
// C2 is a power of 2
|
||||
if (ICI.getPredicate() == ICmpInst::ICMP_ULT && LHSI->hasOneUse() &&
|
||||
RHSV.isPowerOf2() && (LHSV & (RHSV - 1)) == 0)
|
||||
return new ICmpInst(ICmpInst::ICMP_EQ,
|
||||
Builder->CreateAnd(LHSI->getOperand(0), -RHSV),
|
||||
ConstantExpr::getNeg(LHSC));
|
||||
|
||||
// X-C1 >u C2 -> (X & ~C2) == C1
|
||||
// iff C1 & C2 == 0
|
||||
// C2+1 is a power of 2
|
||||
if (ICI.getPredicate() == ICmpInst::ICMP_UGT && LHSI->hasOneUse() &&
|
||||
(RHSV + 1).isPowerOf2() && (LHSV & RHSV) == 0)
|
||||
return new ICmpInst(ICmpInst::ICMP_NE,
|
||||
Builder->CreateAnd(LHSI->getOperand(0), ~RHSV),
|
||||
ConstantExpr::getNeg(LHSC));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user