On Thu, 6 Apr 2006, chefren wrote:

> On 04/05/06 02:07, Andrew Pinski wrote:
> 
> > Actually I bet ntohs16 is violating C aliasing rules.
> > 
> > So getting rid of GCC actually is wrong.  Getting rid
> > of these aliasing violations is the correct way.
> > 
> > -- Pinski
> 
> Interesting, how do you figure that?
> 
> The relevant definition is:
> 
> #define __swap16md(x) ({                                               \
>        u_int16_t __swap16md_x = (x);                                   \
>                                                                        \
>        __asm ("rorw $8, %w1" : "+r" (__swap16md_x));                   \
>        __swap16md_x;                                                   \
> })
> 
> i.e. a block that "returns" a short value (a "compound statement expression"
> is the gcc terminology, we believe).
> 
> Where would aliasing rules enter into this situation?
> 
> 
> Thanks for looking at this, if we can help or assist with solving this: please
> don't hesitate to ask.

The following diff (backported from gcc PR
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10692>) seems to fix the
problem.  I hardly know i386 assembly, so please check if the produced
code is correct.

If I see things correctly, this fix is not in either 3.3.5 or 3.3.6.
Debian -stable backported it into their 3.3.5 gcc. 

Now the funny thing is that according to the PR, this is a mk68k
specific bug, although the fix is not in target specific code.

        -Otto

Index: gcc/reload1.c
===================================================================
RCS file: /cvs/src/gnu/usr.bin/gcc/gcc/reload1.c,v
retrieving revision 1.3
diff -u -p -r1.3 reload1.c
--- gcc/reload1.c       25 Dec 2004 00:23:11 -0000      1.3
+++ gcc/reload1.c       11 Apr 2006 08:48:39 -0000
@@ -6923,6 +6923,10 @@ do_input_reload (chain, rl, j)
      actually no need to store the old value in it.  */
 
   if (optimize
+      /* Only attempt this for input reloads; for RELOAD_OTHER we miss
+        that there may be multiple uses of the previous output reload.
+        Restricting to RELOAD_FOR_INPUT is mostly paranoia.  */
+      && rl->when_needed == RELOAD_FOR_INPUT
       && (reload_inherited[j] || reload_override_in[j])
       && rl->reg_rtx
       && GET_CODE (rl->reg_rtx) == REG

Reply via email to