1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 12:02:58 +02:00

Fix PR611, codegen'ing SREM of FP operands to fmod or fmodf instead of

the sequence used for integer ops

llvm-svn: 22629
This commit is contained in:
Chris Lattner 2005-08-03 20:31:37 +00:00
parent eee2daf85d
commit d124203207
2 changed files with 14 additions and 6 deletions

View File

@ -1306,12 +1306,18 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
case TargetLowering::Promote:
case TargetLowering::Custom:
assert(0 && "Cannot promote/custom handle this yet!");
case TargetLowering::Expand: {
MVT::ValueType VT = Node->getValueType(0);
unsigned Opc = (Node->getOpcode() == ISD::UREM) ? ISD::UDIV : ISD::SDIV;
Result = DAG.getNode(Opc, VT, Tmp1, Tmp2);
Result = DAG.getNode(ISD::MUL, VT, Result, Tmp2);
Result = DAG.getNode(ISD::SUB, VT, Tmp1, Result);
case TargetLowering::Expand:
if (MVT::isInteger(Node->getValueType(0))) {
MVT::ValueType VT = Node->getValueType(0);
unsigned Opc = (Node->getOpcode() == ISD::UREM) ? ISD::UDIV : ISD::SDIV;
Result = DAG.getNode(Opc, VT, Tmp1, Tmp2);
Result = DAG.getNode(ISD::MUL, VT, Result, Tmp2);
Result = DAG.getNode(ISD::SUB, VT, Tmp1, Result);
} else {
// Floating point mod -> fmod libcall.
const char *FnName = Node->getValueType(0) == MVT::f32 ? "fmodf":"fmod";
SDOperand Dummy;
Result = ExpandLibCall(FnName, Node, Dummy);
}
break;
}

View File

@ -124,6 +124,7 @@ void SelectionDAG::viewGraph() {
if (system((LLVM_PATH_GRAPHVIZ " " + Filename).c_str())) {
std::cerr << "Error viewing graph: 'Graphviz' not in path?\n";
} else {
system(("rm " + Filename).c_str());
return;
}
#endif
@ -143,4 +144,5 @@ void SelectionDAG::viewGraph() {
#endif
std::cerr << "SelectionDAG::viewGraph is only available in debug builds on "
<< "systems with Graphviz or gv!\n";
system(("rm " + Filename).c_str());
}