[erlang-bugs] R14B04 and R15A: Possible bug when compiling code using binary expressions with hipe
Sun Dec 11 10:42:58 CET 2011
On Sat, Dec 10, 2011 at 10:14 AM, Kostis Sagonas <> wrote:
> However, the native compiler crash should be fixed. It really boils down to
> the following code:
> f(<<42, _/bits>> = B) -> B.
> for which the BEAM compiler produces:
> label 1:
> label 2:
> This is obviously correct BEAM code, but I think it's suboptimal. I would
> have expected some lighter-weight instruction instead of a bs_match_string
> one, which presumably involves some loop in its implementation. Bjorn what
> say you?
It is not obvious to me without measuring.
If you don't use bs_match_string, you will need one more
That is, one instruction to retrieve 8 bits from the binary and one
instruction to compare that it is equal to 42.
Provided that the binary is aligned on a byte boundary, bs_match_string
will use memcmp(). I think that GCC will inline calls to memcmp(), but
I have no idea how efficient it will be for a size value of one.
Björn Gustavsson, Erlang/OTP, Ericsson AB
More information about the erlang-bugs