Bug#202017: gcc-3.3: Unnecessary branching with INET/INET6 port setting
martin@v.loewis.de (Martin v. =?iso-8859-15?q?L=F6wis?=) writes:
> <herbert@gondor.apana.org.au> writes:
>
> > As you can see, the branch due to the family is unnecessary. This bug
> > exists in gcc272, gcc 2.95 and gcc 3.2
>
> It is unlikely that this bug will ever get fixed, as gcc won't be
> able to determine that the two __asm__ blocks really have the same
> effect.
This is not the problem. gcc assumes the asm will return the same
value unless it is explicitely marked "volatile" (or has no oputputs),
and will happily merge them.
% cat test.c
#define implver() ({ int r; asm("implver %0" : "=r"(r)); r; })
int f(void) { return implver() + implver(); }
% gcc -c -O3 test.c && objdump -d test.o
0000000000000000 <f>:
0: 81 3d e0 47 implver t0
4: 00 00 21 40 addl t0,t0,v0
8: 01 80 fa 6b ret
It might be worth trying whether this works on the tree-ssa branch.
--
Falk
Reply to: