This is the mail archive of the gcc-help@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]

can I disable CSE of call instructions?


The optimization I would like to selectively disable is
the combination of call instructions from N calls to the
same target, if they have the same successor.  This is
seen for example with gcc 3.0.4 for x86 ELF target (Linux),
but not with gcc 2.95.1 for the same target -- so it was
presumably added or made default between those revisions.

In the testcase:

extern void bar(char *, int);

foo(int i)
{
        if (i == 1) {
                bar("this is a test", i);
        }
        else if (i == 2) {
                bar("this is for real", i);
        }
        else  {
                bar("don't know what this is", i);
        }
}

the generated code at -S -O2 contains only one call to "bar".
Each call site separately set up its arguments, then jumps to
"L8":

.L8:
        call    bar
        addl    $16, %esp
        movl    %ebp, %esp
        popl    %ebp
        ret

The debugger behaves confusingly if you try to step back from bar
into foo -- in all case but one, you will get the wrong line number
(and in more complex cases your local variable context is wrong).
We are willing to forego the optimization to avoid this.

Is there an option to turn this off?  If not, any pointers to
where I should look in the gcc source to disable it would be
greatly appreciated!

Kevin Nomura


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