[PATCH] D154725: [SimplifyLibCalls] Fold strcmp for short string literals

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 8 12:52:04 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:567
+  // Fold strcmp(P, "x"), strcmp(P, "xx")
+  if (HasStr2 && (Str2.size() == 1 || Str2.size() == 2)) {
+    if (Str2.size() == 2) {
----------------
You need to guard this behind isOnlyUsedInComparisonWithZero(), as the exact return value of strcmp() is unspecified (only its relation to zero is).


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

https://reviews.llvm.org/D154725



More information about the llvm-commits mailing list