Looks to me like you forgot to put the SetCondInst into a basic block.
You should ALWAYS verify your module before emitting code. The verifier
would have caught this (instruction not in basic block). I suggest you
insert the verifier call into your program and see if your module
passes. If it does, let me know. If not, you'll know what the problem
is. See Stacker for an example use of the Verifier.