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

C1: Replace "cmp reg, 0" with "test reg, reg" on x86

XMLWordPrintable

    • b15
    • x86

        Noticed this when looking at C1 profiling code. There are plenty of usages for `cmp reg, 0` in C1 x86 code, both in generic `LIR_Assembler::comp_op`, and in some profiling paths.

        `test reg, reg` is a denser idiom for this comparison. The difference between `cmp` and `test` on x86 seems to be only with AF (aux carry flag). For ubiquitous int/pointer comparisons, this distinction is irrelevant. C2 already does this transformation in .ad match rules.

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

                Created:
                Updated:
                Resolved: