Dead Code Elimination
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Mon Oct 19 06:45:35 UTC 2026
On 19/10/2026 7:36 PM, Walter Bright wrote:
> On 10/18/2026 8:33 AM, libxmoc wrote:
>> I noticed that dmd doesn't do DCE
>
> Yes, it does. Use the -O switch.
dmd -O
```d
void main() {
}
void foo() {
}
```
```asm.text._Dmain segment
assume CS:.text._Dmain
_Dmain:
push RBP
mov RBP,RSP
xor EAX,EAX
pop RBP
ret
.text._Dmain ends
.text.void onlineapp.foo() segment
assume CS:.text.void onlineapp.foo()
void onlineapp.foo():
push RBP
mov RBP,RSP
pop RBP
ret
add [RAX],AL
.text.void onlineapp.foo() ends
```
More information about the Digitalmars-d
mailing list