Walter's talk on D backend

Stefan Koch uplink.coder at googlemail.com
Wed Sep 25 21:56:46 UTC 2024


On Wednesday, 25 September 2024 at 19:31:52 UTC, claptrap wrote:
> On Wednesday, 25 September 2024 at 11:44:22 UTC, Walter Bright 
> wrote:
>> 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.
>
> Is that different from the DCE that you linked the source code 
> to earlier? I mean dead code elimination, and dead assignment 
> elimination are different routines in DMD?
>
> Maybe my question wasn't clear but I was asking how it is done, 
> not what is it called. IE.. if you have 3 assignments to X, how 
> determine if any of them are redundant?

You look if there is a write to X without a (live) use of X 
beforehand.
whether that can eliminate the x += 1 in
x += 1
x = y.

is up to the quality of implementation.
I should note that data flow analysis is necessary to produce 
good ssa in the first place.
naive SSA leads to a horribly bloated IR. Which is why it's not a 
first choice, if memory is limited.


More information about the Digitalmars-d mailing list