mirror of git://gcc.gnu.org/git/gcc.git
re PR tree-optimization/56064 (Optimize VIEW_CONVERT_EXPR with FIXED_CST)
gcc/ PR tree-optimization/56064 * fixed-value.c (fixed_from_double_int): Sign/zero extend payload bits according to mode. * fixed-value.h (fixed_from_double_int) (const_fixed_from_double_int): Adjust comments. gcc/testsuite/ PR tree-optimization/56064 * gcc.dg/fixed-point/view-convert-2.c: New test. From-SVN: r195885
This commit is contained in:
parent
e45cde9826
commit
ff54464986
|
|
@ -1,3 +1,11 @@
|
||||||
|
2013-02-08 Georg-Johann Lay <avr@gjlay.de>
|
||||||
|
|
||||||
|
PR tree-optimization/56064
|
||||||
|
* fixed-value.c (fixed_from_double_int): Sign/zero extend payload
|
||||||
|
bits according to mode.
|
||||||
|
* fixed-value.h (fixed_from_double_int)
|
||||||
|
(const_fixed_from_double_int): Adjust comments.
|
||||||
|
|
||||||
2013-02-08 Richard Biener <rguenther@suse.de>
|
2013-02-08 Richard Biener <rguenther@suse.de>
|
||||||
|
|
||||||
PR lto/56231
|
PR lto/56231
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ check_real_for_fixed_mode (REAL_VALUE_TYPE *real_value, enum machine_mode mode)
|
||||||
|
|
||||||
|
|
||||||
/* Construct a CONST_FIXED from a bit payload and machine mode MODE.
|
/* Construct a CONST_FIXED from a bit payload and machine mode MODE.
|
||||||
The bits in PAYLOAD are used verbatim. */
|
The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */
|
||||||
|
|
||||||
FIXED_VALUE_TYPE
|
FIXED_VALUE_TYPE
|
||||||
fixed_from_double_int (double_int payload, enum machine_mode mode)
|
fixed_from_double_int (double_int payload, enum machine_mode mode)
|
||||||
|
|
@ -92,7 +92,13 @@ fixed_from_double_int (double_int payload, enum machine_mode mode)
|
||||||
|
|
||||||
gcc_assert (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_DOUBLE_INT);
|
gcc_assert (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_DOUBLE_INT);
|
||||||
|
|
||||||
value.data = payload;
|
if (SIGNED_SCALAR_FIXED_POINT_MODE_P (mode))
|
||||||
|
value.data = payload.sext (1 + GET_MODE_IBIT (mode) + GET_MODE_FBIT (mode));
|
||||||
|
else if (UNSIGNED_SCALAR_FIXED_POINT_MODE_P (mode))
|
||||||
|
value.data = payload.zext (GET_MODE_IBIT (mode) + GET_MODE_FBIT (mode));
|
||||||
|
else
|
||||||
|
gcc_unreachable();
|
||||||
|
|
||||||
value.mode = mode;
|
value.mode = mode;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,12 @@ extern FIXED_VALUE_TYPE fconst1[MAX_FCONST1];
|
||||||
extern rtx const_fixed_from_fixed_value (FIXED_VALUE_TYPE, enum machine_mode);
|
extern rtx const_fixed_from_fixed_value (FIXED_VALUE_TYPE, enum machine_mode);
|
||||||
|
|
||||||
/* Construct a FIXED_VALUE from a bit payload and machine mode MODE.
|
/* Construct a FIXED_VALUE from a bit payload and machine mode MODE.
|
||||||
The bits in PAYLOAD are used verbatim. */
|
The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */
|
||||||
extern FIXED_VALUE_TYPE fixed_from_double_int (double_int,
|
extern FIXED_VALUE_TYPE fixed_from_double_int (double_int,
|
||||||
enum machine_mode);
|
enum machine_mode);
|
||||||
|
|
||||||
/* Return a CONST_FIXED from a bit payload and machine mode MODE.
|
/* Return a CONST_FIXED from a bit payload and machine mode MODE.
|
||||||
The bits in PAYLOAD are used verbatim. */
|
The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */
|
||||||
static inline rtx
|
static inline rtx
|
||||||
const_fixed_from_double_int (double_int payload,
|
const_fixed_from_double_int (double_int payload,
|
||||||
enum machine_mode mode)
|
enum machine_mode mode)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
2013-02-08 Georg-Johann Lay <avr@gjlay.de>
|
||||||
|
|
||||||
|
PR tree-optimization/56064
|
||||||
|
* gcc.dg/fixed-point/view-convert-2.c: New test.
|
||||||
|
|
||||||
2013-02-08 Michael Matz <matz@suse.de>
|
2013-02-08 Michael Matz <matz@suse.de>
|
||||||
|
|
||||||
PR tree-optimization/52448
|
PR tree-optimization/52448
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,139 @@
|
||||||
|
/* PR tree-optimization/56064 */
|
||||||
|
/* { dg-do run } */
|
||||||
|
/* { dg-options "-std=gnu99 -O2" } */
|
||||||
|
|
||||||
|
extern void abort (void);
|
||||||
|
extern void exit (int);
|
||||||
|
|
||||||
|
void test_k (void)
|
||||||
|
{
|
||||||
|
_Accum a;
|
||||||
|
__INT32_TYPE__ i = -__INT32_MAX__;
|
||||||
|
|
||||||
|
if (sizeof (a) != sizeof (i))
|
||||||
|
return;
|
||||||
|
|
||||||
|
__builtin_memcpy (&a, &i, sizeof (a));
|
||||||
|
|
||||||
|
if (a >= 0k)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_0k (void)
|
||||||
|
{
|
||||||
|
_Accum a;
|
||||||
|
__INT32_TYPE__ i = 0;
|
||||||
|
|
||||||
|
if (sizeof (a) != sizeof (i))
|
||||||
|
return;
|
||||||
|
|
||||||
|
__builtin_memcpy (&a, &i, sizeof (a));
|
||||||
|
|
||||||
|
if (a != 0k)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void test_hr (void)
|
||||||
|
{
|
||||||
|
short _Fract a;
|
||||||
|
__INT8_TYPE__ i = -__INT8_MAX__;
|
||||||
|
|
||||||
|
if (sizeof (a) != sizeof (i))
|
||||||
|
return;
|
||||||
|
|
||||||
|
__builtin_memcpy (&a, &i, sizeof (a));
|
||||||
|
|
||||||
|
if (a >= 0hr)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_0hr (void)
|
||||||
|
{
|
||||||
|
short _Fract a;
|
||||||
|
__INT8_TYPE__ i = 0;
|
||||||
|
|
||||||
|
if (sizeof (a) != sizeof (i))
|
||||||
|
return;
|
||||||
|
|
||||||
|
__builtin_memcpy (&a, &i, sizeof (a));
|
||||||
|
|
||||||
|
if (a != 0hr)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void test_si (void)
|
||||||
|
{
|
||||||
|
_Accum a = __ACCUM_MIN__;
|
||||||
|
__INT32_TYPE__ i;
|
||||||
|
|
||||||
|
if (sizeof (a) != sizeof (i))
|
||||||
|
return;
|
||||||
|
|
||||||
|
__builtin_memcpy (&i, &a, sizeof (i));
|
||||||
|
|
||||||
|
if (i >= 0)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_0si (void)
|
||||||
|
{
|
||||||
|
_Accum a = 0;
|
||||||
|
__INT32_TYPE__ i;
|
||||||
|
|
||||||
|
if (sizeof (a) != sizeof (i))
|
||||||
|
return;
|
||||||
|
|
||||||
|
__builtin_memcpy (&i, &a, sizeof (i));
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void test_qi (void)
|
||||||
|
{
|
||||||
|
short _Fract a = __SFRACT_MIN__;
|
||||||
|
__INT8_TYPE__ i;
|
||||||
|
|
||||||
|
if (sizeof (a) != sizeof (i))
|
||||||
|
return;
|
||||||
|
|
||||||
|
__builtin_memcpy (&i, &a, sizeof (i));
|
||||||
|
|
||||||
|
if (i >= 0)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_0qi (void)
|
||||||
|
{
|
||||||
|
short _Fract a = 0hr;
|
||||||
|
__INT8_TYPE__ i;
|
||||||
|
|
||||||
|
if (sizeof (a) != sizeof (i))
|
||||||
|
return;
|
||||||
|
|
||||||
|
__builtin_memcpy (&i, &a, sizeof (i));
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
test_hr();
|
||||||
|
test_k();
|
||||||
|
test_qi();
|
||||||
|
test_si();
|
||||||
|
|
||||||
|
test_0hr();
|
||||||
|
test_0k();
|
||||||
|
test_0qi();
|
||||||
|
test_0si();
|
||||||
|
|
||||||
|
exit (0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue