summaryrefslogtreecommitdiff
path: root/gcc/fixed-value.c
diff options
context:
space:
mode:
authorGeorg-Johann Lay <avr@gjlay.de>2013-01-30 11:04:30 +0000
committerGeorg-Johann Lay <gjl@gcc.gnu.org>2013-01-30 11:04:30 +0000
commitcc06c01d0a29c6e1466feba98d8ae3bf20193822 (patch)
tree7cbebdbd492e700058cfc647470eb384b37f121e /gcc/fixed-value.c
parentd394a308e34df7dfe56e1b3995a2622e1ed19068 (diff)
re PR tree-optimization/56064 (Optimize VIEW_CONVERT_EXPR with FIXED_CST)
gcc/ PR tree-optimization/56064 * fixed-value.c (fixed_from_double_int): New function. * fixed-value.h (fixed_from_double_int): New prototype. (const_fixed_from_double_int): New static inline function. * fold-const.c (native_interpret_fixed): New static function. (native_interpret_expr) <FIXED_POINT_TYPE>: Use it. (can_native_interpret_type_p) <FIXED_POINT_TYPE>: Return true. (native_encode_fixed): New static function. (native_encode_expr) <FIXED_CST>: Use it. (native_interpret_int): Move double_int worker code to... * double-int.c (double_int::from_buffer): ...this new static method. * double-int.h (double_int::from_buffer): Prototype it. gcc/testsuite/ PR tree-optimization/56064 * gcc.dg/fixed-point/view-convert.c: New test. From-SVN: r195574
Diffstat (limited to 'gcc/fixed-value.c')
-rw-r--r--gcc/fixed-value.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/fixed-value.c b/gcc/fixed-value.c
index f917775ce88..2e97a492619 100644
--- a/gcc/fixed-value.c
+++ b/gcc/fixed-value.c
@@ -81,6 +81,24 @@ check_real_for_fixed_mode (REAL_VALUE_TYPE *real_value, enum machine_mode mode)
return FIXED_OK;
}
+
+/* Construct a CONST_FIXED from a bit payload and machine mode MODE.
+ The bits in PAYLOAD are used verbatim. */
+
+FIXED_VALUE_TYPE
+fixed_from_double_int (double_int payload, enum machine_mode mode)
+{
+ FIXED_VALUE_TYPE value;
+
+ gcc_assert (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_DOUBLE_INT);
+
+ value.data = payload;
+ value.mode = mode;
+
+ return value;
+}
+
+
/* Initialize from a decimal or hexadecimal string. */
void