File 0160-beam_core_to_ssa-Eliminate-bottleneck-when-there-are.patch of Package erlang

From b25b91a637d9c9fb7cfa56295be8602f5d025325 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Thu, 2 Oct 2025 07:35:55 +0200
Subject: [PATCH 2/2] beam_core_to_ssa: Eliminate bottleneck when there are
 many clauses

When a `case` had many clauses (say hundred thousand or more) having
all the same body, the beam_core_to_ssa pass could become very
slow.
---
 lib/compiler/src/beam_core_to_ssa.erl | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/compiler/src/beam_core_to_ssa.erl b/lib/compiler/src/beam_core_to_ssa.erl
index 69fecb29ed..84489f5cc2 100644
--- a/lib/compiler/src/beam_core_to_ssa.erl
+++ b/lib/compiler/src/beam_core_to_ssa.erl
@@ -2599,8 +2599,14 @@ select_val_cg(Type, R, Vls, Tf, Vf, Sis, St0) ->
             {TypeIs++[#b_switch{arg=R,fail=Vf,list=Vls}|Sis],St1}
     end.
 
-combine([{Is,Vs1},{Is,Vs2}|Vis]) -> combine([{Is,Vs1 ++ Vs2}|Vis]);
-combine([V|Vis]) -> [V|combine(Vis)];
+
+combine([V|Vis0]) ->
+    case {V, combine(Vis0)} of
+        {{Is,Vs1}, [{Is,Vs2}|Vis]} ->
+            [{Is,Vs1 ++ Vs2}|Vis];
+        {_,Vis} ->
+            [V|Vis]
+    end;
 combine([]) -> [].
 
 select_labels([{Is,Vs}|Vis], St0, Vls, Sis) ->
-- 
2.51.0

openSUSE Build Service is sponsored by