Detect a function can be optimized or not.