Confusion with a Use of a getelementptr instruction being a Use of a select instruction instead

Hello,

I’m doing some Def/Use analysis, and I’m hung up on one tricky spot. The BB in question is attached. Ignore the red.

The issue is that ‘%13 = load…’ instruction does not show up as a Use for the ‘%scevgep25’ definition, and I feel like it should. Instead, it shows up as a Use for ‘%iftmp.55.0 = select…’, though Operand(0) for this ‘%13 = load’ instruction [listed as a Use for ‘%iftmp.55.0 = select…’] is reported as the %scevgep25 instruction, which is correct.

Sorry if that was a bit convoluted. Essentially, it seems that ‘getelementptr’ instructions with their Use’s instructions being (direct or indirect)operands to ‘select’ instructions have their Uses show up as Uses for the select only and not for the getelementptr instruction.

Does anyone have any idea why this might be happening? All the other def/use information I get seems correct.

Thanks,
Griffin

Hello,

I’m doing some Def/Use analysis, and I’m hung up on one tricky spot. The BB in question is attached. Ignore the red.

The issue is that ‘%13 = load…’ instruction does not show up as a Use for the ‘%scevgep25’ definition, and I feel like it should. Instead, it shows up as a Use for ‘%iftmp.55.0 = select…’, though Operand(0) for this ‘%13 = load’ instruction [listed as a Use for ‘%iftmp.55.0 = select…’] is reported as the %scevgep25 instruction, which is correct.

I’m not understanding all of the details of the behavior you’re describing, but I agree that the %13 load should be a use of %scevgep25 and that the select is a use of %14 and %15.

How are you iterating over the uses of %scevgep25? Are you removing or inserting instructions while iterating over the uses, thereby potentially invalidating the use_iterator? Invalidating the use_iterator would be my first guess.

– John T.