[PATCH] D136244: [AArch64] Optimize memcmp when the result is tested for [in]equality with 0

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 24 05:44:44 PDT 2022


dmgreen added a comment.

In D136244#3878647 <https://reviews.llvm.org/D136244#3878647>, @Allen wrote:

> In D136244#3876986 <https://reviews.llvm.org/D136244#3876986>, @dmgreen wrote:
>
>> Could this be done during lowering, int AArch64TargetLowering::LowerSETCC, or does that not work?
>> The getNZCVToSatisfyCondCode method is useful for getting the constant needed for CCMP's.
>
> Thanks for your suggestion, I try to debug the function **br_on_cmp_i128_eq **in file CodeGen/AArch64/i128-cmp.ll, and find that the **setcc **is transform into **br_cc ** in AArch64TargetLowering::LowerOperation
> so I think it can also work in AArch64TargetLowering. Out of intresting, I'd like to know why you recommend processing in the AArch64TargetLowering?

I see. That sounds like a good reason not to do it in Lowering.



================
Comment at: llvm/test/CodeGen/AArch64/i128-cmp.ll:11
+; CHECK-NEXT:    ccmp x1, x3, #0, eq
+; CHECK-NEXT:    cset w0, ne
 ; CHECK-NEXT:    ret
----------------
Allen wrote:
> dmgreen wrote:
> > Are you sure this is correct? It doesn't look right.
> > 
> > I think I would expect `ccmp #0, eq;  cset eq`.
> Yes, I test the executive for the initial case in https://github.com/llvm/llvm-project/issues/58061
How did you test that? Is it the code from https://gcc.godbolt.org/z/Tv1YP6bPc? Could it have been constant-folded away?


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

https://reviews.llvm.org/D136244



More information about the llvm-commits mailing list