I don't think I understand....isn't the question one of return? Investing in a market-indexed mutual fund inside of your RRSP will, on balance, generate a 'tax-free' (I know, I know, actually just tax deferred for a long time) return of around 12% (historical market average), plus you will save taxes in the short-term. Paying off your mortgage will save you whatever the interest rate you are paying---something like 5-6% these days. Capital gain of the residence should probably be ignored for this decision, since you would also ignore the gains inside the RRSP.
Maybe I have just bought into the RRSP mantra, but I honestly remember doing the maths some time ago and I convinced myself the RRSP is the better strategy.