On Mon, Jan 21, 2013 at 2:28 PM, Georg-Johann Lay <a...@gjlay.de> wrote: > This is tentative patch as discussed in > > http://gcc.gnu.org/ml/gcc/2013-01/msg00187.html > > fold-const.c gets 2 new function native_encode_fixed and > native_interpret_fixed. Code common with the integer case is factored out and > moved to the new constructor-like function double_int::from_buffer. > > The code bootstraps fine on x86-linux-gnu and I have test coverage from > avr-unknown-none. > > Ok to apply?
Ok. Thanks, Richard. > There are less intrusive solutions that only handle the int <-> fixed cases, > for example fold-const.c:fold_view_convert_expr() could test for these cases > and use double_int directly without serializing / deserializing through a > memory buffer. > > Johann > > > PR tree-optimization/56064 > * fixed-value.c (const_fixed_from_double_int): New function. > * fixed-value.h (const_fixed_from_double_int): New prototype. > * 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. > > testsuite/ > PR tree-optimization/56064 > * gcc.dg/fixed-point/view-convert.c: New test.