------- Additional Comments From nathan at gcc dot gnu dot org 2004-11-09 12:25 ------- The problem here is that combine only combines chains of instructions that have no other uses of the intermediate results. In this case, the intermediate result is stored into a global variable.
One solution would be to add a peephole, but that would only trigger when (a) the shift and compare were adjacent, and (b) the compare used CR0. You'd also need peepholers for all the instructions that can implicitly set CR0. Really combine, which is a generic peepholer, needs some kind of templatizing on the target machine. It currently functions by generating promising patterns and then seeing if they exist. This is wasteful, in that it generates many patterns that don't exist on the particular target, and it is blind in that it doesn't spot any special cases the target might have (like this case). What's needed is something like pre-reg-alloc peepholes. That of course would be a large amount of work. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16798