[all-commits] [llvm/llvm-project] 5fb67e: [InstCombine] Fold memcmp of constant arrays and v...

Martin Sebor via All-commits all-commits at lists.llvm.org
Fri Jun 17 09:37:23 PDT 2022


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

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

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

The memcmp simplifier is limited to folding to constants calls with constant
arrays and constant sizes.  This change adds the ability to simplify
memcmp(A, B, N) calls with constant A and B and variable N to the pseudocode
equivalent of

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

where Pos is the offset of the first mismatch between A and B.

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




More information about the All-commits mailing list