Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 10,859 Lines • ▼ Show 20 Lines | SDValue DAGCombiner::visitFDIV(SDNode *N) { | ||||
// fold (fdiv c1, c2) -> c1/c2 | // fold (fdiv c1, c2) -> c1/c2 | ||||
if (N0CFP && N1CFP) | if (N0CFP && N1CFP) | ||||
return DAG.getNode(ISD::FDIV, SDLoc(N), VT, N0, N1, Flags); | return DAG.getNode(ISD::FDIV, SDLoc(N), VT, N0, N1, Flags); | ||||
if (SDValue NewSel = foldBinOpIntoSelect(N)) | if (SDValue NewSel = foldBinOpIntoSelect(N)) | ||||
return NewSel; | return NewSel; | ||||
if (Options.UnsafeFPMath) { | if (Options.UnsafeFPMath || Flags.hasAllowReciprocal()) { | ||||
// fold (fdiv X, c2) -> fmul X, 1/c2 if losing precision is acceptable. | // fold (fdiv X, c2) -> fmul X, 1/c2 if losing precision is acceptable. | ||||
if (N1CFP) { | if (N1CFP) { | ||||
// Compute the reciprocal 1.0 / c2. | // Compute the reciprocal 1.0 / c2. | ||||
const APFloat &N1APF = N1CFP->getValueAPF(); | const APFloat &N1APF = N1CFP->getValueAPF(); | ||||
APFloat Recip(N1APF.getSemantics(), 1); // 1.0 | APFloat Recip(N1APF.getSemantics(), 1); // 1.0 | ||||
APFloat::opStatus st = Recip.divide(N1APF, APFloat::rmNearestTiesToEven); | APFloat::opStatus st = Recip.divide(N1APF, APFloat::rmNearestTiesToEven); | ||||
// Only do the transform if the reciprocal is a legal fp immediate that | // Only do the transform if the reciprocal is a legal fp immediate that | ||||
// isn't too nasty (eg NaN, denormal, ...). | // isn't too nasty (eg NaN, denormal, ...). | ||||
▲ Show 20 Lines • Show All 7,341 Lines • Show Last 20 Lines |