There are a number of very informative threatds on this, if you do a search for "upgrades." There is a heirarchy of upgrades that governs when they clear based on the instrument (SWU is best, miles clear later), the date of purchase, the fare class of the ticket, the status of the traveler, etc. All of this changes at the gate, when status becomes king.