[midend]修复创建新归纳变量的错误逻辑,避免生成悬空phi节点的现象
This commit is contained in:
@ -614,12 +614,9 @@ bool StrengthReductionContext::createNewInductionVariable(StrengthReductionCandi
|
||||
return false;
|
||||
}
|
||||
|
||||
// 1. 在循环头创建新的 phi 指令
|
||||
builder->setPosition(header, header->begin());
|
||||
candidate->newPhi = builder->createPhiInst(originalPhi->getType());
|
||||
candidate->newPhi->setName(originalPhi->getName() + "_sr");
|
||||
|
||||
|
||||
// 2. 找到原始归纳变量的初始值和步长
|
||||
// 1. 找到原始归纳变量的初始值和步长
|
||||
Value* initialValue = nullptr;
|
||||
Value* stepValue = nullptr;
|
||||
BasicBlock* latchBlock = nullptr;
|
||||
@ -651,6 +648,11 @@ bool StrengthReductionContext::createNewInductionVariable(StrengthReductionCandi
|
||||
return false;
|
||||
}
|
||||
|
||||
// 2. 在循环头创建新的 phi 指令
|
||||
builder->setPosition(header, header->begin());
|
||||
candidate->newPhi = builder->createPhiInst(originalPhi->getType());
|
||||
candidate->newPhi->setName(originalPhi->getName() + "_sr");
|
||||
|
||||
// 3. 计算新归纳变量的初始值和步长
|
||||
// 新IV的初始值 = 原IV初始值 * multiplier
|
||||
Value* newInitialValue;
|
||||
|
||||
Reference in New Issue
Block a user