On Tue, Nov 27, 2018 at 8:57 PM Gavin Lambert via Boost < boost@lists.boost.org> wrote:
On 28/11/2018 16:28, Emil Dotchevski wrote:
The language currently works correctly in this case, thanks god. The idea that if x and y are of type short, then x+y should be of type short is utterly wrong. When you add two shorts, you get an int, because computing the int result does not use more resources than computing the short result.
That is not always true. There are assembly instructions which can operate on values smaller than a register width, and if the compiler were able to use them then it might be able to use fewer registers for some code patterns.
The optimizer has to use int-size registers only if the int result is assigned to int. If it's assigned to a short, the optimizer can and does use short-size registers.