Extend CSE to eliminate list and tuple matching
Extend CSE to eliminate list and tuple matching

In generated code and in code involving inlining/macros, a newly
constructed list, tuple, or map could be matched in the same function.

Here is an example of generated code:

    %% : sqrsum  dup *  swap  dup *  + ;
    sqrsum(SP_0) ->
        [X1|_] = SP_0,
        SP_1 = [X1|SP_0],         % dup

        [X2,X3|SP_2] = SP_1,
        SP_3 = [(X2*X3)|SP_2],    % *

        [X4,X5|SP_4] = SP_3,
        SP_5 = [X5,X4|SP_4],      % swap

        [X6|_] = SP_5,
        SP_6 = [X6|SP_5],         % dup

        [X7,X8|SP_7] = SP_6,
        SP_8 = [(X7*X8)|SP_7],    % *

        [X9,X10|SP_9] = SP_8,
        [(X9+X10)|SP_9].          % +

Here is the main part of the BEAM code for the function:

    {test,is_nonempty_list,{f,5},[{x,0}]}.
    {get_list,{x,0},{x,1},{x,0}}.
    {gc_bif,'*',{f,0},2,[{x,1},{x,1}],{x,1}}.
    {test,is_nonempty_list,{f,4},[{x,0}]}.
    {test_heap,4,2}.
    {get_list,{x,0},{x,2},{x,0}}.
    {put_list,{x,1},{x,0},{x,0}}.
    {put_list,{x,2},{x,0},{x,0}}.
    {get_list,{x,0},{x,1},{x,0}}.
    {gc_bif,'*',{f,0},2,[{x,1},{x,1}],{x,1}}.
    {test,is_nonempty_list,{f,3},[{x,0}]}.
    {get_list,{x,0},{x,2},{x,0}}.
    {gc_bif,'+',{f,0},3,[{x,1},{x,2}],{x,1}}.
    {test_heap,2,2}.
    {put_list,{x,1},{x,0},{x,0}}.
    return.

We can see that there are redundant list construction and
list matching instructions. This commit extends the
existing Common Sub Expression elimination optimization
so that the redundant instructions are eliminated:

    {test,is_nonempty_list,{f,4},[{x,0}]}.
    {get_list,{x,0},{x,1},{x,0}}.
    {gc_bif,'*',{f,0},2,[{x,1},{x,1}],{x,1}}.
    {test,is_nonempty_list,{f,3},[{x,0}]}.
    {get_list,{x,0},{x,2},{x,0}}.
    {gc_bif,'*',{f,0},3,[{x,2},{x,2}],{x,2}}.
    {gc_bif,'+',{f,0},3,[{x,2},{x,1}],{x,1}}.
    {test_heap,2,2}.
    {put_list,{x,1},{x,0},{x,0}}.
    return.

While at it, also optimize the intersection of expression maps.

erlang/otp,erlang/otp,vinoski/otp,potatosalad/otp,isvilen/otp,uabboli/otp,emacsmirror/erlang,uabboli/otp,potatosalad/otp,rlipscombe/otp,dumbbell/otp,rlipscombe/otp,bjorng/otp,getong/otp,jj1bdx/otp,vinoski/otp,bjorng/otp,uabboli/otp,g-andrade/otp,dumbbell/otp,bjorng/otp,isvilen/otp,getong/otp,bjorng/otp,vinoski/otp,isvilen/otp,g-andrade/otp,jj1bdx/otp,jj1bdx/otp,uabboli/otp,g-andrade/otp,getong/otp,bjorng/otp,getong/otp,rlipscombe/otp,emacsmirror/erlang,vinoski/otp,g-andrade/otp,potatosalad/otp,bjorng/otp,mikpe/otp,potatosalad/otp,g-andrade/otp,emacsmirror/erlang,emacsmirror/erlang,g-andrade/otp,dumbbell/otp,bjorng/otp,jj1bdx/otp,ferd/otp,vinoski/otp,bjorng/otp,mikpe/otp,emacsmirror/erlang,rlipscombe/otp,ferd/otp,rlipscombe/otp,dgud/otp,dgud/otp,isvilen/otp,isvilen/otp,uabboli/otp,dumbbell/otp,g-andrade/otp,g-andrade/otp,bjorng/otp,mikpe/otp,dumbbell/otp,ferd/otp,potatosalad/otp,mikpe/otp,ferd/otp,rlipscombe/otp,isvilen/otp,mikpe/otp,rlipscombe/otp,jj1bdx/otp,uabboli/otp,isvilen/otp,getong/otp,vinoski/otp,uabboli/otp,emacsmirror/erlang,isvilen/otp,jj1bdx/otp,emacsmirror/erlang,erlang/otp,dgud/otp,potatosalad/otp,bjorng/otp,potatosalad/otp,erlang/otp,dumbbell/otp,emacsmirror/erlang,jj1bdx/otp,dumbbell/otp,jj1bdx/otp,dgud/otp,ferd/otp,erlang/otp,isvilen/otp,ferd/otp,jj1bdx/otp,emacsmirror/erlang,getong/otp,getong/otp,getong/otp,potatosalad/otp,emacsmirror/erlang,vinoski/otp,mikpe/otp,rlipscombe/otp,erlang/otp,dumbbell/otp,dumbbell/otp,ferd/otp,ferd/otp,dgud/otp,jj1bdx/otp,mikpe/otp,erlang/otp,g-andrade/otp,g-andrade/otp,dgud/otp,rlipscombe/otp,getong/otp,isvilen/otp,vinoski/otp,ferd/otp,uabboli/otp,erlang/otp,mikpe/otp,erlang/otp,potatosalad/otp,dgud/otp,mikpe/otp,dumbbell/otp,dgud/otp,mikpe/otp,rlipscombe/otp,dgud/otp,vinoski/otp,vinoski/otp,uabboli/otp,potatosalad/otp,dgud/otp,erlang/otp,getong/otp