Elixir delegates to Erlang's pattern matching.
Looking through Elixir's source code, written in Erlang, here is the code that seems to be handling matching:
elixir_clauses.erl:
match(Fun, Expr, #{current_vars := Current, unused_vars := {_, Counter} = Unused} = AfterE, BeforeE) ->
#{
context := Context,
prematch_vars := Prematch,
current_vars := {Read, _}
} = BeforeE,
CallE = BeforeE#{
context := match,
prematch_vars := {Read, Counter},
current_vars := Current,
unused_vars := Unused
},
{EExpr, #{current_vars := NewCurrent, unused_vars := NewUnused}} = Fun(Expr, CallE),
EndE = AfterE#{
context := Context,
prematch_vars := Prematch,
current_vars := NewCurrent,
unused_vars := NewUnused
},
{EExpr, EndE}.
This is Erlang code, so here Elixir is delegating to Erlang's =
operator. As this is the case, Robert Virding (the author of Erlang's pattern matching code)'s answer to this related Erlang question is useful:
A very good description of compiling pattern matching is given in "The
implementation of functional programming languages" by Simon Peyton
Jones. It is a bit old but a very good book. It also contains, amongst
other things, a description of compiling list comprehensions.
The Erlang compiler uses both of these algorithms from the book.