mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-26 07:29:55 +00:00
InstCombine: (X ^ signbit) + C -> X + (signbit ^ C)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181249 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e305e03d6f
commit
8ec23cb07e
@ -974,6 +974,11 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||
return BinaryOperator::CreateSub(ConstantExpr::getAdd(XorRHS, CI),
|
||||
XorLHS);
|
||||
}
|
||||
// (X + signbit) + C could have gotten canonicalized to (X ^ signbit) + C,
|
||||
// transform them into (X + (signbit ^ C))
|
||||
if (XorRHS->getValue().isSignBit())
|
||||
return BinaryOperator::CreateAdd(XorLHS,
|
||||
ConstantExpr::getXor(XorRHS, CI));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,3 +35,13 @@ define i32 @test3(i32 %x) nounwind {
|
||||
; CHECK-NEXT: sub i32 73, %and
|
||||
; CHECK-NEXT: ret
|
||||
}
|
||||
|
||||
define i32 @test4(i32 %x) nounwind {
|
||||
%sub = xor i32 %x, 2147483648
|
||||
%add = add i32 %sub, 42
|
||||
ret i32 %add
|
||||
|
||||
; CHECK: @test4
|
||||
; CHECK-NEXT: add i32 %x, -2147483606
|
||||
; CHECK-NEXT: ret
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user