aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/RuntimeCheck.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/RuntimeCheck.cc')
-rw-r--r--lib/CodeGen/RuntimeCheck.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/CodeGen/RuntimeCheck.cc b/lib/CodeGen/RuntimeCheck.cc
index 40304fd..8075873 100644
--- a/lib/CodeGen/RuntimeCheck.cc
+++ b/lib/CodeGen/RuntimeCheck.cc
@@ -57,7 +57,12 @@ void RuntimeCheck::emitErrorAndExit(Value *Condition, Value *Msg, ArrayRef<Value
}
void RuntimeCheck::emitDivZeroCheck(Value *Divisor, int Line) {
- Value *IsZero = Builder.CreateICmpEQ(Divisor, ConstantInt::get(TheContext, APInt(64, 0)), "is_zero");
+ Value *IsZero;
+ if (Divisor->getType()->isDoubleTy()) {
+ IsZero = Builder.CreateFCmpOEQ(Divisor, ConstantFP::get(Divisor->getType(), 0.0), "is_zero");
+ } else {
+ IsZero = Builder.CreateICmpEQ(Divisor, ConstantInt::get(Divisor->getType(), 0), "is_zero");
+ }
emitErrorAndExit(IsZero, DivZeroMsg, Line);
}