[Bug optimization/14121] New: use inline assembler register constraints as home register hints
thomas dot schlichter at web dot de
gcc-bugzilla@gcc.gnu.org
Wed Feb 11 23:56:00 GMT 2004
Hi,
gcc 3.4.0 (and 3.3.1) seems not to use the register constraints of the inline
assembler as hints where to place local variables. For example following part of
the file bin2dec.c (will provide it later) :
int m2 = m;
unsigned long c = 0;
do {
asm("divl\t%2" : "+a"(x[m2]), "+d"(c) : "r"(1000000000));
} while (--m2 >= 0);
is translated to following x86 assembler instructions (gcc -O2 -S):
movl $1000000000, %ebx
.p2align 4,,15
.L3:
movl %edi, -20(%ebp)
xorl %ecx, %ecx
.p2align 4,,15
.L6:
movl -20(%ebp), %edx
movl (%esi,%edx,4), %eax
movl %ecx, %edx
#APP
divl %ebx
#NO_APP
movl %edx, %ecx
movl -20(%ebp), %edx
movl %eax, (%esi,%edx,4)
decl %edx
movl %edx, -20(%ebp)
jns .L6
So the variable "c" seems to be placed in the register "ecx" whereas it is
constrained to register "edx". If "c" was placed in "edx" the register "ecx"
would become free and could be used for "m2". So this variable would not have to
be placed on the stack...
gcc 2.95.3 seems to do this placement, but I don't know if it does this
coincidental or intentionally... It generates following code (ebx<>m, ecx<>m2,
edx<>c, edi<>x):
movl %ebx,%ecx
xorl %edx,%edx
.p2align 2,0x90
.L10:
movl (%edi,%ecx,4),%eax
movl $1000000000,%esi
#APP
divl %esi
#NO_APP
movl %eax,(%edi,%ecx,4)
decl %ecx
jns .L10
So it would be GREAT if 3.4.0 would do anything like that (plus moving the
assignment to esi outside the loop, of course ;-)
Best reagrds
Thomas Schlichter
--
Summary: use inline assembler register constraints as home
register hints
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: thomas dot schlichter at web dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14121
More information about the Gcc-bugs
mailing list