[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Apr 1 21:05:04 PST 2005
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAGISel.cpp updated: 1.37 -> 1.38
---
Log message:
Turn -0.0 - X -> fneg
---
Diffs of the changes: (+13 -1)
SelectionDAGISel.cpp | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletion(-)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.37 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.38
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.37 Thu Mar 31 15:24:06 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Apr 1 23:04:50 2005
@@ -314,7 +314,7 @@
//
void visitBinary(User &I, unsigned Opcode);
void visitAdd(User &I) { visitBinary(I, ISD::ADD); }
- void visitSub(User &I) { visitBinary(I, ISD::SUB); }
+ void visitSub(User &I);
void visitMul(User &I) { visitBinary(I, ISD::MUL); }
void visitDiv(User &I) {
visitBinary(I, I.getType()->isUnsigned() ? ISD::UDIV : ISD::SDIV);
@@ -454,6 +454,18 @@
}
}
+void SelectionDAGLowering::visitSub(User &I) {
+ // -0.0 - X --> fneg
+ if (ConstantFP *CFP = dyn_cast<ConstantFP>(I.getOperand(0)))
+ if (CFP->isExactlyValue(-0.0)) {
+ SDOperand Op2 = getValue(I.getOperand(1));
+ setValue(&I, DAG.getNode(ISD::FNEG, Op2.getValueType(), Op2));
+ return;
+ }
+
+ visitBinary(I, ISD::SUB);
+}
+
void SelectionDAGLowering::visitBinary(User &I, unsigned Opcode) {
SDOperand Op1 = getValue(I.getOperand(0));
SDOperand Op2 = getValue(I.getOperand(1));
More information about the llvm-commits
mailing list