Richard Biener wrote: > Georg-Johann Lay 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. Let me drop this, I don't like the name "const_fixed_from_double_int". It's bad and I think "fixed_from_double_int" is better. Other constructor-like functions for FIXED_VALUE_TYPE use fixed_from_* whereas const_fixed_* returns a CONST_FIXED rtx. This is less confusing and fits better the naming convention. The new patch also adds const_fixed_from_double_int that actually returns a CONST_FIXED rtx. It's unused, but I would use it in the avr back. Okay with that rename? (Or, at your option, without const_fixed_from_double_int). Johann 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) : Use it. (can_native_interpret_type_p) : Return true. (native_encode_fixed): New static function. (native_encode_expr) : 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. > >> 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) : Use it. >> (can_native_interpret_type_p) : Return true. >> (native_encode_fixed): New static function. >> (native_encode_expr) : 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. >