1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

fold fp div by 0 to inf, the way gcc does. This is legal according to the FP spec

llvm-svn: 21655
This commit is contained in:
Andrew Lenharth 2005-05-02 21:25:47 +00:00
parent 1e1117ed7a
commit d46211fc03

View File

@ -470,6 +470,13 @@ struct DirectFPRules
(BuiltinType)V2->getValue()); (BuiltinType)V2->getValue());
return ConstantClass::get(*Ty, Result); return ConstantClass::get(*Ty, Result);
} }
static Constant *Div(const ConstantClass *V1, const ConstantClass *V2) {
if (V2->isExactlyValue(0.0)) return ConstantClass::get(*Ty, INFINITY);
if (V2->isExactlyValue(-0.0)) return ConstantClass::get(*Ty, -INFINITY);
if (V2->isNullValue()) return 0;
BuiltinType R = (BuiltinType)V1->getValue() / (BuiltinType)V2->getValue();
return ConstantClass::get(*Ty, R);
}
}; };