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

x86: Memory-operand arithmetic instructions have too low costs

    XMLWordPrintable

Details

    • b16
    • x86

    Description

      Arithmetic nodes with memory operands are assigned costs which are too low, which results in patterns like AddI(LoadI ConI) being matched into a constant load and an add with a memory operand instead of a memory load and an add with immediate.

      For example, this function

      public class Sample {
          int loadInt;

          public int testInt() {
              return loadInt + 100;
          }
      }

      results in compiled code:

      movl $0x64, %eax
      addl 0xc(%rsi), %eax

      while the desired output should be:

      movl 0xc(%rsi), %eax
      addl $0x64, %eax

      Also, we can do some small clean-ups in x86_64.ad:

      - The mulHiL rules have unnecessary constraints on the input registers, these can be removed. The no_rax_RegL operand as a consequence can also be removed.
      - The rules involving long division by a constant can be removed because it has been covered by the optimiser during idealisation.
      - The pattern SubI src imm and the likes never match because they are converted to AddI src -imm by the optimiser. As a result, these rules can be removed
      - The rules involving shifting the argument by 1 are covered by and exactly the same as the corresponding rules of shifting by an immediate. As a result, they can be removed.
      - Some rules involving and-ing with a bit mask have unnecessary constraints on the target register.

      Attachments

        Issue Links

          Activity

            People

              qamai Quan Anh Mai
              qamai Quan Anh Mai
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: