8324630: C1: Canonicalizer::do_LookupSwitch doesn't break the loop when the successor is found
Reviewed-by: dlong, thartmann
This commit is contained in:
parent
3742bc626e
commit
d422811bb7
@ -844,9 +844,18 @@ void Canonicalizer::do_LookupSwitch(LookupSwitch* x) {
|
||||
if (x->tag()->type()->is_constant()) {
|
||||
int v = x->tag()->type()->as_IntConstant()->value();
|
||||
BlockBegin* sux = x->default_sux();
|
||||
for (int i = 0; i < x->length(); i++) {
|
||||
if (v == x->key_at(i)) {
|
||||
sux = x->sux_at(i);
|
||||
int low = 0;
|
||||
int high = x->length() - 1;
|
||||
while (low <= high) {
|
||||
int mid = low + ((high - low) >> 1);
|
||||
int key = x->key_at(mid);
|
||||
if (key == v) {
|
||||
sux = x->sux_at(mid);
|
||||
break;
|
||||
} else if (key > v) {
|
||||
high = mid - 1;
|
||||
} else {
|
||||
low = mid + 1;
|
||||
}
|
||||
}
|
||||
set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user