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
Ted Kremenek
15f320fa10
Remove derelict serialization code.
...
llvm-svn: 92374
2009-12-31 23:40:17 +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
af22bc2328
fix refactoro
...
llvm-svn: 92349
2009-12-31 08:23:09 +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
Douglas Gregor
c4174c69ea
Document the edit-distance algorithm used in StringRef, switch it over
...
to SmallVector, and add a unit test.
llvm-svn: 92340
2009-12-31 04:24:34 +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
f9012cc497
use early exits to reduce indentation.
...
llvm-svn: 92335
2009-12-31 02:33:14 +00:00
Chris Lattner
db243bdde8
eliminate another copy of the mdnode printing logic, simplify the
...
one that remains.
llvm-svn: 92334
2009-12-31 02:31:59 +00:00
Chris Lattner
81c909630f
random tidying for MDNode printing.
...
llvm-svn: 92333
2009-12-31 02:27:30 +00:00
Chris Lattner
4776298748
eliminate a bunch of useless forwarding functions with one caller.
...
llvm-svn: 92332
2009-12-31 02:23:35 +00:00
Chris Lattner
ffb8ade190
make mdnMap type safe, rename accessors for consistency with the rest of llvm.
...
llvm-svn: 92331
2009-12-31 02:20:11 +00:00
Chris Lattner
2e52832769
metadata can't be a global var initializer.
...
llvm-svn: 92330
2009-12-31 02:15:45 +00:00
Chris Lattner
0017de9a80
simplify mdnode printing logic. Now N->dump() only
...
dumps one node instead of all of them.
llvm-svn: 92329
2009-12-31 02:13:35 +00:00
Chris Lattner
63181672c5
unify two copies of the NamedMDNode printing code.
...
llvm-svn: 92327
2009-12-31 01:54:05 +00:00
Chris Lattner
d40fbce519
fix printing of function-local metadata to print all the operands of the
...
mdnode, not just operand 0 over and over.
llvm-svn: 92326
2009-12-31 01:44:44 +00:00
Chris Lattner
5922bf638c
simplify printing of mdstring and Argument.
...
llvm-svn: 92325
2009-12-31 01:41:14 +00:00
Chris Lattner
a3660e707c
simplify asmprinting of NamedMDNode
...
llvm-svn: 92324
2009-12-31 01:36:50 +00:00
Chris Lattner
8e4ab636ed
Remove #include of metadata.h from intrinsicinst.h. The only
...
method that needs it (DbgValueInst::getValue) has been moved out
of line.
llvm-svn: 92323
2009-12-31 01:32:41 +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
Chris Lattner
9afb6e9c27
Optimize MDNode to coallocate the operand list immediately
...
after the MDNode in memory. This eliminates the operands
pointer and saves a new[] per node.
Note that the code in DIDerivedType::replaceAllUsesWith is wrong
and quite scary. A MDNode should not be RAUW'd with something
else: this changes all uses of the mdnode, which may not be debug
info related! Debug info should use something non-mdnode for
declarations.
llvm-svn: 92321
2009-12-31 01:05:46 +00:00
Chris Lattner
6108ad9dd5
tidy
...
llvm-svn: 92320
2009-12-31 00:51:46 +00:00
Chris Lattner
b2de9bbb5e
do not bother reuniquing mdnodes whose operands drop to null. Doing
...
so can be a huge performance issue when tearing down modules and mdnodes
are not guaranteed to be unique anyway. This speeds up:
$ time ~/llvm/Release/bin/clang gcc.c -w -S -g
from 72 to 35s, where gcc.c is from:
http://people.csail.mit.edu/smcc/projects/single-file-programs/
llvm-svn: 92315
2009-12-30 21:42:11 +00:00
Chris Lattner
f3520d2c35
remove some misleading comments.
...
llvm-svn: 92311
2009-12-30 20:25:09 +00:00
Douglas Gregor
301af636d3
Implement edit distance for StringRef
...
llvm-svn: 92309
2009-12-30 17:23:44 +00:00
Chris Lattner
740252f319
remove some fixme's
...
llvm-svn: 92304
2009-12-30 06:00:36 +00:00
Chris Lattner
c3422a8190
now that instruction metadata is only parsed in one place, eliminate the
...
parser-global MDsOnInst vector and make ParseInstructionMetadata return
its result by-ref through an argument like the entire rest of the parser.
llvm-svn: 92302
2009-12-30 05:48:36 +00:00
Chris Lattner
fb3b372e6d
reimplement ParseOptionalInfo as ParseOptionalCommaAlign, correctly
...
handle the comma case for metadata.
llvm-svn: 92301
2009-12-30 05:44:30 +00:00
Chris Lattner
f7b95d1fbc
rename ParseOptionalCustomMetadata -> ParseInstructionMetadata,
...
and make it non-optional. This fixes the bug where we'd accept
and ignore a spurious comma after some instructions.
llvm-svn: 92300
2009-12-30 05:31:19 +00:00
Chris Lattner
89aae53e72
convert 4 more instructions over.
...
llvm-svn: 92299
2009-12-30 05:27:33 +00:00
Chris Lattner
2aaf4a0490
add facilities to start factoring instruction metadata parsing
...
out of each opcode's handler. Change ret over so far.
llvm-svn: 92298
2009-12-30 05:23:43 +00:00
Chris Lattner
03a91d987f
reimplement insertvalue/extractvalue metadata handling to not blindly
...
accept invalid input. Actually add a testcase.
llvm-svn: 92297
2009-12-30 05:14:00 +00:00
Chris Lattner
2ed8fad119
remove two bogus calls that accepted metadata in the middle of insert/extract value
...
*constant exprs*.
llvm-svn: 92296
2009-12-30 05:04:46 +00:00
Chris Lattner
63289c0f1e
rename NamedOrCustomMD -> MetadataVar to follow conventions of all the rest of the code.
...
llvm-svn: 92295
2009-12-30 05:02:06 +00:00
Chris Lattner
2e5b6d96ac
rename lltok::Metadata -> lltok::exclaim. We name tokens
...
after their syntactic form, not their semantic form.
llvm-svn: 92294
2009-12-30 04:56:59 +00:00
Chris Lattner
6664b8bd4d
rename MetadataCache -> NumberedMetadata to follow the convention
...
used by other things. Convert it to a vector since it is a dense
numbering.
llvm-svn: 92293
2009-12-30 04:51:58 +00:00