[PATCH] D130956: [X86][MC] Always emit `rep` prefix for `bsf`

Phoebe Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 1 19:02:27 PDT 2022


pengfei created this revision.
pengfei added reviewers: nikic, RKSimon, craig.topper, skan.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
pengfei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

`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

Suggested by Linus in #56789


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130956

Files:
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/test/MC/X86/I386-32.s
  llvm/test/MC/X86/I386-64.s
  llvm/test/MC/X86/x86-32-coverage.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130956.449166.patch
Type: text/x-patch
Size: 4337 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220802/093507fc/attachment.bin>


More information about the llvm-commits mailing list