Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/loopTransform.cpp @ 23799:535618ab1c04
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
Summary: Emit CastII to make narrow ConvI2L dependent on the corresponding range check.
Reviewed-by: kvn, roland
author | thartmann |
---|---|
date | Wed, 27 Jan 2016 09:02:51 +0100 |
parents | 192643caadca |
children | c9035b8e388b |
comparison
equal
deleted
inserted
replaced
23571:16f7b676725a | 23799:535618ab1c04 |
---|---|
2436 } | 2436 } |
2437 | 2437 |
2438 | 2438 |
2439 //============================================================================= | 2439 //============================================================================= |
2440 // Process all the loops in the loop tree and replace any fill | 2440 // Process all the loops in the loop tree and replace any fill |
2441 // patterns with an intrisc version. | 2441 // patterns with an intrinsic version. |
2442 bool PhaseIdealLoop::do_intrinsify_fill() { | 2442 bool PhaseIdealLoop::do_intrinsify_fill() { |
2443 bool changed = false; | 2443 bool changed = false; |
2444 for (LoopTreeIterator iter(_ltree_root); !iter.done(); iter.next()) { | 2444 for (LoopTreeIterator iter(_ltree_root); !iter.done(); iter.next()) { |
2445 IdealLoopTree* lpt = iter.current(); | 2445 IdealLoopTree* lpt = iter.current(); |
2446 changed |= intrinsify_fill(lpt); | 2446 changed |= intrinsify_fill(lpt); |
2534 #endif | 2534 #endif |
2535 return false; | 2535 return false; |
2536 } | 2536 } |
2537 | 2537 |
2538 // Make sure the address expression can be handled. It should be | 2538 // Make sure the address expression can be handled. It should be |
2539 // head->phi * elsize + con. head->phi might have a ConvI2L. | 2539 // head->phi * elsize + con. head->phi might have a ConvI2L(CastII()). |
2540 Node* elements[4]; | 2540 Node* elements[4]; |
2541 Node* cast = NULL; | |
2541 Node* conv = NULL; | 2542 Node* conv = NULL; |
2542 bool found_index = false; | 2543 bool found_index = false; |
2543 int count = store->in(MemNode::Address)->as_AddP()->unpack_offsets(elements, ARRAY_SIZE(elements)); | 2544 int count = store->in(MemNode::Address)->as_AddP()->unpack_offsets(elements, ARRAY_SIZE(elements)); |
2544 for (int e = 0; e < count; e++) { | 2545 for (int e = 0; e < count; e++) { |
2545 Node* n = elements[e]; | 2546 Node* n = elements[e]; |
2550 #ifdef _LP64 | 2551 #ifdef _LP64 |
2551 if (value->Opcode() == Op_ConvI2L) { | 2552 if (value->Opcode() == Op_ConvI2L) { |
2552 conv = value; | 2553 conv = value; |
2553 value = value->in(1); | 2554 value = value->in(1); |
2554 } | 2555 } |
2556 if (value->Opcode() == Op_CastII && | |
2557 value->as_CastII()->has_range_check()) { | |
2558 // Skip range check dependent CastII nodes | |
2559 cast = value; | |
2560 value = value->in(1); | |
2561 } | |
2555 #endif | 2562 #endif |
2556 if (value != head->phi()) { | 2563 if (value != head->phi()) { |
2557 msg = "unhandled shift in address"; | 2564 msg = "unhandled shift in address"; |
2558 } else { | 2565 } else { |
2559 if (type2aelembytes(store->as_Mem()->memory_type(), true) != (1 << n->in(2)->get_int())) { | 2566 if (type2aelembytes(store->as_Mem()->memory_type(), true) != (1 << n->in(2)->get_int())) { |
2562 found_index = true; | 2569 found_index = true; |
2563 shift = n; | 2570 shift = n; |
2564 } | 2571 } |
2565 } | 2572 } |
2566 } else if (n->Opcode() == Op_ConvI2L && conv == NULL) { | 2573 } else if (n->Opcode() == Op_ConvI2L && conv == NULL) { |
2567 if (n->in(1) == head->phi()) { | 2574 conv = n; |
2575 n = n->in(1); | |
2576 if (n->Opcode() == Op_CastII && | |
2577 n->as_CastII()->has_range_check()) { | |
2578 // Skip range check dependent CastII nodes | |
2579 cast = n; | |
2580 n = n->in(1); | |
2581 } | |
2582 if (n == head->phi()) { | |
2568 found_index = true; | 2583 found_index = true; |
2569 conv = n; | |
2570 } else { | 2584 } else { |
2571 msg = "unhandled input to ConvI2L"; | 2585 msg = "unhandled input to ConvI2L"; |
2572 } | 2586 } |
2573 } else if (n == head->phi()) { | 2587 } else if (n == head->phi()) { |
2574 // no shift, check below for allowed cases | 2588 // no shift, check below for allowed cases |
2623 ok.set(loop_exit->in(1)->_idx); | 2637 ok.set(loop_exit->in(1)->_idx); |
2624 | 2638 |
2625 // Address elements are ok | 2639 // Address elements are ok |
2626 if (con) ok.set(con->_idx); | 2640 if (con) ok.set(con->_idx); |
2627 if (shift) ok.set(shift->_idx); | 2641 if (shift) ok.set(shift->_idx); |
2642 if (cast) ok.set(cast->_idx); | |
2628 if (conv) ok.set(conv->_idx); | 2643 if (conv) ok.set(conv->_idx); |
2629 | 2644 |
2630 for (uint i = 0; msg == NULL && i < lpt->_body.size(); i++) { | 2645 for (uint i = 0; msg == NULL && i < lpt->_body.size(); i++) { |
2631 Node* n = lpt->_body.at(i); | 2646 Node* n = lpt->_body.at(i); |
2632 if (n->outcnt() == 0) continue; // Ignore dead | 2647 if (n->outcnt() == 0) continue; // Ignore dead |