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

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 3 12:44:45 PDT 2018


xbolva00 added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:155
+  if (!isOnlyUsedInZeroEqualityComparison(CI))
+    return false;
+
----------------
efriedma wrote:
> Not sure why this check is relevant; memcmp should return the same value as strcmp.
\0 in the middle of string?
https://stackoverflow.com/questions/13095513/what-is-the-difference-between-memcmp-strcmp-and-strncmp-in-c

I think the check is probably right here..


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:164
+  if (ArrSize <= Len)
+    return false;
+  return true;
----------------
efriedma wrote:
> I don't see how this proves anything... just because you have a pointer of type `[N x i8] *` doesn't imply it's actually backed by N bytes of dereferenceable memory.  Please just use llvm::isDereferenceableAndAlignedPointer.
Ok, thanks


https://reviews.llvm.org/D50233





More information about the llvm-commits mailing list