The D45316 introduced the shouldTransformMulToShiftsAddsSubs function to check that breaking down constant multiplications into a series of shifts, adds, and subs is efficient. Unfortunately, this function does not check maximum number of steps on all paths of the algorithm. This patch fixes this bug.
Fix for PR41929.
This comment can be misleading. The number is approximately equal to the minimal number of powers of two that constant can be broken down to by adding or subtracting them.