From f25448763f55d595e00fe570f2108f669f3f6b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Sun, 9 Sep 2018 07:42:53 +0200 Subject: beam_ssa_opt: Don't do CSE for tuple_size/1 Not doing CSE for tuple_size/1 seems to generate slightly better code in most cases. --- lib/compiler/src/beam_ssa_opt.erl | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/compiler/src') diff --git a/lib/compiler/src/beam_ssa_opt.erl b/lib/compiler/src/beam_ssa_opt.erl index 9289b76f28..7fbc090132 100644 --- a/lib/compiler/src/beam_ssa_opt.erl +++ b/lib/compiler/src/beam_ssa_opt.erl @@ -486,6 +486,13 @@ 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=put_tuple}) -> true; +cse_suitable(#b_set{op={bif,tuple_size}}) -> + %% Doing CSE for tuple_size/1 can prevent the + %% creation of test_arity and select_tuple_arity + %% instructions. That could decrease performance + %% and beam_validator could fail to understand + %% that tuple operations that follow are safe. + false; cse_suitable(#b_set{op={bif,Name},args=Args}) -> %% Doing CSE for comparison operators would prevent %% creation of 'test' instructions. -- cgit v1.2.3