+2018-08-29 Jan Hubicka <jh@suse.cz>
+
+ * sreal.h (SREAL_PART_BITS): Change to 31; remove seemingly unnecessary
+ comment that it has to be even number.
+ (class sreal): Change m_sig type to int32_t.
+ * sreal.c (sreal::dump, sreal::to_int, opreator+, operator-): Use
+ int64_t for temporary calculations.
+ (sreal_verify_basics): Drop one bit from minimum and maximum.
+
2018-08-30 Richard Biener <rguenther@suse.de>
PR tree-optimization/87147
void
sreal::dump (FILE *file) const
{
- fprintf (file, "(%" PRIi64 " * 2^%d)", m_sig, m_exp);
+ fprintf (file, "(%" PRIi64 " * 2^%d)", (int64_t)m_sig, m_exp);
}
DEBUG_FUNCTION void
if (m_exp >= SREAL_PART_BITS)
return sign * INTTYPE_MAXIMUM (int64_t);
if (m_exp > 0)
- return sign * (SREAL_ABS (m_sig) << m_exp);
+ return sign * (SREAL_ABS ((int64_t)m_sig) << m_exp);
if (m_exp < 0)
return m_sig >> -m_exp;
return m_sig;
bb = &tmp;
}
- r_sig = a_p->m_sig + bb->m_sig;
+ r_sig = a_p->m_sig + (int64_t)bb->m_sig;
sreal r (r_sig, r_exp);
return r;
}
bb = &tmp;
}
- r_sig = sign * ((int64_t) a_p->m_sig - bb->m_sig);
+ r_sig = sign * ((int64_t) a_p->m_sig - (int64_t)bb->m_sig);
sreal r (r_sig, r_exp);
return r;
}
static void
sreal_verify_basics (void)
{
- sreal minimum = INT_MIN;
- sreal maximum = INT_MAX;
+ sreal minimum = INT_MIN/2;
+ sreal maximum = INT_MAX/2;
sreal seven = 7;
sreal minus_two = -2;
sreal minus_nine = -9;
- ASSERT_EQ (INT_MIN, minimum.to_int ());
- ASSERT_EQ (INT_MAX, maximum.to_int ());
+ ASSERT_EQ (INT_MIN/2, minimum.to_int ());
+ ASSERT_EQ (INT_MAX/2, maximum.to_int ());
ASSERT_FALSE (minus_two < minus_two);
ASSERT_FALSE (seven < seven);
#ifndef GCC_SREAL_H
#define GCC_SREAL_H
-/* SREAL_PART_BITS has to be an even number. */
-#define SREAL_PART_BITS 32
+#define SREAL_PART_BITS 31
#define UINT64_BITS 64
static sreal signedless_plus (const sreal &a, const sreal &b, bool negative);
static sreal signedless_minus (const sreal &a, const sreal &b, bool negative);
- int64_t m_sig; /* Significant. */
+ int32_t m_sig; /* Significant. */
signed int m_exp; /* Exponent. */
};