this looks like a bug - arm target

Falk Hueffner falk.hueffner@student.uni-tuebingen.de
Thu Oct 9 12:26:00 GMT 2003


"Eric de Jong" <list_ericdejong_10@gmx.net> writes:

> I stumbled across a code generation problem. I am still using gcc
> 3.3.0, so maybe this is an old bug. Anyone care to verify this?
> 
> The problem is in the line  "strgtb r2, [r0, #2]":
> 
>  cmp r3, #7
>  strgtb r2, [r0, #2]
>  ble .L9
> 
> In the loop "for (r3=0; r3<8; r3++)" I expected "[r0,#2] = r2, but
> the condition 'gt' in 'strgtb' only stores the result when r3 >
> 7. It should be <=7. (Thus strleb r2,[r0.#2] I think)

Since the stores are dead, gcc is free to omit them if it likes to.
You need to mark the object volatile, in which case gcc 3.3.2 emits:

.L9:
        mov     ip, r1, asl r2
        add     r2, r2, #1
        cmp     r2, #7
        strb    ip, [r0, #2]
        ble     .L9

Admittedly, the code emitted for the non-volatile version is weird,
and there may be an actual bug lurking there.


-- 
	Falk



More information about the Gcc-help mailing list