summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2012-04-08 18:08:12 +0000
committerDuncan Sands <baldrick@free.fr>2012-04-08 18:08:12 +0000
commit2f1dc3814bc68fd1a790a86e10c9f05f89bfa8a5 (patch)
tree6dd0b923a27ab1cdec31e69e96bd9ba407f83e72 /llvm/lib/CodeGen
parentc8e2d91a58b4fd5aba6d70eddbf8835d847f37a3 (diff)
downloadbcm5719-llvm-2f1dc3814bc68fd1a790a86e10c9f05f89bfa8a5.tar.gz
bcm5719-llvm-2f1dc3814bc68fd1a790a86e10c9f05f89bfa8a5.zip
Only have codegen turn fdiv by a constant into fmul by the reciprocal
when -ffast-math, i.e. don't just always do it if the reciprocal can be formed exactly. There is already an IR level transform that does that, and it does it more carefully. llvm-svn: 154296
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index ebffb8562ef..f1b9f4385e4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -5725,16 +5725,14 @@ SDValue DAGCombiner::visitFDIV(SDNode *N) {
if (N0CFP && N1CFP && VT != MVT::ppcf128)
return DAG.getNode(ISD::FDIV, N->getDebugLoc(), VT, N0, N1);
- // fold (fdiv X, c2) -> fmul X, 1/c2 if there is no precision loss or if
- // losing precision is acceptable.
- if (N1CFP && VT != MVT::ppcf128) {
+ // fold (fdiv X, c2) -> fmul X, 1/c2 if losing precision is acceptable.
+ if (N1CFP && VT != MVT::ppcf128 && DAG.getTarget().Options.UnsafeFPMath) {
// Compute the reciprocal 1.0 / c2.
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 &&
- DAG.getTarget().Options.UnsafeFPMath))
+ if (st == APFloat::opOK || st == APFloat::opInexact)
return DAG.getNode(ISD::FMUL, N->getDebugLoc(), VT, N0,
DAG.getConstantFP(Recip, VT));
}
OpenPOWER on IntegriCloud