------- Comment #3 from mingqiao dot wu at gmail dot com  2006-09-20 01:22 
-------
(In reply to comment #2)
> You are violating C aliasing rules here (try -Wstrict-aliasing):
>    return *(CTLFLOAT*)&bits;

Yes, -O2 turns on -fstrict-aliasing, and I saw many warnings like "warning:
dereferencing type-punned pointer will break strict-aliasing rules" without
specifying -Wstrict-aliasing explicitly because -Wall include it. I added
-Wstrict-aliasing to CFLAGS. The disassembly result is different but still not
correct. At 5e8 line, r3 is the latest value to return, but 574 line regard r2
is the return value. I noticed this warning did not appear in gcc-3.4.3. How
should I re-write such code to use -O2 correctly with gcc-4.1.1? Thanks.

00000560 <_CTL_Fixed2Float>:
 560:   e92d4010        stmdb   sp!, {r4, lr}
 564:   e2504000        subs    r4, r0, #0      ; 0x0
 568:   e24dd008        sub     sp, sp, #8      ; 0x8
 56c:   03a02000        moveq   r2, #0  ; 0x0
 570:   1a000002        bne     580 <_CTL_Fixed2Float+0x20>
 574:   e1a00002        mov     r0, r2
 578:   e28dd008        add     sp, sp, #8      ; 0x8
 57c:   e8bd8010        ldmia   sp!, {r4, pc}
 580:   e0240fc4        eor     r0, r4, r4, asr #31
 584:   e0400fc4        sub     r0, r0, r4, asr #31
 588:   ebfffffe        bl      0 <E3D_CLZ>
 58c:   e270200a        rsbs    r2, r0, #10     ; 0xa
 590:   42623000        rsbmi   r3, r2, #0      ; 0x0
 594:   41a00314        movmi   r0, r4, lsl r3
 598:   51a00254        movpl   r0, r4, asr r2
 59c:   e3500000        cmp     r0, #0  ; 0x0
 5a0:   03a035fe        moveq   r3, #1065353216 ; 0x3f800000
 5a4:   058d3004        streq   r3, [sp, #4]
 5a8:   0a00000c        beq     5e0 <_CTL_Fixed2Float+0x80>
 5ac:   e2823084        add     r3, r2, #132    ; 0x84
 5b0:   e20330ff        and     r3, r3, #255    ; 0xff
 5b4:   e1a02b83        mov     r2, r3, lsl #23
 5b8:   b2603000        rsblt   r3, r0, #0      ; 0x0
 5bc:   a1a03100        movge   r3, r0, lsl #2
 5c0:   b1a03103        movlt   r3, r3, lsl #2
 5c4:   e58d2004        str     r2, [sp, #4]
 5c8:   a3c304ff        bicge   r0, r3, #-16777216      ; 0xff000000
 5cc:   b3822102        orrlt   r2, r2, #-2147483648    ; 0x80000000
 5d0:   b3c304ff        biclt   r0, r3, #-16777216      ; 0xff000000
 5d4:   a3c00502        bicge   r0, r0, #8388608        ; 0x800000
 5d8:   b58d2004        strlt   r2, [sp, #4]
 5dc:   b3c00502        biclt   r0, r0, #8388608        ; 0x800000
 5e0:   e59d3004        ldr     r3, [sp, #4]
 5e4:   e59d2004        ldr     r2, [sp, #4]
 5e8:   e1833000        orr     r3, r3, r0
 5ec:   e58d3004        str     r3, [sp, #4]
 5f0:   eaffffdf        b       574 <_CTL_Fixed2Float+0x14>


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29140

Reply via email to