forked from OSchip/llvm-project
Fix PR618 and Regression/CodeGen/CBackend/2005-08-23-Fmod.ll by not emitting
x%y for 'rem' on fp values. llvm-svn: 22984
This commit is contained in:
parent
65de2689b4
commit
9c0a243ce5
|
@ -871,6 +871,9 @@ bool CWriter::doInitialization(Module &M) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function declarations
|
// Function declarations
|
||||||
|
Out << "double fmod(double, double);\n"; // Support for FP rem
|
||||||
|
Out << "float fmodf(float, float);\n";
|
||||||
|
|
||||||
if (!M.empty()) {
|
if (!M.empty()) {
|
||||||
Out << "\n/* Function Declarations */\n";
|
Out << "\n/* Function Declarations */\n";
|
||||||
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
|
||||||
|
@ -1349,6 +1352,17 @@ void CWriter::visitBinaryOperator(Instruction &I) {
|
||||||
Out << "-(";
|
Out << "-(";
|
||||||
writeOperand(BinaryOperator::getNegArgument(cast<BinaryOperator>(&I)));
|
writeOperand(BinaryOperator::getNegArgument(cast<BinaryOperator>(&I)));
|
||||||
Out << ")";
|
Out << ")";
|
||||||
|
} else if (I.getOpcode() == Instruction::Rem &&
|
||||||
|
I.getType()->isFloatingPoint()) {
|
||||||
|
// Output a call to fmod/fmodf instead of emitting a%b
|
||||||
|
if (I.getType() == Type::FloatTy)
|
||||||
|
Out << "fmodf(";
|
||||||
|
else
|
||||||
|
Out << "fmod(";
|
||||||
|
writeOperand(I.getOperand(0));
|
||||||
|
Out << ", ";
|
||||||
|
writeOperand(I.getOperand(1));
|
||||||
|
Out << ")";
|
||||||
} else {
|
} else {
|
||||||
writeOperand(I.getOperand(0));
|
writeOperand(I.getOperand(0));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue