From 54df0e73b3c3d0240eedc5b1469aa89ecb8de531 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Thu, 21 Feb 2019 06:06:08 +0100
Subject: beam_ssa_opt: Do local CSE of get_tuple_element instructions

For some reason, a `get_tuple_element` instruction was not deemed
suitble for local common sub expression elimination.

It turns out that enabling CSE for `get_tuple_element` is benefical.
It will also be even more benefical in a future commit where some
of the optimizations in `sys_core_fold` are removed.
---
 lib/compiler/src/beam_ssa_opt.erl | 1 +
 1 file changed, 1 insertion(+)

(limited to 'lib/compiler')

diff --git a/lib/compiler/src/beam_ssa_opt.erl b/lib/compiler/src/beam_ssa_opt.erl
index f8e19d0aa7..6e548dd529 100644
--- a/lib/compiler/src/beam_ssa_opt.erl
+++ b/lib/compiler/src/beam_ssa_opt.erl
@@ -849,6 +849,7 @@ cse_expr(#b_set{op=Op,args=Args}=I) ->
 cse_suitable(#b_set{op=get_hd}) -> true;
 cse_suitable(#b_set{op=get_tl}) -> true;
 cse_suitable(#b_set{op=put_list}) -> true;
+cse_suitable(#b_set{op=get_tuple_element}) -> true;
 cse_suitable(#b_set{op=put_tuple}) -> true;
 cse_suitable(#b_set{op={bif,tuple_size}}) ->
     %% Doing CSE for tuple_size/1 can prevent the
-- 
cgit v1.2.3