Closed Medowhill closed 4 years ago
Let's remove nop
from the IR in the deadcode elimination. In that case, the result of nop
, e.g., %b1:i0:unit
, should be replace with unit:unit
.
Oh, I was confused... I thought that %b1:i0:unit
was %b0:i0:unit
. I still have a question though. I am wondering whether we really need such test cases. I believe that every optimization so far replaces an instruction with Nop
only if its result is not used. Therefore, such cases seem not to appear in the usual optimization process. Am I missing something here?
Thank you.
It's a kinda compiler-philosophy question.
Even though nop
is not used at all during the specific series of translations and optimizations in KECC, I still believe it's beneficial to optimize them out in deadcode elimination. Because we later may want to support other translations (e.g., from Rust to KECC IR?) and optimizations, which may introduce unused nop
as a placeholder. To summarize, I want KECC to support not only the specific series of translations and optimizations but also all possible combinations of them. It is also a goal shared among LLVM compiler writers, as well.
I see. Thank you!
Hi.
Currently, the 28th line of
deadcode.input.ir
is the following:After dead code elimination, it becomes the following, which is from the 24th line of
deadcode.output.ir
:It is possible because
unit:unit
is the only value of theunit
type, but I am wondering whether such optimization is required in the homework. The lecture note mentions only removing unused allocations, removing nops, and removing unused instructions.Thank you.