Save me from bloodguilt, O God,
the God who saves me,
and my tongue will sing of your righteousness.
Knowing what you deserve can many times help you to know what you need to be saved from. David (along with the rest of us) deserves to die, he knows this and cries out to God for salvation from what he deserves.
And he cries out to God because he knows that God is the saving kind of God.