[llvm-commits] [llvm] r47276 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
sabre at nondot.org
Mon Feb 18 09:50:16 PST 2008
Author: lattner
Date: Mon Feb 18 11:50:16 2008
New Revision: 47276
URL: http://llvm.org/viewvc/llvm-project?rev=47276&view=rev
Log:
Transforming -A + -B --> -(A + B) isn't safe for FP, thanks
to Dale for noticing this!
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=47276&r1=47275&r2=47276&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Feb 18 11:50:16 2008
@@ -2092,10 +2092,12 @@
// -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);
More information about the llvm-commits
mailing list