mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-23 11:38:38 +00:00
We require threse bits to be zero, too.
This shouldn't happen in practice because the icmp would be a constant. Add a check so we don't miscompile code if something goes wrong. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130446 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7a2ba2fbe4
commit
b0884f3f13
@ -772,7 +772,7 @@ Value *InstCombiner::FoldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS) {
|
|||||||
|
|
||||||
// (trunc x) == C1 & (and x, CA) == C2 -> (and x, CA|CMAX) == C1|C2
|
// (trunc x) == C1 & (and x, CA) == C2 -> (and x, CA|CMAX) == C1|C2
|
||||||
// where CMAX is the all ones value for the truncated type,
|
// where CMAX is the all ones value for the truncated type,
|
||||||
// iff the lower bits of CA are zero.
|
// iff the lower bits of C2 and CA are zero.
|
||||||
if (LHSCC == RHSCC && ICmpInst::isEquality(LHSCC) &&
|
if (LHSCC == RHSCC && ICmpInst::isEquality(LHSCC) &&
|
||||||
LHS->hasOneUse() && RHS->hasOneUse()) {
|
LHS->hasOneUse() && RHS->hasOneUse()) {
|
||||||
Value *V;
|
Value *V;
|
||||||
@ -797,7 +797,7 @@ Value *InstCombiner::FoldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS) {
|
|||||||
|
|
||||||
// Check that the low bits are zero.
|
// Check that the low bits are zero.
|
||||||
APInt Low = APInt::getLowBitsSet(BigBitSize, SmallBitSize);
|
APInt Low = APInt::getLowBitsSet(BigBitSize, SmallBitSize);
|
||||||
if ((Low & AndCst->getValue()) == 0) {
|
if ((Low & AndCst->getValue()) == 0 && (Low & BigCst->getValue()) == 0) {
|
||||||
Value *NewAnd = Builder->CreateAnd(V, Low | AndCst->getValue());
|
Value *NewAnd = Builder->CreateAnd(V, Low | AndCst->getValue());
|
||||||
APInt N = SmallCst->getValue().zext(BigBitSize) | BigCst->getValue();
|
APInt N = SmallCst->getValue().zext(BigBitSize) | BigCst->getValue();
|
||||||
Value *NewVal = ConstantInt::get(AndCst->getType()->getContext(), N);
|
Value *NewVal = ConstantInt::get(AndCst->getType()->getContext(), N);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user