The original code attempted to do this, but the std::abs() call didn't actually do anything due to implicit type conversions. Fix the type conversions, and perform the correct check for negated immediates.
This probably has very little practical impact, but it's worth fixing just to avoid confusion in the future, I think.