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

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 3 02:22:50 PDT 2018


xbolva00 created this revision.
xbolva00 added a reviewer: efriedma.
Herald added a subscriber: llvm-commits.

Motivation examples:
int strcmp_memcmp() {

  char buf[12];
  return strcmp(buf, "key") == 0;

}

int strcmp_memcmp2() {

  char buf[12];
  return strcmp(buf, "key") != 0;

}

int strncmp_memcmp() {

  char buf[12];
  return strncmp(buf, "key", 3) == 0;

}

can be turned to memcmp.

See test file for more cases.


Repository:
  rL LLVM

https://reviews.llvm.org/D50233

Files:
  lib/Transforms/Utils/SimplifyLibCalls.cpp
  test/Transforms/InstCombine/strcmp-memcmp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50233.158951.patch
Type: text/x-patch
Size: 31146 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180803/fae4bc15/attachment.bin>


More information about the llvm-commits mailing list