Re: Problem with 1G RAM

MOLNAR Ingo (mingo@chiara.csoma.elte.hu)
Tue, 8 Dec 1998 14:07:43 +0100 (CET)


On Mon, 7 Dec 1998, Richard Henderson wrote:

> On Sat, Dec 05, 1998 at 09:48:44PM +0100, MOLNAR Ingo wrote:
> > on x86, we can do instructions like:
> >
> > movl 0xc0000028(%eax), %ebx
> >
> > the compiler expands it's patters wildly differently when it's a constant.
>
> Um, have you tried this Ingo? Given

[yes i've tried it before posting :)]

>
> #define foo ((int)&__foo)
> int bar(int *x)
> {
> return x[foo+45];
> }
>
> or suchlike you should see __foo combined with other operations.
>
> movl $__foo+45,%eax
> movl (%edx,%eax,4),%eax
>
> in this case due to the shift.

this is what it does:

0: 8b 54 24 04 movl 0x4(%esp,1),%edx
4: b8 2d 00 00 00 movl $0x2d,%eax
9: 8b 04 82 movl (%edx,%eax,4),%eax
c: c3 ret

so yes it has combined it into a constant, but not into an immediate
instruction constant. The thing we can get with

#define foo1 0x12340000

is:
0: 8b 44 24 04 movl 0x4(%esp,1),%eax
4: 8b 80 b4 00 d0 movl 0x48d000b4(%eax),%eax
9: 48
a: c3 ret

which is smaller and faster.

> My guess is that you can do fairly well with the immediates.
> Certainly better than having them be completely variable.

maybe EGCS already does such things? i have GCC 2.7.2.3.

-- mingo

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/