mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 00:21:03 +00:00
InstCombine: Move Sub->Xor rule from SimplifyDemanded to InstCombine
The rule that turns a sub to xor if the LHS is 2^n-1 and the remaining bits are known zero, does not use the demanded bits at all: Move it to the normal InstCombine code path. Differential Revision: http://reviews.llvm.org/D9417 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236268 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1586,6 +1586,19 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
||||
CI->getValue() == I.getType()->getPrimitiveSizeInBits() - 1)
|
||||
return BinaryOperator::CreateLShr(X, CI);
|
||||
}
|
||||
|
||||
// Turn this into a xor if LHS is 2^n-1 and the remaining bits are known
|
||||
// zero.
|
||||
APInt IntVal = C->getValue();
|
||||
if ((IntVal + 1).isPowerOf2()) {
|
||||
unsigned BitWidth = I.getType()->getScalarSizeInBits();
|
||||
APInt KnownZero(BitWidth, 0);
|
||||
APInt KnownOne(BitWidth, 0);
|
||||
computeKnownBits(&I, KnownZero, KnownOne, 0, &I);
|
||||
if ((IntVal | KnownZero).isAllOnesValue()) {
|
||||
return BinaryOperator::CreateXor(Op1, C);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user