constraint generation for loops