[InstCombine] Look through more casts when folding memchr and memcmp
authorMartin Sebor <msebor@redhat.com>
Tue, 28 Jun 2022 21:04:26 +0000 (15:04 -0600)
committerMartin Sebor <msebor@redhat.com>
Tue, 28 Jun 2022 21:58:42 +0000 (15:58 -0600)
commite263a7670e28d880ec45971f91fa88de01fc51e1
treeb70459718d8690409cc62b981280430317b9b697
parenta145a32544a8d04864d9f392e71887f8609206c2
[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
12 files changed:
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/memchr-10.ll [new file with mode: 0644]
llvm/test/Transforms/InstCombine/memchr-9.ll [new file with mode: 0644]
llvm/test/Transforms/InstCombine/memcmp-7.ll [new file with mode: 0644]
llvm/test/Transforms/InstCombine/memcmp-8.ll [new file with mode: 0644]
llvm/test/Transforms/InstCombine/memrchr-7.ll [new file with mode: 0644]
llvm/test/Transforms/InstCombine/str-int-3.ll
llvm/test/Transforms/InstCombine/strcall-no-nul.ll [new file with mode: 0644]
llvm/test/Transforms/InstCombine/strlen-9.ll [new file with mode: 0644]
llvm/test/Transforms/InstCombine/strnlen-1.ll
llvm/test/Transforms/InstCombine/wcslen-1.ll