@@ -201,9 +201,7 @@ struct ComplexDeinterleavingCompositeNode {
201201 }
202202 }
203203
204- bool AreOperandsValid () {
205- return OperandsValid;
206- }
204+ bool AreOperandsValid () { return OperandsValid; }
207205};
208206
209207class ComplexDeinterleavingGraph {
@@ -918,11 +916,11 @@ ComplexDeinterleavingGraph::identifyNode(Value *R, Value *I, bool &FromCache) {
918916 return It->second ;
919917 }
920918
921- if (NodePtr CN = identifyPartialReduction (R, I))
919+ if (NodePtr CN = identifyPartialReduction (R, I))
922920 return CN;
923921
924922 bool IsReduction = RealPHI == R && (!ImagPHI || ImagPHI == I);
925- if (!IsReduction && R->getType () != I->getType ())
923+ if (!IsReduction && R->getType () != I->getType ())
926924 return nullptr ;
927925
928926 if (NodePtr CN = identifySplat (R, I))
@@ -1450,18 +1448,20 @@ bool ComplexDeinterleavingGraph::identifyNodes(Instruction *RootI) {
14501448 if (It != RootToNode.end ()) {
14511449 auto RootNode = It->second ;
14521450 assert (RootNode->Operation ==
1453- ComplexDeinterleavingOperation::ReductionOperation || RootNode->Operation == ComplexDeinterleavingOperation::ReductionSingle);
1451+ ComplexDeinterleavingOperation::ReductionOperation ||
1452+ RootNode->Operation ==
1453+ ComplexDeinterleavingOperation::ReductionSingle);
14541454 // Find out which part, Real or Imag, comes later, and only if we come to
14551455 // the latest part, add it to OrderedRoots.
14561456 auto *R = cast<Instruction>(RootNode->Real );
14571457 auto *I = RootNode->Imag ? cast<Instruction>(RootNode->Imag ) : nullptr ;
14581458
14591459 Instruction *ReplacementAnchor;
1460- if (I)
1460+ if (I)
14611461 ReplacementAnchor = R->comesBefore (I) ? I : R;
1462- else
1462+ else
14631463 ReplacementAnchor = R;
1464-
1464+
14651465 if (ReplacementAnchor != RootI)
14661466 return false ;
14671467 OrderedRoots.push_back (RootI);
@@ -1553,7 +1553,7 @@ void ComplexDeinterleavingGraph::identifyReductionNodes() {
15531553 for (size_t j = i + 1 ; j < OperationInstruction.size (); ++j) {
15541554 if (Processed[j])
15551555 continue ;
1556-
1556+
15571557 auto *Imag = OperationInstruction[j];
15581558 if (Real->getType () != Imag->getType ())
15591559 continue ;
@@ -1588,18 +1588,20 @@ void ComplexDeinterleavingGraph::identifyReductionNodes() {
15881588
15891589 // We want to check that we have 2 operands, but the function attributes
15901590 // being counted as operands bloats this value.
1591- if (Real->getNumOperands () < 2 )
1591+ if (Real->getNumOperands () < 2 )
15921592 continue ;
15931593
15941594 RealPHI = ReductionInfo[Real].first ;
15951595 ImagPHI = nullptr ;
15961596 PHIsFound = false ;
15971597 auto Node = identifyNode (Real->getOperand (0 ), Real->getOperand (1 ));
1598- if (Node && PHIsFound) {
1599- LLVM_DEBUG (dbgs () << " Identified single reduction starting from instruction: "
1600- << *Real << " /" << *ReductionInfo[Real].second << " \n " );
1598+ if (Node && PHIsFound) {
1599+ LLVM_DEBUG (
1600+ dbgs () << " Identified single reduction starting from instruction: "
1601+ << *Real << " /" << *ReductionInfo[Real].second << " \n " );
16011602 Processed[i] = true ;
1602- auto RootNode = prepareCompositeNode (ComplexDeinterleavingOperation::ReductionSingle, Real, nullptr );
1603+ auto RootNode = prepareCompositeNode (
1604+ ComplexDeinterleavingOperation::ReductionSingle, Real, nullptr );
16031605 RootNode->addOperand (Node);
16041606 RootToNode[Real] = RootNode;
16051607 submitCompositeNode (RootNode);
@@ -2059,7 +2061,8 @@ Value *ComplexDeinterleavingGraph::replaceNode(IRBuilderBase &Builder,
20592061 return ReplacementNode;
20602062}
20612063
2062- void ComplexDeinterleavingGraph::processReductionSingle (Value *OperationReplacement, RawNodePtr Node) {
2064+ void ComplexDeinterleavingGraph::processReductionSingle (
2065+ Value *OperationReplacement, RawNodePtr Node) {
20632066 auto *Real = cast<Instruction>(Node->Real );
20642067 auto *OldPHI = ReductionInfo[Real].first ;
20652068 auto *NewPHI = OldToNewPHI[OldPHI];
@@ -2071,21 +2074,21 @@ void ComplexDeinterleavingGraph::processReductionSingle(Value *OperationReplacem
20712074 IRBuilder<> Builder (Incoming->getTerminator ());
20722075
20732076 Value *NewInit = nullptr ;
2074- if (auto *C = dyn_cast<Constant>(Init)) {
2075- if (C->isZeroValue ())
2077+ if (auto *C = dyn_cast<Constant>(Init)) {
2078+ if (C->isZeroValue ())
20762079 NewInit = Constant::getNullValue (NewVTy);
20772080 }
20782081
20792082 if (!NewInit)
20802083 NewInit = Builder.CreateIntrinsic (Intrinsic::vector_interleave2, NewVTy,
2081- {Init, Constant::getNullValue (VTy)});
2084+ {Init, Constant::getNullValue (VTy)});
20822085
20832086 NewPHI->addIncoming (NewInit, Incoming);
20842087 NewPHI->addIncoming (OperationReplacement, BackEdge);
20852088
20862089 auto *FinalReduction = ReductionInfo[Real].second ;
20872090 Builder.SetInsertPoint (&*FinalReduction->getParent ()->getFirstInsertionPt ());
2088- // TODO Ensure that the `AddReduce` here matches the original, found in `FinalReduction`
2091+
20892092 auto *AddReduce = Builder.CreateAddReduce (OperationReplacement);
20902093 FinalReduction->replaceAllUsesWith (AddReduce);
20912094}
@@ -2151,7 +2154,8 @@ void ComplexDeinterleavingGraph::replaceNodes() {
21512154 ReductionInfo[RootImag].first ->removeIncomingValue (BackEdge);
21522155 DeadInstrRoots.push_back (RootReal);
21532156 DeadInstrRoots.push_back (RootImag);
2154- } else if (RootNode->Operation == ComplexDeinterleavingOperation::ReductionSingle) {
2157+ } else if (RootNode->Operation ==
2158+ ComplexDeinterleavingOperation::ReductionSingle) {
21552159 auto *RootInst = cast<Instruction>(RootNode->Real );
21562160 ReductionInfo[RootInst].first ->removeIncomingValue (BackEdge);
21572161 DeadInstrRoots.push_back (ReductionInfo[RootInst].second );
0 commit comments