[erlang-patches] Patch for binary pattern matching of floats with HiPE

Kostis Sagonas kostis@REDACTED
Mon Sep 5 11:53:59 CEST 2011


On 09/03/11 21:06, Paul Guyot wrote:
> Hello,
>
> HiPE generates bad code for a pattern matching of a float with a variable size length such as :
> <<F:S/float>>
>
> The following function always fail when compiled natively and behaves as expected with BEAM:
>
> bin_to_float(B,S) ->
>      <<F:S/float>>  = B,
>      F.
>
> Judging from the almost identical code for integers, this obviously is a typo. I guess both code could be factorized, although I do not know what the policy is for duplicate code in HiPE (it's just about 14x2 lines).
>
> The following commit fixes this bug. Also, a test is obvious to implement and I wish HiPE tests were open source, so we could enrich them.
>
> https://github.com/pguyot/otp/commit/79e0c0345539624ed8bdcea2450dc2252f8375e8
> git fetch git://github.com/pguyot/otp.git fix-hipe-bs_get_float2

Hi Paul,

Your patch is fine. As a matter of fact, I agree with you that the code 
around that line needs refactoring to avoid code duplication. If you 
have the time/energy to do this and add it to your patch, it will be 
appreciated. Otherwise, I guess your current patch will do. Can I ask 
the folks at OTP to add this to 'pu' and graduate it soon?

Related to your wish, it's inaccurate that the HiPE tests are not open 
source. It's just that they are still under CVS (in a repository where 
only HiPE members have write access), using a different format than the 
ones in OTP. But they are available to anyone and you can get them via 
the command:

    cvs -d:pserver:guest@REDACTED:/hipe checkout tests

Actually, there was a test for the case you discovered but for some 
unknown reason it was commented out :-(  Not anymore.

Merci beaucoup pour le "bug fix",

Kostis



More information about the erlang-patches mailing list