[PATCH] D131260: [DAG] select Cond, -1, C --> or (sext Cond), C if Cond is MVT::i1

Amaury SECHET via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 7 19:05:15 PDT 2022


deadalnix added inline comments.


================
Comment at: llvm/test/CodeGen/X86/memcmp.ll:371
 ; X64-NEXT:    xorl %eax, %eax
 ; X64-NEXT:    cmpl %edx, %ecx
+; X64-NEXT:    sbbl %eax, %eax
----------------
pengfei wrote:
> deadalnix wrote:
> > In both cases here, `cmpl %edx, %ecx` seems to be recomputed for no reason (?) It seems to be able to reuse `cmpl %ecx, %eax` in length5 and `cmpw %dx, %cx` in length3, at least before this diff.
> > 
> > Is there a reason why this isn't the case here? I'm not quite sure how memcmp is being lowered, and `-debug` really isn't useful here. @gchatelet , you were looking for ways to improve memcmp, I think there is a low hanging fruit somewhere in there.
> `xor` will change EFLAGS, so we need to recomputed to get the correct EFLAGS.
Sure, but the xor itself doesn't seem necessary. For instance, length5 does:
  setae %al
  movzbl %al, %eax

Which does away witth he need for the xor, with in turn does away with the need to recompute the cmpl. Both function do the same thing in that block, there is no reason to have different codegen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131260



More information about the llvm-commits mailing list