Reland "[X86][MC] Always emit `rep` prefix for `bsf`"
authorPhoebe Wang <phoebe.wang@intel.com>
Fri, 5 Aug 2022 01:58:34 +0000 (09:58 +0800)
committerPhoebe Wang <phoebe.wang@intel.com>
Fri, 5 Aug 2022 02:22:48 +0000 (10:22 +0800)
commit7f648d27a85a98fa077f0968dea081821627d477
tree45adb59eecb853ba0e80c2ea77b17ca6ca3c1b6a
parentc308a88716422b626e4141e29164ac032ae4ce07
Reland "[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: craig.topper, skan

Differential Revision: https://reviews.llvm.org/D130956
llvm/lib/Target/X86/X86MCInstLower.cpp
llvm/test/CodeGen/X86/clz.ll
llvm/test/CodeGen/X86/peephole-na-phys-copy-folding.ll
llvm/test/CodeGen/X86/stack-folding-x86_64.ll