diff options
author | Chris Lattner <sabre@nondot.org> | 2005-04-02 05:04:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-04-02 05:04:50 +0000 |
commit | b9fccc41933648647e3f7669612c683eb5de0d58 (patch) | |
tree | 48b68743d8c7dbf1cb14d9d924b5dadea78bf0d0 | |
parent | 43fdea070cd54094b5c3b69ce5a25c04d93c91af (diff) |
Turn -0.0 - X -> fneg
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21011 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 7535298203..052daa29c4 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -314,7 +314,7 @@ public: // 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::visitBr(BranchInst &I) { } } +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)); |