Add edge case handler for stack reduction
Inputs with the form 8-3*2+1 reduced incorrectly due to the "+" operation dropping the "-" for the first operand. Added code to detect this special case and give the expected result.
(cherry picked from commit 91205962)