[PATCH] D128089: [InstCombine] Fold strncmp of constant arrays and variable size
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 21 01:12:50 PDT 2022
nikic added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:1173
+ if (Pos == MinSize ||
+ (StrNCmp && (LStr[Pos] == '\0' && RStr[Pos] == '\0'))) {
+ // One array is a leading part of the other of equal or greater
----------------
Not really sure why the change in code structure is needed. As far as I can tell, the only thing that's actually changing here is that a
```
if (StrNCmp && (LStr[Pos] == '\0' && RStr[Pos] == '\0'))
break;
```
condition gets added to the top of the loop body? Or am I misunderstanding something here?
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:1181
+ Pos = UINT64_MAX;
+ break;
+ }
----------------
Can just `return Zero` here?
================
Comment at: llvm/test/Transforms/InstCombine/strncmp-5.ll:94
+
+; Vefify that a strncmp() call involving a constant array with unknown
+; contents is not folded.
----------------
Verify
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128089/new/
https://reviews.llvm.org/D128089
More information about the llvm-commits
mailing list