On Tue, Oct 28, 2014 at 5:22 AM, Yangfei (Felix) wrote: > Hi Sterling, > How do you think about this issue? > As c6x/bfin port handles this the same way, is it OK for the patch to be applied? > Thanks. I have committed this patch as attached. I made a couple of minor cleanups, plus some small fixes to the ChangeLog entry. The new code generated is better than the old code, but I'm not particularly happy with the result. In particular, it is way too conservative around spilling the trip count, and it still maintains the trip count inside the loop, in spite of the trip count being dead at that point. It won't always be dead, but when it is, it should be eliminated. So there is quite a bit of performance that could still be gained here. Thanks for the patch Felix. Sterling 2014-10-10 Felix Yang * config/xtensa/xtensa.h (TARGET_LOOPS): New Macro. * config/xtensa/xtensa.c: Include dumpfile.h and hw-doloop.h. (xtensa_reorg, xtensa_reorg_loops): New. (xtensa_can_use_doloop_p, xtensa_invalid_within_doloop): New. (hwloop_optimize, hwloop_fail, hwloop_pattern_reg): New. (xtensa_emit_loop_end): Emit the zero-overhead loop end label. (xtensa_doloop_hooks): Define. * config/xtensa/xtensa.md (doloop_end, loop_end): New (zero_cost_loop_start): Rewritten. (zero_cost_loop_end): Likewise.