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

Maksim Kita via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 03:46:11 PDT 2023


kitaisreal added inline comments.


================
Comment at: llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp:920
+
+  bool Match = !HasStr1 && HasStr2 && Str2.size() == 1;
+  if (!Match)
----------------
xbolva00 wrote:
> GCC I think “inlines “ strcmp up to some  length, but not strictly 1, no?
> 
> Also it can inline (expand) strcmp calls if we know that src/dst are dereferenceable with known size. 
It expands strcmp if size is 1 or 2 https://godbolt.org/z/jhbToh5Kb.
I plan to add case for string with size 2 in separate patch, because control flow becomes more complicated and it will make patch harder to review.


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

https://reviews.llvm.org/D154725



More information about the llvm-commits mailing list