https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120434
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Kang-Che Sung from comment #5) > Note that I only report this as a bug for x86-64 targets. I've also tested > an RISC-V (64-bit) and on that target the zero-extension would make larger > code. > > So I can say such an optimization would be target specific - using > sign-extension might be better on some architectures while using > zero-extension might be better on others. That can be taken into account too. when it comes to taking into account cost between sign vs zero extend in the expansion phase. E.g. If we know the 31st bit is not set for unsigned, just sign extend :).