Possible bug in HiPE pattern matching

Jon Meredith jon@REDACTED
Thu Jul 9 22:53:01 CEST 2009


Hi all,

I think I've discovered an issue with pattern matching under HiPE  
going back on at least 5.6.3 under Debian/lenny and 5.7.2 under OS X

Here is a module that demonstrates the issue

-module(bug).
-export([f/1,g/1]).
f(0) -> zero;
f(-10) -> one;
f(-20) -> two;
f(-30) -> three;
f(-40) -> four;
f(-50) -> five;
f(-60) -> six;
f(-70) -> seven;
f(-80) -> eight;  %% Uncomment this line to make it work with HiPE
f(X) -> {error, X}.

g(X) ->
     case X of
         0 -> zero;
         -10 -> one;
         -20 -> two;
         -30 -> three;
         -40 -> four;
         -50 -> five;
         -60 -> six;
         -70 -> seven;
         -80 -> eight;  %% Uncomment this line to make it work with HiPE
         X -> {error, X}
     end.

Running normally without HiPE it does what I expect

   jmeredith@REDACTED:~$ /usr/bin/erlc bug.erl
   jmeredith@REDACTED:~$ /usr/bin/erl
   Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [smp:2]  
[async-threads:0] [hipe] [kernel-poll:false]

   Eshell V5.6.3  (abort with ^G)
   1> bug:f(0).
   zero
   2> bug:g(0).
   zero

If I compile with +native, the pattern doesn't match the first case as  
it should

   jmeredith@REDACTED:~$ /usr/bin/erlc +native bug.erl
   jmeredith@REDACTED:~$ /usr/bin/erl
   Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [smp:2]  
[async-threads:0] [hipe] [kernel-poll:false]

   Eshell V5.6.3  (abort with ^G)
   1> bug:f(0).
   {error,0}
   2> bug:g(0).
   {error,0}

If I remove the commented lines above it works correctly.  Is there  
something I don't understand about HiPE?

Many thanks, Jon



More information about the erlang-bugs mailing list