Commit 117f6947 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Handle left shift (when magnitude > mantissa) when converting float constants to int.

[r15744]
parent 3f2ebeb2
......@@ -1651,9 +1651,13 @@ int fc_flt2int(const fp_value *a, void *result, ir_mode *dst_mode) {
}
assert(exp_val >= 0 && "floating point value not integral before fc_flt2int() call");
shift = a->desc.mantissa_size - exp_val + 2;
shift = exp_val - a->desc.mantissa_size - 2;
sc_shrI(_mant(a), shift, 64, 0, result);
if (shift > 0) {
sc_shlI(_mant(a), shift, 64, 0, result);
} else {
sc_shrI(_mant(a), -shift, 64, 0, result);
}
/* check for overflow */
highest = sc_get_highest_set_bit(result);
......
......@@ -1646,9 +1646,7 @@ void sc_divmod(const void *value1, const void *value2, void *div_buffer, void *m
}
void sc_shl(const void *val1, const void *val2, int radius, int sign, void *buffer) {
long offset = sc_val_to_long(val2);
void sc_shlI(const void *val1, long offset, int radius, int sign, void *buffer) {
carry_flag = 0;
DEBUGPRINTF_COMPUTATION(("%s << %ld ", sc_print_hex(value1), offset));
......@@ -1661,6 +1659,12 @@ void sc_shl(const void *val1, const void *val2, int radius, int sign, void *buff
}
}
void sc_shl(const void *val1, const void *val2, int radius, int sign, void *buffer) {
long offset = sc_val_to_long(val2);
sc_shlI(val1, offset, radius, sign, buffer);
}
void sc_shrI(const void *val1, long offset, int radius, int sign, void *buffer) {
carry_flag = 0;
......
......@@ -143,6 +143,11 @@ void sc_mod(const void *value1, const void *value2, void *buffer);
*/
void sc_divmod(const void *value1, const void *value2, void *div_buffer, void *mod_buffer);
/**
* buffer = value1 << offset
*/
void sc_shlI(const void *val1, long offset, int radius, int sign, void *buffer);
/**
* buffer = value1 << value2
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment