Walter's talk on D backend

user1234 user1234 at 12.de
Mon Sep 23 11:03:45 UTC 2024


On Monday, 23 September 2024 at 09:43:50 UTC, claptrap wrote:
> On Monday, 23 September 2024 at 08:44:04 UTC, Walter Bright 
> wrote:
>> On 9/23/2024 1:23 AM, claptrap wrote:
>>> Thats why OP asked about phi instructions, you need them to 
>>> merge the versions of a variable that reach the start of a 
>>> basic block. Or at least you need to have some mechanism for 
>>> it.
>>
>> Seems to me it's the same thing from a different angle.
>
> 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?

I cant reply for DMD but as I detect a confusion, let me add 
something about that... SSA is not about variables it's about 
nodes assigned uniquely once

So if X is a variable then each use of it is either a load or a 
store. (there can be bit cast and ptr arithmetic too, but let 
keep thing simple.)

<!--
(pseudo LLVM IR, to illustrate, with X, a global uint)

```
%1 = i32  load  ptr @X
%3 = i32  add   i32 %1, i32 %1
      i32  store ptr @X, i32 %3
     (LLVM does not make store reuseable, that'd be be a non-sense)
```

You see variables are not accessed as-is, either you have a load 
or a store.
An SSA node is what starts with "%"

-->


More information about the Digitalmars-d mailing list