I co-wrote a tour of some recent MSVC backend improvements!

Have a look for some before-and-after assembly samples and more details.

https://devblogs.microsoft.com/cppblog/a-tour-of-4-msvc-backend-improvements/

#cpp

A Tour of 4 MSVC Backend Improvements

This blog post presents some of the optimizations the backend team has implemented for Visual Studio 2022.

C++ Team Blog

One is a bit tracker which can recognise custom byteswap functions and optimise down to bswap

Before > After

#cpp

Another is loop unswitching, which tries to avoid unnecessary branching based on invariant conditions in loops.

It basically does the equivalent of translating the 1st C++ sample into the 2nd one

#cpp

Next is better codegen for min/max chains.

Given the 1st C++ sample, the compiler used to generate what's in the 2nd pic. Now it generates the 3rd.

#cpp

@TartanLlama Oh, damn, that's WAYYY better. is this SSE only mode? and does this scale to the various AVX variants?
@fclc this is with /O2 and /fp:fast, which is required