mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 20:14:43 +02:00
6991577: add IfOp optimization to C1
Ifop optimization for c1 Reviewed-by: never, phh, iveresov
This commit is contained in:
parent
225a3b0eb8
commit
e1a504b343
6 changed files with 246 additions and 173 deletions
|
@ -415,28 +415,26 @@ bool Constant::is_equal(Value v) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
BlockBegin* Constant::compare(Instruction::Condition cond, Value right,
|
||||
BlockBegin* true_sux, BlockBegin* false_sux) {
|
||||
Constant::CompareResult Constant::compare(Instruction::Condition cond, Value right) const {
|
||||
Constant* rc = right->as_Constant();
|
||||
// other is not a constant
|
||||
if (rc == NULL) return NULL;
|
||||
if (rc == NULL) return not_comparable;
|
||||
|
||||
ValueType* lt = type();
|
||||
ValueType* rt = rc->type();
|
||||
// different types
|
||||
if (lt->base() != rt->base()) return NULL;
|
||||
if (lt->base() != rt->base()) return not_comparable;
|
||||
switch (lt->tag()) {
|
||||
case intTag: {
|
||||
int x = lt->as_IntConstant()->value();
|
||||
int y = rt->as_IntConstant()->value();
|
||||
switch (cond) {
|
||||
case If::eql: return x == y ? true_sux : false_sux;
|
||||
case If::neq: return x != y ? true_sux : false_sux;
|
||||
case If::lss: return x < y ? true_sux : false_sux;
|
||||
case If::leq: return x <= y ? true_sux : false_sux;
|
||||
case If::gtr: return x > y ? true_sux : false_sux;
|
||||
case If::geq: return x >= y ? true_sux : false_sux;
|
||||
case If::eql: return x == y ? cond_true : cond_false;
|
||||
case If::neq: return x != y ? cond_true : cond_false;
|
||||
case If::lss: return x < y ? cond_true : cond_false;
|
||||
case If::leq: return x <= y ? cond_true : cond_false;
|
||||
case If::gtr: return x > y ? cond_true : cond_false;
|
||||
case If::geq: return x >= y ? cond_true : cond_false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -444,12 +442,12 @@ BlockBegin* Constant::compare(Instruction::Condition cond, Value right,
|
|||
jlong x = lt->as_LongConstant()->value();
|
||||
jlong y = rt->as_LongConstant()->value();
|
||||
switch (cond) {
|
||||
case If::eql: return x == y ? true_sux : false_sux;
|
||||
case If::neq: return x != y ? true_sux : false_sux;
|
||||
case If::lss: return x < y ? true_sux : false_sux;
|
||||
case If::leq: return x <= y ? true_sux : false_sux;
|
||||
case If::gtr: return x > y ? true_sux : false_sux;
|
||||
case If::geq: return x >= y ? true_sux : false_sux;
|
||||
case If::eql: return x == y ? cond_true : cond_false;
|
||||
case If::neq: return x != y ? cond_true : cond_false;
|
||||
case If::lss: return x < y ? cond_true : cond_false;
|
||||
case If::leq: return x <= y ? cond_true : cond_false;
|
||||
case If::gtr: return x > y ? cond_true : cond_false;
|
||||
case If::geq: return x >= y ? cond_true : cond_false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -459,14 +457,14 @@ BlockBegin* Constant::compare(Instruction::Condition cond, Value right,
|
|||
assert(xvalue != NULL && yvalue != NULL, "not constants");
|
||||
if (xvalue->is_loaded() && yvalue->is_loaded()) {
|
||||
switch (cond) {
|
||||
case If::eql: return xvalue == yvalue ? true_sux : false_sux;
|
||||
case If::neq: return xvalue != yvalue ? true_sux : false_sux;
|
||||
case If::eql: return xvalue == yvalue ? cond_true : cond_false;
|
||||
case If::neq: return xvalue != yvalue ? cond_true : cond_false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return not_comparable;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue