diff options
author | Georg-Johann Lay <avr@gjlay.de> | 2013-02-08 13:23:34 +0000 |
---|---|---|
committer | Georg-Johann Lay <gjl@gcc.gnu.org> | 2013-02-08 13:23:34 +0000 |
commit | ff54464986fd1994754f5cbaa3921628818cc63f (patch) | |
tree | f151da27f7789e368ab8961edc7f453c040b899a /gcc/fixed-value.c | |
parent | e45cde982611c5a86c215dd4079ca7f0375e141b (diff) | |
download | gcc-ff54464986fd1994754f5cbaa3921628818cc63f.zip gcc-ff54464986fd1994754f5cbaa3921628818cc63f.tar.gz gcc-ff54464986fd1994754f5cbaa3921628818cc63f.tar.bz2 |
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
Diffstat (limited to 'gcc/fixed-value.c')
-rw-r--r-- | gcc/fixed-value.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/fixed-value.c b/gcc/fixed-value.c index 2e97a49..18ce47e 100644 --- a/gcc/fixed-value.c +++ b/gcc/fixed-value.c @@ -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. - The bits in PAYLOAD are used verbatim. */ + The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */ FIXED_VALUE_TYPE 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); - 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; return value; |