|
31 | 31 | #include "opto/movenode.hpp" |
32 | 32 | #include "opto/mulnode.hpp" |
33 | 33 | #include "opto/phaseX.hpp" |
| 34 | +#include "opto/rangeinference.hpp" |
34 | 35 | #include "opto/subnode.hpp" |
35 | | -#include "opto/utilities/xor.hpp" |
36 | 36 | #include "runtime/stubRoutines.hpp" |
37 | 37 |
|
38 | 38 | // Portions of code courtesy of Clifford Click |
@@ -1011,35 +1011,8 @@ Node* OrINode::Ideal(PhaseGVN* phase, bool can_reshape) { |
1011 | 1011 | // the logical operations the ring's ADD is really a logical OR function. |
1012 | 1012 | // This also type-checks the inputs for sanity. Guaranteed never to |
1013 | 1013 | // be passed a TOP or BOTTOM type, these are filtered out by pre-check. |
1014 | | -const Type *OrINode::add_ring( const Type *t0, const Type *t1 ) const { |
1015 | | - const TypeInt *r0 = t0->is_int(); // Handy access |
1016 | | - const TypeInt *r1 = t1->is_int(); |
1017 | | - |
1018 | | - // If both args are bool, can figure out better types |
1019 | | - if ( r0 == TypeInt::BOOL ) { |
1020 | | - if ( r1 == TypeInt::ONE) { |
1021 | | - return TypeInt::ONE; |
1022 | | - } else if ( r1 == TypeInt::BOOL ) { |
1023 | | - return TypeInt::BOOL; |
1024 | | - } |
1025 | | - } else if ( r0 == TypeInt::ONE ) { |
1026 | | - if ( r1 == TypeInt::BOOL ) { |
1027 | | - return TypeInt::ONE; |
1028 | | - } |
1029 | | - } |
1030 | | - |
1031 | | - // If either input is all ones, the output is all ones. |
1032 | | - // x | ~0 == ~0 <==> x | -1 == -1 |
1033 | | - if (r0 == TypeInt::MINUS_1 || r1 == TypeInt::MINUS_1) { |
1034 | | - return TypeInt::MINUS_1; |
1035 | | - } |
1036 | | - |
1037 | | - // If either input is not a constant, just return all integers. |
1038 | | - if( !r0->is_con() || !r1->is_con() ) |
1039 | | - return TypeInt::INT; // Any integer, but still no symbols. |
1040 | | - |
1041 | | - // Otherwise just OR them bits. |
1042 | | - return TypeInt::make( r0->get_con() | r1->get_con() ); |
| 1014 | +const Type* OrINode::add_ring(const Type* t1, const Type* t2) const { |
| 1015 | + return RangeInference::infer_or(t1->is_int(), t2->is_int()); |
1043 | 1016 | } |
1044 | 1017 |
|
1045 | 1018 | //============================================================================= |
@@ -1087,22 +1060,8 @@ Node* OrLNode::Ideal(PhaseGVN* phase, bool can_reshape) { |
1087 | 1060 | } |
1088 | 1061 |
|
1089 | 1062 | //------------------------------add_ring--------------------------------------- |
1090 | | -const Type *OrLNode::add_ring( const Type *t0, const Type *t1 ) const { |
1091 | | - const TypeLong *r0 = t0->is_long(); // Handy access |
1092 | | - const TypeLong *r1 = t1->is_long(); |
1093 | | - |
1094 | | - // If either input is all ones, the output is all ones. |
1095 | | - // x | ~0 == ~0 <==> x | -1 == -1 |
1096 | | - if (r0 == TypeLong::MINUS_1 || r1 == TypeLong::MINUS_1) { |
1097 | | - return TypeLong::MINUS_1; |
1098 | | - } |
1099 | | - |
1100 | | - // If either input is not a constant, just return all integers. |
1101 | | - if( !r0->is_con() || !r1->is_con() ) |
1102 | | - return TypeLong::LONG; // Any integer, but still no symbols. |
1103 | | - |
1104 | | - // Otherwise just OR them bits. |
1105 | | - return TypeLong::make( r0->get_con() | r1->get_con() ); |
| 1063 | +const Type* OrLNode::add_ring(const Type* t1, const Type* t2) const { |
| 1064 | + return RangeInference::infer_or(t1->is_long(), t2->is_long()); |
1106 | 1065 | } |
1107 | 1066 |
|
1108 | 1067 | //---------------------------Helper ------------------------------------------- |
@@ -1189,46 +1148,14 @@ const Type* XorINode::Value(PhaseGVN* phase) const { |
1189 | 1148 | // the logical operations the ring's ADD is really a logical OR function. |
1190 | 1149 | // This also type-checks the inputs for sanity. Guaranteed never to |
1191 | 1150 | // be passed a TOP or BOTTOM type, these are filtered out by pre-check. |
1192 | | -const Type *XorINode::add_ring( const Type *t0, const Type *t1 ) const { |
1193 | | - const TypeInt *r0 = t0->is_int(); // Handy access |
1194 | | - const TypeInt *r1 = t1->is_int(); |
1195 | | - |
1196 | | - if (r0->is_con() && r1->is_con()) { |
1197 | | - // compute constant result |
1198 | | - return TypeInt::make(r0->get_con() ^ r1->get_con()); |
1199 | | - } |
1200 | | - |
1201 | | - // At least one of the arguments is not constant |
1202 | | - |
1203 | | - if (r0->_lo >= 0 && r1->_lo >= 0) { |
1204 | | - // Combine [r0->_lo, r0->_hi] ^ [r0->_lo, r1->_hi] -> [0, upper_bound] |
1205 | | - jint upper_bound = xor_upper_bound_for_ranges<jint, juint>(r0->_hi, r1->_hi); |
1206 | | - return TypeInt::make(0, upper_bound, MAX2(r0->_widen, r1->_widen)); |
1207 | | - } |
1208 | | - |
1209 | | - return TypeInt::INT; |
| 1151 | +const Type* XorINode::add_ring(const Type* t1, const Type* t2) const { |
| 1152 | + return RangeInference::infer_xor(t1->is_int(), t2->is_int()); |
1210 | 1153 | } |
1211 | 1154 |
|
1212 | 1155 | //============================================================================= |
1213 | 1156 | //------------------------------add_ring--------------------------------------- |
1214 | | -const Type *XorLNode::add_ring( const Type *t0, const Type *t1 ) const { |
1215 | | - const TypeLong *r0 = t0->is_long(); // Handy access |
1216 | | - const TypeLong *r1 = t1->is_long(); |
1217 | | - |
1218 | | - if (r0->is_con() && r1->is_con()) { |
1219 | | - // compute constant result |
1220 | | - return TypeLong::make(r0->get_con() ^ r1->get_con()); |
1221 | | - } |
1222 | | - |
1223 | | - // At least one of the arguments is not constant |
1224 | | - |
1225 | | - if (r0->_lo >= 0 && r1->_lo >= 0) { |
1226 | | - // Combine [r0->_lo, r0->_hi] ^ [r0->_lo, r1->_hi] -> [0, upper_bound] |
1227 | | - julong upper_bound = xor_upper_bound_for_ranges<jlong, julong>(r0->_hi, r1->_hi); |
1228 | | - return TypeLong::make(0, upper_bound, MAX2(r0->_widen, r1->_widen)); |
1229 | | - } |
1230 | | - |
1231 | | - return TypeLong::LONG; |
| 1157 | +const Type* XorLNode::add_ring(const Type* t1, const Type* t2) const { |
| 1158 | + return RangeInference::infer_xor(t1->is_long(), t2->is_long()); |
1232 | 1159 | } |
1233 | 1160 |
|
1234 | 1161 | Node* XorLNode::Ideal(PhaseGVN* phase, bool can_reshape) { |
|
0 commit comments