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

Kan Shengchen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 2 19:45:04 PDT 2022


skan added inline comments.


================
Comment at: llvm/test/CodeGen/X86/peephole-na-phys-copy-folding.ll:376
   %cmp = icmp sgt i32 %val, 0
   %res = tail call i32 asm "bsfl $1,$0", "=r,r,~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %val)
   store i32 %res, ptr %mem, align 4
----------------
craig.topper wrote:
> skan wrote:
> > aaronpuchert wrote:
> > > pengfei wrote:
> > > > aaronpuchert wrote:
> > > > > Goes a bit too far I think. We can turn a generic builtin into `rep; bsf`, but if the inline assembly explicitly asks for `bsf` I think we should emit that.
> > > > You are right. So this is to check *no* REP prefix was generated. :)
> > > Sorry, I missed the `-NOT`. But is that needed? After all the `-NEXT` shouldn't match if there is a `rep` in between.
> > > 
> > > If there is a reason to keep this, the second occurrence should likely be `CHECK64` instead of `CHECK32`.
> > I think the two `CHECK-NOT` are redundant here b/c `CHECK-NEXT` can gurantee `#APP` is followed by `bsfl`.
> Doesn't the CHECK-NEXT only guarantee that the next line contains bsfl. It doesn't rule out any text before the bsfl.
I think if there is `rep` between `#APP` and `#NO_APP`, the following check will fail.
```
; CHECK32-NEXT:    #APP
; CHECK32-NEXT:    bsfl %edx, %edx
; CHECK32-NEXT:    #NO_APP
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130956/new/

https://reviews.llvm.org/D130956



More information about the llvm-commits mailing list