[all-commits] [llvm/llvm-project] e263a7: [InstCombine] Look through more casts when folding...

Martin Sebor via All-commits all-commits at lists.llvm.org
Tue Jun 28 15:00:04 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e263a7670e28d880ec45971f91fa88de01fc51e1
      https://github.com/llvm/llvm-project/commit/e263a7670e28d880ec45971f91fa88de01fc51e1
  Author: Martin Sebor <msebor at redhat.com>
  Date:   2022-06-28 (Tue, 28 Jun 2022)

  Changed paths:
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
    A llvm/test/Transforms/InstCombine/memchr-10.ll
    A llvm/test/Transforms/InstCombine/memchr-9.ll
    A llvm/test/Transforms/InstCombine/memcmp-7.ll
    A llvm/test/Transforms/InstCombine/memcmp-8.ll
    A llvm/test/Transforms/InstCombine/memrchr-7.ll
    M llvm/test/Transforms/InstCombine/str-int-3.ll
    A llvm/test/Transforms/InstCombine/strcall-no-nul.ll
    A llvm/test/Transforms/InstCombine/strlen-9.ll
    M llvm/test/Transforms/InstCombine/strnlen-1.ll
    M llvm/test/Transforms/InstCombine/wcslen-1.ll

  Log Message:
  -----------
  [InstCombine] Look through more casts when folding memchr and memcmp

Enhance getConstantDataArrayInfo to let the memchr and memcmp library
call folders look through arbitrarily long sequences of bitcast and
GEP instructions.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D128364


  Commit: 8827679826b82753fcf6e8a827a127c384f1a93e
      https://github.com/llvm/llvm-project/commit/8827679826b82753fcf6e8a827a127c384f1a93e
  Author: Martin Sebor <msebor at redhat.com>
  Date:   2022-06-28 (Tue, 28 Jun 2022)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
    M llvm/test/Transforms/InstCombine/memcmp-4.ll
    A llvm/test/Transforms/InstCombine/strncmp-5.ll
    A llvm/test/Transforms/InstCombine/strncmp-6.ll

  Log Message:
  -----------
  [InstCombine] Fold strncmp of constant arrays and variable size

Extend the solution accepted in D127766 to strncmp and simplify
strncmp(A, B, N) calls with constant A and B and variable N to
the equivalent of

  N <= Pos ? 0 : (A < B ? -1 : B < A ? +1 : 0)

where Pos is the offset of either the first mismatch between A
and B or the terminating null character if both A and B are equal
strings.

Reviewed By: courbet

Differential Revision: https://reviews.llvm.org/D128089


Compare: https://github.com/llvm/llvm-project/compare/a145a32544a8...8827679826b8


More information about the All-commits mailing list