[llvm] b836063 - [LoopFusion] Drop duplicate write-write dependence check (NFC) (#203173)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 02:27:46 PDT 2026
Author: Madhur Amilkanthwar
Date: 2026-06-11T14:57:41+05:30
New Revision: b836063bbf6f856c85801e40e31e8221f240653d
URL: https://github.com/llvm/llvm-project/commit/b836063bbf6f856c85801e40e31e8221f240653d
DIFF: https://github.com/llvm/llvm-project/commit/b836063bbf6f856c85801e40e31e8221f240653d.diff
LOG: [LoopFusion] Drop duplicate write-write dependence check (NFC) (#203173)
`dependencesAllowFusion()` re-tested every FC0-write vs FC1-write pair
in the second loop nest, duplicating the checks already done in the
first. Iterate only the remaining FC0-read vs FC1-write pairs; the set
of checked dependences (W0xW1, W0xR1, R0xW1) is unchanged.
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopFuse.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index 931f67d6777f8..b5126f9f3b704 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -1203,16 +1203,13 @@ struct LoopFuser {
}
}
- for (Instruction *WriteL1 : FC1.MemWrites) {
- for (Instruction *WriteL0 : FC0.MemWrites)
- if (!dependencesAllowFusion(FC0, FC1, *WriteL0, *WriteL1)) {
- return false;
- }
- for (Instruction *ReadL0 : FC0.MemReads)
+ // Write-write and write-read pairs are already covered above; only the
+ // read-before-write pairs from FC0 reads to FC1 writes remain.
+ for (Instruction *ReadL0 : FC0.MemReads)
+ for (Instruction *WriteL1 : FC1.MemWrites)
if (!dependencesAllowFusion(FC0, FC1, *ReadL0, *WriteL1)) {
return false;
}
- }
// Walk through all uses in FC1. For each use, find the reaching def. If the
// def is located in FC0 then it is not safe to fuse.
More information about the llvm-commits
mailing list