mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
Transforming -A + -B --> -(A + B) isn't safe for FP, thanks
to Dale for noticing this! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47276 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
913b19f6fc
commit
e10c0b9d66
@ -2092,10 +2092,12 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||
// -A + B --> B - A
|
||||
// -A + -B --> -(A + B)
|
||||
if (Value *LHSV = dyn_castNegVal(LHS)) {
|
||||
if (Value *RHSV = dyn_castNegVal(RHS)) {
|
||||
Instruction *NewAdd = BinaryOperator::createAdd(LHSV, RHSV, "sum");
|
||||
InsertNewInstBefore(NewAdd, I);
|
||||
return BinaryOperator::createNeg(NewAdd);
|
||||
if (LHS->getType()->isIntOrIntVector()) {
|
||||
if (Value *RHSV = dyn_castNegVal(RHS)) {
|
||||
Instruction *NewAdd = BinaryOperator::createAdd(LHSV, RHSV, "sum");
|
||||
InsertNewInstBefore(NewAdd, I);
|
||||
return BinaryOperator::createNeg(NewAdd);
|
||||
}
|
||||
}
|
||||
|
||||
return BinaryOperator::createSub(RHS, LHSV);
|
||||
|
Loading…
Reference in New Issue
Block a user