Skip to content

Come up with a way to optimize the parse tree #384

@dplassgit

Description

@dplassgit

E.g.,

a=(foo.bar==(baz and bam.qux)) OR true

will always be true, so there is no need to evaluate (foo.bar==(baz or bam.qux)) (unless it makes a proc call). However, the way codegen works will make it nigh impossible to know that fact, because the IL would be something like

temp0 = foo.bar
temp1 = baz
temp2 = bam.qux
temp3 = temp1 AND temp2  // worse, it generates an AND short-circuit path
temp4 = temp0 == temp3
a = temp4 OR true // LINE 5 worse, it generates an OR short-circuit path

After LINE 5 is optimized to a = true, I'm not sure the dead code eliminator is smart enough to realize that temp4 is never read on LINE 5 because of all the short-circuiting paths that are added.

Instead, we could find the BinOp node with OR true and replace it with a constant true

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions