Skip to content

Commit fa72036

Browse files
committed
libgccjit: Fix float playback for cross-compilation
gcc/jit/ChangeLog: PR jit/113343 * jit-playback.cc (new_rvalue_from_const): Fix to have the correct value when cross-compiling.
1 parent 30c2678 commit fa72036

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

gcc/jit/jit-playback.cc

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see
4343
#include "gcc.h"
4444
#include "diagnostic.h"
4545
#include "stmt.h"
46+
#include "realmpfr.h"
4647

4748
#include "jit-playback.h"
4849
#include "jit-result.h"
@@ -1078,22 +1079,16 @@ new_rvalue_from_const <double> (type *type,
10781079
// FIXME: type-checking, or coercion?
10791080
tree inner_type = type->as_tree ();
10801081

1082+
mpfr_t mpf_value;
1083+
1084+
mpfr_init2 (mpf_value, 64);
1085+
mpfr_set_d (mpf_value, value, MPFR_RNDN);
1086+
10811087
/* We have a "double", we want a REAL_VALUE_TYPE.
10821088
1083-
real.cc:real_from_target appears to require the representation to be
1084-
split into 32-bit values, and then sent as an pair of host long
1085-
ints. */
1089+
realmpfr.cc:real_from_mpfr. */
10861090
REAL_VALUE_TYPE real_value;
1087-
union
1088-
{
1089-
double as_double;
1090-
uint32_t as_uint32s[2];
1091-
} u;
1092-
u.as_double = value;
1093-
long int as_long_ints[2];
1094-
as_long_ints[0] = u.as_uint32s[0];
1095-
as_long_ints[1] = u.as_uint32s[1];
1096-
real_from_target (&real_value, as_long_ints, DFmode);
1091+
real_from_mpfr (&real_value, mpf_value, inner_type, MPFR_RNDN);
10971092
tree inner = build_real (inner_type, real_value);
10981093
return new rvalue (this, inner);
10991094
}

0 commit comments

Comments
 (0)