Am 10/23/2014 08:16 PM schrieb Denis Chertykov: >> This optimization makes most sign-extensions one instruction shorter in the >> case when the source register may be clobbered and the register numbers are >> different. Source and destination may overlap. >> >> Ok for trunk? >> >> Johann >> >> gcc/ >> * config/avr/avr.md (extendqihi2, extendqipsi2, extendqisi2) >> (extendhipsi2, extendhisi2): Optimize if source reg is unused >> after the insns and has different REGNO than destination. > > Approved. > > Denis. Finally I switched to a solution that avoids all the ugly asm snippets and special casing, and which is exact w.r.t code size. So allow me drop the patch from above and to propose this one for trunk. Sorry for the inconvenience. In any case it uses LSL/SBC idiom instead of the old CLR/SBRC/COM. Johann * avr-protos.h (avr_out_sign_extend): New. * avr.c (avr_adjust_insn_length) [ADJUST_LEN_SEXT]: Handle. (avr_out_sign_extend): New function. * avr.md (extendqihi2, extendqipsi2, extendqisi2, extendhipsi2) (extendhisi2, extendpsisi2): Use it. (adjust_len) [sext]: New.