Identify if an instruction is in a nested loop

For example:

for (i = 0; i < 10; i++){
   for (j = 0;j < 10; j++){

In the above example, I would like to differentiate the modification of b from the modification of a due to b is being modified inside the nested loop of what a is being modified. We already have LoopInfo for the instructions but don’t know how to use that for this purpose.
Thanks in advance for your help.

I am not sure of your exact requirement, I think with "LoopNestAnalysis` you can iterate through a loop nest map each instruction to its corresponding loop.

Hope this helps.