September 24
On Tuesday, 24 September 2024 at 06:23:24 UTC, Walter Bright wrote:
> ```
> x = x + 6
> ```
>
> ```
> r1 = x
> r2 = 6
> r3 = r1 + r2
> x = r3
> ```
>
> The r's are only assigned once.

Doesn't that just come implicitly from them being temporaries?

For SSA the x's would have to be assigned only once, so the last line "x=r3", x would be renamed there.
September 24
On 9/24/2024 12:47 AM, claptrap wrote:
> Doesn't that just come implicitly from them being temporaries?

Yes, exactly.

September 24
On Tuesday, 24 September 2024 at 09:42:25 UTC, Walter Bright wrote:
> On 9/24/2024 12:47 AM, claptrap wrote:
>> Doesn't that just come implicitly from them being temporaries?
>
> Yes, exactly.

```
x = x + 1
x = y + 1
```

So if you have that, how do you determine that the first assignment to 'x' is redundant?
September 24
On Tuesday, 24 September 2024 at 06:23:24 UTC, Walter Bright wrote:
> ```
> x = x + 6
> ```
>
> ```
> r1 = x
> r2 = 6
> r3 = r1 + r2
> x = r3
> ```
>
> The r's are only assigned once.

You did not quite answer my question - how is the example snippet translated?

Also what is the value of x above? Clearly x is assigned to more than once - first assignment is not shown, so this is not SSA.
September 24
On Tuesday, 24 September 2024 at 06:14:52 UTC, Walter Bright wrote:
> On 9/23/2024 2:43 AM, claptrap wrote:
>> How do you do dead code elimination in your backend? I mean if you have 3 assignments to X, and say 5 uses of X, how do you determine if any of the assignments are redundant?
>
> By using DFA (Data Flow Analysis).
>
> https://github.com/dlang/dmd/blob/master/compiler/src/dmd/backend/gother.d#L1375
>
> DMD does do all the conventional data flow analysis optimizations.

Yes well, SSA is supposed to make it easier to do some optimizations, but all optimizations are possible without SSA - using data flow analysis, etc.

But the description provided so far does not show DMD compiler uses SSA.
September 24
On Tuesday, 24 September 2024 at 22:20:31 UTC, Dibyendu Majumdar wrote:
> On Tuesday, 24 September 2024 at 06:14:52 UTC, Walter Bright
>
>
> Yes well, SSA is supposed to make it easier to do some optimizations, but all optimizations are possible without SSA - using data flow analysis, etc.
>
> But the description provided so far does not show DMD compiler uses SSA.

It clearly doesn't use SSA, it happens to generate some sequences of temporaries that are SSA, but probably every compiler does that. Its like a fence with only half the panels installed, is it still a fence? Maybe, does it actual do what it's supposed to? Nope.






September 25
On Sunday, 22 September 2024 at 08:35:14 UTC, Walter Bright wrote:
> On 9/18/2024 5:34 AM, Dibyendu Majumdar wrote:
>
>> The register allocator description also did not really explain how it works. There was mention of coloring - was that a reference to graph coloring?
>
> I don't know if it's exactly like graph coloring, but it's about preparing bit vectors of register use and the live range of variable (also expressed as a bit vector), and mapping a register onto 0's in a register's bit vector.
>

Given the description of the expression tree - does the register allocator work globally across the whole method/function or just on each expression tree?
September 25
On 9/24/2024 3:20 PM, Dibyendu Majumdar wrote:
> But the description provided so far does not show DMD compiler uses SSA.

And it doesn't. It uses binary trees, which are very much like SSA.
September 25
On 9/23/2024 6:39 AM, claptrap wrote:
> If you have an 3 "elem" that store to variable "X", and one use of "X", there's no way to tell if any of those stores are redundant without actually working out how they all depend on each other.

The working out is "dead assignment elimination" which is another DFA that DMD does.
September 25
On Wednesday, 25 September 2024 at 11:41:59 UTC, Walter Bright wrote:
> On 9/24/2024 3:20 PM, Dibyendu Majumdar wrote:
>> But the description provided so far does not show DMD compiler uses SSA.
>
> And it doesn't. It uses binary trees, which are very much like SSA.

The problem is they are not ... so its confusing for people if you make such a claim.