-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Description
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