<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97510>97510</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[DebugInfo][LoopStrengthReduce] Missing debug location updates for new phi and binop instructions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
debuginfo,
llvm:transforms
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Apochens
</td>
</tr>
</table>
<pre>
[**LSR-L2406**](https://github.com/llvm/llvm-project/blob/3641efcf8cb256ddbd20f4add5ce55800cad5399/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp#L2406), [**L2410**](https://github.com/llvm/llvm-project/blob/3641efcf8cb256ddbd20f4add5ce55800cad5399/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp#L2410)
[L2406] The new phi instruction `NewPH` replacing the old phi instruction `PH` and cast instruction `ShadowUse` does not inherent any debug location.
[L2410] The new binop instruction `NewIncr` replacing the old binop instruction `Incr` does not inherent any debug location.
godbolt: https://godbolt.org/z/eGGd9Pxb5 (see `%IV.S.` and `%IV.S.next` in the optimized code)
```cpp
/* Add new PHINode. */
-> PHINode *NewPH = PHINode::Create(DestTy, 2, "IV.S.", PH->getIterator());
/* create new increment. '++d' in above example. */
Constant *CFP = ConstantFP::get(DestTy, C->getZExtValue());
-> BinaryOperator *NewIncr = BinaryOperator::Create(
Incr->getOpcode() == Instruction::Add ? Instruction::FAdd
: Instruction::FSub,
NewPH, CFP, "IV.S.next.", Incr->getIterator());
NewPH->addIncoming(NewInit, PH->getIncomingBlock(Entry));
NewPH->addIncoming(NewIncr, PH->getIncomingBlock(Latch));
/* Remove cast operation */
ShadowUse->replaceAllUsesWith(NewPH);
ShadowUse->eraseFromParent();
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVktv4zYQ_jX0hVhDpqzXwQfZjjYG0l0jzm6B3ihyLLGVSYGk8thfX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