Thanks for the explanation. I think I am clear about what you are thinking now. That's an interesting question. I am not sure about reason why GCC's reload cannot handle a doloop_end insn. I guess maybe the doloop_end pattern is special? I mean it's a branch insn in a parallel form.
> > On Thu, Oct 23, 2014 at 11:40 PM, Yangfei (Felix) <felix.y...@huawei.com> > wrote: > > 1. The original xtensa port never generates "loop" instruction at all. > > 2. A port doesn't need to implement hwloop_pattern_reg hook if it has no > zero-cost loop instruction. > > > > Is that clear? > > We are talking in circles. I understand very well what goes on here. > > My point is: > > 1. Right now, today, GCC generates loops with branch instructions even when > the > trip count is spilled. > 2. Branch instructions and loop instructions have identical register > requirements. > > Therefore: > > 3. loop instructions should be generatable when the trip count is spilled.