Good information from the two previous posters.
The most important thing is to consider whether you should be paying yourself salary or repaying the loan.
If you need long term working capital, then leave profits in the company and pay tax on them at the lower Corporation Tax rate so that you can use the retained funds to repay the loan.
If you expect the company to be profitable in the long term, you should pay yourself a salary up to the maximum of the 20% tax rate before repaying the loan.
If the company is losing money and there is a risk that it might go into insolvency, then you should be repaying the loans before taking any salary.
I have seen many cases where companies have gone into liquidation owing their directors money where the same directors seem to have got salaries which were presumably taxed.
If the amount needed by the company is large, you might consider buying some expensive asset and leasing it to the company. That means that if the company fails, you will still own the asset. Leasing is messy from a tax point of view - so this probably only applies to property.
Brendan