Open ainar-g opened 3 years ago
/cc @matloob
This would require implementing the GVN (global value numbering) optimization in golang.org/x/tools/go/ssa to recognize that both occurrences of the repeated expression v.max
must have the same value. This is not trivial in general: any operations in between the two statements could change the address of v, or assign to its max field.
nilness
currently (as of golang/tools@ae774e9781d2 with Go 1.15.6) correctly reports this issue:But not this one:
Full reproduction code.