summaryrefslogtreecommitdiff
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <bjorn@erlang.org>2023-04-27 10:05:48 +0200
committerGitHub <noreply@github.com>2023-04-27 10:05:48 +0200
commit726e31de4635c7ef7a52c42555d66a89fd74035a (patch)
treea0b690fe09918c1134815345c419009e6d96a097 /lib/compiler/src
parentb9ce2f45df308b2359812372579b599d897c8214 (diff)
parentd25bf59b5aea489e770b9ac0228eaa5b2998191d (diff)
downloaderlang-726e31de4635c7ef7a52c42555d66a89fd74035a.tar.gz
Merge pull request #7172 from bjorng/bjorn/compiler/fix-min-max-bool/GH-7170
Eliminate compiler crash in beam_ssa_codegen
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/beam_ssa_codegen.erl6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_ssa_codegen.erl b/lib/compiler/src/beam_ssa_codegen.erl
index c4708e9b11..9f6169829b 100644
--- a/lib/compiler/src/beam_ssa_codegen.erl
+++ b/lib/compiler/src/beam_ssa_codegen.erl
@@ -1450,6 +1450,12 @@ cg_copy_1([], _St) -> [].
element(1, Val) =:= atom orelse
element(1, Val) =:= literal)).
+bif_to_test(min, Args, Fail, St) ->
+ %% The min/2 and max/2 BIFs can only be rewritten to tests when
+ %% both arguments are known to be booleans.
+ bif_to_test('and', Args, Fail, St);
+bif_to_test(max, Args, Fail, St) ->
+ bif_to_test('or', Args, Fail, St);
bif_to_test('or', [V1,V2], {f,Lbl}=Fail, St0) when Lbl =/= 0 ->
{SuccLabel,St} = new_label(St0),
{[{test,is_eq_exact,{f,SuccLabel},[V1,{atom,false}]},