Dear all, I've been trying to play with the RTX costs by using a target function using the macro TARGET_RTX_COSTS. However, I haven't been able to really make any good progress. This is the program I have:
#include <stdio.h> #include <stdlib.h> int main(void) { long a = 0xcafe; printf("Final: %lx %lx\n", a, a+5); return EXIT_SUCCESS; } What I would like to see is not have the two elements set as constants in registers but only one and the other set with an add instruction. I first looked at what rtx were sent to this function and I am perplexed about how this would work. After many calls to the function, I finally get this : (const_int 51966 [0xcafe]) (const_int 51966 [0xcafe]) (const_int 51971 [0xcb03]) (const_int 51971 [0xcb03]) All of these have an outer code of SET. Therefore, I'm not quite positive of how I'm supposed to implement my rtx_cost function. Since I don't seem to get a choice between a set 0xcb03 and a (plus 0xcafe 5), how can I tell the compiler the different costs? Jc On Thu, Feb 5, 2009 at 4:10 PM, Ian Lance Taylor <i...@google.com> wrote: > Jean Christophe Beyler <jean.christophe.bey...@gmail.com> writes: > >> I'm currently working on removing the constant folding and constant >> propagation because, on the architecture I'm working on, it is highly >> costly to move a constant into a register if the number is big (we can >> say over 16 bits). >> >> Currently, I've been looking into this and it seems that I have to >> hack into the fold-const.c file, CCP, SCCVN and probably the propagate >> passes to tell the compiler to be careful if the number is too big. >> But I'm sure there are many other places I'll have to hack and slash >> to tell him to stop the folding and propagation. Is there an easier >> way to do this ? > > This type of thing is normally controlled by the TARGET_RTX_COSTS > hook. E.g., see the handling of CONST_INT mips_rtx_costs in > config/mips/mips.c. > > Ian >