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.
I don't understand what this is trying to do, why the special case? Surely the fix in isLegalICmpImmediate is enough?