forked from erlang/otp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid optimization that beam_validator might consider unsafe
Eliminating a repeated `=:=` test can result in code that beam_validator doesn't consider safe. This commit makes the optimization keep the `=:=` if it seems to be significant, that is, if one or both operands will gain type information from it. That makes it possible to compile code from erlang#6599 such as: f(X, X) when is_integer(X) -> ok; f(Y, Y = #{}) -> Y#{ok := ok}. (Six other examples from erlang#6599 can now also be compiled.) Running `scripts/diffable` shows that this fix prevented the optimization in 14 modules (out of about 1000). Closes erlang#6599
- Loading branch information
Showing
2 changed files
with
125 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters