1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

6136 Commits

Author SHA1 Message Date
Chris Lattner
ef4fba933d add a simple instcombine xform, simplify another one to use hasAllZeroIndices()
instead of hand rolling a loop.

llvm-svn: 92403
2010-01-01 23:09:08 +00:00
Chris Lattner
feb7b1af69 generalize the pointer difference optimization to handle
a constantexpr gep on the 'base' side of the expression.
This completes comment #4 in PR3351, which comes from
483.xalancbmk.

llvm-svn: 92402
2010-01-01 22:42:29 +00:00
Chris Lattner
89b1b63bdf teach instcombine to optimize pointer difference idioms involving constant
expressions.  This is a step towards comment #4 in PR3351.

llvm-svn: 92401
2010-01-01 22:29:12 +00:00
Chris Lattner
de358b45b6 use 'match' to simplify some code.
llvm-svn: 92400
2010-01-01 22:12:03 +00:00
Chris Lattner
ce7717e168 implement the transform requested in PR5284
llvm-svn: 92398
2010-01-01 18:34:40 +00:00
Chris Lattner
6d58c7dd39 add missing line.
llvm-svn: 92384
2010-01-01 01:54:08 +00:00
Chris Lattner
e5f5e4b151 add a few trivial instcombines for llvm.powi.
llvm-svn: 92383
2010-01-01 01:52:15 +00:00
Chris Lattner
662a872e15 When factoring multiply expressions across adds, factor both
positive and negative forms of constants together.  This 
allows us to compile:

int foo(int x, int y) {
    return (x-y) + (x-y) + (x-y);
}

into:

_foo:                                                       ## @foo
	subl	%esi, %edi
	leal	(%rdi,%rdi,2), %eax
	ret

instead of (where the 3 and -3 were not factored):

_foo:
        imull   $-3, 8(%esp), %ecx
        imull   $3, 4(%esp), %eax
        addl    %ecx, %eax
        ret

this started out as:
    movl    12(%ebp), %ecx
    imull   $3, 8(%ebp), %eax
    subl    %ecx, %eax
    subl    %ecx, %eax
    subl    %ecx, %eax
    ret

This comes from PR5359.

llvm-svn: 92381
2010-01-01 01:13:15 +00:00
Chris Lattner
4a56803f29 clean up some comments.
llvm-svn: 92377
2010-01-01 00:04:26 +00:00
Chris Lattner
8812fc68ee switch from std::map to DenseMap for rank data structures.
llvm-svn: 92375
2010-01-01 00:01:34 +00:00
Chris Lattner
ebe5932016 reuse negates where possible instead of always creating them from scratch.
This allows us to optimize test12 into:

define i32 @test12(i32 %X) {
  %factor = mul i32 %X, -3                        ; <i32> [#uses=1]
  %Z = add i32 %factor, 6                         ; <i32> [#uses=1]
  ret i32 %Z
}

instead of:

define i32 @test12(i32 %X) {
  %Y = sub i32 6, %X                              ; <i32> [#uses=1]
  %C = sub i32 %Y, %X                             ; <i32> [#uses=1]
  %Z = sub i32 %C, %X                             ; <i32> [#uses=1]
  ret i32 %Z
}

llvm-svn: 92373
2009-12-31 20:34:32 +00:00
Chris Lattner
bdf261d481 we don't need a smallptrset to detect duplicates, the values are
sorted, so we can just do a linear scan.

llvm-svn: 92372
2009-12-31 19:49:01 +00:00
Chris Lattner
5551708ece make reassociate more careful about not leaving around dead mul's
llvm-svn: 92370
2009-12-31 19:34:45 +00:00
Chris Lattner
0e3d1bade8 remove debug
llvm-svn: 92369
2009-12-31 19:25:19 +00:00
Chris Lattner
59379f8bb0 teach reassociate to factor x+x+x -> x*3. While I'm at it,
fix RemoveDeadBinaryOp to actually do something.

llvm-svn: 92368
2009-12-31 19:24:52 +00:00
Chris Lattner
333b35d45e change reassociate to use SmallVector for its key datastructures
instead of std::vector.

llvm-svn: 92366
2009-12-31 18:40:32 +00:00
Chris Lattner
0c384066c0 change an if to an assert, fix comment.
llvm-svn: 92364
2009-12-31 18:18:46 +00:00
Chris Lattner
e8cca9664a move the rest of the add optimization code out to OptimizeAdd,
improve some comments, simplify a bit of code.

llvm-svn: 92363
2009-12-31 18:17:13 +00:00
Chris Lattner
236f281971 factor statistic updating better.
llvm-svn: 92362
2009-12-31 17:51:05 +00:00
Chris Lattner
4870f6a384 simple fix for an incorrect factoring which causes a
miscompilation, PR5458.

llvm-svn: 92354
2009-12-31 08:33:49 +00:00
Chris Lattner
d8516bddb2 factor code out into helper functions.
llvm-svn: 92347
2009-12-31 07:59:34 +00:00
Chris Lattner
b4d616f2d4 switch some std::vector's to smallvector. Reduce nesting.
llvm-svn: 92346
2009-12-31 07:48:51 +00:00
Chris Lattner
fe111bf087 use more modern datastructures.
llvm-svn: 92344
2009-12-31 07:33:14 +00:00
Chris Lattner
3ebdd96db7 clean up -debug output.
llvm-svn: 92343
2009-12-31 07:17:37 +00:00
Chris Lattner
ecba817b0e fix Analysis/DebugInfo.h to not include Metadata.h. Do this
by moving one method out of line and eliminating redundant checks
from other methods.

llvm-svn: 92337
2009-12-31 03:02:08 +00:00
Chris Lattner
c12382b7c8 rename "elements" of metadata to "operands". "Elements" are
things that occur in types.  "operands" are things that occur
in values.

llvm-svn: 92322
2009-12-31 01:22:29 +00:00
Benjamin Kramer
e59de5e9b0 Use an array instead of a SmallVector.
llvm-svn: 92264
2009-12-29 11:04:52 +00:00
Chris Lattner
31895ba512 prune #includes.
llvm-svn: 92260
2009-12-29 09:12:29 +00:00
Chris Lattner
84e9de4a58 Final step in the metadata API restructuring: move the
getMDKindID/getMDKindNames methods to LLVMContext (and add
convenience methods to Module), eliminating MetadataContext.
Move the state that it maintains out to LLVMContext.

llvm-svn: 92259
2009-12-29 09:01:33 +00:00
Chris Lattner
a78c161348 remove useless argument.
llvm-svn: 92256
2009-12-29 08:03:58 +00:00
Chris Lattner
9ec640a902 This is a major cleanup of the instruction metadata interfaces that
I asked Devang to do back on Sep 27.  Instead of going through the
MetadataContext class with methods like getMD() and getMDs(), just
ask the instruction directly for its metadata with getMetadata()
and getAllMetadata().

This includes a variety of other fixes and improvements: previously
all Value*'s were bloated because the HasMetadata bit was thrown into
value, adding a 9th bit to a byte.  Now this is properly sunk down to
the Instruction class (the only place where it makes sense) and it
will be folded away somewhere soon.

This also fixes some confusion in getMDs and its clients about 
whether the returned list is indexed by the MDID or densely packed.
This is now returned sorted and densely packed and the comments make
this clear.

This introduces a number of fixme's which I'll follow up on.

llvm-svn: 92235
2009-12-28 23:41:32 +00:00
Chris Lattner
e0b9847223 split code that doesn't need to be templated out of IRBuilder into a new
non-templated IRBuilderBase class.  Move that large CreateGlobalString
out of line, eliminating the need to #include GlobalVariable.h in IRBuilder.h

llvm-svn: 92227
2009-12-28 21:28:46 +00:00
Chris Lattner
cd3aa9d1ff rename getMDKind -> getMDKindID, make it autoinsert if an MD Kind
doesn't exist already, eliminate registerMDKind.  Tidy up a bunch
of random stuff.

llvm-svn: 92225
2009-12-28 20:45:51 +00:00
Chris Lattner
6dd4686b48 Metadata.h doesn't need to include ValueHandle.h anymore.
llvm-svn: 92211
2009-12-28 08:20:46 +00:00
Chris Lattner
5d3919d5f9 move an optimization for memcmp out of simplifylibcalls and into
SDISel.  This optimization was causing simplifylibcalls to 
introduce type-unsafe nastiness.  This is the first step, I'll be 
expanding the memcmp optimizations shortly, covering things that
we really really wouldn't want simplifylibcalls to do.

llvm-svn: 92098
2009-12-24 00:37:38 +00:00
Chris Lattner
7dbb93e430 reorder to follow a normal fall-through style, no functionality change.
llvm-svn: 92084
2009-12-23 23:24:51 +00:00
David Greene
1b160211dd Remove dump routine and the associated Debug.h from a header. Patch up
other files to compensate.

llvm-svn: 92075
2009-12-23 22:58:38 +00:00
Eric Christopher
ce677a909d Update objectsize intrinsic and associated dependencies. Fix
lowering code and update testcases.

llvm-svn: 91979
2009-12-23 02:51:48 +00:00
Chris Lattner
4a7bce50b8 Fix the Convert to scalar to not insert dead loads in the store case. The
load is needed when we have a small store into a large alloca (at which 
point we get a load/insert/store sequence), but when you do a full-sized
store, this load ends up being dead.

This dead load is bad in really large nasty testcases where the load ends
up causing mem2reg to insert large chains of dependent phi nodes which only
ADCE can delete.  Instead of doing this, just don't insert the dead load.

This fixes rdar://6864035

llvm-svn: 91917
2009-12-22 19:33:28 +00:00
Chris Lattner
0fbb62fcc5 fix some fixme's by using twines
llvm-svn: 91916
2009-12-22 19:23:33 +00:00
Bob Wilson
0dc93264b1 Generalize SROA to allow the first index of a GEP to be non-zero. Add a
missing check that an array reference doesn't go past the end of the array,
and remove some redundant checks for in-bound array and vector references
that are no longer needed.

llvm-svn: 91897
2009-12-22 06:57:14 +00:00
Chris Lattner
4e30207029 Implement PR5795 by merging duplicated return blocks. This could go further
by merging all returns in a function into a single one, but simplifycfg 
currently likes to duplicate the return (an unfortunate choice!)

llvm-svn: 91890
2009-12-22 06:07:30 +00:00
Chris Lattner
cd79ebb23c The phi translated pointer can be computed when returning a partially cached result
instead of stored.  This reduces memdep memory usage, and also eliminates a bunch of
weakvh's.  This speeds up gvn on gcc.c-torture/20001226-1.c from 23.9s to 8.45s (2.8x)
on a different machine than earlier.

llvm-svn: 91885
2009-12-22 04:25:02 +00:00
Eric Christopher
c1b128aa04 Whitespace fixes.
llvm-svn: 91875
2009-12-22 01:23:51 +00:00
Daniel Dunbar
8efbce934e Add suggested parentheses.
llvm-svn: 91853
2009-12-21 23:27:57 +00:00
Chris Lattner
8bd3f74d82 Add a fastpath to Load GVN to special case when we have exactly one dominating
load to avoid even messing around with SSAUpdate at all.  In this case (which
is very common, we can just use the input value directly).

This speeds up GVN time on gcc.c-torture/20001226-1.c from 36.4s to 16.3s,
which still isn't great, but substantially better and this is a simple speedup
that applies to lots of different cases.

llvm-svn: 91851
2009-12-21 23:15:48 +00:00
Chris Lattner
41cad2092d refactor some code out to a new helper method.
llvm-svn: 91849
2009-12-21 23:04:33 +00:00
Chris Lattner
1cbad45619 improve indentation avoid a pointless conversion from weakvh to trackingvh,
no functionality change.

llvm-svn: 91848
2009-12-21 22:43:03 +00:00
Bob Wilson
eb77079db5 Remove special-case SROA optimization of variable indexes to one-element and
two-element arrays.  After restructuring the SROA code, it was not safe to
do this without adding more checking.  It is not clear that this special-case
has really been useful, and removing this simplifies the code quite a bit.

llvm-svn: 91828
2009-12-21 18:39:47 +00:00
Chris Lattner
cd9fb503c8 revert r89298, which was committed without a testcase. I think
the underlying PHI node insertion issue in SSAUpdate is fixed.

llvm-svn: 91821
2009-12-21 07:45:57 +00:00