Generally, you want to avoid if statements at all times in HLSL. Unless you're compiling to 3.0 shader target.
The actual assembly that is output is actually not capable of using the IFs the same way you are using them.
In actually, it always computes what is inside the if, and then uses it based on the conditional.
I would recommend the directX HLSL tutorial at first. You're getting there tho.
(Also, the shaderX2 books are extremely useful for beginners... the introductory one anyway).