reg getInductionVariable


The function getInductionVariable mandates the loop to be in “SimplifyForm”.

Loop::getInductionVariable(ScalarEvolution &SE) {
if (!isLoopSimplifyForm())
return nullptr;


bool Loop::isLoopSimplifyForm() {
return getLoopPreheader() && getLoopLatch() && hasDedicatedExits();


/// Return true if no exit block for the loop has a predecessor that is

/// outside the loop.
bool hasDedicatedExits() const;

Is it necessary for the loop to have DedicatedExists to find the induction variable?
Can this condition be relaxed?

Potentially, but it is often simpler to force simplified form. If need
dedicated exists, split the exiting edges of a loop. That will create
dedicated exist blocks.