In May I posted an RFC about a worklist-based replacement for for_each_rtx: https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00435.html (see there for rationale).
This series is the first part of the process. It adds the new iterators and converts all for_each_rtx users in generic code. If these patches are OK, the remaining changes would be: (1) do the same for config/ (2) get rid of for_each_rtx (3) (optionally) convert recursive format walkers to use the new iterators too, if that makes things better I have local patches for some of (3) but they're a lower priority than (1) or (2). I think the only changes I made since last time are to address the feedback from the RFC. Bootstrapped & regression-tested on x86_64-linux-gnu. Also tested by making sure there were no assembly differences for gcc.dg, g++.dg and gcc.c-torture for: x86_64-linux-gnu i686-linux-gnu sh64-linux-gnu powerpc64-linux-gnu mips64-linux-gnu hppa64-hp-hpux11.23 aarch64-linux-gnueabi arm-linux-gnueabi which includes auto-inc/dec targets and a user of bt-load.c (sh64-elf). Many of the patches are pretty mechanical conversions to FOR_EACH_SUBRTX. I've only added a covering note if there's something unusual going on.