提交 79e27e98 编写于 作者: R rasbold

6717150: improper constant folding of subnormal strictfp multiplications and divides

Summary: suppress constant folding of double divides and multiplications on ia32
Reviewed-by: never
上级 627fc840
...@@ -710,11 +710,18 @@ const Type *DivDNode::Value( PhaseTransform *phase ) const { ...@@ -710,11 +710,18 @@ const Type *DivDNode::Value( PhaseTransform *phase ) const {
if( t2 == TypeD::ONE ) if( t2 == TypeD::ONE )
return t1; return t1;
// If divisor is a constant and not zero, divide them numbers #if defined(IA32)
if( t1->base() == Type::DoubleCon && if (!phase->C->method()->is_strict())
t2->base() == Type::DoubleCon && // Can't trust native compilers to properly fold strict double
t2->getd() != 0.0 ) // could be negative zero // division with round-to-zero on this platform.
return TypeD::make( t1->getd()/t2->getd() ); #endif
{
// If divisor is a constant and not zero, divide them numbers
if( t1->base() == Type::DoubleCon &&
t2->base() == Type::DoubleCon &&
t2->getd() != 0.0 ) // could be negative zero
return TypeD::make( t1->getd()/t2->getd() );
}
// If the dividend is a constant zero // If the dividend is a constant zero
// Note: if t1 and t2 are zero then result is NaN (JVMS page 213) // Note: if t1 and t2 are zero then result is NaN (JVMS page 213)
......
...@@ -152,6 +152,14 @@ const Type *MulNode::Value( PhaseTransform *phase ) const { ...@@ -152,6 +152,14 @@ const Type *MulNode::Value( PhaseTransform *phase ) const {
if( t1 == Type::BOTTOM || t2 == Type::BOTTOM ) if( t1 == Type::BOTTOM || t2 == Type::BOTTOM )
return bottom_type(); return bottom_type();
#if defined(IA32)
// Can't trust native compilers to properly fold strict double
// multiplication with round-to-zero on this platform.
if (op == Op_MulD && phase->C->method()->is_strict()) {
return TypeD::DOUBLE;
}
#endif
return mul_ring(t1,t2); // Local flavor of type multiplication return mul_ring(t1,t2); // Local flavor of type multiplication
} }
...@@ -360,7 +368,7 @@ const Type *MulFNode::mul_ring(const Type *t0, const Type *t1) const { ...@@ -360,7 +368,7 @@ const Type *MulFNode::mul_ring(const Type *t0, const Type *t1) const {
// Compute the product type of two double ranges into this node. // Compute the product type of two double ranges into this node.
const Type *MulDNode::mul_ring(const Type *t0, const Type *t1) const { const Type *MulDNode::mul_ring(const Type *t0, const Type *t1) const {
if( t0 == Type::DOUBLE || t1 == Type::DOUBLE ) return Type::DOUBLE; if( t0 == Type::DOUBLE || t1 == Type::DOUBLE ) return Type::DOUBLE;
// We must be adding 2 double constants. // We must be multiplying 2 double constants.
return TypeD::make( t0->getd() * t1->getd() ); return TypeD::make( t0->getd() * t1->getd() );
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册