[llvm] [InstCombine] Combine interleaved PHI reduction chains. (PR #143878)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 19 03:17:21 PDT 2025
================
@@ -996,6 +997,150 @@ Instruction *InstCombinerImpl::foldPHIArgOpIntoPHI(PHINode &PN) {
return NewCI;
}
+/// Try to fold reduction ops interleaved through two PHIs to a single PHI.
+///
+/// For example, combine:
+/// %phi1 = phi [init1, %BB1], [%op1, %BB2]
+/// %phi2 = phi [init2, %BB1], [%op2, %BB2]
+/// %op1 = binop %phi1, constant1
+/// %op2 = binop %phi2, constant2
+/// %rdx = binop %op1, %op2
----------------
dtcxzyw wrote:
We have a similar transform in `InstCombinerImpl::foldBinopWithPhiOperands`. But it looks hard to refactor the code :(
https://github.com/llvm/llvm-project/pull/143878
More information about the llvm-commits
mailing list