[all-commits] [llvm/llvm-project] c2066d: [X86][MC] Always emit `rep` prefix for `bsf`

Phoebe Wang via All-commits all-commits at lists.llvm.org
Wed Aug 3 02:09:56 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c2066d19cda20d0e98b95da1493e6c3f26fd9618
  Author: Phoebe Wang <phoebe.wang at intel.com>
  Date:   2022-08-03 (Wed, 03 Aug 2022)

  Changed paths:
    M llvm/lib/Target/X86/X86MCInstLower.cpp
    M llvm/test/CodeGen/X86/clz.ll
    M llvm/test/CodeGen/X86/dagcombine-select.ll
    M llvm/test/CodeGen/X86/peephole-na-phys-copy-folding.ll
    M llvm/test/CodeGen/X86/stack-folding-x86_64.ll

  Log Message:
  [X86][MC] Always emit `rep` prefix for `bsf`

`BMI` new instruction `tzcnt` has better performance than `bsf` on new
processors. Its encoding has a mandatory prefix '0xf3' compared to
`bsf`. If we force emit `rep` prefix for `bsf`, we will gain better
performance when the same code run on new processors.

GCC has already done this way: https://c.godbolt.org/z/6xere6fs1

Fixes #34191

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D130956

More information about the All-commits mailing list