mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-13 14:46:53 +00:00
[InstCombine] rename variable for easier reading; NFC
We usually give constants a 'C' somewhere in the name... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299474 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7597f2aad7
commit
828ad8830a
@ -1042,9 +1042,9 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||
if (Value *V = SimplifyUsingDistributiveLaws(I))
|
||||
return replaceInstUsesWith(I, V);
|
||||
|
||||
const APInt *Val;
|
||||
if (match(RHS, m_APInt(Val))) {
|
||||
if (Val->isSignBit()) {
|
||||
const APInt *RHSC;
|
||||
if (match(RHS, m_APInt(RHSC))) {
|
||||
if (RHSC->isSignBit()) {
|
||||
// If wrapping is not allowed, then the addition must set the sign bit:
|
||||
// X + (signbit) --> X | signbit
|
||||
if (I.hasNoSignedWrap() || I.hasNoUnsignedWrap())
|
||||
@ -1060,17 +1060,17 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||
const APInt *C;
|
||||
if (match(LHS, m_ZExt(m_Xor(m_Value(X), m_APInt(C)))) &&
|
||||
C->isMinSignedValue() &&
|
||||
C->sext(LHS->getType()->getScalarSizeInBits()) == *Val) {
|
||||
C->sext(LHS->getType()->getScalarSizeInBits()) == *RHSC) {
|
||||
// add(zext(xor i16 X, -32768), -32768) --> sext X
|
||||
return CastInst::Create(Instruction::SExt, X, LHS->getType());
|
||||
}
|
||||
|
||||
if (Val->isNegative() &&
|
||||
if (RHSC->isNegative() &&
|
||||
match(LHS, m_ZExt(m_NUWAdd(m_Value(X), m_APInt(C)))) &&
|
||||
Val->sge(-C->sext(Val->getBitWidth()))) {
|
||||
RHSC->sge(-C->sext(RHSC->getBitWidth()))) {
|
||||
// (add (zext (add nuw X, C)), Val) -> (zext (add nuw X, C+Val))
|
||||
Constant *NewC =
|
||||
ConstantInt::get(X->getType(), *C + Val->trunc(C->getBitWidth()));
|
||||
ConstantInt::get(X->getType(), *C + RHSC->trunc(C->getBitWidth()));
|
||||
return new ZExtInst(Builder->CreateNUWAdd(X, NewC), I.getType());
|
||||
}
|
||||
}
|
||||
@ -1320,6 +1320,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||
return BinaryOperator::CreateOr(A, B);
|
||||
}
|
||||
|
||||
|
||||
// (add (or A, B) (and A, B)) --> (add A, B)
|
||||
{
|
||||
Value *A = nullptr, *B = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user