summaryrefslogtreecommitdiff
path: root/lib/compiler/src/beam_a.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compiler/src/beam_a.erl')
-rw-r--r--lib/compiler/src/beam_a.erl22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_a.erl b/lib/compiler/src/beam_a.erl
index 97f4089a1b..3e249de7ef 100644
--- a/lib/compiler/src/beam_a.erl
+++ b/lib/compiler/src/beam_a.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2012-2020. All Rights Reserved.
+%% Copyright Ericsson AB 2012-2023. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -25,6 +25,8 @@
-export([module/2]).
+-include("beam_asm.hrl").
+
-spec module(beam_asm:module_code(), [compile:option()]) ->
{'ok',beam_utils:module_code()}.
@@ -85,6 +87,24 @@ rename_instrs([I|Is]) ->
[rename_instr(I)|rename_instrs(Is)];
rename_instrs([]) -> [].
+rename_instr({bif,Bif,Fail,[A,B],Dst}=I) ->
+ case Bif of
+ '=<' ->
+ {bif,'>=',Fail,[B,A],Dst};
+ '<' ->
+ case [A,B] of
+ [{integer,N},{tr,_,#t_integer{}}=Src] ->
+ {bif,'>=',Fail,[Src,{integer,N+1}],Dst};
+ [{tr,_,#t_integer{}}=Src,{integer,N}] ->
+ {bif,'>=',Fail,[{integer,N-1},Src],Dst};
+ [_,_] ->
+ I
+ end;
+ '>' ->
+ rename_instr({bif,'<',Fail,[B,A],Dst});
+ _ ->
+ I
+ end;
rename_instr({bs_put_binary=I,F,Sz,U,Fl,Src}) ->
{bs_put,F,{I,U,Fl},[Sz,Src]};
rename_instr({bs_put_float=I,F,Sz,U,Fl,Src}) ->