From ff48ea6787526d7e669af93ce2681b911d39675c Mon Sep 17 00:00:00 2001 From: Zong Li Date: Thu, 1 Nov 2018 17:34:39 +0000 Subject: soft-fp: Use temporary variable in FP_FRAC_SUB_3/FP_FRAC_SUB_4 In FRAC_SUB_3(R, X, Y) and FRAC_SUB_4(R,, X, Y), it reference both the X[N] and X[N] after R[N] have been set. If one of the X and Y is the same address with R, the result of the calculation is wrong, because the value of the original X and Y are overwritten. In glibc, there are two places use FRAC_SUB and occurs the overlap. The first is _FP_DIV_MEAT_N_loop in op-common.h, it uses the source _FP_DIV_MEAT_N_loop_u as the destination. This macro only be used when N is one(_FP_DIV_MEAT_1_loop) and then the _FP_FRAC_SUB_##wc extend to _FP_FRAC_SUB_1 in this macro. so it also work because _FP_FRAC_SUB_1 has no overlap problem in its implementation. The second places is _FP_DIV_MEAT_4_udiv, the original value of X##_f[0] is overwritten before the calculatation. In FRAC_SUB_1 and FRAC_SUB_2, there don't refer the source after destination have been set, so they have no problem. After this modification, we can pass the soft floating testing of glibc testsuites on RV32. * soft-fp/op-4.h (_FP_FRAC_SUB_3, _FP_FRAC_SUB_4): Use temporary variable to avoid overlap arguments. --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ChangeLog') diff --git a/ChangeLog b/ChangeLog index 83a28dbb2f..3bbd5628c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-11-01 Zong Li + + * soft-fp/op-4.h (_FP_FRAC_SUB_3, _FP_FRAC_SUB_4): Use temporary + variable to avoid overlap arguments. + 2018-11-01 Joseph Myers * posix/bug-regex22.c (main): Use puts with distinct error -- cgit v1.2.3