diff options
author | Björn Gustavsson <[email protected]> | 2019-04-16 10:42:57 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-05-23 12:20:07 +0200 |
commit | 50a2d448e775668a5cbd835c9ff5eae6058f8739 (patch) | |
tree | 5df5d1dd0ccb0c7dfd64aa2a5e6414f1ac178bd5 /lib | |
parent | 3bfd8439d07bee689d2a2877e01a827cab1f028c (diff) | |
download | otp-50a2d448e775668a5cbd835c9ff5eae6058f8739.tar.gz otp-50a2d448e775668a5cbd835c9ff5eae6058f8739.tar.bz2 otp-50a2d448e775668a5cbd835c9ff5eae6058f8739.zip |
Optimize expression comparing a boolean to 'false'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compiler/src/beam_ssa_type.erl | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_ssa_type.erl b/lib/compiler/src/beam_ssa_type.erl index a1c10c7a34..82371f4ba3 100644 --- a/lib/compiler/src/beam_ssa_type.erl +++ b/lib/compiler/src/beam_ssa_type.erl @@ -552,6 +552,17 @@ simplify(#b_set{op={bif,'=:='},args=[A1,_A2]=Args}=I, Ts) -> {true,#t_atom{elements=[true]}} -> %% Bool =:= true ==> Bool A1; + {true,#t_atom{elements=[false]}} -> + %% Bool =:= false ==> not Bool + %% + %% This will be further optimized to eliminate the + %% 'not', swapping the success and failure + %% branches in the br instruction. If A1 comes + %% from a type test (such as is_atom/1) or a + %% comparison operator (such as >=) that can be + %% translated to test instruction, this + %% optimization will eliminate one instruction. + simplify(I#b_set{op={bif,'not'},args=[A1]}, Ts); {_,_} -> eval_bif(I, Ts) end |