You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/DeveloperGuide/DynamaticFeaturesAndOptimizations/FTD/GSAAnalysis.md
+20-4Lines changed: 20 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,12 +100,28 @@ After all ϕ gates are created, the final step is to connect the missing inputs
100
100
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.
101
101
102
102
### `isBlockArgAlreadyPresent` and `isValueAlreadyPresent`
103
-
These helper functions prevent duplicate inputs from being recorded.
104
103
105
-
// TODO: explain their implementation details later.
104
+
These two helper functions avoid recording duplicate inputs for a ϕ.
106
105
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.
0 commit comments