diff options
author | Igor Kirillov <igor.kirillov@arm.com> | 2023-08-30 14:52:28 +0000 |
---|---|---|
committer | Igor Kirillov <igor.kirillov@arm.com> | 2023-08-31 10:38:01 +0000 |
commit | e2cb07c322e85604dc48f9caec52b3570db0e1d8 (patch) | |
tree | 1d68cbca86c78d1338a21377f8ad2593ee8a0fa6 /llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp | |
parent | 69f1cd58aaab7e3508b86ae97795cd85fd84edd0 (diff) | |
download | llvm-e2cb07c322e85604dc48f9caec52b3570db0e1d8.zip llvm-e2cb07c322e85604dc48f9caec52b3570db0e1d8.tar.gz llvm-e2cb07c322e85604dc48f9caec52b3570db0e1d8.tar.bz2 |
[CodeGen] Fix incorrect insertion point selection for reduction nodes in ComplexDeinterleavingPass
When replacing ComplexDeinterleavingPass::ReductionOperation, we can do it
either from the Real or Imaginary part. The correct way is to take whichever
is later in the BasicBlock, but before the patch, we just always took the
Real part.
Fixes https://github.com/llvm/llvm-project/issues/65044
Differential Revision: https://reviews.llvm.org/D159209
Diffstat (limited to 'llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp b/llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp index 952f454..7979ac9 100644 --- a/llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp +++ b/llvm/lib/CodeGen/ComplexDeinterleavingPass.cpp @@ -1424,7 +1424,17 @@ bool ComplexDeinterleavingGraph::identifyNodes(Instruction *RootI) { // CompositeNode we should choose only one either Real or Imag instruction to // use as an anchor for generating complex instruction. auto It = RootToNode.find(RootI); - if (It != RootToNode.end() && It->second->Real == RootI) { + if (It != RootToNode.end()) { + auto RootNode = It->second; + assert(RootNode->Operation == + ComplexDeinterleavingOperation::ReductionOperation); + // Find out which part, Real or Imag, comes later, and only if we come to + // the latest part, add it to OrderedRoots. + auto *R = cast<Instruction>(RootNode->Real); + auto *I = cast<Instruction>(RootNode->Imag); + auto *ReplacementAnchor = R->comesBefore(I) ? I : R; + if (ReplacementAnchor != RootI) + return false; OrderedRoots.push_back(RootI); return true; } |