Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8267531

[x86] Assembler::andb(Address,Register) encoding is incorrect

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b24

      Description

      Synopsis is provisional. See the attached test.

      $ java -Xint -XX:CompileCommand=quiet -XX:CompileOnly=Test Test > int.out
      $ java -Xcomp -XX:CompileCommand=quiet -XX:CompileOnly=Test Test > comp.out

      $ diff int.out comp.out
      36c36
      < vMeth_check_sum: -3490822255
      ---
      > vMeth_check_sum: -3490822268
      48c48
      < vMeth_check_sum: -4561152040
      ---
      > vMeth_check_sum: -4561152066
      60c60
      < vMeth_check_sum: -5631481825
      ---
      > vMeth_check_sum: -5631481864
      72c72
      < vMeth_check_sum: -6701811610
      ---
      > vMeth_check_sum: -6701811662
      84c84
      < vMeth_check_sum: -7772141395
      ---
      > vMeth_check_sum: -7772141460
      96c96
      < vMeth_check_sum: -8842471180
      ---
      > vMeth_check_sum: -8842471258
      108c108
      < vMeth_check_sum: -9912800965
      ---
      > vMeth_check_sum: -9912801056
      120c120
      < vMeth_check_sum: -10983130750
      ---
      > vMeth_check_sum: -10983130854


      This only happens with C2, and only on recent builds I bisected this failure to JDK-8241502.
      I further bisected to this hunk. Assembler::andb is newly introduced by JDK-8241502.

      // And Memory with Register
      instruct andB_mem_rReg(memory dst, rRegI src, rFlagsReg cr)
      %{
        match(Set dst (StoreB dst (AndI (LoadB dst) src)));
        effect(KILL cr);

        ins_cost(150);
        format %{ "andb $dst, $src\t# byte" %}
      - opcode(0x20);
      - ins_encode(REX_breg_mem(src, dst), OpcP, reg_mem(src, dst));
      + ins_encode %{
      + __ andb($dst$$Address, $src$$Register);
      + %}
        ins_pipe(ialu_mem_reg);
      %}

      Staring closely to its implementation, I think prefix(..., /* is_byte_instr = */ true) is missing:

      diff --git a/src/hotspot/cpu/x86/assembler_x86.cpp b/src/hotspot/cpu/x86/assembler_x86.cpp
      index c5236b35bf4..72629508414 100644
      --- a/src/hotspot/cpu/x86/assembler_x86.cpp
      +++ b/src/hotspot/cpu/x86/assembler_x86.cpp
      @@ -1471,7 +1471,7 @@ void Assembler::vaesenclast(XMMRegister dst, XMMRegister nds, XMMRegister src, i
       
       void Assembler::andb(Address dst, Register src) {
         InstructionMark im(this);
      - prefix(dst, src);
      + prefix(dst, src, true);
         emit_int8(0x20);
         emit_operand(src, dst);
       }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              shade Aleksey Shipilev
              Reporter:
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: