can I disable CSE of call instructions?

Kevin Nomura
Thu Jan 9 22:17:00 GMT 2003

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

         call    bar
         addl    $16, %esp
         movl    %ebp, %esp
         popl    %ebp

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

More information about the Gcc-help mailing list