[erlang-bugs] Possible bug in HiPE pattern matching

Mikael Pettersson mikpe@REDACTED
Fri Jul 10 01:44:59 CEST 2009


Jon Meredith writes:
 > 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}

Confirmed on i686, x86-64, and powerpc, so it looks like a middle-end
(Icode or RTL) rather than a backend bug. Someone, likely me or Kostis,
will take a look at it.

 > Is there  
 > something I don't understand about HiPE?

Bugs happen, that's all.

Thanks for reporting this problem.

/Mikael


More information about the erlang-questions mailing list