mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-07 16:42:07 +00:00
I did not intend to merge these in.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_35@223646 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4eff4f7003
commit
62e4903904
@ -53,9 +53,6 @@ public:
|
||||
/// getNullValue.
|
||||
bool isNullValue() const;
|
||||
|
||||
/// \brief Returns true if the value is one.
|
||||
bool isOneValue() const;
|
||||
|
||||
/// isAllOnesValue - Return true if this is the value that would be returned by
|
||||
/// getAllOnesValue.
|
||||
bool isAllOnesValue() const;
|
||||
|
@ -107,28 +107,6 @@ bool Constant::isAllOnesValue() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Constant::isOneValue() const {
|
||||
// Check for 1 integers
|
||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(this))
|
||||
return CI->isOne();
|
||||
|
||||
// Check for FP which are bitcasted from 1 integers
|
||||
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(this))
|
||||
return CFP->getValueAPF().bitcastToAPInt() == 1;
|
||||
|
||||
// Check for constant vectors which are splats of 1 values.
|
||||
if (const ConstantVector *CV = dyn_cast<ConstantVector>(this))
|
||||
if (Constant *Splat = CV->getSplatValue())
|
||||
return Splat->isOneValue();
|
||||
|
||||
// Check for constant vectors which are splats of 1 values.
|
||||
if (const ConstantDataVector *CV = dyn_cast<ConstantDataVector>(this))
|
||||
if (Constant *Splat = CV->getSplatValue())
|
||||
return Splat->isOneValue();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Constant::isMinSignedValue() const {
|
||||
// Check for INT_MIN integers
|
||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(this))
|
||||
|
@ -1462,17 +1462,11 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
||||
if (Value *V = SimplifyUsingDistributiveLaws(I))
|
||||
return ReplaceInstUsesWith(I, V);
|
||||
|
||||
// If this is a 'B = x-(-A)', change to B = x+A.
|
||||
// If this is a 'B = x-(-A)', change to B = x+A. This preserves NSW/NUW.
|
||||
if (Value *V = dyn_castNegVal(Op1)) {
|
||||
BinaryOperator *Res = BinaryOperator::CreateAdd(Op0, V);
|
||||
|
||||
if (const auto *BO = dyn_cast<BinaryOperator>(Op1)) {
|
||||
assert(BO->getOpcode() == Instruction::Sub &&
|
||||
"Expected a subtraction operator!");
|
||||
if (BO->hasNoSignedWrap() && I.hasNoSignedWrap())
|
||||
Res->setHasNoSignedWrap(true);
|
||||
}
|
||||
|
||||
Res->setHasNoSignedWrap(I.hasNoSignedWrap());
|
||||
Res->setHasNoUnsignedWrap(I.hasNoUnsignedWrap());
|
||||
return Res;
|
||||
}
|
||||
|
||||
@ -1561,7 +1555,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
||||
|
||||
// 0 - (X sdiv C) -> (X sdiv -C) provided the negation doesn't overflow.
|
||||
if (match(Op1, m_SDiv(m_Value(X), m_Constant(C))) && match(Op0, m_Zero()) &&
|
||||
!C->isMinSignedValue() && !C->isOneValue())
|
||||
!C->isMinSignedValue())
|
||||
return BinaryOperator::CreateSDiv(X, ConstantExpr::getNeg(C));
|
||||
|
||||
// 0 - (X << Y) -> (-X << Y) when X is freely negatable.
|
||||
|
@ -464,12 +464,3 @@ define i32 @test38(i32 %A) {
|
||||
; CHECK-NEXT: [[SEXT:%.*]] = sext i1 [[ICMP]] to i32
|
||||
; CHECK-NEXT: ret i32 [[SEXT]]
|
||||
}
|
||||
|
||||
define i32 @test39(i32 %A, i32 %x) {
|
||||
%B = sub i32 0, %A
|
||||
%C = sub nsw i32 %x, %B
|
||||
ret i32 %C
|
||||
; CHECK-LABEL: @test39(
|
||||
; CHECK: %C = add i32 %x, %A
|
||||
; CHECK: ret i32 %C
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user