Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions experimental/lib/Analysis/GSAAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,37 @@ void experimental::gsa::GSAAnalysis::convertSSAToGSAMerges(
};

// Add to the list of operands of the new gate all the values which were not
// already used
// TODO: Edit senders if needed
// already used.
// Since in STQ one block can't be producer of more than one phi operand,
// sender logic is not needed.

// Handle self-dependent merges: if the merge uses its own result as an input,
// record that operand so it can be reconnected to the generated phi later.
SmallVector<GateInput *> selfInputs;

for (Value v : mergeOp.getOperands()) {
if (!isAlreadyPresent(v)) {
GateInput *gateInput = new GateInput(v);
if (v == mergeOp.getResult())
selfInputs.push_back(gateInput);
gateInputList.push_back(gateInput);
operands.push_back(gateInput);
}
}

// If the list of operands is not empty (i.e. the phi has at least
// one input), add it to the phis associated to that block
Gate *newPhi = nullptr;
if (!operands.empty()) {
Gate *newPhi = new Gate(mergeOp.getResult(), operands, GateType::PhiGate,
++uniqueGateIndex);
newPhi = new Gate(mergeOp.getResult(), operands, GateType::PhiGate,
++uniqueGateIndex);
gatesPerBlock[block].push_back(newPhi);
}

// Reconnect self-dependent operands to the newly created Phi
for (GateInput *gi : selfInputs)
gi->input = newPhi;

convertPhiToMu(region, bi);
convertPhiToGamma(region, bi);

Expand Down