[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#327351: gcc-4.0: Gcc miscompiles libc on hppa - breaks rounding



"Wesley W. Terpstra" <terpstra@debian.org> writes:

> Package: gcc-4.0
> Version: 4.0.1-6
> Severity: important
>
> When compiling the fesetround function (which controls the processor
> rounding mode), gcc-4.0 incorrectly optimizes away the code!!!
>
> Here's the C code in question:
>   __asm__ ("fstd %%fr0,0(%1)" : "=m" (*sw) : "r" (sw));
>   sw[0] &= ~FE_DOWNWARD;
>   sw[0] |= round;
>   __asm__ ("fldd 0(%0),%%fr0" : : "r" (sw));
>
> gcc-3.3 outputs:
> #APP
>         fstd %fr0,0(%r20)
> #NO_APP
> 	ldw -56(%r30),%r19
> 	depi 0,22,2,%r19
> 	or %r19,%r26,%r19
> 	stw %r19,-56(%r30)
> #APP
> 	fldd 0(%r20),%fr0
> #NO_APP
>
> gcc-4.0 outputs:
> #APP
>         fstd %fr0,0(%r28)
> 	fldd 0(%r28),%fr0
> #NO_APP

This is not a bug in gcc. The second asm is not marked as reading *sw,
so the store can be moved behind it, or omitted if it isn't needed
elsewhere. If you access *sw, you need to tell gcc. So the bug is in
whatever code contains this asm.

-- 
	Falk



Reply to: