src/share/vm/opto/connode.cpp

changeset 1210
93c14e5562c4
parent 1190
36ee9b69616e
child 1279
bd02caa94611
equal deleted inserted replaced
1190:36ee9b69616e 1210:93c14e5562c4
1253 const TypeD *td = t->is_double_constant(); 1253 const TypeD *td = t->is_double_constant();
1254 JavaValue v; 1254 JavaValue v;
1255 v.set_jdouble(td->getd()); 1255 v.set_jdouble(td->getd());
1256 return TypeLong::make( v.get_jlong() ); 1256 return TypeLong::make( v.get_jlong() );
1257 } 1257 }
1258
1259 //------------------------------Value------------------------------------------
1260 const Type* CountLeadingZerosINode::Value(PhaseTransform* phase) const {
1261 const Type* t = phase->type(in(1));
1262 if (t == Type::TOP) return Type::TOP;
1263 const TypeInt* ti = t->isa_int();
1264 if (ti && ti->is_con()) {
1265 jint i = ti->get_con();
1266 // HD, Figure 5-6
1267 if (i == 0)
1268 return TypeInt::make(BitsPerInt);
1269 int n = 1;
1270 unsigned int x = i;
1271 if (x >> 16 == 0) { n += 16; x <<= 16; }
1272 if (x >> 24 == 0) { n += 8; x <<= 8; }
1273 if (x >> 28 == 0) { n += 4; x <<= 4; }
1274 if (x >> 30 == 0) { n += 2; x <<= 2; }
1275 n -= x >> 31;
1276 return TypeInt::make(n);
1277 }
1278 return TypeInt::INT;
1279 }
1280
1281 //------------------------------Value------------------------------------------
1282 const Type* CountLeadingZerosLNode::Value(PhaseTransform* phase) const {
1283 const Type* t = phase->type(in(1));
1284 if (t == Type::TOP) return Type::TOP;
1285 const TypeLong* tl = t->isa_long();
1286 if (tl && tl->is_con()) {
1287 jlong l = tl->get_con();
1288 // HD, Figure 5-6
1289 if (l == 0)
1290 return TypeInt::make(BitsPerLong);
1291 int n = 1;
1292 unsigned int x = (((julong) l) >> 32);
1293 if (x == 0) { n += 32; x = (int) l; }
1294 if (x >> 16 == 0) { n += 16; x <<= 16; }
1295 if (x >> 24 == 0) { n += 8; x <<= 8; }
1296 if (x >> 28 == 0) { n += 4; x <<= 4; }
1297 if (x >> 30 == 0) { n += 2; x <<= 2; }
1298 n -= x >> 31;
1299 return TypeInt::make(n);
1300 }
1301 return TypeInt::INT;
1302 }
1303
1304 //------------------------------Value------------------------------------------
1305 const Type* CountTrailingZerosINode::Value(PhaseTransform* phase) const {
1306 const Type* t = phase->type(in(1));
1307 if (t == Type::TOP) return Type::TOP;
1308 const TypeInt* ti = t->isa_int();
1309 if (ti && ti->is_con()) {
1310 jint i = ti->get_con();
1311 // HD, Figure 5-14
1312 int y;
1313 if (i == 0)
1314 return TypeInt::make(BitsPerInt);
1315 int n = 31;
1316 y = i << 16; if (y != 0) { n = n - 16; i = y; }
1317 y = i << 8; if (y != 0) { n = n - 8; i = y; }
1318 y = i << 4; if (y != 0) { n = n - 4; i = y; }
1319 y = i << 2; if (y != 0) { n = n - 2; i = y; }
1320 y = i << 1; if (y != 0) { n = n - 1; }
1321 return TypeInt::make(n);
1322 }
1323 return TypeInt::INT;
1324 }
1325
1326 //------------------------------Value------------------------------------------
1327 const Type* CountTrailingZerosLNode::Value(PhaseTransform* phase) const {
1328 const Type* t = phase->type(in(1));
1329 if (t == Type::TOP) return Type::TOP;
1330 const TypeLong* tl = t->isa_long();
1331 if (tl && tl->is_con()) {
1332 jlong l = tl->get_con();
1333 // HD, Figure 5-14
1334 int x, y;
1335 if (l == 0)
1336 return TypeInt::make(BitsPerLong);
1337 int n = 63;
1338 y = (int) l; if (y != 0) { n = n - 32; x = y; } else x = (((julong) l) >> 32);
1339 y = x << 16; if (y != 0) { n = n - 16; x = y; }
1340 y = x << 8; if (y != 0) { n = n - 8; x = y; }
1341 y = x << 4; if (y != 0) { n = n - 4; x = y; }
1342 y = x << 2; if (y != 0) { n = n - 2; x = y; }
1343 y = x << 1; if (y != 0) { n = n - 1; }
1344 return TypeInt::make(n);
1345 }
1346 return TypeInt::INT;
1347 }

mercurial