llvm-6502/lib
Benjamin Kramer b20a8fc8a6 X86: Try to use a smaller encoding by transforming (X << C1) & C2 into (X & (C2 >> C1)) & C1. (Part of PR5039)
This tends to happen a lot with bitfield code generated by clang. A simple example for x86_64 is
uint64_t foo(uint64_t x) { return (x&1) << 42; }
which used to compile into bloated code:
	shlq	$42, %rdi               ## encoding: [0x48,0xc1,0xe7,0x2a]
	movabsq	$4398046511104, %rax    ## encoding: [0x48,0xb8,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00]
	andq	%rdi, %rax              ## encoding: [0x48,0x21,0xf8]
	ret                             ## encoding: [0xc3]

with this patch we can fold the immediate into the and:
	andq	$1, %rdi                ## encoding: [0x48,0x83,0xe7,0x01]
	movq	%rdi, %rax              ## encoding: [0x48,0x89,0xf8]
	shlq	$42, %rax               ## encoding: [0x48,0xc1,0xe0,0x2a]
	ret                             ## encoding: [0xc3]

It's possible to save another byte by using 'andl' instead of 'andq' but I currently see no way of doing
that without making this code even more complicated. See the TODOs in the code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129990 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-22 15:30:40 +00:00
..
Analysis PR9214: Convert Metadata API to use ArrayRef. 2011-04-21 19:59:31 +00:00
Archive
AsmParser PR9214: Convert Metadata API to use ArrayRef. 2011-04-21 19:59:31 +00:00
Bitcode PR9214: Convert Metadata API to use ArrayRef. 2011-04-21 19:59:31 +00:00
CodeGen Typo 2011-04-22 01:40:20 +00:00
CompilerDriver
ExecutionEngine 80-col fix. 2011-04-22 03:07:06 +00:00
Linker
MC Delete the other unused variable in this function. Sorry I missed this 2011-04-22 01:29:18 +00:00
Object Use enums for constant values. 2011-04-22 06:34:01 +00:00
Support Add support for 64-bit object files to Path. 2011-04-22 03:50:19 +00:00
Target X86: Try to use a smaller encoding by transforming (X << C1) & C2 into (X & (C2 >> C1)) & C1. (Part of PR5039) 2011-04-22 15:30:40 +00:00
Transforms PR9214: Convert Metadata API to use ArrayRef. 2011-04-21 19:59:31 +00:00
VMCore PR9214: Convert Metadata API to use ArrayRef. 2011-04-21 19:59:31 +00:00
CMakeLists.txt
Makefile