1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 20:43:44 +02:00
Commit Graph

1519 Commits

Author SHA1 Message Date
Chris Lattner
11f2a4542e New constant expression lowering pass to simplify your instruction selection needs.
Contributed by Vladimir Prus!

llvm-svn: 14399
2004-06-25 07:48:09 +00:00
Vikram S. Adve
be2d02dd92 This file is unused, and duplicates functionality in TraceValues.cpp.
llvm-svn: 14369
2004-06-24 20:16:22 +00:00
Chris Lattner
b4df848a58 Two fixes. First, stop using the ugly shouldSubstituteIndVar method.
Second, disable substitution of quadratic addrec expressions to avoid putting
multiplies in loops!

llvm-svn: 14358
2004-06-24 06:49:18 +00:00
Misha Brukman
cf1f753730 Moved to lib/VMCore
llvm-svn: 14348
2004-06-23 17:21:17 +00:00
Brian Gaeke
5da0956b27 Use new IsNAN() wrapper.
llvm-svn: 14340
2004-06-23 00:25:35 +00:00
Misha Brukman
43f0a951fe File depends on DSA, moved to lib/Analysis/DataStructure
llvm-svn: 14325
2004-06-22 18:11:38 +00:00
Chris Lattner
97ab2cec69 *FINALLY* Fix a really nasty nondeterministic bug that has been haunting us
since May 1st.  In this code, the pred iterator was being invalidated sometimes
causing the wrong entries to be added to PHI nodes.

The fix for this is to defererence and safe the *PI value before we hack on
branch instructions, which changes use/def chains, which SOMETIMES invalidates
the iterator.

llvm-svn: 14278
2004-06-21 07:19:01 +00:00
Chris Lattner
892df61ed3 Comment out the isnan stuff until we get a proper autoconf test for it
breaking the build on sparc is not acceptable.

llvm-svn: 14277
2004-06-21 06:17:21 +00:00
Chris Lattner
8723083f3b Make order of argument addition deterministic. In particular, the layout
of ConstantInt objects in memory used to determine which order arguments
were added in in some cases.

llvm-svn: 14276
2004-06-21 00:07:58 +00:00
Chris Lattner
27578fd2f5 Make use of BinaryOperator::create* methods to shrinkify code.
llvm-svn: 14262
2004-06-20 05:04:01 +00:00
Chris Lattner
6324d6d00b Fix the inliner to be deterministic, not letting its output depend on the
relative location of Function objects in memory.

llvm-svn: 14260
2004-06-20 04:11:48 +00:00
Chris Lattner
58b3f16797 Add some DEBUG output to the simplifycfg routines
Fix another non-deterministic behavior, this one should actually speed up the
code though as it was doing silly things.

llvm-svn: 14258
2004-06-20 01:13:18 +00:00
Chris Lattner
39a31b56ac Now that dominator tree children are built in determinstic order, this horrible code
can go away

llvm-svn: 14254
2004-06-19 20:23:35 +00:00
Chris Lattner
ef8a52f263 This will hopefully fix a heisenbug that Vladimir Merzliakov is running
into valiantly trying to compile stuff on freebsd.

llvm-svn: 14251
2004-06-19 19:01:26 +00:00
Chris Lattner
3d68124555 Fix a nasty bug, noticed by Reid
llvm-svn: 14249
2004-06-19 18:15:50 +00:00
Chris Lattner
185f2b060b Fix one source of nondeterminism in the -licm pass: the hoist pass
was processing blocks in whatever order they happened to end up in the
dominator tree data structure.  Force an ordering.

llvm-svn: 14248
2004-06-19 08:56:43 +00:00
Chris Lattner
d2720878ec Change to use the StableBasicBlockNumbering class
llvm-svn: 14247
2004-06-19 08:42:40 +00:00
Chris Lattner
3aed3a8bf2 Do not let the numbering of PHI nodes placed in the function depend on
non-deterministic things like the ordering of blocks in the dominance
frontier of a BB.  Unfortunately, I don't know of a better way to solve
this problem than to explicitly sort the BB's in function-order before
processing them.  This is guaranteed to slow the pass down a bit, but
is absolutely necessary to get usable diffs between two different tools
executing the mem2reg or scalarrepl pass.

Before this, bazillions of spurious diff failures occurred all over the
place due to the different order of processing PHIs:

-       %tmp.111 = getelementptr %struct.Connector_struct* %upcon.0.0, uint 0, uint 0
+       %tmp.111 = getelementptr %struct.Connector_struct* %upcon.0.1, uint 0, uint 0

Now, the diffs match.

llvm-svn: 14244
2004-06-19 07:40:14 +00:00
Chris Lattner
6e7b76ce94 Do not sort by the address of LLVM ConstantInt* objects. This produces
nondeterministic results that depend on where these objects land in memory.
Instead, sort by the value of the constant, which is stable.

Before this patch, the -simplifycfg pass run from two different compilers
could cause different code to be generated, though it was semantically the
same:

@@ -12258,8 +12258,8 @@
        %s_addr.1 = phi sbyte* [ %s, %entry ], [ %inc.0, %no_exit ]             ; <sbyte*> [#uses=5]
        %tmp.1 = load sbyte* %s_addr.1          ; <sbyte> [#uses=1]
        switch sbyte %tmp.1, label %no_exit [
-                sbyte 0, label %loopexit
                 sbyte 46, label %loopexit
+                sbyte 0, label %loopexit
        ]

We need to stomp all of this stuff out.

llvm-svn: 14243
2004-06-19 07:02:14 +00:00
Chris Lattner
5b4da6dd16 Do not loop over uses as we delete them. This causes iterators to be
invalidated out from under us.  This bug goes back to revision 1.1: scary.

llvm-svn: 14242
2004-06-19 02:02:22 +00:00
Chris Lattner
91b27e01b3 Implement Transforms/InstCombine/and.ll:test17, a common case that
occurs due to unordered comparison macros in math.h

llvm-svn: 14221
2004-06-18 06:07:51 +00:00
Chris Lattner
8f9fb1d2ea Do not function resolve intrinsics. This prevents warnings and possible bad
things from happening due to

declare bool %llvm.isunordered(double, double)
declare bool %llvm.isunordered(float, float)

llvm-svn: 14219
2004-06-18 05:50:48 +00:00
Brian Gaeke
4a904bfdcc I love the smell of a freshly broken PowerPC build in the morning.
llvm-svn: 14206
2004-06-17 22:27:04 +00:00
Chris Lattner
13cea4ef6f Fix compilation problem on freebsd. Problem noted by Vladimir Merzliakov in
PR371

llvm-svn: 14203
2004-06-17 21:20:52 +00:00
Chris Lattner
0cd29ae2cd Rename Type::PrimitiveID to TypeId and ::getPrimitiveID() to ::getTypeID()
llvm-svn: 14201
2004-06-17 18:19:28 +00:00
Chris Lattner
00b0a866dd Rename Type::PrimitiveID to TypeId and ::getPrimitiveID() to ::getTypeID()
Delete two functions that are now methods on the Type class

llvm-svn: 14200
2004-06-17 18:16:02 +00:00
Brian Gaeke
a46100448f Fix typo in DEBUG printout.
llvm-svn: 14196
2004-06-17 07:26:52 +00:00
Brian Gaeke
cf3cb8944a Um, did someone make a typo or something?
llvm-svn: 14192
2004-06-15 23:09:50 +00:00
Chris Lattner
1adcf0441d Remove support for the isnan intrinsic
llvm-svn: 14186
2004-06-15 21:37:54 +00:00
Brian Gaeke
a4353cabab Quick hack to get this file compiling again on Mac OS X. The right thing to do
is write an autoconf macro that checks whether __isnan or isnan actually works
**using the C++ compiler after #include <cmath>**, instead of doing it the easy
way with AC_CHECK_FUNCS().

llvm-svn: 14171
2004-06-14 06:33:19 +00:00
Alkis Evlogimenos
dd550dc9cd Add constant folding capabilities to the isunordered intrinsic.
llvm-svn: 14168
2004-06-13 01:23:56 +00:00
Chris Lattner
66790212ba Constant fold the isnan intrinsic
llvm-svn: 14150
2004-06-11 06:16:23 +00:00
Chris Lattner
52654bf072 Fix a bug in my checkin from last night that caused miscompilations of
186.crafty, fhourstones and 132.ijpeg.

Bugpoint makes really nasty miscompilations embarassingly easy to find.  It
narrowed it down to the instcombiner and this testcase (from fhourstones):

bool %l7153_l4706_htstat_loopentry_2E_4_no_exit_2E_4(int* %i, [32 x int]* %works, int* %tmp.98.out) {
newFuncRoot:
        %tmp.96 = load int* %i          ; <int> [#uses=1]
        %tmp.97 = getelementptr [32 x int]* %works, long 0, int %tmp.96         ; <int*> [#uses=1]
        %tmp.98 = load int* %tmp.97             ; <int> [#uses=2]
        %tmp.99 = load int* %i          ; <int> [#uses=1]
        %tmp.100 = and int %tmp.99, 7           ; <int> [#uses=1]
        %tmp.101 = seteq int %tmp.100, 7                ; <bool> [#uses=2]
        %tmp.102 = cast bool %tmp.101 to int            ; <int> [#uses=0]
        br bool %tmp.101, label %codeRepl4.exitStub, label %codeRepl3.exitStub

codeRepl4.exitStub:             ; preds = %newFuncRoot
        store int %tmp.98, int* %tmp.98.out
        ret bool true

codeRepl3.exitStub:             ; preds = %newFuncRoot
        store int %tmp.98, int* %tmp.98.out
        ret bool false
}

... which only has one combination performed on it:

$ llvm-as < t.ll | opt -instcombine -debug | llvm-dis
IC: Old =       %tmp.101 = seteq int %tmp.100, 7                ; <bool> [#uses=1]
    New =       setne int %tmp.100, 0           ; <bool>:<badref> [#uses=0]
IC: MOD =       br bool %tmp.101, label %codeRepl3.exitStub, label %codeRepl4.exitStub
IC: MOD =       %tmp.97 = getelementptr [32 x int]* %works, uint 0, int %tmp.96         ; <int*> [#uses=1]

It doesn't get much better than this.  :)

llvm-svn: 14109
2004-06-10 02:33:20 +00:00
Chris Lattner
18cab818db More minor cleanups
llvm-svn: 14108
2004-06-10 02:12:35 +00:00
Chris Lattner
ba89f54271 Eliminate many occurrances of Instruction::
llvm-svn: 14107
2004-06-10 02:07:29 +00:00
Chris Lattner
b2434f1222 Implement InstCombine/select.ll:test15*
llvm-svn: 14095
2004-06-09 07:59:58 +00:00
Chris Lattner
90a2bbc74c Be more careful about the order we put stuff onto the worklist. This allow us to
collapse this:
bool %le(int %A, int %B) {
        %c1 = setgt int %A, %B
        %tmp = select bool %c1, int 1, int 0
        %c2 = setlt int %A, %B
        %result = select bool %c2, int -1, int %tmp
        %c3 = setle int %result, 0
        ret bool %c3
}

into:

bool %le(int %A, int %B) {
        %c3 = setle int %A, %B          ; <bool> [#uses=1]
        ret bool %c3
}

which is handy, because the Java FE makes these sequences all over the place.

This is tested as: test/Regression/Transforms/InstCombine/JavaCompare.ll

llvm-svn: 14086
2004-06-09 05:08:07 +00:00
Chris Lattner
a7b01d4467 Implement select.ll:test14*
llvm-svn: 14083
2004-06-09 04:24:29 +00:00
Brian Gaeke
68eb7345df Expand head-of-file comment.
llvm-svn: 13982
2004-06-03 05:03:02 +00:00
Brian Gaeke
56ae0e9023 Use new form of unconditional branch constructor.
llvm-svn: 13930
2004-06-01 20:06:10 +00:00
Chris Lattner
d702e10ea0 Fix one of the major things that is causing the C Backend to infinite loop
llvm-svn: 13872
2004-05-28 05:02:13 +00:00
John Criswell
e56868d266 Fix a bug in the -deadtypeelim pass. The SymbolTable re-write changed it
to eliminate the wrong type.

llvm-svn: 13855
2004-05-27 21:16:46 +00:00
Chris Lattner
97bd391386 Fix InstCombine/load.ll & PR347.
This code hadn't been updated after the "structs with more than 256 elements"
related changes to the GEP instruction.  Also it was not handling the
ConstantAggregateZero class.

Now it does!

llvm-svn: 13834
2004-05-27 17:30:27 +00:00
Chris Lattner
c65ff058f3 Implement constant folding of fmod, which is used a lot in povray
llvm-svn: 13823
2004-05-27 07:25:00 +00:00
Chris Lattner
e91dc2545c Restructure call constant folding code a bit to make it simpler
Add support for acos/asin/atan.  188.ammp contains three calls to acos with
constant arguments.  Constant folding it allows elimination of those 3 calls
and three FP divisions of the results.

llvm-svn: 13821
2004-05-27 06:26:28 +00:00
Alkis Evlogimenos
7542a978fc Do not pass a null pointer if this instruction is not prepended or
appended anywhere.

llvm-svn: 13798
2004-05-26 22:50:28 +00:00
Alkis Evlogimenos
3c45e590c5 Use one destination constructor for the unconditional branch.
llvm-svn: 13792
2004-05-26 21:38:14 +00:00
Reid Spencer
fec48b0d9d Convert to SymbolTable's new iteration interface.
llvm-svn: 13754
2004-05-25 08:53:40 +00:00
Reid Spencer
08e75b22a5 Convert to SymbolTable's new lookup and iteration interfaces.
llvm-svn: 13751
2004-05-25 08:52:20 +00:00
Reid Spencer
09c1dbce28 Remove unused header file.
llvm-svn: 13750
2004-05-25 08:51:36 +00:00
Reid Spencer
169865d831 Make this pass simply invoke SymbolTable::strip().
llvm-svn: 13749
2004-05-25 08:51:25 +00:00
Chris Lattner
66f55c8e78 Implement InstCombine:shift.ll:test16, which turns (X >> C1) & C2 != C3
into (X & (C2 << C1)) != (C3 << C1), where the shift may be either left or
right and the compare may be any one.

This triggers 1546 times in 176.gcc alone, as it is a common pattern that
occurs for bitfield accesses.

llvm-svn: 13740
2004-05-25 06:32:08 +00:00
Chris Lattner
b8fb5e789b Implement instcombine/cast.ll:test16:
Canonicalize cast X to bool into a setne instruction

llvm-svn: 13736
2004-05-25 04:29:21 +00:00
Chris Lattner
79409ebc27 Fix a bug in my previous checkin
llvm-svn: 13717
2004-05-24 06:24:46 +00:00
Chris Lattner
52e7345268 Spelling people's names right is kinda important
llvm-svn: 13702
2004-05-23 21:27:29 +00:00
Chris Lattner
fbdf40f86a Fix cases where we missed inlining some more obvious candidates because the
caller was in an SCC.

llvm-svn: 13693
2004-05-23 21:22:17 +00:00
Chris Lattner
bf8b81252f Simplify the interface and remove an unneeded #include
llvm-svn: 13692
2004-05-23 21:21:35 +00:00
Chris Lattner
fee8ce6131 Fairly substantial changes to update the alias analysis we are querying as
we make the transformation.  This allows us to use interprocedural alias
analyses successfully.

llvm-svn: 13691
2004-05-23 21:21:17 +00:00
Chris Lattner
cf81f974b8 Adjust to the changes in the AliasSetTracker interface
llvm-svn: 13690
2004-05-23 21:20:19 +00:00
Chris Lattner
33de90e8c6 Add support for replacement of formal arguments with simpler expressions.
llvm-svn: 13689
2004-05-23 21:19:55 +00:00
Chris Lattner
f113f6a630 Implement the -lowergc pass which is used by code generators (like the CBE)
that do not have builtin support for garbage collection.

llvm-svn: 13688
2004-05-23 21:19:22 +00:00
Brian Gaeke
16bd3c5d34 Add CloneTraceInto(), which is based on (and has mostly the same
effects as) CloneFunctionInto().

llvm-svn: 13601
2004-05-19 09:08:14 +00:00
Brian Gaeke
9adf9d8bfc Move RemapInstruction() to ValueMapper, so that it can be shared with
CloneTrace, and because it is primarily an operation on ValueMaps.  It
is now a global (non-static) function which can be pulled in using
ValueMapper.h.

llvm-svn: 13600
2004-05-19 09:08:12 +00:00
Brian Gaeke
b41b628afd Clean up this pass somewhat:
Add better comments, including a better head-of-file comment.
Prune #includes.
Fix a FIXME that Chris put here by using doInitialization().
Use DEBUG() to print out debug msgs.
Give names to basic blocks inserted by this pass.
Expand tabs.
Use InsertProfilingInitCall() from ProfilingUtils to insert the initialize call.

llvm-svn: 13581
2004-05-14 21:21:52 +00:00
Chris Lattner
729d1ba904 This was not meant to be committed
llvm-svn: 13565
2004-05-13 20:56:34 +00:00
Chris Lattner
b296747100 Fix a nasty bug that caused us to unroll EXTREMELY large loops due to overflow
in the size calculation.

This is not something you want to see:
Loop Unroll: F[main] Loop %no_exit Loop Size = 2 Trip Count = 2147483648 - UNROLLING!

The problem was that 2*2147483648 == 0.

Now we get:
Loop Unroll: F[main] Loop %no_exit Loop Size = 2 Trip Count = 2147483648 - TOO LARGE: 4294967296>100

Thanks to some anonymous person playing with the demo page that repeatedly
caused zion to go into swapping land.  That's one way to ensure you'll get
a quick bugfix.  :)

Testcase here: Transforms/LoopUnroll/2004-05-13-DontUnrollTooMuch.ll

llvm-svn: 13564
2004-05-13 20:43:31 +00:00
Chris Lattner
f97ef5191a Do not pass in the same argument to the extracted function more than once, and
give the extracted function a more useful name than just foo_code.

llvm-svn: 13493
2004-05-12 16:26:18 +00:00
Chris Lattner
645130ed0e Implement support for code extracting basic blocks that have a return
instruction in them.

llvm-svn: 13490
2004-05-12 16:07:41 +00:00
Chris Lattner
ed40ce44d6 Implement splitting of PHI nodes, allowing block extraction of BB's that have
PHI node entries from multiple outside-the-region blocks.  This also fixes
extraction of the entry block in a function.  Yaay.

This has successfully block extracted all (but one) block from the score_move
function in obsequi (out of 33).  Hrm, I wonder which block the bug is in.  :)

llvm-svn: 13489
2004-05-12 15:29:13 +00:00
Chris Lattner
3ee79b93d7 * Pull some code out into the definedInRegion/definedInCaller methods
* Add a stub for the severSplitPHINodes which will allow us to bbextract
  bb's with PHI nodes in them soon.
* Remove unused arguments from findInputsOutputs
* Dramatically simplify the code in findInputsOutputs.  In particular,
  nothing really cares whether or not a PHI node is using something.
* Move moveCodeToFunction to after emitCallAndSwitchStatement as that's the
  order they get called.
* Fix a bug where we would code extract a region that included a call to
  vastart.  Like 'alloca', calls to vastart must stay in the function that
  they are defined in.
* Add some comments.

llvm-svn: 13482
2004-05-12 06:01:40 +00:00
Chris Lattner
67e58adb41 Generate substantially better code when there are a limited number of exits
from the extracted region.  If the return has 0 or 1 exit blocks, the new
function returns void.  If it has 2 exits, it returns bool, otherwise it
returns a ushort as before.

This allows us to use a conditional branch instruction when there are two
exit blocks, as often happens during block extraction.

llvm-svn: 13481
2004-05-12 04:14:24 +00:00
Chris Lattner
7f4cd3b0be Two minor improvements:
1. Get rid of the silly abort block.  When doing bb extraction, we get one
     abort block for every block extracted, which is kinda annoying.
  2. If the switch ends up having a single destination, turn it into an
     unconditional branch.

I would like to add support for conditional branches, but to do this we will
want to have the function return a bool instead of a ushort.

llvm-svn: 13478
2004-05-12 03:22:33 +00:00
Chris Lattner
0efd1cb264 Fix stupid bug in my checkin yesterday
llvm-svn: 13429
2004-05-08 22:41:42 +00:00
Chris Lattner
e3b3e333b0 Implement folding of GEP's like:
%tmp.0 = getelementptr [50 x sbyte]* %ar, uint 0, int 5         ; <sbyte*> [#uses=2]
        %tmp.7 = getelementptr sbyte* %tmp.0, int 8             ; <sbyte*> [#uses=1]

together.  This patch actually allows us to simplify and generalize the code.

llvm-svn: 13415
2004-05-07 22:09:22 +00:00
Chris Lattner
6340390476 Fix PR336: The instcombine pass asserts when visiting load instruction
llvm-svn: 13400
2004-05-07 15:35:56 +00:00
Chris Lattner
05f657f5c2 Do not mark instructions in unreachable sections of the function as live.
This fixes PR332 and ADCE/2004-05-04-UnreachableBlock.llx

llvm-svn: 13349
2004-05-04 17:00:46 +00:00
Chris Lattner
7896144611 Minor efficiency tweak, suggested by Patrick Meredith
llvm-svn: 13341
2004-05-04 15:19:33 +00:00
Brian Gaeke
a5b32230db Fix typo
llvm-svn: 13340
2004-05-03 23:52:07 +00:00
Brian Gaeke
dcfc3c580e In InsertProfilingInitCall(), make it legal to pass in a null array, in
which case you'll get a null array and zero passed to the profiling function.

llvm-svn: 13336
2004-05-03 22:06:33 +00:00
Brian Gaeke
c8cd0e9092 Add initial implementation of basic-block tracing instrumentation pass.
llvm-svn: 13335
2004-05-03 22:06:32 +00:00
Chris Lattner
d8345001fa Do not clone arbitrary condition instructions.
llvm-svn: 13316
2004-05-02 05:19:36 +00:00
Chris Lattner
da2d746a3b Do not infinitely "unroll" single BB loops.
llvm-svn: 13315
2004-05-02 05:02:03 +00:00
Chris Lattner
5f393764c8 Dont' merge terminators that are needed to select PHI node values.
llvm-svn: 13312
2004-05-02 01:00:44 +00:00
Chris Lattner
bd705d7776 Implement SimplifyCFG/branch-cond-merge.ll
Turning "if (A < B && B < C)" into "if (A < B & B < C)"

llvm-svn: 13311
2004-05-01 23:35:43 +00:00
Chris Lattner
eb59aec632 Make sure to reprocess instructions used by deleted instructions to avoid
missing opportunities for combination.

llvm-svn: 13309
2004-05-01 23:27:23 +00:00
Chris Lattner
f5a5668cf6 Make sure the instruction combiner doesn't lose track of instructions
when replacing them, missing the opportunity to do simplifications

llvm-svn: 13308
2004-05-01 23:19:52 +00:00
Chris Lattner
911e21e8ca Fix my missing parens
llvm-svn: 13307
2004-05-01 22:41:51 +00:00
Chris Lattner
82278b599b Implement SimplifyCFG/branch-cond-prop.ll
llvm-svn: 13306
2004-05-01 22:36:37 +00:00
Chris Lattner
9b53c7c797 Fix a major pessimization in the instcombiner. If an allocation instruction
is only used by a cast, and the casted type is the same size as the original
allocation, it would eliminate the cast by folding it into the allocation.

Unfortunately, it was placing the new allocation instruction right before
the cast, which could pull (for example) alloca instructions into the body
of a function.  This turns statically allocatable allocas into expensive
dynamically allocated allocas, which is bad bad bad.

This fixes the problem by placing the new allocation instruction at the same
place the old one was, duh. :)

llvm-svn: 13289
2004-04-30 04:37:52 +00:00
Chris Lattner
02c65b5395 Changes to fix up the inst_iterator to pass to boost iterator checks. This
patch was graciously contributed by Vladimir Prus.

llvm-svn: 13185
2004-04-27 15:13:33 +00:00
Chris Lattner
5bad19bde7 Instcombine X/-1 --> 0-X
llvm-svn: 13172
2004-04-26 14:01:59 +00:00
Misha Brukman
144b5572e1 * Allow aggregating extracted function arguments (controlled by flag)
* Commandline option (for now) controls that flag that is passed in

llvm-svn: 13141
2004-04-23 23:54:17 +00:00
Chris Lattner
b72fa5f541 Move the scev expansion code into this pass, where it belongs. There is
still room for cleanup, but at least the code modification is out of the
analysis now.

llvm-svn: 13135
2004-04-23 21:29:48 +00:00
Misha Brukman
1dc8e19185 Clarify the logic: the flag is renamed to `deleteFn' to signify it will delete
the function instead of isolating it. This also means the condition is reversed.

llvm-svn: 13112
2004-04-22 23:00:51 +00:00
Misha Brukman
ddace6ecbe Add a flag to choose between isolating a function or deleting the function from
the Module. The default behavior keeps functionality as before: the chosen
function is the one that remains.

llvm-svn: 13111
2004-04-22 22:52:22 +00:00
Chris Lattner
6716bcd0cc Disable a previous patch that was causing indvars to loop infinitely :(
llvm-svn: 13108
2004-04-22 15:12:36 +00:00
Chris Lattner
507ba1c3c3 Fix an extremely serious thinko I made in revision 1.60 of this file.
llvm-svn: 13106
2004-04-22 14:59:40 +00:00
Chris Lattner
d1906e2ace Implement a todo, rewriting all possible scev expressions inside of the
loop.  This eliminates the extra add from the previous case, but it's
not clear that this will be a performance win overall.  Tommorows test
results will tell. :)

llvm-svn: 13103
2004-04-21 23:36:08 +00:00
Chris Lattner
96752d27f4 This code really wants to iterate over the OPERANDS of an instruction, not
over its USES.  If it's dead it doesn't have any uses!  :)

Thanks to the fabulous and mysterious Bill Wendling for pointing this out.  :)

llvm-svn: 13102
2004-04-21 22:29:37 +00:00
Chris Lattner
a3e2004609 Implement a fixme. The helps loops that have induction variables of different
types in them.  Instead of creating an induction variable for all types, it
creates a single induction variable and casts to the other sizes.  This generates
this code:

no_exit:                ; preds = %entry, %no_exit
        %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=4]
***     %j.0.0 = cast uint %indvar to short             ; <short> [#uses=1]
        %indvar = cast uint %indvar to int              ; <int> [#uses=1]
        %tmp.7 = getelementptr short* %P, uint %indvar          ; <short*> [#uses=1]
        store short %j.0.0, short* %tmp.7
        %inc.0 = add int %indvar, 1             ; <int> [#uses=2]
        %tmp.2 = setlt int %inc.0, %N           ; <bool> [#uses=1]
        %indvar.next = add uint %indvar, 1              ; <uint> [#uses=1]
        br bool %tmp.2, label %no_exit, label %loopexit

instead of:

no_exit:                ; preds = %entry, %no_exit
        %indvar = phi ushort [ %indvar.next, %no_exit ], [ 0, %entry ]          ; <ushort> [#uses=2]
***     %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=3]
        %indvar = cast uint %indvar to int              ; <int> [#uses=1]
        %indvar = cast ushort %indvar to short          ; <short> [#uses=1]
        %tmp.7 = getelementptr short* %P, uint %indvar          ; <short*> [#uses=1]
        store short %indvar, short* %tmp.7
        %inc.0 = add int %indvar, 1             ; <int> [#uses=2]
        %tmp.2 = setlt int %inc.0, %N           ; <bool> [#uses=1]
        %indvar.next = add uint %indvar, 1
***     %indvar.next = add ushort %indvar, 1
        br bool %tmp.2, label %no_exit, label %loopexit

This is an improvement in register pressure, but probably doesn't happen that
often.

The more important fix will be to get rid of the redundant add.

llvm-svn: 13101
2004-04-21 22:22:01 +00:00