Mercurial > hg > truffle
comparison src/share/vm/c1/c1_Instruction.cpp @ 1899:42a10fc37986
6991577: add IfOp optimization to C1
Summary: Ifop optimization for c1
Reviewed-by: never, phh, iveresov
author | roland |
---|---|
date | Fri, 15 Oct 2010 09:38:20 +0200 |
parents | f02a8bbe6ed4 |
children | f95d63e2154a |
comparison
equal
deleted
inserted
replaced
1852:94d77a279225 | 1899:42a10fc37986 |
---|---|
413 } | 413 } |
414 } | 414 } |
415 return false; | 415 return false; |
416 } | 416 } |
417 | 417 |
418 | 418 Constant::CompareResult Constant::compare(Instruction::Condition cond, Value right) const { |
419 BlockBegin* Constant::compare(Instruction::Condition cond, Value right, | |
420 BlockBegin* true_sux, BlockBegin* false_sux) { | |
421 Constant* rc = right->as_Constant(); | 419 Constant* rc = right->as_Constant(); |
422 // other is not a constant | 420 // other is not a constant |
423 if (rc == NULL) return NULL; | 421 if (rc == NULL) return not_comparable; |
424 | 422 |
425 ValueType* lt = type(); | 423 ValueType* lt = type(); |
426 ValueType* rt = rc->type(); | 424 ValueType* rt = rc->type(); |
427 // different types | 425 // different types |
428 if (lt->base() != rt->base()) return NULL; | 426 if (lt->base() != rt->base()) return not_comparable; |
429 switch (lt->tag()) { | 427 switch (lt->tag()) { |
430 case intTag: { | 428 case intTag: { |
431 int x = lt->as_IntConstant()->value(); | 429 int x = lt->as_IntConstant()->value(); |
432 int y = rt->as_IntConstant()->value(); | 430 int y = rt->as_IntConstant()->value(); |
433 switch (cond) { | 431 switch (cond) { |
434 case If::eql: return x == y ? true_sux : false_sux; | 432 case If::eql: return x == y ? cond_true : cond_false; |
435 case If::neq: return x != y ? true_sux : false_sux; | 433 case If::neq: return x != y ? cond_true : cond_false; |
436 case If::lss: return x < y ? true_sux : false_sux; | 434 case If::lss: return x < y ? cond_true : cond_false; |
437 case If::leq: return x <= y ? true_sux : false_sux; | 435 case If::leq: return x <= y ? cond_true : cond_false; |
438 case If::gtr: return x > y ? true_sux : false_sux; | 436 case If::gtr: return x > y ? cond_true : cond_false; |
439 case If::geq: return x >= y ? true_sux : false_sux; | 437 case If::geq: return x >= y ? cond_true : cond_false; |
440 } | 438 } |
441 break; | 439 break; |
442 } | 440 } |
443 case longTag: { | 441 case longTag: { |
444 jlong x = lt->as_LongConstant()->value(); | 442 jlong x = lt->as_LongConstant()->value(); |
445 jlong y = rt->as_LongConstant()->value(); | 443 jlong y = rt->as_LongConstant()->value(); |
446 switch (cond) { | 444 switch (cond) { |
447 case If::eql: return x == y ? true_sux : false_sux; | 445 case If::eql: return x == y ? cond_true : cond_false; |
448 case If::neq: return x != y ? true_sux : false_sux; | 446 case If::neq: return x != y ? cond_true : cond_false; |
449 case If::lss: return x < y ? true_sux : false_sux; | 447 case If::lss: return x < y ? cond_true : cond_false; |
450 case If::leq: return x <= y ? true_sux : false_sux; | 448 case If::leq: return x <= y ? cond_true : cond_false; |
451 case If::gtr: return x > y ? true_sux : false_sux; | 449 case If::gtr: return x > y ? cond_true : cond_false; |
452 case If::geq: return x >= y ? true_sux : false_sux; | 450 case If::geq: return x >= y ? cond_true : cond_false; |
453 } | 451 } |
454 break; | 452 break; |
455 } | 453 } |
456 case objectTag: { | 454 case objectTag: { |
457 ciObject* xvalue = lt->as_ObjectType()->constant_value(); | 455 ciObject* xvalue = lt->as_ObjectType()->constant_value(); |
458 ciObject* yvalue = rt->as_ObjectType()->constant_value(); | 456 ciObject* yvalue = rt->as_ObjectType()->constant_value(); |
459 assert(xvalue != NULL && yvalue != NULL, "not constants"); | 457 assert(xvalue != NULL && yvalue != NULL, "not constants"); |
460 if (xvalue->is_loaded() && yvalue->is_loaded()) { | 458 if (xvalue->is_loaded() && yvalue->is_loaded()) { |
461 switch (cond) { | 459 switch (cond) { |
462 case If::eql: return xvalue == yvalue ? true_sux : false_sux; | 460 case If::eql: return xvalue == yvalue ? cond_true : cond_false; |
463 case If::neq: return xvalue != yvalue ? true_sux : false_sux; | 461 case If::neq: return xvalue != yvalue ? cond_true : cond_false; |
464 } | 462 } |
465 } | 463 } |
466 break; | 464 break; |
467 } | 465 } |
468 } | 466 } |
469 return NULL; | 467 return not_comparable; |
470 } | 468 } |
471 | 469 |
472 | 470 |
473 // Implementation of BlockBegin | 471 // Implementation of BlockBegin |
474 | 472 |