src/share/vm/opto/library_call.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8054033 Sdiff src/share/vm/opto

src/share/vm/opto/library_call.cpp

Print this page




1888 
1889     Node *slow_path = _gvn.transform(new IfTrueNode(if2));
1890 
1891     // Calculate DPow(abs(x), y)*(1 & (long)y)
1892     // Node for constant 1
1893     Node *conone = longcon(1);
1894     // 1& (long)y
1895     Node *signnode= _gvn.transform(new AndLNode(conone, longy));
1896 
1897     // A huge number is always even. Detect a huge number by checking
1898     // if y + 1 == y and set integer to be tested for parity to 0.
1899     // Required for corner case:
1900     // (long)9.223372036854776E18 = max_jlong
1901     // (double)(long)9.223372036854776E18 = 9.223372036854776E18
1902     // max_jlong is odd but 9.223372036854776E18 is even
1903     Node* yplus1 = _gvn.transform(new AddDNode(y, makecon(TypeD::make(1))));
1904     Node *cmpyplus1= _gvn.transform(new CmpDNode(yplus1, y));
1905     Node *bolyplus1 = _gvn.transform(new BoolNode( cmpyplus1, BoolTest::eq ));
1906     Node* correctedsign = NULL;
1907     if (ConditionalMoveLimit != 0) {
1908       correctedsign = _gvn.transform( CMoveNode::make(C, NULL, bolyplus1, signnode, longcon(0), TypeLong::LONG));
1909     } else {
1910       IfNode *ifyplus1 = create_and_xform_if(ylong_path,bolyplus1, PROB_FAIR, COUNT_UNKNOWN);
1911       RegionNode *r = new RegionNode(3);
1912       Node *phi = new PhiNode(r, TypeLong::LONG);
1913       r->init_req(1, _gvn.transform(new IfFalseNode(ifyplus1)));
1914       r->init_req(2, _gvn.transform(new IfTrueNode(ifyplus1)));
1915       phi->init_req(1, signnode);
1916       phi->init_req(2, longcon(0));
1917       correctedsign = _gvn.transform(phi);
1918       ylong_path = _gvn.transform(r);
1919       record_for_igvn(r);
1920     }
1921 
1922     // zero node
1923     Node *conzero = longcon(0);
1924     // Check (1&(long)y)==0?
1925     Node *cmpeq1 = _gvn.transform(new CmpLNode(correctedsign, conzero));
1926     // Check if (1&(long)y)!=0?, if so the result is negative
1927     Node *bol3 = _gvn.transform(new BoolNode( cmpeq1, BoolTest::ne ));
1928     // abs(x)
1929     Node *absx=_gvn.transform(new AbsDNode(x));
1930     // abs(x)^y
1931     Node *absxpowy = _gvn.transform(new PowDNode(C, control(), absx, y));
1932     // -abs(x)^y
1933     Node *negabsxpowy = _gvn.transform(new NegDNode (absxpowy));
1934     // (1&(long)y)==1?-DPow(abs(x), y):DPow(abs(x), y)
1935     Node *signresult = NULL;
1936     if (ConditionalMoveLimit != 0) {
1937       signresult = _gvn.transform( CMoveNode::make(C, NULL, bol3, absxpowy, negabsxpowy, Type::DOUBLE));
1938     } else {
1939       IfNode *ifyeven = create_and_xform_if(ylong_path,bol3, PROB_FAIR, COUNT_UNKNOWN);
1940       RegionNode *r = new RegionNode(3);
1941       Node *phi = new PhiNode(r, Type::DOUBLE);
1942       r->init_req(1, _gvn.transform(new IfFalseNode(ifyeven)));
1943       r->init_req(2, _gvn.transform(new IfTrueNode(ifyeven)));
1944       phi->init_req(1, absxpowy);
1945       phi->init_req(2, negabsxpowy);
1946       signresult = _gvn.transform(phi);
1947       ylong_path = _gvn.transform(r);
1948       record_for_igvn(r);
1949     }
1950     // Set complex path fast result
1951     r->init_req(2, ylong_path);
1952     phi->init_req(2, signresult);
1953 
1954     static const jlong nan_bits = CONST64(0x7ff8000000000000);
1955     Node *slow_result = makecon(TypeD::make(*(double*)&nan_bits)); // return NaN
1956     r->init_req(1,slow_path);
1957     phi->init_req(1,slow_result);


2251     answer_if_true  = (want_max ? xvalue : yvalue);
2252     answer_if_false = (want_max ? yvalue : xvalue);
2253     break;
2254   }
2255 
2256   jint hi, lo;
2257   if (want_max) {
2258     // We can sharpen the minimum.
2259     hi = MAX2(txvalue->_hi, tyvalue->_hi);
2260     lo = MAX2(txvalue->_lo, tyvalue->_lo);
2261   } else {
2262     // We can sharpen the maximum.
2263     hi = MIN2(txvalue->_hi, tyvalue->_hi);
2264     lo = MIN2(txvalue->_lo, tyvalue->_lo);
2265   }
2266 
2267   // Use a flow-free graph structure, to avoid creating excess control edges
2268   // which could hinder other optimizations.
2269   // Since Math.min/max is often used with arraycopy, we want
2270   // tightly_coupled_allocation to be able to see beyond min/max expressions.
2271   Node* cmov = CMoveNode::make(C, NULL, best_bol,
2272                                answer_if_false, answer_if_true,
2273                                TypeInt::make(lo, hi, widen));
2274 
2275   return _gvn.transform(cmov);
2276 
2277   /*
2278   // This is not as desirable as it may seem, since Min and Max
2279   // nodes do not have a full set of optimizations.
2280   // And they would interfere, anyway, with 'if' optimizations
2281   // and with CMoveI canonical forms.
2282   switch (id) {
2283   case vmIntrinsics::_min:
2284     result_val = _gvn.transform(new (C, 3) MinINode(x,y)); break;
2285   case vmIntrinsics::_max:
2286     result_val = _gvn.transform(new (C, 3) MaxINode(x,y)); break;
2287   default:
2288     ShouldNotReachHere();
2289   }
2290   */
2291 }




1888 
1889     Node *slow_path = _gvn.transform(new IfTrueNode(if2));
1890 
1891     // Calculate DPow(abs(x), y)*(1 & (long)y)
1892     // Node for constant 1
1893     Node *conone = longcon(1);
1894     // 1& (long)y
1895     Node *signnode= _gvn.transform(new AndLNode(conone, longy));
1896 
1897     // A huge number is always even. Detect a huge number by checking
1898     // if y + 1 == y and set integer to be tested for parity to 0.
1899     // Required for corner case:
1900     // (long)9.223372036854776E18 = max_jlong
1901     // (double)(long)9.223372036854776E18 = 9.223372036854776E18
1902     // max_jlong is odd but 9.223372036854776E18 is even
1903     Node* yplus1 = _gvn.transform(new AddDNode(y, makecon(TypeD::make(1))));
1904     Node *cmpyplus1= _gvn.transform(new CmpDNode(yplus1, y));
1905     Node *bolyplus1 = _gvn.transform(new BoolNode( cmpyplus1, BoolTest::eq ));
1906     Node* correctedsign = NULL;
1907     if (ConditionalMoveLimit != 0) {
1908       correctedsign = _gvn.transform(CMoveNode::make(NULL, bolyplus1, signnode, longcon(0), TypeLong::LONG));
1909     } else {
1910       IfNode *ifyplus1 = create_and_xform_if(ylong_path,bolyplus1, PROB_FAIR, COUNT_UNKNOWN);
1911       RegionNode *r = new RegionNode(3);
1912       Node *phi = new PhiNode(r, TypeLong::LONG);
1913       r->init_req(1, _gvn.transform(new IfFalseNode(ifyplus1)));
1914       r->init_req(2, _gvn.transform(new IfTrueNode(ifyplus1)));
1915       phi->init_req(1, signnode);
1916       phi->init_req(2, longcon(0));
1917       correctedsign = _gvn.transform(phi);
1918       ylong_path = _gvn.transform(r);
1919       record_for_igvn(r);
1920     }
1921 
1922     // zero node
1923     Node *conzero = longcon(0);
1924     // Check (1&(long)y)==0?
1925     Node *cmpeq1 = _gvn.transform(new CmpLNode(correctedsign, conzero));
1926     // Check if (1&(long)y)!=0?, if so the result is negative
1927     Node *bol3 = _gvn.transform(new BoolNode( cmpeq1, BoolTest::ne ));
1928     // abs(x)
1929     Node *absx=_gvn.transform(new AbsDNode(x));
1930     // abs(x)^y
1931     Node *absxpowy = _gvn.transform(new PowDNode(C, control(), absx, y));
1932     // -abs(x)^y
1933     Node *negabsxpowy = _gvn.transform(new NegDNode (absxpowy));
1934     // (1&(long)y)==1?-DPow(abs(x), y):DPow(abs(x), y)
1935     Node *signresult = NULL;
1936     if (ConditionalMoveLimit != 0) {
1937       signresult = _gvn.transform(CMoveNode::make(NULL, bol3, absxpowy, negabsxpowy, Type::DOUBLE));
1938     } else {
1939       IfNode *ifyeven = create_and_xform_if(ylong_path,bol3, PROB_FAIR, COUNT_UNKNOWN);
1940       RegionNode *r = new RegionNode(3);
1941       Node *phi = new PhiNode(r, Type::DOUBLE);
1942       r->init_req(1, _gvn.transform(new IfFalseNode(ifyeven)));
1943       r->init_req(2, _gvn.transform(new IfTrueNode(ifyeven)));
1944       phi->init_req(1, absxpowy);
1945       phi->init_req(2, negabsxpowy);
1946       signresult = _gvn.transform(phi);
1947       ylong_path = _gvn.transform(r);
1948       record_for_igvn(r);
1949     }
1950     // Set complex path fast result
1951     r->init_req(2, ylong_path);
1952     phi->init_req(2, signresult);
1953 
1954     static const jlong nan_bits = CONST64(0x7ff8000000000000);
1955     Node *slow_result = makecon(TypeD::make(*(double*)&nan_bits)); // return NaN
1956     r->init_req(1,slow_path);
1957     phi->init_req(1,slow_result);


2251     answer_if_true  = (want_max ? xvalue : yvalue);
2252     answer_if_false = (want_max ? yvalue : xvalue);
2253     break;
2254   }
2255 
2256   jint hi, lo;
2257   if (want_max) {
2258     // We can sharpen the minimum.
2259     hi = MAX2(txvalue->_hi, tyvalue->_hi);
2260     lo = MAX2(txvalue->_lo, tyvalue->_lo);
2261   } else {
2262     // We can sharpen the maximum.
2263     hi = MIN2(txvalue->_hi, tyvalue->_hi);
2264     lo = MIN2(txvalue->_lo, tyvalue->_lo);
2265   }
2266 
2267   // Use a flow-free graph structure, to avoid creating excess control edges
2268   // which could hinder other optimizations.
2269   // Since Math.min/max is often used with arraycopy, we want
2270   // tightly_coupled_allocation to be able to see beyond min/max expressions.
2271   Node* cmov = CMoveNode::make(NULL, best_bol,
2272                                answer_if_false, answer_if_true,
2273                                TypeInt::make(lo, hi, widen));
2274 
2275   return _gvn.transform(cmov);
2276 
2277   /*
2278   // This is not as desirable as it may seem, since Min and Max
2279   // nodes do not have a full set of optimizations.
2280   // And they would interfere, anyway, with 'if' optimizations
2281   // and with CMoveI canonical forms.
2282   switch (id) {
2283   case vmIntrinsics::_min:
2284     result_val = _gvn.transform(new (C, 3) MinINode(x,y)); break;
2285   case vmIntrinsics::_max:
2286     result_val = _gvn.transform(new (C, 3) MaxINode(x,y)); break;
2287   default:
2288     ShouldNotReachHere();
2289   }
2290   */
2291 }


src/share/vm/opto/library_call.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File