This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

local vars transmission (fwd)


Sorry, I forgot the attachments.

mihai

---------- Forwarded message ----------
Date: Fri, 5 Mar 2004 21:59:51 -0500 (EST)
From: Mihai Burcea <burceam@eecg.utoronto.ca>
To: gcc@gcc.gnu.org
Subject: local vars transmission

Hi, 

I have attached 4 files: 2 very similar source files and 2 quite different 
rtl dumps. 
I would like to understand why the beginning part of the rtl dumps, i.e. 
extracting the local variables, differs from one case to the other.

However, I should explain my context first:
- this is gcc-3.3.1, and I got the rtl dumps by doing 
   gcc -dr -O2 -c local_dbl.c
- both source codes contain a preprocessed function code (hence the 
includes and decls in the beginning); the actual function body is at the 
end; its actual purpose is irrelevant to me.
- the only difference between the two source codes is this: 
839d838
<   auto int *_pp_burceam_int;
864d862
<   (_pp_burceam_int) = (((int *) (*((__ompc_args) + (3)))));
875c873
<       (_p_i_2) = (1) + (*_pp_burceam_int);

(so basically I just added a local int * to the function, extracted it, 
and used it in one place).

- the function really only has one argument, that is __ompc_args; this is 
really just an envelope for the real arguments, who are "packed" into it. 
As you can see in the source code, the very first thing that happens in 
the function (always) is unpacking those arguments, extracting them from 
__ompc_args, into local variables.
Since it is not the arguments themselves that are packed into __ompc_args, 
but pointers to them, the local variables will also be pointers to the 
type that the original arguments had.

e.g. let's say that the original arguments that are to be passed to the 
function are these: int x, double d, int * a;
Then the corresponding local variables will always be these:
int * _pp_x;
double * _pp_d;
int ** _pp_a;

etc. I think you get the idea.

In the first case, local_dbl.c, there are three arguments: 
double dielectric, double lambda, and some struct ** atomall.
I'm really only interested in the doubles.
The RTL for extracting them from __ompc_args looks like this: 

-------------------------------------------

(insn 32 6 33 (nil) (set (reg/f:SI 58)
        (mem/f:SI (reg/f:SI 53 virtual-incoming-args) [0 __ompc_args+0 S4 
A32])) -1 (nil)
    (nil))

(insn 33 32 34 (nil) (set (reg:SI 59)
        (mem:SI (reg/f:SI 58) [0 S4 A32])) -1 (nil)
    (nil))

(insn 34 33 36 (nil) (set (mem/f:SI (plus:SI (reg/f:SI 54 
virtual-stack-vars)
                (const_int -4 [0xfffffffc])) [0 _pp_dielectric+0 S4 A32])
        (reg:SI 59)) -1 (nil)
    (nil))

(insn 36 34 37 (nil) (parallel [
            (set (reg/f:SI 60)
                (plus:SI (mem/f:SI (reg/f:SI 53 virtual-incoming-args) [0 
__ompc_args+0 S4 A32])
                    (const_int 4 [0x4])))
            (clobber (reg:CC 17 flags))
        ]) -1 (nil)
    (nil))

(insn 37 36 38 (nil) (set (reg:SI 61)
        (mem:SI (reg/f:SI 60) [0 S4 A32])) -1 (nil)
    (nil))

(insn 38 37 40 (nil) (set (mem/f:SI (plus:SI (reg/f:SI 54 
virtual-stack-vars)
                (const_int -8 [0xfffffff8])) [0 _pp_lambda+0 S4 A32])
        (reg:SI 61)) -1 (nil)
    (nil))

(insn 40 38 41 (nil) (parallel [
            (set (reg/f:SI 62)
                (plus:SI (mem/f:SI (reg/f:SI 53 virtual-incoming-args) [0 
__ompc_args+0 S4 A32])
                    (const_int 8 [0x8])))
            (clobber (reg:CC 17 flags))
        ]) -1 (nil)
    (nil))

(insn 41 40 42 (nil) (set (reg:SI 63)
        (mem:SI (reg/f:SI 62) [0 S4 A32])) -1 (nil)
    (nil))

(insn 42 41 43 (nil) (set (mem/f:SI (plus:SI (reg/f:SI 54 
virtual-stack-vars)
                (const_int -12 [0xfffffff4])) [0 _pp_atomall+0 S4 A32])
        (reg:SI 63)) -1 (nil)
    (nil))


------------------------

The only thing I did in the second case is add a local int * variable, 
int * _pp_burceamint;
This lead to the following sequence of RTL code generated:

(insn 34 7 36 (nil) (set (reg/v/f:SI 59)
        (mem:SI (reg/v/f:SI 58) [6 S4 A32])) -1 (nil)
    (nil))

(insn 36 34 38 (nil) (set (reg/v/f:SI 60)
        (mem:SI (plus:SI (reg/v/f:SI 58)
                (const_int 4 [0x4])) [6 S4 A32])) -1 (nil)
    (nil))

(insn 38 36 40 (nil) (set (reg/v/f:SI 61)
        (mem:SI (plus:SI (reg/v/f:SI 58)
                (const_int 8 [0x8])) [6 S4 A32])) -1 (nil)
    (nil))

(insn 40 38 41 (nil) (set (reg/v/f:SI 62)
        (mem:SI (plus:SI (reg/v/f:SI 58)
                (const_int 12 [0xc])) [6 S4 A32])) -1 (nil)
    (nil))


My question is, why are the 2 cases different ? Why isn't one way always 
used ? Why does the fact that I added one local variable affect the way 
that all local vars are treated ?

Thank you very much, at least for the patience of reading through this.

mihai

Attachment: localvars.tgz
Description: GNU Zip compressed data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]