On Mon, 2015-11-09 at 21:47 +0100, Bernd Schmidt wrote: > On 11/09/2015 05:59 PM, Steve Ellcey wrote: > > Here is a version with the code moved into a new function. How does > > this look? > > > > 2015-11-09 Steve Ellcey <sell...@imgtec.com> > > > > * optabs.c (prepare_libcall_arg): New function. > > (expand_fixed_convert): Add call to prepare_libcall_arg. > > Hold on a moment - I see that emit_library_call_value_1 calls > promote_function_mode for arguments. Can you investigate why that > doesn't do what you need? > > > Bernd
emit_library_call_value_1 has no way of knowing if the promotion should be signed or unsigned because it has a mode (probably QImode or HImode) that it knows may need to be promoted to SImode but it has no way to know if that should be a signed or unsigned promotion because it has no tree type information about the library call argument types. Right now it guesses based on the return type but it may guess wrong when converting an unsigned int to a signed fixed type or visa versa. By doing the promotion in expand_fixed_convert GCC can use the uintp argument to ensure that the signedness of the promotion is done correctly. We could pass that argument into emit_library_call_value_1 so it can do the correct promotion but that would require changing the argument list for emit_library_call and emit_library_call_value_1 and changing all the other call locations for those functions and that seemed like overkill. Steve Ellcey