On Tue, Nov 11, 2008 at 06:24:09PM -0500, Sparr wrote: > Why does "foo++;" compile to "subi Rd,lo8(-(1))" instead of "inc Rd"? I > am keeping global register variables in registers below 16, which are not > valid for subi so they get duplicated to perform the increment. I am > preparing to check out the machine description for the avr target, but > thought I would ask here before I go that deep.
The addqi3 pattern already has alternatives that use inc/dec - listed after the one using subi. You could try to change the order so that "subi" is the last one and inc/dec is preferred, all else being equal. Not sure why this doesn't already work as expected in your case though, despite this paragraph from gccint.info: If all the operands fit any one alternative, the instruction is valid. Otherwise, for each alternative, the compiler counts how many instructions must be added to copy the operands so that that alternative applies. The alternative requiring the least copying is chosen. If two alternatives need the same amount of copying, the one that comes first is chosen. These choices can be altered with the `?' and `!' characters: Based on the above, it seems GCC thinks the two alternatives require the same amount of copying, even though subi may need more as it only works with r16-r31. You could also experiment with putting `?' in the second alternative, to disparage "subi" slightly. Hope this helps, Marek _______________________________________________ AVR-GCC-list mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
