[PATCH] D50233: [InstCombine] Transform str(n)cmp to memcmp

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 4 13:13:14 PDT 2018


xbolva00 added a comment.

In https://reviews.llvm.org/D50233#1223705, @efriedma wrote:

> > But that also implies that you have to emit an inline implementation since you might not control what the implementation of memcmp supplied by libc does?
>
> Assuming there isn't a data race, the libc implementation of memcmp can't actually do anything undefined.  In assembly, "uninitialized" data always has some fixed value.
>
>  -------------
>
> Given the problems here, we probably want to move this transform to the ExpandMemCmp pass, and only transform when we'll expand the compare inline.


Cannot we just check the conditions of expansion https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/ExpandMemCmp.cpp#L678 and apply it here? We basically miss check for optForSize. So if this transformation passes, memcmp will be expanded too.

Do we guarantee the correctness of programs if a custom opt pipeline is used (eg. disabled ExpandMemCmp, enabled InstCombine pass)?


Repository:
  rL LLVM

https://reviews.llvm.org/D50233





More information about the llvm-commits mailing list