GCC-4.1 -fno-function-cse still supported?

2006-05-12 Thread Etienne Lorrain
  Hello,

  the docs for -fno-function-cse says:
`-fno-function-cse'
 Do not put function addresses in registers; make each instruction
 that calls a constant function contain the function's address
 explicitly.

 This option results in less efficient code, but some strange hacks
 that alter the assembler output may be confused by the
 optimizations performed when this option is not used.

 The default is `-ffunction-cse'

  But when I tried (replacing in Gujin some calll by lcallw based on which 
function
 is called) it did not work as I expected it. For instance, -fno-function-cse 
seem
 ignored here:

[EMAIL PROTECTED] ~]$ cat tmp.c
int (*fct) (int i);

int test_function_cse (int j) {
if (j  0)
return fct(j - 1);
else
return fct(j + 1);
}
[EMAIL PROTECTED] ~]$ gcc -Os -S tmp.c
[EMAIL PROTECTED] ~]$ cat tmp.s
.file   tmp.c
.text
.globl test_function_cse
.type   test_function_cse, @function
test_function_cse:
pushl   %ebp
movlfct, %ecx
movl%esp, %ebp
movl8(%ebp), %eax
testl   %eax, %eax
jle .L2
decl%eax
jmp .L6
.L2:
incl%eax
.L6:
movl%eax, 8(%ebp)
popl%ebp
jmp *%ecx
.size   test_function_cse, .-test_function_cse
.comm   fct,4,4
.ident  GCC: (GNU) 4.1.0 20060304 (Red Hat 4.1.0-3)
.section.note.GNU-stack,,@progbits
[EMAIL PROTECTED] ~]$ gcc -Os -fno-function-cse -S tmp.c
[EMAIL PROTECTED] ~]$ cat tmp.s
.file   tmp.c
.text
.globl test_function_cse
.type   test_function_cse, @function
test_function_cse:
pushl   %ebp
movlfct, %ecx
movl%esp, %ebp
movl8(%ebp), %eax
testl   %eax, %eax
jle .L2
decl%eax
jmp .L6
.L2:
incl%eax
.L6:
movl%eax, 8(%ebp)
popl%ebp
jmp *%ecx
.size   test_function_cse, .-test_function_cse
.comm   fct,4,4
.ident  GCC: (GNU) 4.1.0 20060304 (Red Hat 4.1.0-3)
.section.note.GNU-stack,,@progbits
[EMAIL PROTECTED] ~]$ gcc -Os -fno-function-cse -fno-optimize-sibling-calls -S 
tmp.c
[EMAIL PROTECTED] ~]$ cat tmp.s
.file   tmp.c
.text
.globl test_function_cse
.type   test_function_cse, @function
test_function_cse:
pushl   %ebp
movlfct, %edx
movl%esp, %ebp
movl8(%ebp), %eax
testl   %eax, %eax
jle .L2
decl%eax
jmp .L6
.L2:
incl%eax
.L6:
pushl   %eax
call*%edx
popl%edx
leave
ret
.size   test_function_cse, .-test_function_cse
.comm   fct,4,4
.ident  GCC: (GNU) 4.1.0 20060304 (Red Hat 4.1.0-3)
.section.note.GNU-stack,,@progbits
[EMAIL PROTECTED] ~]$

  Thanks,
  Etienne.






___ 
Faites de Yahoo! votre page d'accueil sur le web pour retrouver directement vos 
services préférés : vérifiez vos nouveaux mails, lancez vos recherches et 
suivez l'actualité en temps réel. 
Rendez-vous sur http://fr.yahoo.com/set


Re: GCC-4.1 -fno-function-cse still supported?

2006-05-12 Thread Daniel Jacobowitz
On Fri, May 12, 2006 at 08:40:07PM +0200, Etienne Lorrain wrote:
   But when I tried (replacing in Gujin some calll by lcallw based on which 
 function
  is called) it did not work as I expected it. For instance, -fno-function-cse 
 seem
  ignored here:

What are you expecting to happen here?  The description said calls a
constant function.  This:

 int (*fct) (int i);

is of course a function pointer.


-- 
Daniel Jacobowitz
CodeSourcery