mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 21:32:39 +00:00
Compile X + ~X to -1. This implements Instcombine/add.ll:test34
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32890 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0a2c88dafc
commit
e617c9ed5d
@ -1871,10 +1871,16 @@ FoundSExt:
|
||||
if (dyn_castFoldableMul(RHS, C2) == LHS)
|
||||
return BinaryOperator::createMul(LHS, AddOne(C2));
|
||||
|
||||
// X + ~X --> -1 since ~X = -X-1
|
||||
if (dyn_castNotVal(LHS) == RHS ||
|
||||
dyn_castNotVal(RHS) == LHS)
|
||||
return ReplaceInstUsesWith(I, ConstantInt::getAllOnesValue(I.getType()));
|
||||
|
||||
|
||||
// (A & C1)+(B & C2) --> (A & C1)|(B & C2) iff C1&C2 == 0
|
||||
if (match(RHS, m_And(m_Value(), m_ConstantInt(C2))))
|
||||
if (Instruction *R = AssociativeOpt(I, AddMaskingAnd(C2))) return R;
|
||||
if (Instruction *R = AssociativeOpt(I, AddMaskingAnd(C2)))
|
||||
return R;
|
||||
|
||||
if (ConstantInt *CRHS = dyn_cast<ConstantInt>(RHS)) {
|
||||
Value *X = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user