As a follow up to r279090, if dp hasn't been defined, we shouldn't attempt to do an optimization here.