Using IF in T-SQL weakens or breaks execution plan caching?
SQL Server optimises the process of compilation of the query plan for the stored procedure by ignoring the conditional branches inside the stored procedure.  The plan will be generated based on the parameters used for the first execution, this will cause problems if the parameters are different for the branches.

I would place the SQL for each of the branches into their own stored procedure, so that the plan generated is based on the actual usage of parameters for that branch.