mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-15 07:39:31 +00:00
Transforming -A + -B --> -(A + B) isn't safe for FP, thanks
to Dale for noticing this! llvm-svn: 47276
This commit is contained in:
parent
a3318d17d4
commit
a378b03483
@ -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