I recently did something similar, I arrived at SFO earlier than anticipated and was booked in P for SFO-LAX. I was able to take an earlier flight and still stay in first even though there was a waitlist. I didn't do it at the gate though, I went to customer service to process the change.