[XLA:GPU] Refactor code that sets priorities into a function.
[XLA:GPU] Refactor code that sets priorities into a function.

This change lookups and erases a few more elements from `reverse_map_`, but overall it shouldn't make a dent in the compile time.

With this change, we check if priority is negative before inserting into the queue, not after. This also doesn't affect compile time, but arguably makes the code easier to understand.
