Skip to content

Commit f3dad30

Browse files
isAlreadyPresent
1 parent 4386e72 commit f3dad30

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

  • docs/DeveloperGuide/DynamaticFeaturesAndOptimizations/FTD

docs/DeveloperGuide/DynamaticFeaturesAndOptimizations/FTD/GSAAnalysis.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,28 @@ After all ϕ gates are created, the final step is to connect the missing inputs
100100
The input of a ϕ gate can itself be another ϕ. This happens when the input comes from a block argument of another block (excluding bb0). In this case, the ϕ input cannot be connected immediately. Instead, it is marked as missing and the necessary information is stored. After all ϕ gates are extracted, these missing inputs are revisited and the connections are reconstructed.
101101

102102
### `isBlockArgAlreadyPresent` and `isValueAlreadyPresent`
103-
These helper functions prevent duplicate inputs from being recorded.
104103

105-
// TODO: explain their implementation details later.
104+
These two helper functions avoid recording duplicate inputs for a ϕ.
106105

107-
### Why can a value appear multiple times?
108-
// TODo
106+
- `isValueAlreadyPresent`
107+
108+
This one is straightforward: it directly checks if the same SSA value is already in the operand list (`operands`).
109+
110+
If found, we don’t add it again; instead, we just update its sender list to record that this value can also arrive from the current predecessor (`pred`).
111+
112+
- `isBlockArgAlreadyPresent`
113+
114+
Block arguments are trickier, because at this stage we may not have the actual value to compare.
115+
116+
Instead, two block arguments are considered duplicates if:
117+
118+
- they originate from the same argument position of the same block, and
119+
120+
- they target the same argument position of the same block.
121+
122+
If these conditions hold, we treat them as the same missing ϕ input. As with values, we don’t add a new entry; instead, we **update the sender list** of the existing one to include the current predecessor.
123+
124+
In both cases, the key idea is: a duplicate input means the same logical operand is reachable through multiple control-flow edges, so we reuse the operand and just record the extra senders.
109125

110126
## Convert ϕ Gates into μ Gates
111127

0 commit comments

Comments
 (0)