< prev index next >

src/hotspot/share/opto/ifnode.cpp

Print this page




 880   //                         /
 881   //        this_bool = x {<,<=} b
 882   //                       / \
 883   //  fail = {True,False} /   \ success = {False,True}
 884   //                     /
 885   //
 886   // (Second test guaranteed canonicalized, first one may not have
 887   // been canonicalized yet)
 888   //
 889   // into:
 890   //
 891   // cond = (x - lo) {<u,<=u,>u,>=u} adjusted_lim
 892   //                       / \
 893   //                 fail /   \ success
 894   //                     /
 895   //
 896 
 897   // Figure out which of the two tests sets the upper bound and which
 898   // sets the lower bound if any.
 899   Node* adjusted_lim = NULL;
 900   if (hi_type->_lo > lo_type->_hi && hi_type->_hi == max_jint && lo_type->_lo == min_jint) {

 901     assert((dom_bool->_test.is_less() && !proj->_con) ||
 902            (dom_bool->_test.is_greater() && proj->_con), "incorrect test");
 903     // this test was canonicalized
 904     assert(this_bool->_test.is_less() && fail->_con, "incorrect test");
 905 
 906     // this_bool = <
 907     //   dom_bool = >= (proj = True) or dom_bool = < (proj = False)
 908     //     x in [a, b[ on the fail (= True) projection, b > a-1 (because of hi_type->_lo > lo_type->_hi test above):
 909     //     lo = a, hi = b, adjusted_lim = b-a, cond = <u
 910     //   dom_bool = > (proj = True) or dom_bool = <= (proj = False)
 911     //     x in ]a, b[ on the fail (= True) projection, b > a:
 912     //     lo = a+1, hi = b, adjusted_lim = b-a-1, cond = <u
 913     // this_bool = <=
 914     //   dom_bool = >= (proj = True) or dom_bool = < (proj = False)
 915     //     x in [a, b] on the fail (= True) projection, b+1 > a-1:
 916     //     lo = a, hi = b, adjusted_lim = b-a+1, cond = <u
 917     //     lo = a, hi = b, adjusted_lim = b-a, cond = <=u doesn't work because b = a - 1 is possible, then b-a = -1
 918     //   dom_bool = > (proj = True) or dom_bool = <= (proj = False)
 919     //     x in ]a, b] on the fail (= True) projection b+1 > a:
 920     //     lo = a+1, hi = b, adjusted_lim = b-a, cond = <u
 921     //     lo = a+1, hi = b, adjusted_lim = b-a-1, cond = <=u doesn't work because a = b is possible, then b-a-1 = -1
 922 
 923     if (hi_test == BoolTest::lt) {
 924       if (lo_test == BoolTest::gt || lo_test == BoolTest::le) {
 925         lo = igvn->transform(new AddINode(lo, igvn->intcon(1)));
 926       }
 927     } else {
 928       assert(hi_test == BoolTest::le, "bad test");
 929       if (lo_test == BoolTest::ge || lo_test == BoolTest::lt) {
 930         adjusted_lim = igvn->transform(new SubINode(hi, lo));
 931         adjusted_lim = igvn->transform(new AddINode(adjusted_lim, igvn->intcon(1)));
 932         cond = BoolTest::lt;
 933       } else {
 934         assert(lo_test == BoolTest::gt || lo_test == BoolTest::le, "bad test");
 935         adjusted_lim = igvn->transform(new SubINode(hi, lo));
 936         lo = igvn->transform(new AddINode(lo, igvn->intcon(1)));
 937         cond = BoolTest::lt;
 938       }
 939     }
 940   } else if (lo_type->_lo > hi_type->_hi && lo_type->_hi == max_jint && hi_type->_lo == min_jint) {

 941 
 942     // this_bool = <
 943     //   dom_bool = < (proj = True) or dom_bool = >= (proj = False)
 944     //     x in [b, a[ on the fail (= False) projection, a > b-1 (because of lo_type->_lo > hi_type->_hi above):
 945     //     lo = b, hi = a, adjusted_lim = a-b, cond = >=u
 946     //   dom_bool = <= (proj = True) or dom_bool = > (proj = False)
 947     //     x in [b, a] on the fail (= False) projection, a+1 > b-1:
 948     //     lo = b, hi = a, adjusted_lim = a-b+1, cond = >=u
 949     //     lo = b, hi = a, adjusted_lim = a-b, cond = >u doesn't work because a = b - 1 is possible, then b-a = -1
 950     // this_bool = <=
 951     //   dom_bool = < (proj = True) or dom_bool = >= (proj = False)
 952     //     x in ]b, a[ on the fail (= False) projection, a > b:
 953     //     lo = b+1, hi = a, adjusted_lim = a-b-1, cond = >=u
 954     //   dom_bool = <= (proj = True) or dom_bool = > (proj = False)
 955     //     x in ]b, a] on the fail (= False) projection, a+1 > b:
 956     //     lo = b+1, hi = a, adjusted_lim = a-b, cond = >=u
 957     //     lo = b+1, hi = a, adjusted_lim = a-b-1, cond = >u doesn't work because a = b is possible, then b-a-1 = -1
 958 
 959     swap(lo, hi);
 960     swap(lo_type, hi_type);




 880   //                         /
 881   //        this_bool = x {<,<=} b
 882   //                       / \
 883   //  fail = {True,False} /   \ success = {False,True}
 884   //                     /
 885   //
 886   // (Second test guaranteed canonicalized, first one may not have
 887   // been canonicalized yet)
 888   //
 889   // into:
 890   //
 891   // cond = (x - lo) {<u,<=u,>u,>=u} adjusted_lim
 892   //                       / \
 893   //                 fail /   \ success
 894   //                     /
 895   //
 896 
 897   // Figure out which of the two tests sets the upper bound and which
 898   // sets the lower bound if any.
 899   Node* adjusted_lim = NULL;
 900   if (lo_type != NULL && hi_type != NULL && hi_type->_lo > lo_type->_hi &&
 901       hi_type->_hi == max_jint && lo_type->_lo == min_jint) {
 902     assert((dom_bool->_test.is_less() && !proj->_con) ||
 903            (dom_bool->_test.is_greater() && proj->_con), "incorrect test");
 904     // this test was canonicalized
 905     assert(this_bool->_test.is_less() && fail->_con, "incorrect test");
 906 
 907     // this_bool = <
 908     //   dom_bool = >= (proj = True) or dom_bool = < (proj = False)
 909     //     x in [a, b[ on the fail (= True) projection, b > a-1 (because of hi_type->_lo > lo_type->_hi test above):
 910     //     lo = a, hi = b, adjusted_lim = b-a, cond = <u
 911     //   dom_bool = > (proj = True) or dom_bool = <= (proj = False)
 912     //     x in ]a, b[ on the fail (= True) projection, b > a:
 913     //     lo = a+1, hi = b, adjusted_lim = b-a-1, cond = <u
 914     // this_bool = <=
 915     //   dom_bool = >= (proj = True) or dom_bool = < (proj = False)
 916     //     x in [a, b] on the fail (= True) projection, b+1 > a-1:
 917     //     lo = a, hi = b, adjusted_lim = b-a+1, cond = <u
 918     //     lo = a, hi = b, adjusted_lim = b-a, cond = <=u doesn't work because b = a - 1 is possible, then b-a = -1
 919     //   dom_bool = > (proj = True) or dom_bool = <= (proj = False)
 920     //     x in ]a, b] on the fail (= True) projection b+1 > a:
 921     //     lo = a+1, hi = b, adjusted_lim = b-a, cond = <u
 922     //     lo = a+1, hi = b, adjusted_lim = b-a-1, cond = <=u doesn't work because a = b is possible, then b-a-1 = -1
 923 
 924     if (hi_test == BoolTest::lt) {
 925       if (lo_test == BoolTest::gt || lo_test == BoolTest::le) {
 926         lo = igvn->transform(new AddINode(lo, igvn->intcon(1)));
 927       }
 928     } else {
 929       assert(hi_test == BoolTest::le, "bad test");
 930       if (lo_test == BoolTest::ge || lo_test == BoolTest::lt) {
 931         adjusted_lim = igvn->transform(new SubINode(hi, lo));
 932         adjusted_lim = igvn->transform(new AddINode(adjusted_lim, igvn->intcon(1)));
 933         cond = BoolTest::lt;
 934       } else {
 935         assert(lo_test == BoolTest::gt || lo_test == BoolTest::le, "bad test");
 936         adjusted_lim = igvn->transform(new SubINode(hi, lo));
 937         lo = igvn->transform(new AddINode(lo, igvn->intcon(1)));
 938         cond = BoolTest::lt;
 939       }
 940     }
 941   } else if (lo_type != NULL && hi_type != NULL && lo_type->_lo > hi_type->_hi &&
 942              lo_type->_hi == max_jint && hi_type->_lo == min_jint) {
 943 
 944     // this_bool = <
 945     //   dom_bool = < (proj = True) or dom_bool = >= (proj = False)
 946     //     x in [b, a[ on the fail (= False) projection, a > b-1 (because of lo_type->_lo > hi_type->_hi above):
 947     //     lo = b, hi = a, adjusted_lim = a-b, cond = >=u
 948     //   dom_bool = <= (proj = True) or dom_bool = > (proj = False)
 949     //     x in [b, a] on the fail (= False) projection, a+1 > b-1:
 950     //     lo = b, hi = a, adjusted_lim = a-b+1, cond = >=u
 951     //     lo = b, hi = a, adjusted_lim = a-b, cond = >u doesn't work because a = b - 1 is possible, then b-a = -1
 952     // this_bool = <=
 953     //   dom_bool = < (proj = True) or dom_bool = >= (proj = False)
 954     //     x in ]b, a[ on the fail (= False) projection, a > b:
 955     //     lo = b+1, hi = a, adjusted_lim = a-b-1, cond = >=u
 956     //   dom_bool = <= (proj = True) or dom_bool = > (proj = False)
 957     //     x in ]b, a] on the fail (= False) projection, a+1 > b:
 958     //     lo = b+1, hi = a, adjusted_lim = a-b, cond = >=u
 959     //     lo = b+1, hi = a, adjusted_lim = a-b-1, cond = >u doesn't work because a = b is possible, then b-a-1 = -1
 960 
 961     swap(lo, hi);
 962     swap(lo_type, hi_type);


< prev index next >