[llvm] [LoopFusion] Fix sink instructions (PR #147501)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 11 07:10:41 PDT 2025
================
@@ -1176,9 +1176,31 @@ struct LoopFuser {
return true;
}
+ void fixPHINodes(SmallVector<Instruction *, 4> &SafeToSink,
+ const FusionCandidate &FC0,
+ const FusionCandidate &FC1) const {
+ // Iterate over SafeToSink instructions and update PHI nodes
+ // to take values from the latch block of FC0 if they are taking
+ // from the latch block of FC1.
+ for (Instruction *Inst : SafeToSink) {
+ LLVM_DEBUG(dbgs() << "UPDATING: Instruction: " << *Inst << "\n");
+ // Continue if the instruction is not a PHI node.
+ if (!isa<PHINode>(Inst))
+ continue;
+ PHINode *Phi = dyn_cast<PHINode>(Inst);
+ LLVM_DEBUG(dbgs() << "UPDATING: PHI node: " << *Phi << "\n");
----------------
kasuga-fj wrote:
If `Inst` is a PHI node, the following messages will be printed, which seem redundant to me.
```
UPDATING: Instruction: phi ...
UPDATING: PHI node: phi ...
```
If it is not a PHI node, the following message will be displayed, but it is not actually updated.
```
UPDATING: Instruction: ...
```
https://github.com/llvm/llvm-project/pull/147501
More information about the llvm-commits
mailing list