True but what I've noticed with GCC 4.3.2 is that with this code:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    long a = 0xcafecafe;

    printf("Final: %lx %lx %lx\n", a, a+5, a+15);
    return EXIT_SUCCESS;
}

Whether I compile it with a big number like here or a smaller number,
I'll get something like:

    la  r8,$LC0                         #Loading the address of
"Final: %lx %lx %lx\n"
    lid r9,0xcafecafe                #Loading the first immediate
    lid r10,0xcafecb03             #Loading the second immediate
    lid r11,0xcafecb0d             #Loading the third immediate

But in my case, the lid is very costly for this large number. It would
be more efficient to have:

    la  r8,$LC0                         #Loading the address of
"Final: %lx %lx %lx\n"
    lid r9,0xcafecafe                #Loading the first immediate
    addi r10,r9,0x5                     #Loading the second immediate
    addi r11,r9,0xf                   #Loading the third immediate

So my question is, can I explain this in the machine description alone
and if so, does anybody know where?

Thanks again,
Jean Christophe Beyler

On Thu, Feb 5, 2009 at 4:02 PM, Joe Buck <joe.b...@synopsys.com> wrote:
> On Thu, Feb 05, 2009 at 12:46:01PM -0800, Joe Buck wrote:
>> On Thu, Feb 05, 2009 at 12:34:14PM -0800, Jean Christophe Beyler wrote:
>> > 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).
>>
>> But in practice most constants that cprop deals with are values like
>> -1, 0, 1, or 2.  Wouldn't it be better to be able to constrain cprop
>> based on the values of the constants, than to eliminate it altogether?
>
> I shouldn't have said "most", but small constants are common.
>
>

Reply via email to