<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body style="background-color: rgb(255, 255, 255); color: rgb(0, 0,
    0);" bgcolor="#FFFFFF" text="#000000">
    <br>
    <br>
    <div class="moz-cite-prefix">On 03/12/2015 07:37 PM, Andrew Haley
      wrote:<br>
    </div>
    <blockquote cite="mid:5501DCE8.3010108@redhat.com" type="cite"><!--[if !IE]><DIV style="border-left: 2px solid #009900; border-right: 2px solid #009900;  padding: 0px 15px; margin: 2px 0px;"><![endif]-->
      <pre wrap="">On 03/12/2015 05:15 PM, Peter Levart wrote:
</pre>
      <blockquote type="cite"><!--[if !IE]><DIV style="border-left: 2px solid #009900; border-right: 2px solid #009900;  padding: 0px 15px; margin: 2px 0px;"><![endif]-->
        <pre wrap="">...or are JIT+CPU smart enough and there would be no difference?
</pre>
        <!--[if !IE]></DIV><![endif]--></blockquote>
      <pre wrap="">C2 always orders things based on profile counts, so there is no
difference.  Your suggestion would be better for interpreted code
and I guess C1 also, so I agree it is worthwhile.

Thanks,
Andrew.

</pre>
      <!--[if !IE]></DIV><![endif]--></blockquote>
    <br>
    What about the following variant (or similar with ifs in case switch
    is sub-optimal):<br>
    <br>
        public final long getLongUnaligned(Object o, long offset) {<br>
            switch ((int) offset & 7) {<br>
                case 1:<br>
                case 5: return<br>
                    (toUnsignedLong(getByte(o, offset)) <<
    pickPos(56, 0)) |<br>
                    (toUnsignedLong(getShort(o, offset + 1)) <<
    pickPos(48, 8)) |<br>
                    (toUnsignedLong(getInt(o, offset + 3)) <<
    pickPos(32, 24)) |<br>
                    (toUnsignedLong(getByte(o, offset + 7)) <<
    pickPos(56, 56));<br>
                case 2:<br>
                case 6: return<br>
                    (toUnsignedLong(getShort(o, offset)) <<
    pickPos(48, 0)) |<br>
                    (toUnsignedLong(getInt(o, offset + 2)) <<
    pickPos(32, 16)) |<br>
                    (toUnsignedLong(getShort(o, offset + 6)) <<
    pickPos(48, 48));<br>
                case 3:<br>
                case 7: return<br>
                    (toUnsignedLong(getByte(o, offset)) <<
    pickPos(56, 0)) |<br>
                    (toUnsignedLong(getInt(o, offset + 1)) <<
    pickPos(32, 8)) |<br>
                    (toUnsignedLong(getShort(o, offset + 5)) <<
    pickPos(48, 40)) |<br>
                    (toUnsignedLong(getByte(o, offset + 7)) <<
    pickPos(56, 56));<br>
                case 4: return<br>
                    (toUnsignedLong(getInt(o, offset)) <<
    pickPos(32, 0)) |<br>
                    (toUnsignedLong(getInt(o, offset + 4)) <<
    pickPos(32, 32));<br>
                case 0: <br>
                default: return<br>
                    getLong(o, offset);<br>
            }<br>
        }<br>
    <br>
    <br>
    ...it may have more branches, but less instructions in average per
    call.<br>
    <br>
    <br>
    <br>
    Peter<br>
    <br>
  </body>
</html>