1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
Commit Graph

3037 Commits

Author SHA1 Message Date
Chris Lattner
5a58a65c10 Switch ValueSymbolTable to use StringMap<Value*> instead of std::map<std::string, Value*>
as its main datastructure.  There are many improvements yet to be made, but
this speeds up opt --std-compile-opts on 447.dealII by 7.3%.

llvm-svn: 34193
2007-02-12 05:18:08 +00:00
Chris Lattner
bbd6f81f3d simplify code by using Value::takeName
llvm-svn: 34177
2007-02-11 01:37:51 +00:00
Chris Lattner
b131b3e07e Simplify code by using value::takename
llvm-svn: 34176
2007-02-11 01:23:03 +00:00
Chris Lattner
fc50a34437 simplify name juggling through the use of Value::takeName.
llvm-svn: 34175
2007-02-11 01:08:35 +00:00
Chris Lattner
9dafd9fe90 Privatize StructLayout::MemberOffsets, adding an accessor
llvm-svn: 34156
2007-02-10 19:55:17 +00:00
Chris Lattner
12663c4a66 Fix Transforms/DeadArgElim/2007-02-07-FuncRename.ll, fallout from PR411.
This happened because deadargelim now causes VMCore to auto-rename every
function that it hacks arguments out of.  Because it hacks arguments out of
functions in a non-deterministic order, this caused the resultant numbering
to be nondet.  The fix is to just be careful to not rename functions!

llvm-svn: 34005
2007-02-07 19:31:33 +00:00
Chris Lattner
22fc4be632 shrink vmcore by moving symbol table stripping support out of VMCore into
the one IPO pass that uses it.

llvm-svn: 33990
2007-02-07 06:22:45 +00:00
Chris Lattner
474d7b219d redesign the primary datastructure used by mem2reg to eliminate an
std::map of std::vector's (ouch!).  This speeds up mem2reg by 10% on 176.gcc.

llvm-svn: 33974
2007-02-07 01:15:04 +00:00
Chris Lattner
5fee493a8c With the last change, we no longer need both directions of mapping from
BBNumbers.  Instead of using a bi-directional mapping, just use a single
densemap.  This speeds up mem2reg on 176.gcc by 8%, from  1.3489 to
1.2485s.

llvm-svn: 33940
2007-02-05 23:37:20 +00:00
Reid Spencer
8749d297f5 Apply the VISIBILITY_HIDDEN field to the remaining anonymous classes in
the Transforms library. This reduces debug library size by 132 KB, debug
binary size by 376 KB, and reduces link time for llvm tools slightly.

llvm-svn: 33939
2007-02-05 23:32:05 +00:00
Chris Lattner
7703e811eb Simplify use of DFBlocks, this makes no noticable performance difference,
but paves the way to eliminate BBNumbers.

llvm-svn: 33938
2007-02-05 23:31:26 +00:00
Reid Spencer
b509040034 This file should have been removed when -raise was removed. It isn't
used any more.

llvm-svn: 33937
2007-02-05 23:27:02 +00:00
Chris Lattner
c7487c93da Switch InsertedPHINodes back to SmallPtrSet now that the SmallPtrSet::erase
bug is fixed.

llvm-svn: 33932
2007-02-05 23:11:37 +00:00
Chris Lattner
0ae77ee391 switch a SmallPtrSet back to an std::set for now, this caused problems.
llvm-svn: 33930
2007-02-05 22:28:52 +00:00
Chris Lattner
9a99e6ee24 switch an std::set over to a SmallPtrSet, speeding up mem2reg 6% on 176.gcc.
llvm-svn: 33929
2007-02-05 22:15:21 +00:00
Chris Lattner
19e7a5695d switch an std::set over to SmallPtrSet, speeding up mem2reg 3.4% on 176.gcc.
llvm-svn: 33928
2007-02-05 22:13:11 +00:00
Chris Lattner
5d5bf2ed87 eliminate some malloc traffic, this speeds up mem2reg by 3.4%.
llvm-svn: 33927
2007-02-05 21:58:48 +00:00
Reid Spencer
eaf3451a3b Add missing and needed #include.
llvm-svn: 33926
2007-02-05 21:47:39 +00:00
Reid Spencer
d6dc4cc8e9 Make the class VISIBILITY_HIDDEN.
Reduce lexical size of the anonymous namespace.

llvm-svn: 33925
2007-02-05 21:45:12 +00:00
Reid Spencer
83803ddedb For PR411:
Adjust to changes in Module interface:
getMainFunction() -> getFunction("main")
getNamedFunction(X) -> getFunction(X)

llvm-svn: 33922
2007-02-05 21:19:13 +00:00
Reid Spencer
6af21b3029 For PR411:
This patch replaces the SymbolTable class with ValueSymbolTable which does
not support types planes. This means that all symbol names in LLVM must now
be unique. The patch addresses the necessary changes to deal with this and
removes code no longer needed as a result. This completes the bulk of the
changes for this PR. Some cleanup patches will follow.

llvm-svn: 33918
2007-02-05 20:47:22 +00:00
Reid Spencer
d8c5428a48 For PR411:
This pass is no longer needed.

llvm-svn: 33917
2007-02-05 20:41:05 +00:00
Reid Spencer
4885d68272 Create a pass to strip dead function declarations (prototypes). This is
for use by llvm-extract and bugpoint.

llvm-svn: 33916
2007-02-05 20:24:25 +00:00
Chris Lattner
1441407576 Fix miscompilations of consumer-typeset, telecomm-gsm, and 176.gcc.
llvm-svn: 33902
2007-02-05 05:57:49 +00:00
Reid Spencer
21f40213a8 For PR1177:
Revert last patch which caused iteration invalidation.

llvm-svn: 33901
2007-02-05 05:23:32 +00:00
Chris Lattner
4402e15b4b fix a miscompilation of 176.gcc
llvm-svn: 33900
2007-02-05 04:09:35 +00:00
Owen Anderson
0fbb2d629f Use DenseMap for pointer->pointer maps.
llvm-svn: 33897
2007-02-05 02:39:47 +00:00
Chris Lattner
49be595b1f rewrite shift/shift folding, now that types are not signed.
llvm-svn: 33892
2007-02-05 00:57:54 +00:00
Nick Lewycky
7439ef2aba Fix indenting, remove tabs.
Learn from sext and zext. The destination value falls within the range of the
source type.

Generalize properties regarding constant ints.

Get smarter about marking blocks as unreachable. If 1 >= 2 in order for this
block to execute, then it isn't reachable.

llvm-svn: 33889
2007-02-04 23:43:05 +00:00
Reid Spencer
310b497b59 For PR1163:
Make the Module's dependent library use a std::vector instead of SetVector
adjust #includes in .cpp files because SetVector.h is no longer included.

llvm-svn: 33855
2007-02-04 00:40:42 +00:00
Chris Lattner
471e586dd4 remove some dead code
llvm-svn: 33845
2007-02-03 23:28:07 +00:00
Reid Spencer
45d9d72ac0 For PR1072:
Removing -raise has neglible positive or negative side effects so we are
opting to remove it. See the PR for comparison details.

llvm-svn: 33844
2007-02-03 23:15:56 +00:00
Chris Lattner
71fe09f397 Switch inliner over to use DenseMap instead of std::map for ValueMap. This
speeds up the inliner 16%.

llvm-svn: 33801
2007-02-03 00:08:31 +00:00
Chris Lattner
d3fb549bdc Switch this back to using an std::map. DenseMap entries are getting invalidated
llvm-svn: 33799
2007-02-02 22:36:16 +00:00
Chris Lattner
3ae99a1181 Remove more malloc thrashing, this speeds up IPSCCP on kimwitu another 6.7%.
llvm-svn: 33796
2007-02-02 21:15:06 +00:00
Chris Lattner
dec49cea56 Convert an std::set to SmallSet, this speeds up IPSCCP 17% on kimwitu.
llvm-svn: 33794
2007-02-02 20:57:39 +00:00
Chris Lattner
e9c0bac4c5 eliminate a malloc/free for (almost) every GEP processed. This speeds up
IPSCCP 3.3% on kimwitu.

llvm-svn: 33793
2007-02-02 20:51:48 +00:00
Chris Lattner
449f7d0d63 switch hash_map's over to DenseMap in SCCP. This speeds up SCCP by 30% in
a release-assert build on kimwitu++.

llvm-svn: 33792
2007-02-02 20:38:30 +00:00
Reid Spencer
bbb8dc1b9f Remove dead code and fix indentation per Chris' review comments.
llvm-svn: 33785
2007-02-02 14:41:37 +00:00
Reid Spencer
f5f46b0082 Use short form of binary operator create functions.
llvm-svn: 33783
2007-02-02 14:08:20 +00:00
Chris Lattner
1f032e74ae bugfix for reid's shift patch.
llvm-svn: 33779
2007-02-02 05:29:55 +00:00
Reid Spencer
591bfa1e0b Changes to support making the shift instructions be true BinaryOperators.
This feature is needed in order to support shifts of more than 255 bits
on large integer types.  This changes the syntax for llvm assembly to
make shl, ashr and lshr instructions look like a binary operator:
   shl i32 %X, 1
instead of
   shl i32 %X, i8 1
Additionally, this should help a few passes perform additional optimizations.

llvm-svn: 33776
2007-02-02 02:16:23 +00:00
Chris Lattner
2d85458c52 Fix Transforms/InstCombine/2007-02-01-LoadSinkAlloca.ll, a serious code
pessimization where instcombine can sink a load (good for code size) that
prevents an alloca from being promoted by mem2reg (bad for everything).

llvm-svn: 33771
2007-02-01 22:30:07 +00:00
Reid Spencer
eb51781c22 Ensure that ConvertOperandToType generates a result conversion by
initializing the Res variable to 0 and asserting it is not zero after the
result should have been created.

llvm-svn: 33761
2007-02-01 19:14:51 +00:00
Chris Lattner
618f24b0ed Fix bugs in the inliner having to do with single-entry phi nodes and valuemap
updating.  These were exposed by Devang's recent passmgr changes (with
non-default passorderings) because now the inliner can be interleved with
the LCSSA pass.

llvm-svn: 33760
2007-02-01 18:48:38 +00:00
Chris Lattner
bebab8c026 remove temporary vectors.
llvm-svn: 33715
2007-01-31 20:08:52 +00:00
Chris Lattner
237fa61eb7 eliminate temporary vectors
llvm-svn: 33713
2007-01-31 20:07:32 +00:00
Chris Lattner
8b052ca7d0 eliminate temporary vectors
llvm-svn: 33712
2007-01-31 19:59:55 +00:00
Chris Lattner
b32b59cd84 Revert another incorrectly applied chunk, which fixes InstCombine/vec_insert_to_shuffle.ll
llvm-svn: 33705
2007-01-31 18:09:17 +00:00
Chris Lattner
f456997cb6 eliminate temporary vectors
llvm-svn: 33693
2007-01-31 04:40:53 +00:00
Chris Lattner
eb3d93c6a8 Move symbolic constant folding code to libanalysis.
llvm-svn: 33688
2007-01-31 00:53:10 +00:00
Chris Lattner
7db51ec161 Adjust #includes to match movement of constant folding code from transformutils to libanalysis.
llvm-svn: 33680
2007-01-30 23:46:24 +00:00
Chris Lattner
1765c2eed8 move a bunch of constant folding code f rom Transforms/Utils/Local.cpp into
libanalysis/ConstantFolding.cpp.

llvm-svn: 33679
2007-01-30 23:45:45 +00:00
Chris Lattner
4c01d0055a remove now-dead code.
llvm-svn: 33678
2007-01-30 23:29:47 +00:00
Chris Lattner
a49a1d15dc the inliner pass now passes targetdata down through the inliner api's
llvm-svn: 33677
2007-01-30 23:28:39 +00:00
Chris Lattner
23628987e2 The inliner/cloner can now optionally take TargetData info, which can be
used by constant folding.

llvm-svn: 33676
2007-01-30 23:22:39 +00:00
Chris Lattner
d1acbffe1b pass TD to constant folding apis
llvm-svn: 33674
2007-01-30 23:16:15 +00:00
Chris Lattner
129e04aa43 use smallvector instead of vector to make constant folding a bit more efficient
llvm-svn: 33672
2007-01-30 23:15:19 +00:00
Chris Lattner
58e09aa521 adjust to api change
llvm-svn: 33671
2007-01-30 23:14:52 +00:00
Chris Lattner
659afcca15 Change constant folding APIs to take an optional TargetData, and change
ConstantFoldInstOperands/ConstantFoldCall to take a pointer to an array
of operands + size, instead of an std::vector.

In some cases, switch to using a SmallVector instead of a vector.
This allows us to get rid of some special case gross code that was there
to avoid the cost of constructing a vector.

llvm-svn: 33670
2007-01-30 23:13:49 +00:00
Chris Lattner
27f0acaaec remove some bits that are not yet meant to land.
llvm-svn: 33666
2007-01-30 22:50:32 +00:00
Chris Lattner
b1ada91005 Symbolically evaluate constant expressions like &A[123] - &A[4].f.
This occurs in C++ code like:

#include <iostream>
#include <iterator>
int a[] = { 1, 2, 3, 4, 5 };
int main() {
  using namespace std;
  copy(a, a + sizeof(a)/sizeof(a[0]), ostream_iterator<int>(cout, "\n"));
  return 0;
}

Before we would decide the loop trip count is:
sdiv (i32 sub (i32 ptrtoint (i32* getelementptr ([5 x i32]* @a, i32 0, i32 5) to i32), i32 ptrtoint ([5 x i32]* @a to i32)), i32 4)

Now we decide it is "5".  Amazing.

This code will need to be refactored, but I'm doing that as a separate
commit.

llvm-svn: 33665
2007-01-30 22:32:46 +00:00
Reid Spencer
19af04a142 For PR1136: Rename GlobalVariable::isExternal as isDeclaration to avoid
confusion with external linkage types.

llvm-svn: 33663
2007-01-30 20:08:39 +00:00
Nick Lewycky
33d4dec543 Simplify names of lattice values. SGTUNE becomes SGT, for example.
Fix initializeConstant, now initializeInt. Fixes major performance
bottleneck.

X == Y || X->DominatedBy(Y) is redundant. Remove the X == Y part.

Fix crasher in makeEqual where getOrInsertNode would add a new constant,
producing an NE relationship between the two members we're trying to make
equal. This now allows us to mark more BBs as unreachable.

llvm-svn: 33612
2007-01-29 02:56:54 +00:00
Anton Korobeynikov
611d5e2eda Propagate changes from my local tree. This patch includes:
1. New parameter attribute called 'inreg'. It has meaning "place this
parameter in registers, if possible". This is some generalization of
gcc's regparm(n) attribute. It's currently used only in X86-32 backend.
2. Completely rewritten CC handling/lowering code inside X86 backend.
Merged stdcall + c CCs and fastcall + fast CC.
3. Dropped CSRET CC. We cannot add struct return variant for each
target-specific CC (e.g. stdcall + csretcc and so on).
4. Instead of CSRET CC introduced 'sret' parameter attribute. Setting in
on first attribute has meaning 'This is hidden pointer to structure
return. Handle it gently'.
5. Fixed small bug in llvm-extract + add new feature to
FunctionExtraction pass, which relinks all internal-linkaged callees
from deleted function to external linkage. This will allow further
linking everything together.

NOTEs: 1. Documentation will be updated soon.
       2. llvm-upgrade should be improved to translate csret => sret.
          Before this, there will be some unexpected test fails.
llvm-svn: 33597
2007-01-28 13:31:35 +00:00
Chris Lattner
f068e202fd Fix test/Transforms/InstCombine/2007-01-27-AndICmp.ll, a miscompilation of
Mozilla that Anton tracked down.

llvm-svn: 33591
2007-01-27 23:08:34 +00:00
Jim Laskey
64f4242072 Change the MachineDebugInfo to MachineModuleInfo to better reflect usage
for debugging and exception handling.

llvm-svn: 33550
2007-01-26 21:22:28 +00:00
Reid Spencer
cec82ab067 For PR761:
The Module::setEndianness and Module::setPointerSize methods have been
removed. Instead you can get/set the DataLayout. Adjust thise accordingly.

llvm-svn: 33530
2007-01-26 08:11:39 +00:00
Devang Patel
bf44036fbf Inherit CallGraphSCCPass directly from Pass.
llvm-svn: 33514
2007-01-26 00:47:38 +00:00
Devang Patel
a9eae6951d Inherit BasicBlockPass directly from Pass.
llvm-svn: 33511
2007-01-25 23:23:25 +00:00
Chris Lattner
1e8602cf97 Make llvm-extract preserve the callingconv of prototypes in the extracted
code.

llvm-svn: 33500
2007-01-25 17:38:26 +00:00
Reid Spencer
7811139c74 Cleanup checks in the load and store of casted pointer transforms. Two
changes: (1) don't special case for i1 any more, (2) use the new
TargetData::getTypeSizeInBits method to ensure source and dest are the
same bit width.

llvm-svn: 33427
2007-01-22 05:51:25 +00:00
Reid Spencer
e33c18f4d2 For PR970:
Clean up handling of isFloatingPoint() and dealing with PackedType.
Patch by Gordon Henriksen!

llvm-svn: 33415
2007-01-21 00:29:26 +00:00
Reid Spencer
71e0eb3771 Revise the store V, (cast P) -> store (cast V) -> P transform.
We only want to do this if the src and destination types have the same
bit width. This patch uses TargetData::getTypeSizeInBits() instead of
making a special case for integer types and avoiding the transform if
they don't match.

llvm-svn: 33414
2007-01-20 23:35:48 +00:00
Chris Lattner
9df9e3e57b Teach TargetData to handle 'preferred' alignment for each target, and use
these alignment amounts to align scalars when we can.  Patch by Scott Michel!

llvm-svn: 33409
2007-01-20 22:35:55 +00:00
Owen Anderson
906c09f205 Correct a comment.
llvm-svn: 33397
2007-01-20 10:07:23 +00:00
Reid Spencer
af3564823f For this transform: store V, (cast P) -> store (cast V), P
don't allow the transform if V and the pointer's element type are different
width integer types.

llvm-svn: 33371
2007-01-19 21:20:31 +00:00
Reid Spencer
14b42c0040 For PR1043:
This is the final patch for this PR. It implements some minor cleanup
in the use of IntegerType, to wit:
1. Type::getIntegerTypeMask -> IntegerType::getBitMask
2. Type::Int*Ty changed to IntegerType* from Type*
3. ConstantInt::getType() returns IntegerType* now, not Type*

This also fixes PR1120.

Patch by Sheng Zhou.

llvm-svn: 33370
2007-01-19 21:13:56 +00:00
Chris Lattner
ef4715a124 Fix InstCombine/2007-01-18-VectorInfLoop.ll, a case where instcombine
infinitely loops.

llvm-svn: 33343
2007-01-18 22:16:33 +00:00
Reid Spencer
7ba10cda74 Clean up some code around the store V, (cast P) -> store (cast V), P
transform. Change some variable names so it is clear what is source and
what is dest of the cast. Also, add an assert to ensure that the integer
to integer case is asserting if the bitwidths are different. This prevents
illegal casts from being formed and catches bitwidth bugs sooner.

llvm-svn: 33337
2007-01-18 18:54:33 +00:00
Reid Spencer
9423a82dc3 For PR1094:
Adjust the use of SetVector for changes in SetVector's interface.
Patch by Gordon Henriksen.

llvm-svn: 33280
2007-01-17 02:23:37 +00:00
Chris Lattner
946ceae164 Fix a regression in my isIntegral patch that broke 471.omnetpp. This is
because TargetData::getTypeSize() returns the same for i1 and i8.  This fix
is not right for the full generality of bitwise types, but it fixes the
regression.

llvm-svn: 33237
2007-01-15 17:55:20 +00:00
Nick Lewycky
36110b8456 Don't print address of ETNode. Print the DFSNumIn which uniquely identifies
the basic block and is stable across runs in gdb or valgrind.

Make Node::update handle edges which dominate and are tighter than
existing edges.

Replace makeEqual's "squeeze theorem" code. Fixes miscompilation.

Gate the calls to defToOps and opsToDef. Before this, we were getting IG
edges about values which weren't even defined in the dominated area. This
reduces the size of the IG by about half.

llvm-svn: 33236
2007-01-15 14:30:07 +00:00
Chris Lattner
1a96e01743 Implement InstCombine/phi.ll:test7, deletion of trivial value loops for
induction variables.

llvm-svn: 33234
2007-01-15 07:30:06 +00:00
Chris Lattner
d4a0c800f4 simplify some code now that types are signless
llvm-svn: 33232
2007-01-15 07:02:54 +00:00
Chris Lattner
bc687c27d7 delete stores to allocas with one use. This is a trivial form of DSE which
often kicks in for ?: expressions.

llvm-svn: 33231
2007-01-15 06:51:56 +00:00
Chris Lattner
c5e1611848 rename Type::isIntegral to Type::isInteger, eliminating the old Type::isInteger.
rename Type::getIntegralTypeMask to Type::getIntegerTypeMask.

This makes naming much more consistent.  For example, there are now no longer any
instances of IntegerType that are not considered isInteger! :)

llvm-svn: 33225
2007-01-15 02:27:26 +00:00
Chris Lattner
8fbcb083aa Eliminate calls to isInteger, generalizing code and tightening checks as needed.
llvm-svn: 33218
2007-01-15 01:55:30 +00:00
Chris Lattner
e7c5d04b53 Fix Analysis/Dominators/2006-10-02-BreakCritEdges.ll
llvm-svn: 33210
2007-01-15 00:15:09 +00:00
Chris Lattner
34dd9c63b6 instcombine has always been miscompiling fcmp x, x, disregarding possible
NANs.  This fixes PR1111 and Transforms/InstCombine/2007-01-14-FcmpSelf.ll

llvm-svn: 33208
2007-01-14 19:42:17 +00:00
Chris Lattner
9801f36d97 Fix PR1110 and Analysis/Dominators/2007-01-14-BreakCritEdges.ll by being
more careful about unreachable code when updating dominator info.

llvm-svn: 33204
2007-01-14 18:33:35 +00:00
Chris Lattner
8b316c71e2 Fix Transforms/InstCombine/2007-01-13-ExtCompareMiscompile.ll, which is part
of PR1107

llvm-svn: 33185
2007-01-13 23:11:38 +00:00
Reid Spencer
2a25084316 Fix indentation to prior level for easier diffs.
llvm-svn: 33184
2007-01-13 05:10:53 +00:00
Nick Lewycky
fa95bfe36f "Default context" blocks can occur after a non-default one. This meant
that properties were being applied where they didn't belong. Fixes crash
in new MiBench testcase.

Also mark debugging code as such in #ifdef.

llvm-svn: 33177
2007-01-13 02:05:28 +00:00
Chris Lattner
8b6e091a62 Fix a minor bug handling constant exprs, introduced by a recent patch.
llvm-svn: 33175
2007-01-13 00:42:58 +00:00
Chris Lattner
ec0b2f5e29 fix a bug in a recent patch
llvm-svn: 33164
2007-01-13 00:02:49 +00:00
Chris Lattner
7cfcfbb801 simplify some code
llvm-svn: 33150
2007-01-12 22:51:20 +00:00
Chris Lattner
48ec71f551 Remove over-general comparisons
llvm-svn: 33147
2007-01-12 22:49:11 +00:00
Chris Lattner
18fa0e53fa eliminate redundant check
llvm-svn: 33132
2007-01-12 18:35:11 +00:00
Chris Lattner
115b9b1a2b Branch conditions must be i1
llvm-svn: 33129
2007-01-12 18:30:11 +00:00
Reid Spencer
373d2bccea For PR1064:
Implement the arbitrary bit-width integer feature. The feature allows
integers of any bitwidth (up to 64) to be defined instead of just 1, 8,
16, 32, and 64 bit integers.

This change does several things:
1. Introduces a new Derived Type, IntegerType, to represent the number of
   bits in an integer. The Type classes SubclassData field is used to
   store the number of bits. This allows 2^23 bits in an integer type.
2. Removes the five integer Type::TypeID values for the 1, 8, 16, 32 and
   64-bit integers. These are replaced with just IntegerType which is not
   a primitive any more.
3. Adjust the rest of LLVM to account for this change.

Note that while this incremental change lays the foundation for arbitrary
bit-width integers, LLVM has not yet been converted to actually deal with
them in any significant way. Most optimization passes, for example, will
still only deal with the byte-width integer types.  Future increments
will rectify this situation.

llvm-svn: 33113
2007-01-12 07:05:14 +00:00
Reid Spencer
3d986f6487 Implement review feedback for the ConstantBool->ConstantInt merge. Chris
recommended that getBoolValue be replaced with getZExtValue and that
get(bool) be replaced by get(const Type*, uint64_t). This implements
those changes.

llvm-svn: 33110
2007-01-12 04:24:46 +00:00
Nick Lewycky
8229bc7c80 If we know that it's a constant being casted, propagate through the cast
instruction. Doesn't work the other way though (can't recover bits that
have been truncated).

llvm-svn: 33104
2007-01-12 01:23:53 +00:00
Nick Lewycky
8f02993e38 Clean up logic after ConstantBool removal.
llvm-svn: 33096
2007-01-12 00:02:12 +00:00
Reid Spencer
f3265181e2 Rename BoolTy as Int1Ty. Patch by Sheng Zhou.
llvm-svn: 33076
2007-01-11 18:21:29 +00:00
Zhou Sheng
17235b194b Remove unnecessary boolean type check.
llvm-svn: 33075
2007-01-11 14:38:17 +00:00
Zhou Sheng
23d24526b2 For PR1043:
Merge ConstantIntegral and ConstantBool into ConstantInt.
Remove ConstantIntegral and ConstantBool from LLVM.

llvm-svn: 33073
2007-01-11 12:24:14 +00:00
Zhou Sheng
7c83700514 Fixed indentation.
llvm-svn: 33072
2007-01-11 10:33:26 +00:00
Nick Lewycky
fad35ab64a Quiet compiler warning. The only reason the function is marked virtual
is so that it can be called from inside a debugger.

llvm-svn: 33067
2007-01-11 02:38:21 +00:00
Nick Lewycky
7fb0a6d2ab New predicate simplifier!
Please do not enable, there is still some known miscompile problem.

llvm-svn: 33066
2007-01-11 02:32:38 +00:00
Chris Lattner
441127f582 Fix a bug in heap-sra that caused compilation failure of office-ispell.
llvm-svn: 33043
2007-01-09 23:29:37 +00:00
Jeff Cohen
2bfbf6b99c Unbreak VC++ build.
llvm-svn: 33021
2007-01-08 20:17:17 +00:00
Reid Spencer
c857bb0b27 Comparison of primitive type sizes should now be done in bits, not bytes.
This patch converts getPrimitiveSize to getPrimitiveSizeInBits where it is
appropriate to do so (comparison of integer primitive types).

llvm-svn: 33012
2007-01-08 16:32:00 +00:00
Reid Spencer
405e204fb3 For PR1097:
Enable complex addressing modes on 64-bit platforms involving two induction
variables by keeping a size and scale in 64-bits not 32.
Patch by Dan Gohman.

llvm-svn: 33011
2007-01-08 16:17:51 +00:00
Reid Spencer
74e4297a4c Types should be const.
llvm-svn: 33001
2007-01-07 21:45:41 +00:00
Chris Lattner
cd53253271 this pass is unused
llvm-svn: 32998
2007-01-07 18:12:43 +00:00
Chris Lattner
aa5051ae7f Change the interface to Module::getOrInsertFunction to be easier to use,to resolve PR1088, and to help PR411.
This simplifies many clients also

llvm-svn: 32989
2007-01-07 08:12:01 +00:00
Chris Lattner
a2f5c06174 prepare for adjustment to getOrInsertFunction method
llvm-svn: 32985
2007-01-07 07:54:34 +00:00
Chris Lattner
a966510e59 relax some types
llvm-svn: 32982
2007-01-07 07:22:20 +00:00
Chris Lattner
3e1aa998fb relax types
llvm-svn: 32981
2007-01-07 06:59:47 +00:00
Chris Lattner
e7017c4ccf relax some types
llvm-svn: 32980
2007-01-07 06:58:05 +00:00
Chris Lattner
e7eca26371 add -debug output for -indvars.
llvm-svn: 32971
2007-01-07 01:14:12 +00:00
Chris Lattner
808722cded Fix regressions in InstCombine/call-cast-target.ll and InstCombine/2003-11-13-ConstExprCastCall.ll
llvm-svn: 32959
2007-01-06 19:53:32 +00:00
Reid Spencer
cdaf88ff9d For PR411:
Take an incremental step towards type plane elimination. This change
separates types from values in the symbol tables by finally making use
of the TypeSymbolTable class. This yields more natural interfaces for
dealing with types and unclutters the SymbolTable class.

llvm-svn: 32956
2007-01-06 07:24:44 +00:00
Chris Lattner
7a0046dc65 this final call to canLosslesslyBitCastTo is dead, because ValueRequiresCast
is only called on integers.

llvm-svn: 32949
2007-01-06 02:11:56 +00:00
Chris Lattner
3155b15453 simplify some more code now that there are not multiple different integer
types of the same size

llvm-svn: 32948
2007-01-06 02:09:32 +00:00
Chris Lattner
9691941c37 eliminate some uses of canLosslesslyBitCastTo, this actually makes the code stronger, by nuking
relational pointer comparisons with casts.

llvm-svn: 32947
2007-01-06 01:45:59 +00:00
Chris Lattner
176b690f07 no need to worry about int vs uint any more.
llvm-svn: 32946
2007-01-06 01:37:35 +00:00
Chris Lattner
6cef95214b Implement InstCombine/vec_shuffle.ll:%test7, simplifying shuffles with
undef operands.

llvm-svn: 32899
2007-01-05 07:36:08 +00:00
Chris Lattner
79238a345b fold things like a^b != c^a -> b != c. This implements InstCombine/xor.ll:test27
llvm-svn: 32893
2007-01-05 03:04:57 +00:00
Chris Lattner
f02fdf92a2 Compile X + ~X to -1. This implements Instcombine/add.ll:test34
llvm-svn: 32890
2007-01-05 02:17:46 +00:00
Reid Spencer
dd9d393e32 Death to useless bitcast instructions!
llvm-svn: 32866
2007-01-04 05:23:51 +00:00
Chris Lattner
06b8d30502 Enable a couple xforms for packed vectors (undef | v) -> -1 for packed.
llvm-svn: 32858
2007-01-04 02:12:40 +00:00
Jim Laskey
06f1a4227e Vectors are not supported by ConstantInt::getAllOnesValue.
llvm-svn: 32827
2007-01-03 00:11:03 +00:00
Reid Spencer
7eeddcbe43 Fix a typo.
llvm-svn: 32803
2006-12-31 22:26:06 +00:00
Reid Spencer
0fb7fa82d4 For PR950:
This patch replaces signed integer types with signless ones:
1. [US]Byte -> Int8
2. [U]Short -> Int16
3. [U]Int   -> Int32
4. [U]Long  -> Int64.
5. Removal of isSigned, isUnsigned, getSignedVersion, getUnsignedVersion
   and other methods related to signedness. In a few places this warranted
   identifying the signedness information from other sources.

llvm-svn: 32785
2006-12-31 05:48:39 +00:00
Reid Spencer
66a349efb1 For PR1066:
Fix this by ensuring that a bitcast is inserted to do sign switching. This
is only temporarily needed as the merging of signed and unsigned is next
on the SignlessTypes plate.

llvm-svn: 32757
2006-12-24 00:40:59 +00:00
Reid Spencer
a4415de894 Shut up some compilers that can't accurately analyze variable usage
correctly and emit "may be used uninitialized" warnings.

llvm-svn: 32756
2006-12-23 19:17:57 +00:00
Reid Spencer
c9426f9566 For PR1065:
Don't allow CmpInst instances to be processed in FoldSelectOpOp because
you can't easily swap their operands.

llvm-svn: 32753
2006-12-23 18:58:04 +00:00
Reid Spencer
4428c3483b For PR950:
This patch removes the SetCC instructions and replaces them with the ICmp
and FCmp instructions. The SetCondInst instruction has been removed and
been replaced with ICmpInst and FCmpInst.

llvm-svn: 32751
2006-12-23 06:05:41 +00:00
Chris Lattner
456861c115 add a simple fast-path for dead allocas
llvm-svn: 32750
2006-12-22 23:14:42 +00:00
Reid Spencer
7f2fd86692 Remove isSigned calls via foreknowledge of main's argument types.
llvm-svn: 32730
2006-12-21 07:49:49 +00:00
Reid Spencer
3b3cc92060 Get rid of a useless if statement whose then and else blocks were identical.
llvm-svn: 32729
2006-12-21 07:15:54 +00:00
Chris Lattner
c4b04b65ba handle undef values much more carefully: generalize the resolveundefbranches
code to handle instructions as well, so that we properly fold things like
X & undef -> 0.
This fixes Transforms/SCCP/2006-12-19-UndefBug.ll

llvm-svn: 32715
2006-12-20 06:21:33 +00:00
Chris Lattner
dfbfc21795 switch statistics over to not use static ctors.
llvm-svn: 32709
2006-12-19 23:16:47 +00:00
Chris Lattner
8f9d2ddaf7 eliminate static ctor from example.
llvm-svn: 32696
2006-12-19 22:24:09 +00:00
Chris Lattner
a4ef9d3263 remove dead statistic
llvm-svn: 32695
2006-12-19 22:23:21 +00:00
Chris Lattner
4d19c9634d switch more statistics over to STATISTIC, eliminating static ctors. Also,
delete some dead ones.

llvm-svn: 32694
2006-12-19 22:17:40 +00:00
Chris Lattner
44723daefa Eliminate static ctors due to Statistic objects
llvm-svn: 32693
2006-12-19 22:09:18 +00:00
Chris Lattner
7d23f71814 Convert more Statistic's over to STATISTIC
llvm-svn: 32692
2006-12-19 21:49:03 +00:00
Chris Lattner
9e7640cf02 Switch over Transforms/Scalar to use the STATISTIC macro. For each statistic
converted, we lose a static initializer.  This also allows GCC to emit warnings
about unused statistics.

llvm-svn: 32690
2006-12-19 21:40:18 +00:00
Reid Spencer
f6bd59ba81 Convert the last uses of CastInst::createInferredCast to a normal cast
creation. These changes are still temporary but at least this pushes
knowledge of signedness out closer to where it can be determined properly
and allows signedness to be removed from VMCore.

llvm-svn: 32654
2006-12-18 08:47:13 +00:00
Reid Spencer
f31673d965 Convert the last use of two-argument ConstantExpr::getCast into another
form so we can remove that method from ConstantExpr.

llvm-svn: 32652
2006-12-18 08:16:27 +00:00
Bill Wendling
7f6a73eb5c Added an automatic cast to "std::ostream*" etc. from OStream. We then can
rework the hacks that had us passing OStream in. We pass in std::ostream*
instead, check for null, and then dispatch to the correct print() method.

llvm-svn: 32636
2006-12-17 05:15:13 +00:00
Chris Lattner
6bdae11796 when inserting a dummy argument to work-around the CBE not supporting
zero arg vararg functions, pass undef instead of 'int 0', which is cheaper.

llvm-svn: 32634
2006-12-16 21:21:53 +00:00
Chris Lattner
ab423afd90 re-enable a temporarily-reverted patch
llvm-svn: 32595
2006-12-15 07:32:38 +00:00
Reid Spencer
67cca26f75 Fix a bug in EvaluateInDifferentType. The type of operand should not be
used to determine whether a ZExt or SExt cast is performed. Instead, pass
an "isSigned" bool to the function and determine its value from the opcode
of the cast involved.
Also, clean up some cruft from previous patches.

llvm-svn: 32548
2006-12-13 18:21:21 +00:00
Reid Spencer
8479bb2735 Implement review feedback. Most of this has to do with removing unnecessary
cast instructions. A few are bug fixes.

llvm-svn: 32544
2006-12-13 17:19:09 +00:00
Reid Spencer
a9a637d6e2 For mul transforms, when checking for a cast from bool as either operand,
make sure to also check that it is a zext from bool, not any other cast
operation type.

llvm-svn: 32539
2006-12-13 08:33:33 +00:00
Reid Spencer
32b08ba50f Fix and/or/xor (cast A), (cast B) --> cast (and/or/xor A, B)
The cast patch introduced the possibility that the wrong cast opcode
could be used and that this transform could trigger on different kinds
of cast operations. This patch rectifies that.

llvm-svn: 32538
2006-12-13 08:27:15 +00:00
Reid Spencer
ad772bfec3 Change the interface to SCEVExpander::InsertCastOfTo to take a cast opcode
so the decision of which opcode to use is pushed upward to the caller.
Adjust the callers to pass the expected opcode.

llvm-svn: 32535
2006-12-13 08:06:42 +00:00
Reid Spencer
540e6eb24b Fix some casts. isdigit(c) returns 0 or 1, not 0 or -1
llvm-svn: 32534
2006-12-13 08:04:32 +00:00
Chris Lattner
b486de5e73 revert my recent int<->fp and vector union promotion changes, they expose
obscure bugs affecting the X86 code generator.  I will reenable this
when fixed.

llvm-svn: 32524
2006-12-13 02:26:45 +00:00
Reid Spencer
50702907eb Replace CastInst::createInferredCast calls with more accurate cast
creation calls.

llvm-svn: 32521
2006-12-13 00:50:17 +00:00
Reid Spencer
0e981c9088 Replace inferred getCast(V,Ty) calls with more strict variants.
Rename getZeroExtend and getSignExtend to getZExt and getSExt to match
the the casting mnemonics in the rest of LLVM.

llvm-svn: 32514
2006-12-12 23:36:14 +00:00
Chris Lattner
6ff0a2a18d this can be trunc or bitcast, per line 3092.
llvm-svn: 32487
2006-12-12 19:11:20 +00:00
Chris Lattner
2f28a1e015 Fix regression on 400.perlbench last night.
llvm-svn: 32486
2006-12-12 18:41:03 +00:00
Reid Spencer
3ac324ab41 Fix numerous inferred casts.
llvm-svn: 32479
2006-12-12 09:18:51 +00:00
Reid Spencer
3d1b0dfba6 Fix the casting for the computation of the Malloc size.
llvm-svn: 32477
2006-12-12 09:17:08 +00:00
Reid Spencer
562b83c7df Change inferred getCast into specific getCast. Passes all tests.
llvm-svn: 32469
2006-12-12 05:05:00 +00:00
Chris Lattner
a9b75a7e35 Patch for PR1045 and Transforms/ScalarRepl/2006-12-11-SROA-Crash.ll
llvm-svn: 32468
2006-12-12 04:24:41 +00:00
Chris Lattner
28e7eaf6b8 trunc to integer, not to FP.
llvm-svn: 32426
2006-12-11 01:17:00 +00:00
Chris Lattner
a8eec08185 implement promotion of unions containing two packed types of the same width.
This implements Transforms/ScalarRepl/union-packed.ll

llvm-svn: 32422
2006-12-11 00:35:08 +00:00
Chris Lattner
098fb42690 * Eliminate calls to CastInst::createInferredCast.
* Add support for promoting unions with fp values in them.  This produces
   our new int<->fp bitcast instructions, implementing
   Transforms/ScalarRepl/union-fp-int.ll

As an example, this allows us to compile this:

union intfloat { int i; float f; };
float invsqrt(const float arg_x) {
    union intfloat x = { .f = arg_x };
    const float xhalf = arg_x * 0.5f;
    x.i = 0x5f3759df - (x.i >> 1);
    return x.f * (1.5f - xhalf * x.f * x.f);
}

into:

_invsqrt:
        movss 4(%esp), %xmm0
        movd %xmm0, %eax
        sarl %eax
        movl $1597463007, %ecx
        subl %eax, %ecx
        movd %ecx, %xmm1
        mulss LCPI1_0, %xmm0
        mulss %xmm1, %xmm0
        movss LCPI1_1, %xmm2
        mulss %xmm1, %xmm0
        subss %xmm0, %xmm2
        movl 8(%esp), %eax
        mulss %xmm2, %xmm1
        movss %xmm1, (%eax)
        ret

instead of:

_invsqrt:
        subl $4, %esp
        movss 8(%esp), %xmm0
        movss %xmm0, (%esp)
        movl (%esp), %eax
        movl $1597463007, %ecx
        sarl %eax
        subl %eax, %ecx
        movl %ecx, (%esp)
        mulss LCPI1_0, %xmm0
        movss (%esp), %xmm1
        mulss %xmm1, %xmm0
        mulss %xmm1, %xmm0
        movss LCPI1_1, %xmm2
        subss %xmm0, %xmm2
        mulss %xmm2, %xmm1
        movl 12(%esp), %eax
        movss %xmm1, (%eax)
        addl $4, %esp
        ret

llvm-svn: 32418
2006-12-10 23:56:50 +00:00
Reid Spencer
069149765d Incorporate any changes in the successor blocks into the result of
MarkAliveBlocks.

llvm-svn: 32375
2006-12-08 21:52:01 +00:00
Bill Wendling
f13d78d3b8 What should be the last unnecessary <iostream>s in the library.
llvm-svn: 32333
2006-12-07 22:21:48 +00:00
Bill Wendling
23b8b13c9d Removing even more <iostream> includes.
llvm-svn: 32320
2006-12-07 20:04:42 +00:00
Bill Wendling
a3246c4272 Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are
now cerr, cout, and NullStream resp.

llvm-svn: 32298
2006-12-07 01:30:32 +00:00
Reid Spencer
ff6cd88f93 Update ConstantIntegral Max/Min tests for new interface.
llvm-svn: 32288
2006-12-06 20:39:57 +00:00
Chris Lattner
06ba0b8202 add missing #include
llvm-svn: 32280
2006-12-06 18:14:47 +00:00
Chris Lattner
a531ce882e Detemplatize the Statistic class. The only type it is instantiated with
is 'unsigned'.

llvm-svn: 32279
2006-12-06 17:46:33 +00:00
Chris Lattner
3d1758e08c Remove the 'printname' argument to WriteAsOperand. It is always true, and
passing false would make the asmprinter fail anyway.

llvm-svn: 32264
2006-12-06 06:16:21 +00:00
Chris Lattner
8fac1e29c7 counter should be unsigned.
llvm-svn: 32252
2006-12-06 01:50:04 +00:00
Chris Lattner
e0738f8f8b add an instcombine xform. This speeds up 462.libquantum from 9.78s to
7.48s.  This regression is due to unforseen consequences of the cast patch.

llvm-svn: 32209
2006-12-05 01:26:29 +00:00
Devang Patel
ae17721f63 SCCP does not handle Packed Type properly. Disable Packed Type handling
for now.

llvm-svn: 32208
2006-12-04 23:54:59 +00:00
Reid Spencer
d727d239f8 Update call to CastInst::getCastOpcode for its new signature.
llvm-svn: 32166
2006-12-04 02:48:01 +00:00
Jeff Cohen
f99052befb Unbreak VC++ build.
llvm-svn: 32113
2006-12-02 02:22:01 +00:00
Chris Lattner
1629b0d995 disable transformations that are invalid for fp vectors. This fixes
Transforms/InstCombine/2006-12-01-BadFPVectorXform.ll

llvm-svn: 32112
2006-12-02 00:13:08 +00:00
Reid Spencer
529fb41272 Remove 4 FIXMEs to hack around cast-to-bool problems which no longer exist.
llvm-svn: 32051
2006-11-30 23:13:36 +00:00
Chris Lattner
f3806f1c16 make it clear that this is always a zext
llvm-svn: 32044
2006-11-30 17:35:08 +00:00
Chris Lattner
affa9441cd One more bugfix, 3 cases of making casts explicit.
llvm-svn: 32043
2006-11-30 17:32:29 +00:00
Chris Lattner
0b4753a96c Fix a bug in globalopt due to the recent cast patch.
llvm-svn: 32042
2006-11-30 17:26:08 +00:00
Chris Lattner
2fd5719f50 implement cast.ll:test35. With this, we recognize:
unsigned short swp(unsigned short a) {
       return ((a & 0xff00) >> 8 | (a & 0x00ff) << 8);
}

as an idiom for bswap.

llvm-svn: 32011
2006-11-29 07:18:39 +00:00
Chris Lattner
03fdea2e74 Teach instcombine to turn trunc(srl x, c) -> srl (trunc(x), c) when safe.
This implements InstCombine/cast.ll:test34.  It fires hundreds of times on
176.gcc.

llvm-svn: 32009
2006-11-29 07:04:07 +00:00
Chris Lattner
0409f2c48d Implement Regression/Transforms/InstCombine/bswap-fold.ll,
folding   seteq (bswap(x)), c -> seteq(x,bswap(c))

llvm-svn: 32006
2006-11-29 05:02:16 +00:00
Reid Spencer
a866877d2f Join a split line.
llvm-svn: 31996
2006-11-29 01:11:01 +00:00
Reid Spencer
c48fe0fd4d Undo the last patch until 253.perlbmk passes with these changes.
llvm-svn: 31977
2006-11-28 20:23:51 +00:00
Reid Spencer
8587322e79 Remove 4 FIXME's from the CAST patch now that the back end is correctly
producing code for "trunc to bool". This passes all tests on Linux.

llvm-svn: 31963
2006-11-28 07:23:01 +00:00
Chris Lattner
b391cbb939 Fix PR1014 and InstCombine/2006-11-27-XorBug.ll.
llvm-svn: 31941
2006-11-27 19:55:07 +00:00
Reid Spencer
992d9788b3 For PR950:
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.

llvm-svn: 31931
2006-11-27 01:05:10 +00:00
Bill Wendling
999f49061f Remove #include <iostream> and use llvm_* streams instead.
llvm-svn: 31925
2006-11-26 10:17:54 +00:00
Bill Wendling
5c13d56f78 Replace #include <iostream> with llvm_* streams.
llvm-svn: 31924
2006-11-26 10:02:32 +00:00
Bill Wendling
1b3a86000a Removed #include <iostream> and replaced with llvm_* streams.
llvm-svn: 31923
2006-11-26 09:46:52 +00:00
Bill Wendling
f2fadcee85 Removed #include <iostream> and used the llvm_cerr/DOUT streams instead.
llvm-svn: 31922
2006-11-26 09:17:06 +00:00
Nick Lewycky
cd25e651c2 Update to new predicate simplifier VRP design. Fixes PR966 and PR967.
Remove predicate simplifier from default gcc3 pipeline. New design is too
slow to enable by default.
Add new testcases for problems encountered in development.

llvm-svn: 31895
2006-11-22 23:49:16 +00:00
Chris Lattner
632c66b8ef This xform is handled by FoldOpIntoPhi in visitCastInst in a more elegant way.
llvm-svn: 31889
2006-11-21 17:05:13 +00:00
Chris Lattner
cdb67482da Do not convert massive blocks on phi nodes into select statements. Instead
only do these transformations if there are a small number of phi's.
This speeds up Ptrdist/ks from 2.35s to 2.19s on my mac pro.

llvm-svn: 31853
2006-11-18 19:19:36 +00:00
Chris Lattner
cc4df7e0ab If an indvar with a variable stride is used by the exit condition, go ahead
and handle it like constant stride vars.  This fixes some bad codegen in
variable stride cases.  For example, it compiles this:

void foo(int k, int i) {
  for (k=i+i; k <= 8192; k+=i)
    flags2[k] = 0;
}

to:

LBB1_1: #bb.preheader
        movl %eax, %ecx
        addl %ecx, %ecx
        movl L_flags2$non_lazy_ptr, %edx
LBB1_2: #bb
        movb $0, (%edx,%ecx)
        addl %eax, %ecx
        cmpl $8192, %ecx
        jle LBB1_2      #bb
LBB1_5: #return
        ret

or (if the array is local and we are in dynamic-nonpic or static mode):

LBB3_2: #bb
        movb $0, _flags2(%ecx)
        addl %eax, %ecx
        cmpl $8192, %ecx
        jle LBB3_2      #bb

and:

        lis r2, ha16(L_flags2$non_lazy_ptr)
        lwz r2, lo16(L_flags2$non_lazy_ptr)(r2)
        slwi r3, r4, 1
LBB1_2: ;bb
        li r5, 0
        add r6, r4, r3
        stbx r5, r2, r3
        cmpwi cr0, r6, 8192
        bgt cr0, LBB1_5 ;return

instead of:

        leal (%eax,%eax,2), %ecx
        movl %eax, %edx
        addl %edx, %edx
        addl L_flags2$non_lazy_ptr, %edx
        xorl %esi, %esi
LBB1_2: #bb
        movb $0, (%edx,%esi)
        movl %eax, %edi
        addl %esi, %edi
        addl %ecx, %esi
        cmpl $8192, %esi
        jg LBB1_5       #return

and:

        lis r2, ha16(L_flags2$non_lazy_ptr)
        lwz r2, lo16(L_flags2$non_lazy_ptr)(r2)
        mulli r3, r4, 3
        slwi r5, r4, 1
        li r6, 0
        add r2, r2, r5
LBB1_2: ;bb
        li r5, 0
        add r7, r3, r6
        stbx r5, r2, r6
        add r6, r4, r6
        cmpwi cr0, r7, 8192
        ble cr0, LBB1_2 ;bb

This speeds up Benchmarks/Shootout/sieve from 8.533s to 6.464s and
implements LoopStrengthReduce/var_stride_used_by_compare.ll

llvm-svn: 31809
2006-11-17 06:17:33 +00:00
Chris Lattner
0a2d29b345 Fix a gcc 4.2 warning.
llvm-svn: 31751
2006-11-15 04:53:24 +00:00
Chris Lattner
0114b0c20e implement InstCombine/shift-simplify.ll by transforming:
(X >> Z) op (Y >> Z)  -> (X op Y) >> Z

for all shifts and all ops={and/or/xor}.

llvm-svn: 31729
2006-11-14 07:46:50 +00:00
Chris Lattner
616335f272 implement InstCombine/and-compare.ll:test1. This compiles:
typedef struct { unsigned prefix : 4; unsigned code : 4; unsigned unsigned_p : 4; } tree_common;
int foo(tree_common *a, tree_common *b) { return a->code == b->code; }

into:

_foo:
        movl 4(%esp), %eax
        movl 8(%esp), %ecx
        movl (%eax), %eax
        xorl (%ecx), %eax
        # TRUNCATE movb %al, %al
        shrb $4, %al
        testb %al, %al
        sete %al
        movzbl %al, %eax
        ret

instead of:

_foo:
        movl 8(%esp), %eax
        movb (%eax), %al
        shrb $4, %al
        movl 4(%esp), %ecx
        movb (%ecx), %cl
        shrb $4, %cl
        cmpb %al, %cl
        sete %al
        movzbl %al, %eax
        ret

saving one cycle by eliminating a shift.

llvm-svn: 31727
2006-11-14 06:06:06 +00:00
Chris Lattner
65a873caa2 Fix InstCombine/2006-11-10-ashr-miscompile.ll a miscompilation introduced
by the shr -> [al]shr patch.  This was reduced from 176.gcc.

llvm-svn: 31653
2006-11-10 23:38:52 +00:00
Chris Lattner
4e6c828296 second patch to fix PR992/993.
llvm-svn: 31610
2006-11-09 23:36:08 +00:00
Chris Lattner
23d3dac40a Minimal patch to fix PR992/PR993
llvm-svn: 31608
2006-11-09 23:17:45 +00:00
Chris Lattner
cd3c5f59e2 Teach ShrinkDemandedConstant how to handle X+C. This implements:
add.ll:test33, add.ll:test34, shift-sra.ll:test2

llvm-svn: 31586
2006-11-09 05:12:27 +00:00
Chris Lattner
d1bcd014a8 reenable factoring of GEP expressions, being more precise about the
case that it bad to do.

llvm-svn: 31563
2006-11-08 19:42:28 +00:00
Chris Lattner
77e0e67f23 make this code more efficient by not creating a phi node we are just going to
delete in the first place.  This also makes it simpler.

llvm-svn: 31562
2006-11-08 19:29:23 +00:00
Jim Laskey
28fec74f1b Remove redundant <cmath>.
llvm-svn: 31561
2006-11-08 19:16:44 +00:00
Chris Lattner
f2cd0aeced disable this factoring optzn for GEPs for now, this severely pessimizes some
loops.

llvm-svn: 31560
2006-11-08 18:49:31 +00:00
Reid Spencer
da1f5b882a For PR950:
This patch converts the old SHR instruction into two instructions,
AShr (Arithmetic) and LShr (Logical). The Shr instructions now are not
dependent on the sign of their operands.

llvm-svn: 31542
2006-11-08 06:47:33 +00:00
Chris Lattner
924b2b109f scalarrepl should not split the two elements of the vsiidx array:
int func(vFloat v0, vFloat v1) {
        int ii;
        vSInt32 vsiidx[2];
        vsiidx[0] = _mm_cvttps_epi32(v0);
        vsiidx[1] = _mm_cvttps_epi32(v1);
        ii = ((int *) vsiidx)[4];
        return ii;
}

This fixes Transforms/ScalarRepl/2006-11-07-InvalidArrayPromote.ll

llvm-svn: 31524
2006-11-07 22:42:47 +00:00
Jeff Cohen
e1003da1a2 Unbreak VC++ build.
llvm-svn: 31464
2006-11-05 19:31:28 +00:00
Nick Lewycky
8b17d79f5e Remove commented line from earlier debugging.
llvm-svn: 31460
2006-11-05 14:19:40 +00:00
Andrew Lenharth
c2f822392c The wrong parameter was being tested to deturmine i32 vs i64
llvm-svn: 31431
2006-11-03 22:45:50 +00:00
Chris Lattner
8f8a1ed82e remove dead code
llvm-svn: 31398
2006-11-03 01:34:58 +00:00
Reid Spencer
4bafa71dc1 For PR786:
Turn on -Wunused and -Wno-unused-parameter. Clean up most of the resulting
fall out by removing unused variables. Remaining warnings have to do with
unused functions (I didn't want to delete code without review) and unused
variables in generated code. Maintainers should clean up the remaining
issues when they see them. All changes pass DejaGnu tests and Olden.

llvm-svn: 31380
2006-11-02 20:25:50 +00:00
Reid Spencer
1abf69e923 For PR950:
Replace the REM instruction with UREM, SREM and FREM.

llvm-svn: 31369
2006-11-02 01:53:59 +00:00
Devang Patel
ae6d81559a There can be more than one PHINode at the start of the block.
llvm-svn: 31362
2006-11-01 23:04:45 +00:00
Devang Patel
3f3161cee2 Handle PHINode with only one incoming value.
This fixes http://llvm.org/bugs/show_bug.cgi?id=979

llvm-svn: 31358
2006-11-01 22:26:43 +00:00
Chris Lattner
953b8e6f7d Fix GlobalOpt/2006-11-01-ShrinkGlobalPhiCrash.ll and McGill/chomp
llvm-svn: 31352
2006-11-01 18:03:33 +00:00
Chris Lattner
2cedfa5156 Factor gep instructions through phi nodes.
llvm-svn: 31346
2006-11-01 07:43:41 +00:00
Chris Lattner
61ea2af8fe Turn a phi of many loads into a phi of the address and a single load of the
result.  This can significantly shrink code and exposes identities more
aggressively.

llvm-svn: 31344
2006-11-01 07:13:54 +00:00
Chris Lattner
e43c3b1681 Fix a bug in the previous patch
llvm-svn: 31342
2006-11-01 04:55:47 +00:00
Chris Lattner
7211110992 Fold things like "phi [add (a,b), add(c,d)]" into two phi's and one add.
This triggers thousands of times on multisource.

llvm-svn: 31341
2006-11-01 04:51:18 +00:00
Chris Lattner
3b7a9fa472 generalize the fix for PR977 to also fix
Transforms/LCSSA/2006-10-31-UnreachableBlock-2.ll

llvm-svn: 31317
2006-10-31 18:56:48 +00:00
Chris Lattner
79daf6ae80 Fix PR977 and Transforms/LCSSA/2006-10-31-UnreachableBlock.ll
llvm-svn: 31315
2006-10-31 17:52:18 +00:00
Chris Lattner
cc8731fef4 Fix SimplifyCFG/2006-10-29-InvokeCrash.ll, a crash compiling QT.
llvm-svn: 31284
2006-10-29 21:21:20 +00:00
Chris Lattner
65f872288d add option to isCriticalEdge
llvm-svn: 31258
2006-10-28 06:58:17 +00:00
Chris Lattner
a1da382ad3 break edges more intelligently
llvm-svn: 31257
2006-10-28 06:45:33 +00:00
Chris Lattner
85bc826ca6 Expose a smarter way to break critical edges.
llvm-svn: 31256
2006-10-28 06:44:56 +00:00
Chris Lattner
41216d38c5 SplitCriticalEdge checks to see if an edge is critical, don't check twice
llvm-svn: 31255
2006-10-28 06:38:14 +00:00
Chris Lattner
93414d06c4 prepare for a change I'm about to make
llvm-svn: 31248
2006-10-28 00:59:20 +00:00
Reid Spencer
4665cb220d Simplify code a bit by changing instances of:
InsertNewInstBefore(new CastInst(Val, ValTy, Val->GetName()), I)
into:
   InsertCastBefore(Val, ValTy, I)

llvm-svn: 31204
2006-10-26 19:19:06 +00:00
Reid Spencer
6833ffe8b8 For PR950:
Make necessary changes to support DIV -> [SUF]Div. This changes llvm to
have three division instructions: signed, unsigned, floating point. The
bytecode and assembler are bacwards compatible, however.

llvm-svn: 31195
2006-10-26 06:15:43 +00:00
Nick Lewycky
e7580b4a17 Fix 2006-10-25-AddSetCC. A relational operator (like setlt) can never
produce an EQ property.

llvm-svn: 31193
2006-10-26 02:35:18 +00:00
Nick Lewycky
be9829c45f Resurrect r1.25.
Fix and comment the "or", "and" and "xor" transformations.

llvm-svn: 31189
2006-10-25 23:48:24 +00:00
Chris Lattner
f4a5fcbb3a hide symbols properly
llvm-svn: 31184
2006-10-25 21:14:31 +00:00
Chris Lattner
0cf64c9469 Fix Transforms/ScalarRepl/2006-10-23-PointerUnionCrash.ll
llvm-svn: 31151
2006-10-24 06:26:32 +00:00
Chris Lattner
d13449ed3e Revert back to r1.21, which was the last revision of predsimplify that
passes llvm-gcc bootstrap.

llvm-svn: 31146
2006-10-24 00:36:21 +00:00
Chris Lattner
91e628645b Handle fallout from the recent branch-on-undef changes. This fixes
Prolangs-C/agrep and SCCP/2006-10-23-IPSCCP-Crash.ll

llvm-svn: 31132
2006-10-23 18:57:02 +00:00