Commit Graph

43859 Commits

Author SHA1 Message Date
Chris Lattner
96908b17ae generalize the previous check to handle -1 on either side of the
select, inserting a not to compensate.  Add a missing isZero check
that I lost somehow.

This improves codegen of:

void *func(long count) {
      return new int[count];
}

from:

__Z4funcl:                              ## @_Z4funcl
	movl	$4, %ecx                ## encoding: [0xb9,0x04,0x00,0x00,0x00]
	movq	%rdi, %rax              ## encoding: [0x48,0x89,0xf8]
	mulq	%rcx                    ## encoding: [0x48,0xf7,0xe1]
	testq	%rdx, %rdx              ## encoding: [0x48,0x85,0xd2]
	movq	$-1, %rdi               ## encoding: [0x48,0xc7,0xc7,0xff,0xff,0xff,0xff]
	cmoveq	%rax, %rdi              ## encoding: [0x48,0x0f,0x44,0xf8]
	jmp	__Znam                  ## TAILCALL
                                        ## encoding: [0xeb,A]

to:

__Z4funcl:                              ## @_Z4funcl
	movl	$4, %ecx                ## encoding: [0xb9,0x04,0x00,0x00,0x00]
	movq	%rdi, %rax              ## encoding: [0x48,0x89,0xf8]
	mulq	%rcx                    ## encoding: [0x48,0xf7,0xe1]
	cmpq	$1, %rdx                ## encoding: [0x48,0x83,0xfa,0x01]
	sbbq	%rdi, %rdi              ## encoding: [0x48,0x19,0xff]
	notq	%rdi                    ## encoding: [0x48,0xf7,0xd7]
	orq	%rax, %rdi              ## encoding: [0x48,0x09,0xc7]
	jmp	__Znam                  ## TAILCALL
                                        ## encoding: [0xeb,A]



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120932 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-05 02:00:51 +00:00
Chris Lattner
a2b5600e61 Improve an integer select optimization in two ways:
1. generalize 
    (select (x == 0), -1, 0) -> (sign_bit (x - 1))
to:
    (select (x == 0), -1, y) -> (sign_bit (x - 1)) | y

2. Handle the identical pattern that happens with !=:
   (select (x != 0), y, -1) -> (sign_bit (x - 1)) | y

cmov is often high latency and can't fold immediates or
memory operands.  For example for (x == 0) ? -1 : 1, before 
we got:

< 	testb	%sil, %sil
< 	movl	$-1, %ecx
< 	movl	$1, %eax
< 	cmovel	%ecx, %eax

now we get:

> 	cmpb	$1, %sil
> 	sbbl	%eax, %eax
> 	orl	$1, %eax




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120929 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-05 01:23:24 +00:00
Bill Wendling
d643486058 Initialize HasPOPCNT.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120923 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 23:57:24 +00:00
Rafael Espindola
b4172fa729 Once the layout is done we don't need to keep updating which fragments are
valid. Addresses will not change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120921 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 22:47:22 +00:00
Rafael Espindola
db74aeadcd Remember the contents of leb and dwarfline fragments when relaxing. This avoids
having to evaluate the expression again when writing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120920 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 21:58:52 +00:00
Cameron Zwarich
2a7942926b Remove PHIElimination's private copy of SkipPHIsAndLabels.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120918 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 20:40:15 +00:00
Benjamin Kramer
1292c22645 Add patterns for the x86 popcnt instruction.
- Also adds a new POPCNT subtarget feature that is currently enabled if the target
  supports SSE4.2 (nehalem) or SSE4A (barcelona).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120917 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 20:32:23 +00:00
Bill Wendling
a6091be84c Silence 'may be used uninitialized in this function' warnings. Static analysis
may determine that they cannot be used uninitialized. But that might be a bit
too much for the compiler to determine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120916 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 20:20:34 +00:00
Michael J. Spencer
9d425e7687 Support/PathV2: Remove redundant calls to make_error_code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120913 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 18:45:32 +00:00
Benjamin Kramer
fd6d53fbad APInt: microoptimize a few methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120912 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 18:05:36 +00:00
Benjamin Kramer
3069cbf7b3 Remove unneeded zero arrays.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120910 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 15:28:22 +00:00
Benjamin Kramer
299ee184f4 Apparently APFloat::getZero doesn't like PPCDoubleDoubles.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120909 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 14:43:08 +00:00
Benjamin Kramer
983839609f Simplify code. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120907 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 14:22:24 +00:00
Bob Wilson
c24130bade The Thumb tADDrSPi instruction is not valid when the destination is SP.
Check for that and try narrowing it to tADDspi instead.  Radar 8724703.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120892 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 04:40:19 +00:00
Rafael Espindola
5d4918dbd1 There are two reasons why we might want to use
foo = a - b
.long foo
instead of just
.long a - b

First, on darwin9 64 bits the assembler produces the wrong result. Second,
if "a" is the end of the section all darwin assemblers (9, 10 and mc) will not
consider a - b to be a constant but will if the dummy foo is created.

Split how we handle these cases. The first one is something MC should take care
of. The second one has to be handled by the caller.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120889 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 03:21:47 +00:00
Michael J. Spencer
470ae13be8 Support/FileSystem: Add status implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120870 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 00:32:40 +00:00
Michael J. Spencer
4958466f9f Support/Windows/FileSystem: Fix MinGW warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120868 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 00:32:14 +00:00
Michael J. Spencer
01a87c413d Support/FileSystem: Add file_size implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120867 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 00:31:48 +00:00
Rafael Espindola
767b1be390 Next step: Only pad debug_line when the target is darwin. Add a FIXME to avoid
doing that if the target is darwin10 or newer.

This fixes
*) Direct object emission was producing objects without the workaround on
   darwin9.
*) Assembly printing was producing objects with the workaround on linux.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120866 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 00:31:13 +00:00
Jim Grosbach
ceab50198e Encode condition code for Thumb1 conditional branch instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120865 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-04 00:20:40 +00:00
Jim Grosbach
ed09087dd3 Correctly size-reduce the t2CMPzrr instruction to tCMPzr when possible.
tCMPzhir has undefined behavior when both source registers are low registers.
rdar://8728577

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120858 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 23:54:18 +00:00
Bill Wendling
fb62d550de Use correct variable names to match the patterns.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120857 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 23:44:24 +00:00
Jakob Stoklund Olesen
5b3f779f33 Also inore '()' while creating mdnode name from ObjC symbol name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120856 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 23:40:45 +00:00
Rafael Espindola
a8de83c68a First step in fixing MC. Make it clear that we are avoiding a bug in the
darwin9 linker, what is needed to avoid it and where to get more information.

Also make the workaround simpler. Just the regular end_sequence we normally
create is more than 4 bytes.

Tested by building cctools and ld64 from darwin9 on a darwin10 system and using
those. I checked that I was able to reproduce the bootstrap failure when
the the workaround was disabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120854 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 23:36:59 +00:00
Devang Patel
ddb85acdbe Ignore '+' while creating mdnode name from ObjC symbol name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120853 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 23:29:30 +00:00
Jim Grosbach
1b555d9f96 Match pattern operand names to expected encoding field names. This corrects the
operand encoding ordering of the instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120852 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 23:21:25 +00:00
Jim Grosbach
4fa102b84e Remove incorrect BL target encoding (it's similar to, but not the same as the
ARM instruction). Add encoding of bits 13 and 11.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120849 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 22:33:42 +00:00
Jim Grosbach
d91f4e40e6 Encode the 32-bit wide Thumb (and Thumb2) instructions with the high order
halfword being emitted to the stream first. rdar://8728174

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120848 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 22:31:40 +00:00
Nate Begeman
5812b10adb Revert this change since it breaks a couple of the AVX tests.
I'm unclear if the tests are actually correct or not, but reverting for now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120847 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 22:29:15 +00:00
Jakob Stoklund Olesen
6ed4c6af97 Rename virtRegMap to avoid confusion with the VirtRegMap that it isn't.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120846 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 22:25:09 +00:00
Jakob Stoklund Olesen
5daec2215b Coalesce debug locations when possible, causing less DBG_VALUE instructions to
be emitted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120845 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 22:25:07 +00:00
Nate Begeman
07c21d85b4 Scalar f32/f64 are also subregs of ymm regs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120844 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 21:54:39 +00:00
Nate Begeman
163e83d69a Remove SSE1-4 disable when AVX is enabled. While this may be useful for development,
it completely breaks scalar fp in xmm regs when AVX is enabled.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120843 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 21:54:14 +00:00
Jakob Stoklund Olesen
42acf069c9 Emit DBG_VALUE instructions from LiveDebugVariables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120842 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 21:47:10 +00:00
Jakob Stoklund Olesen
8d2584a1d9 Also update virtRegMap when renaming virtual registers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120841 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 21:47:08 +00:00
Jim Grosbach
41ad0c4c73 When using the 'push' mnemonic for Thumb2 stmdb, be explicit when it's the
32-bit wide version by adding the .w suffix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120838 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 20:33:01 +00:00
Benjamin Kramer
b3a04d46e8 Remove unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120836 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 19:55:37 +00:00
Jim Grosbach
6e57298127 Reduce t2 ldr/str instructions to the correct t1 versions when there's an
immediate offset.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120833 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 19:47:11 +00:00
Jason W Kim
2ccf148fba fix ARM::fixup_arm_branch, cleanup, and share more code between ELF and Darwin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120832 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 19:40:23 +00:00
Jim Grosbach
0b951ceb02 No need to declare EncoderMethod property anymore; just assign to it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120831 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 19:31:00 +00:00
Jakob Stoklund Olesen
68be956fff Delete the StrongPHIElimination pass, leaving only a shell.
The StrongPHIElimination pass did not work, and nobody has worked on it for two
years.

A rewrite is underway, so I am leaving this shell pass instead of deleting it
completely.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120830 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 19:21:53 +00:00
Jakob Stoklund Olesen
7a26aca73f Add IntervalMap::iterator::set{Start,Stop,Value} methods that allow limited
editing of the current interval.

These methods may cause coalescing, there are corresponding set*Unchecked
methods for editing without coalescing. The non-coalescing methods are useful
for applying monotonic transforms to all keys or values in a map without
accidentally coalescing transformed and untransformed intervals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120829 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 19:02:00 +00:00
Michael J. Spencer
b531f45a9d Support/FileSystem: Add equivalent implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120827 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 18:49:13 +00:00
Michael J. Spencer
db04b39dad Support/FileSystem: Fix MinGW build. It doesn't have _chsize_s.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120826 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 18:48:56 +00:00
Jim Grosbach
d253545c17 Add FIXMEs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120824 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 18:37:17 +00:00
Jim Grosbach
2c971ab9d9 Size reduction for tPUSH come from t2STMDB_UPD, not t2STMIA_UPD.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120822 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 18:31:03 +00:00
Michael J. Spencer
b39e33f39b And I really hate line endings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120821 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 18:04:11 +00:00
Michael J. Spencer
af45fc005b Support/Windows/FileSystem: Fix MinGW build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120820 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 18:03:28 +00:00
Michael J. Spencer
3920d3b4f4 Support/FileSystem: Add resize_file implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120819 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 17:54:07 +00:00
Michael J. Spencer
a50b98c517 Support/FileSystem: Add rename implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120818 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-03 17:53:55 +00:00