coderkalyan / coderkalyan/femtoc

hir: dead constant elimination

Open
#59 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Zig
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Because of the way type analysis is done, an integer/float literal that's used anywhere creates two instructions:
In step 1 (HirGen.zig reduction):
%0 = int(1234)
%1 = coerce(@Ref.u32, %0)

In step 2 (type_analysis.zig):
%0 = constant(@Ref.comptime_uint, 1234)
%1 = constant(@Ref.u32, 1234)

After type analysis, instruction %0 (the comptime_uint) constant is no longer needed, and is distracting. It's not breaking anything right now, but does need to be skipped. It would be nice to only have one relevant constant for i.e. top level declaration block_inline.

We should adapt the currently disabled dead_code_elimination into a dead_constant_elimination that removes the unused constants.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.