Commit Graph

104188 Commits

Author SHA1 Message Date
Chris Lattner 48f75ad678 while we're at it, handle 'sdiv exact' of a power of 2 also,
this fixes a few rejects on c++ iterator loops.

llvm-svn: 129694
2011-04-18 07:00:40 +00:00
Chris Lattner 562d6e82bd fix rdar://9297011 - udiv by power of two causing fast-isel rejects
llvm-svn: 129693
2011-04-18 06:55:51 +00:00
Chris Lattner 80254a53cc Add a new bit that ImmLeaf's can opt into, which allows them to duck out of
the generated FastISel.  X86 doesn't need to generate code to match ADD16ri8 
since ADD16ri will do just fine.  This is a small codesize win in the generated
instruction selector.

llvm-svn: 129692
2011-04-18 06:36:55 +00:00
Chris Lattner 07add49a4b Implement major new fastisel functionality: the matcher can now handle immediates with
value constraints on them (when defined as ImmLeaf's).  This is particularly important
for X86-64, where almost all reg/imm instructions take a i64immSExt32 immediate operand,
which has a value constraint.  Before this patch we ended up iseling the examples into
such amazing code as:

	movabsq	$7, %rax
	imulq	%rax, %rdi
	movq	%rdi, %rax
	ret

now we produce:

	imulq	$7, %rdi, %rax
	ret

This dramatically shrinks the generated code at -O0 on x86-64.

llvm-svn: 129691
2011-04-18 06:22:33 +00:00
Chris Lattner 353fda159d relax this test to just check that the lock prefix is encoded properly,
and to not rely on the register allocator's arbitrary operand choices.

llvm-svn: 129690
2011-04-18 06:15:35 +00:00
Eli Friedman 3f8ecf5cc5 Revert r129688; it's breaking buildbots.
llvm-svn: 129689
2011-04-18 05:54:54 +00:00
Eli Friedman 2dc287a147 More malloc elimination: it's a bad idea to use raw_svector_ostream on a
small heap-allocated SmallString because it unconditionally forces a malloc.

llvm-svn: 129688
2011-04-18 05:38:58 +00:00
Eli Friedman 0e40208d7b Make the StringMaps attached to MCContext use the MCContext's allocator;
reduces the number of calls to malloc().

llvm-svn: 129687
2011-04-18 05:02:31 +00:00
Anders Carlsson 73a559fe93 Use an empty ArrayRef instead of an empty std::vector for the Function::get overload that takes no parameters.
llvm-svn: 129686
2011-04-18 04:55:06 +00:00
NAKAMURA Takumi 6483513a6d docs: Redefine Heading elements as below;
H1 ... Title (and might be Chapter in future)
H2 ... Section
H3 ... Subsection
H4 ... Sub-subsection

llvm-svn: 129683
2011-04-18 01:17:51 +00:00
Anders Carlsson 940f02d248 Clean up code generation of typeid expressions and add C++ standard references.
llvm-svn: 129682
2011-04-18 00:57:03 +00:00
Anders Carlsson ce758c1d27 Put a typeid test in its own namespace.
llvm-svn: 129681
2011-04-17 23:33:40 +00:00
Chris Lattner 722f0ccdf9 introduce a new OpKind abstraction which wraps up operand flavors in a tidy little wrapper.
No functionality change.

llvm-svn: 129680
2011-04-17 23:29:05 +00:00
Chris Lattner 97bbee2fb4 Fix a miscompilation I introduced in r129652, thanks for Eli for tracking
it down.  we effectively were compile the testcase into:

void test14(int x) {
  switch (x) {
    case 11: break;
    case 42: test14(97);  // fallthrough
    default: test14(42); break;

which is not the same thing at all.  This fixes a miscompilation of 
MallocBench/gs seen on the clang-x86_64-linux-fnt buildbot.

llvm-svn: 129679
2011-04-17 23:21:26 +00:00
Chris Lattner 9080391b55 change OperandsSignature to use SmallVector<char> instead of std::vector<string>
since the strings are always exactly one character, and there are usually only 2-3 operands.

llvm-svn: 129678
2011-04-17 22:24:13 +00:00
Chris Lattner 0d7a5a7daa since the VT is fixed for a ImmLeaf, there is no reason to expose it to the matching code.
llvm-svn: 129677
2011-04-17 22:17:27 +00:00
Chris Lattner c479e0631f switch the rest of the x86 immediate patterns over to ImmLeaf,
simplifying them and exposing more information to tblgen.  It would be nice
if other target authors adopted this as well, particularly arm since it has fastisel.

llvm-svn: 129676
2011-04-17 22:12:55 +00:00
Chris Lattner 2ff8c1a25f now that predicates have a decent abstraction layer on them, introduce a new
kind of predicate: one that is specific to imm nodes.  The predicate function
specified here just checks an int64_t directly instead of messing around with
SDNode's.  The virtue of this is that it means that fastisel and other things
can reason about these predicates.

llvm-svn: 129675
2011-04-17 22:05:17 +00:00
Anders Carlsson 02feb58dd7 Use the right type name.
llvm-svn: 129674
2011-04-17 21:57:29 +00:00
Anders Carlsson fcaaa697ec When laying out bases in, always try the "base subobject" LLVM type. If it
turns out that a field or base needs to be laid out in the tail padding of
the base, CGRecordLayoutBuilder::ResizeLastBaseFieldIfNecessary will convert
it to an array of i8.

I've audited the new test results to make sure that they are still valid. I've
also verified that we pass a self-host with this change.

This (finally) fixes PR5589!

llvm-svn: 129673
2011-04-17 21:56:13 +00:00
Anders Carlsson 2caf2074fd Cleanup tests, no functionality change.
llvm-svn: 129672
2011-04-17 21:49:47 +00:00
Anders Carlsson 56c4d80a4e Add addBaseSubobjectTypeName which isn't used yet.
llvm-svn: 129671
2011-04-17 21:40:34 +00:00
Chris Lattner 514e292b72 Rework our internal representation of node predicates to expose more
structure and fix some fixmes.  We now have a TreePredicateFn class
that handles all of the decoding of these things.  This is an internal
cleanup that has no impact on the code generated by tblgen.

llvm-svn: 129670
2011-04-17 21:38:24 +00:00
Anders Carlsson c58f8cb7fc Move code to add a type name to a TagDecl type out into a helper function. No functionality change.
llvm-svn: 129669
2011-04-17 21:36:59 +00:00
Chris Lattner 4604bddc07 remove some debugging code I added.
llvm-svn: 129668
2011-04-17 21:36:19 +00:00
Anders Carlsson b6d31e7dcc Use a SmallVector for field types in CGRecordLayoutBuilder now that llvm::StructType::get takes an ArrayRef.
llvm-svn: 129667
2011-04-17 21:32:41 +00:00
Chris Lattner b53ccb8e36 1. merge fast-isel-shift-imm.ll into fast-isel-x86-64.ll
2. implement rdar://9289501 - fast isel should fold trivial multiplies to shifts
3. teach tblgen to handle shift immediates that are different sizes than the 
   shifted operands, eliminating some code from the X86 fast isel backend.
4. Have FastISel::SelectBinaryOp use (the poorly named) FastEmit_ri_ function
   instead of FastEmit_ri to simplify code.

llvm-svn: 129666
2011-04-17 20:23:29 +00:00
Michael J. Spencer a9e4117991 Make -mno-mmx imply -mno-3dnow. This is what gcc does, and it makes sense.
Also, fold the sse4 and sse4.1 cases together.

Patch by Alexander Best!

llvm-svn: 129665
2011-04-17 19:22:03 +00:00
Chris Lattner eb729d48ff fix an x86 fast isel issue where we'd completely give up on folding an address
when we have a global variable base an an index.  Instead, just give up on
folding the global variable.

Before we'd geenrate:

_test:                                  ## @test
## BB#0:
	movq	_rtx_length@GOTPCREL(%rip), %rax
	leaq	(%rax), %rax
	addq	%rdi, %rax
	movzbl	(%rax), %eax
	ret

now we generate:

_test:                                  ## @test
## BB#0:
	movq	_rtx_length@GOTPCREL(%rip), %rax
	movzbl	(%rax,%rdi), %eax
	ret

The difference is even more significant when there is a scale
involved.

This fixes rdar://9289558 - total fail with addr mode formation at -O0/x86-64

llvm-svn: 129664
2011-04-17 17:47:38 +00:00
Chris Lattner 4832660b4d fix an oversight which caused us to compile the testcase (and other
less trivial things) into a dummy lea.  Before we generated:

_test:                                  ## @test
	movq	_G@GOTPCREL(%rip), %rax
	leaq	(%rax), %rax
	ret

now we produce:

_test:                                  ## @test
	movq	_G@GOTPCREL(%rip), %rax
	ret

This is part of rdar://9289558

llvm-svn: 129662
2011-04-17 17:12:08 +00:00
Chris Lattner 4b026b962a tidy up and reduce indentation.
llvm-svn: 129661
2011-04-17 17:05:12 +00:00
Chris Lattner 38b6057a93 when assertions are disabled, labels go away. Hopefully fixes the windows build.
llvm-svn: 129660
2011-04-17 16:19:57 +00:00
Eli Friedman 2e2ff8894d Hack to turn the valgrind buildbot green, until Devang can address it
properly.

llvm-svn: 129657
2011-04-17 06:40:15 +00:00
Chris Lattner 045c43855c Fix rdar://9289512 - not folding load into compare at -O0
The basic issue here is that bottom-up isel is matching the branch
and compare, and was failing to fold the load into the branch/compare
combo.  Fixing this (by allowing folding into any instruction of a
sequence that is selected) allows us to produce things like:


cmpb    $0, 52(%rax)
je      LBB4_2

instead of:

movb    52(%rax), %cl
cmpb    $0, %cl
je      LBB4_2

This makes the generated -O0 code run a bit faster, but also speeds up
compile time by putting less pressure on the register allocator and 
generating less code.

This was one of the biggest classes of missing load folding.  Implementing
this shrinks 176.gcc's c-decl.s (as a random example) by about 4% in (verbose-asm)
line count.

llvm-svn: 129656
2011-04-17 06:35:44 +00:00
Chris Lattner d70ff0d807 split a complex predicate out to a helper function. Simplify two for loops,
which don't need to check for falling off the end of a block *and* end of phi
nodes, since terminators are never phis.

llvm-svn: 129655
2011-04-17 06:03:19 +00:00
Eli Friedman 55f7bf3289 Remove working entry from README.
llvm-svn: 129654
2011-04-17 02:36:27 +00:00
Chris Lattner fba7ca63cc fix rdar://9289583 - fast isel should handle non-canonical commutative binops
allowing us to fold the immediate into the 'and' in this case:

int test1(int i) {
  return 8&i;
}

llvm-svn: 129653
2011-04-17 01:16:47 +00:00
Chris Lattner bc204c8043 implement rdar://9289524 - case followed immediately by break results in empty IR block,
a -O0 code quality issue.

llvm-svn: 129652
2011-04-17 00:54:30 +00:00
Chris Lattner 30107ed600 fold memcpy/set/move_chk to llvm.memcpy/set/move when the sizes
are trivial.  This exposes opportunities earlier, and allows fastisel
to do good things with these at -O0.

This addresses rdar://9289468 - clang doesn't fold memset_chk at -O0

llvm-svn: 129651
2011-04-17 00:40:24 +00:00
Eli Friedman 55b0acd624 PR9055: extend the fix to PR4050 (r70179) to apply to zext and anyext.
Returning a new node makes the code try to replace the old node, which
in the included testcase is killed by CSE.

llvm-svn: 129650
2011-04-16 23:25:34 +00:00
Chris Lattner 56784f9de6 fix rdar://9289603 - clang should fold trivial ?: for enums as well as integer constants into select at -O0
by making the isCheapEnoughToEvaluateUnconditionally predicate handle anything that folds to a constant.  In particular, we now fold enums.

llvm-svn: 129649
2011-04-16 23:15:35 +00:00
Frits van Bommel d6d4f987b4 Rename a misleadingly-named variable.
llvm-svn: 129644
2011-04-16 14:32:34 +00:00
Frits van Bommel d097212a08 Add test cases for Jay's r129641 and fix a 32-bit-centric testcase in a file with a 64-bit datalayout.
llvm-svn: 129643
2011-04-16 14:31:50 +00:00
Francois Pichet beb17d9359 Unbreak the MSVC 2010 build.
For further information on this particular issue see: http://connect.microsoft.com/VisualStudio/feedback/details/520043/error-converting-from-null-to-a-pointer-type-in-std-pair

llvm-svn: 129642
2011-04-16 14:20:39 +00:00
Jay Foad 7d03e9be47 Fix bug when checking phi operands in InstCombiner::visitPHINode(),
found by code inspection.

llvm-svn: 129641
2011-04-16 14:17:37 +00:00
Francois Pichet 47f86e6c60 MSVC needs the return 0 to compile.
llvm-svn: 129640
2011-04-16 13:59:23 +00:00
Benjamin Kramer 659bfb34ff Remove unused variable.
llvm-svn: 129639
2011-04-16 10:30:47 +00:00
Benjamin Kramer c186dcf2c5 Write out uint64_t as i{0..32},i{33..64} instead of i{0..32},0.
llvm-svn: 129638
2011-04-16 10:25:32 +00:00
Nick Lewycky 303b5e21fc Don't use C++ comments in C code.
llvm-svn: 129637
2011-04-16 04:25:36 +00:00
Rafael Espindola a83b177035 Put each personality function in a section. This fixes the gnu ld warning:
error in foo.o; no .eh_frame_hdr table will be created.

llvm-svn: 129635
2011-04-16 03:51:21 +00:00