llvm-6502/test
Benjamin Kramer fd48a80e14 [SimplifyLibCalls] Turn memchr(const, C, const) into a bitfield check.
strchr("123!", C) != nullptr is a common pattern to check if C is one
of 1, 2, 3 or !. If the largest element of the string is smaller than
the target's register size we can easily create a bitfield and just
do a simple test for set membership.

int foo(char C) { return strchr("123!", C) != nullptr; } now becomes

	cmpl	$64, %edi ## range check
	sbbb	%al, %al
	movabsq	$0xE000200000001, %rcx
	btq	%rdi, %rcx ## bit test
	sbbb	%cl, %cl
	andb	%al, %cl ## and the two conditions
	andb	$1, %cl
	movzbl	%cl, %eax ## returning an int
	ret

(imho the backend should expand this into a series of branches, but
that's a different story)

The code is currently limited to bit fields that fit in a register, so
usually 64 or 32 bits. Sadly, this misses anything using alpha chars
or {}. This could be fixed by just emitting a i128 bit field, but that
can generate really ugly code so we have to find a better way. To some
degree this is also recreating switch lowering logic, but we can't
simply emit a switch instruction and thus change the CFG within
instcombine.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232902 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-21 21:09:33 +00:00
..
Analysis When simplifying a SCEV truncate by distributing, consider it a simplification to replace a cast, even if we end up with a trunc around the term. Fixes PR22960! 2015-03-20 02:25:00 +00:00
Assembler
Bindings
Bitcode
BugPoint Bugpoint: Fix invalid 'inlinedAt:' references in testcase 2015-03-20 19:51:34 +00:00
CodeGen R600: Cleanup test with multiple check prefixes 2015-03-21 19:15:46 +00:00
DebugInfo Don't declare all text sections at the start of the .s 2015-03-20 20:00:01 +00:00
ExecutionEngine
Feature Rewrite test/Feature/md_on_instruction.ll 2015-03-20 18:34:53 +00:00
FileCheck
Instrumentation [sanitizer] experimental tracing for cmp instructions 2015-03-21 01:29:36 +00:00
Integer
JitListener
Linker
LTO
MC Reorganize the x86 ELF relocation selection logic. 2015-03-20 19:48:54 +00:00
Object
Other
SymbolRewriter
TableGen
tools test: Make a start on a test suite for libLTO. 2015-03-19 23:55:38 +00:00
Transforms [SimplifyLibCalls] Turn memchr(const, C, const) into a bitfield check. 2015-03-21 21:09:33 +00:00
Unit
Verifier Verifier: Check that !dbg attachments have the right type 2015-03-20 19:26:58 +00:00
YAMLParser
.clang-format
CMakeLists.txt test: Make a start on a test suite for libLTO. 2015-03-19 23:55:38 +00:00
lit.cfg Tell lit.cfg about more Windows triples. 2015-03-20 22:08:40 +00:00
lit.site.cfg.in test: Make a start on a test suite for libLTO. 2015-03-19 23:55:38 +00:00
Makefile test: Make a start on a test suite for libLTO. 2015-03-19 23:55:38 +00:00
Makefile.tests
TestRunner.sh