diff options
| author | Anton Korobeynikov <asl@math.spbu.ru> | 2012-04-10 13:22:49 +0000 |
|---|---|---|
| committer | Anton Korobeynikov <asl@math.spbu.ru> | 2012-04-10 13:22:49 +0000 |
| commit | 4d1220de348c5aaeef3b4183986c405543dacd98 (patch) | |
| tree | a6e3a07db3f47575318efa5427866185799afda1 /llvm/lib/CodeGen | |
| parent | 1baf89eac94e1e4a62d8bf7eebb9938b40905435 (diff) | |
| download | bcm5719-llvm-4d1220de348c5aaeef3b4183986c405543dacd98.tar.gz bcm5719-llvm-4d1220de348c5aaeef3b4183986c405543dacd98.zip | |
Transform div to mul with reciprocal only when fp imm is legal.
This fixes PR12516 and uncovers one weird problem in legalize (workarounded)
llvm-svn: 154394
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index cf7ce587f36..b5b20284c1d 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -5769,8 +5769,15 @@ SDValue DAGCombiner::visitFDIV(SDNode *N) { APFloat N1APF = N1CFP->getValueAPF(); APFloat Recip(N1APF.getSemantics(), 1); // 1.0 APFloat::opStatus st = Recip.divide(N1APF, APFloat::rmNearestTiesToEven); - // Only do the transform if the reciprocal is not too horrible (eg not NaN). - if (st == APFloat::opOK || st == APFloat::opInexact) + // Only do the transform if the reciprocal is not too horrible (eg not NaN) + // and the reciprocal is a legal fp imm. + if ((st == APFloat::opOK || st == APFloat::opInexact) && + (!LegalOperations || + // FIXME: custom lowering of ConstantFP might fail (see e.g. ARM + // backend)... we should handle this gracefully after Legalize. + // TLI.isOperationLegalOrCustom(llvm::ISD::ConstantFP, VT) || + TLI.isOperationLegal(llvm::ISD::ConstantFP, VT) || + TLI.isFPImmLegal(Recip, VT))) return DAG.getNode(ISD::FMUL, N->getDebugLoc(), VT, N0, DAG.getConstantFP(Recip, VT)); } |

