[PATCH] Fix carry bug in 128-bit unsigned integer adding
Liu Yu
Yu.Liu at freescale.com
Wed Jan 9 14:05:31 EST 2008
>
> take a look at how include/math-emu/op-4.h implements
> __FP_FRAC_ADD_4 & __FP_FRAC_SUB_4. Will that fix the bug, if
> so we should make the code match how its done there.
>
> - k
>
>
The macro define __FP_FRAC_ADD_4 is below. It can fix the carry bug.
But still exist a problem that r[0-2] and x[0-2] cannot be referred to
the same variable.
If r0 and x0 are the same variable, the comparison ( r0 < x0 ) will
always fail.
I don't know whether we need to fix this problem.
---
#define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
do { \
int _c1, _c2, _c3; \
r0 = x0 + y0; \
_c1 = r0 < x0; \
r1 = x1 + y1; \
_c2 = r1 < x1; \
r1 += _c1; \
_c2 |= r1 < _c1; \
r2 = x2 + y2; \
_c3 = r2 < x2; \
r2 += _c2; \
_c3 |= r2 < _c2; \
r3 = x3 + y3 + _c3; \
} while (0)
#endif
More information about the Linuxppc-dev
mailing list