< prev index next >

src/share/vm/opto/loopTransform.cpp

Print this page




3157   if (!lpt->is_counted() || !lpt->is_inner()) {
3158     return false;
3159   }
3160 
3161   // Must have constant stride
3162   CountedLoopNode* head = lpt->_head->as_CountedLoop();
3163   if (!head->is_valid_counted_loop() || !head->is_normal_loop()) {
3164     return false;
3165   }
3166 
3167   // Check that the body only contains a store of a loop invariant
3168   // value that is indexed by the loop phi.
3169   Node* store = NULL;
3170   Node* store_value = NULL;
3171   Node* shift = NULL;
3172   Node* offset = NULL;
3173   if (!match_fill_loop(lpt, store, store_value, shift, offset)) {
3174     return false;
3175   }
3176 





3177 #ifndef PRODUCT
3178   if (TraceLoopOpts) {
3179     tty->print("ArrayFill    ");
3180     lpt->dump_head();
3181   }
3182 #endif
3183 
3184   // Now replace the whole loop body by a call to a fill routine that
3185   // covers the same region as the loop.
3186   Node* base = store->in(MemNode::Address)->as_AddP()->in(AddPNode::Base);
3187 
3188   // Build an expression for the beginning of the copy region
3189   Node* index = head->init_trip();
3190 #ifdef _LP64
3191   index = new ConvI2LNode(index);
3192   _igvn.register_new_node_with_optimizer(index);
3193 #endif
3194   if (shift != NULL) {
3195     // byte arrays don't require a shift but others do.
3196     index = new LShiftXNode(index, shift->in(2));


3264         head->init_trip() == _igvn.intcon(0)) {
3265       if (TraceOptimizeFill) {
3266         tty->print_cr("Eliminated zeroing in allocation");
3267       }
3268       alloc->maybe_set_complete(&_igvn);
3269     } else {
3270 #ifdef ASSERT
3271       if (TraceOptimizeFill) {
3272         tty->print_cr("filling array but bounds don't match");
3273         alloc->dump();
3274         head->init_trip()->dump();
3275         head->limit()->dump();
3276         length->dump();
3277       }
3278 #endif
3279     }
3280   }
3281 */
3282 
3283   // Redirect the old control and memory edges that are outside the loop.
3284   Node* exit = head->loopexit()->proj_out(0);
3285   // Sometimes the memory phi of the head is used as the outgoing
3286   // state of the loop.  It's safe in this case to replace it with the
3287   // result_mem.
3288   _igvn.replace_node(store->in(MemNode::Memory), result_mem);
3289   lazy_replace(exit, result_ctrl);
3290   _igvn.replace_node(store, result_mem);
3291   // Any uses the increment outside of the loop become the loop limit.
3292   _igvn.replace_node(head->incr(), head->limit());
3293 
3294   // Disconnect the head from the loop.
3295   for (uint i = 0; i < lpt->_body.size(); i++) {
3296     Node* n = lpt->_body.at(i);
3297     _igvn.replace_node(n, C->top());
3298   }
3299 
3300   return true;
3301 }


3157   if (!lpt->is_counted() || !lpt->is_inner()) {
3158     return false;
3159   }
3160 
3161   // Must have constant stride
3162   CountedLoopNode* head = lpt->_head->as_CountedLoop();
3163   if (!head->is_valid_counted_loop() || !head->is_normal_loop()) {
3164     return false;
3165   }
3166 
3167   // Check that the body only contains a store of a loop invariant
3168   // value that is indexed by the loop phi.
3169   Node* store = NULL;
3170   Node* store_value = NULL;
3171   Node* shift = NULL;
3172   Node* offset = NULL;
3173   if (!match_fill_loop(lpt, store, store_value, shift, offset)) {
3174     return false;
3175   }
3176 
3177   Node* exit = head->loopexit()->proj_out(0);
3178   if (exit == NULL) {
3179     return false;
3180   }
3181 
3182 #ifndef PRODUCT
3183   if (TraceLoopOpts) {
3184     tty->print("ArrayFill    ");
3185     lpt->dump_head();
3186   }
3187 #endif
3188 
3189   // Now replace the whole loop body by a call to a fill routine that
3190   // covers the same region as the loop.
3191   Node* base = store->in(MemNode::Address)->as_AddP()->in(AddPNode::Base);
3192 
3193   // Build an expression for the beginning of the copy region
3194   Node* index = head->init_trip();
3195 #ifdef _LP64
3196   index = new ConvI2LNode(index);
3197   _igvn.register_new_node_with_optimizer(index);
3198 #endif
3199   if (shift != NULL) {
3200     // byte arrays don't require a shift but others do.
3201     index = new LShiftXNode(index, shift->in(2));


3269         head->init_trip() == _igvn.intcon(0)) {
3270       if (TraceOptimizeFill) {
3271         tty->print_cr("Eliminated zeroing in allocation");
3272       }
3273       alloc->maybe_set_complete(&_igvn);
3274     } else {
3275 #ifdef ASSERT
3276       if (TraceOptimizeFill) {
3277         tty->print_cr("filling array but bounds don't match");
3278         alloc->dump();
3279         head->init_trip()->dump();
3280         head->limit()->dump();
3281         length->dump();
3282       }
3283 #endif
3284     }
3285   }
3286 */
3287 
3288   // Redirect the old control and memory edges that are outside the loop.

3289   // Sometimes the memory phi of the head is used as the outgoing
3290   // state of the loop.  It's safe in this case to replace it with the
3291   // result_mem.
3292   _igvn.replace_node(store->in(MemNode::Memory), result_mem);
3293   lazy_replace(exit, result_ctrl);
3294   _igvn.replace_node(store, result_mem);
3295   // Any uses the increment outside of the loop become the loop limit.
3296   _igvn.replace_node(head->incr(), head->limit());
3297 
3298   // Disconnect the head from the loop.
3299   for (uint i = 0; i < lpt->_body.size(); i++) {
3300     Node* n = lpt->_body.at(i);
3301     _igvn.replace_node(n, C->top());
3302   }
3303 
3304   return true;
3305 }
< prev index next >