Commit Graph

12042 Commits

Author SHA1 Message Date
Chris Lattner 24f200ad7b Switch this from using an std::map to using a DenseMap. This speeds up
phi-elimination from 0.6 to 0.54s on kc++.

llvm-svn: 13454
2004-05-10 19:17:36 +00:00
Chris Lattner 39a1e0a33e Use a new VRegPHIUseCount to compute uses of PHI values by other phi values
in the basic block being processed.  This fixes PhiElimination on kimwitu++
from taking 105s to taking a much more reasonable 0.6s (in a debug build).

llvm-svn: 13453
2004-05-10 19:06:37 +00:00
Chris Lattner a2f7b9bddc Now that we use an ilist of machine instructions, iterators are more robust
than before.  Because this is the case, we can compute the first non-phi
instruction once when de-phi'ing a block.  This shaves ~4s off of
phielimination of _Z7yyparsev in kimwitu++ from 109s -> 105s.  There are
still much more important gains to come.

llvm-svn: 13452
2004-05-10 18:47:18 +00:00
Chris Lattner 72fb3256f8 Fix a fairly serious pessimizaion that was preventing us from efficiently
compiling things like 'add long %X, 1'.  The problem is that we were switching
the order of the operands for longs even though we can't fold them yet.

llvm-svn: 13451
2004-05-10 15:15:55 +00:00
Chris Lattner eefb8a7dd0 Bug fixed
llvm-svn: 13450
2004-05-10 14:28:09 +00:00
Chris Lattner 5eb8094c2d Patch to fix PR337. Make sure to mark all aliased physical registers as used
when we see a read of a register.  This is important in cases like:

AL = ...
AH = ...

   = AX

The read of AX must make both the AL and AH defs live until the use.

llvm-svn: 13444
2004-05-10 05:12:43 +00:00
Chris Lattner 60ef22da3d Testcase for PR337, which was reduced by Reid Spencer.
llvm-svn: 13443
2004-05-10 05:11:24 +00:00
Reid Spencer 45e25d8295 Bug 178 Fixed
llvm-svn: 13442
2004-05-09 23:32:39 +00:00
Reid Spencer be4fadf1b8 Changes to make the Stacker Stack use 64 bit values. This *should* get
around the problem with Stacker on Solaris because the Stack can handle
64-bit entries (pointer sized).

llvm-svn: 13441
2004-05-09 23:20:19 +00:00
Chris Lattner a367dd745b Fix some comments, avoid sign extending booleans when zero extend works fine
llvm-svn: 13440
2004-05-09 23:16:33 +00:00
Chris Lattner 1542a98e7b Generate more efficient code for casting booleans to integers (no sign extension required)
llvm-svn: 13439
2004-05-09 22:28:45 +00:00
Chris Lattner f719a52088 syntactically loopify natural loops so that the GCC loop optimizer can find them. This should *dramatically* improve the performance of CBE compiled code on targets that depend on GCC's loop optimizations (like PPC)
llvm-svn: 13438
2004-05-09 20:41:32 +00:00
Chris Lattner 87d036caf2 Do not emit prototypes for setjmp/longjmp, as they are handled specially
llvm-svn: 13437
2004-05-09 16:03:29 +00:00
Chris Lattner 17fcb67a20 Fine grainify namespacification
llvm-svn: 13436
2004-05-09 06:22:29 +00:00
Chris Lattner 9c29991970 Make the floating point constant pools local to each function, split the
FindUsedTypes manipulation stuff out to be a seperate pass, and make the
main CWriter be a function pass now!

llvm-svn: 13435
2004-05-09 06:20:51 +00:00
Brian Gaeke e3e557e553 Bug fixed.
Rewrite portability intro.

llvm-svn: 13434
2004-05-09 05:28:35 +00:00
Chris Lattner 14d328e2a5 Get this looking more like a function pass.
llvm-svn: 13433
2004-05-09 04:30:20 +00:00
Chris Lattner 254677fe0a Implement the AddPrototypes method
llvm-svn: 13432
2004-05-09 04:29:57 +00:00
Chris Lattner e7cc64f6e7 Add support for inserting all prototypes up-front
llvm-svn: 13431
2004-05-09 04:29:49 +00:00
Chris Lattner 2484a6336f Print all PHI copies for successor blocks before the terminator, whether it be a conditional branch or switch.
llvm-svn: 13430
2004-05-09 03:42:48 +00:00
Chris Lattner 8ec5f88c79 Fix stupid bug in my checkin yesterday
llvm-svn: 13429
2004-05-08 22:41:42 +00:00
Tanya Lattner 090365b154 Fixed up sched graph.
llvm-svn: 13428
2004-05-08 16:14:24 +00:00
Tanya Lattner f751ca6767 Registering the ModuloScheduling pass.
llvm-svn: 13427
2004-05-08 16:14:02 +00:00
Tanya Lattner 8ad6335dfa Changed CPUResource to allow access to max num users for a resource.
Also added ModuloScheduling as a friend.

llvm-svn: 13426
2004-05-08 16:13:26 +00:00
Tanya Lattner 39bd20d6eb Changed CPUResource to allow access to maxnum users.
llvm-svn: 13425
2004-05-08 16:12:50 +00:00
Tanya Lattner a6820d6704 Updating my versions of ModuloScheduling in cvs. Still not complete.
llvm-svn: 13424
2004-05-08 16:12:10 +00:00
Brian Gaeke 1096ba9422 Add support for widening integral casts.
Flesh out the SetCC support... which currently ends in a little bit
of unfinished code (which is probably completely hilarious) for
generating the condition value splitting the basic block up into 4
blocks, like this (clearly a better API is needed for this!):

       BB
   cond. branch
     /         /          R1=1    R2=0
     \      /
      \    /
    R=phi(R1,R2)

Other minor edits.

llvm-svn: 13423
2004-05-08 06:36:14 +00:00
Brian Gaeke 91bf7cb79b Add a bunch more branches
llvm-svn: 13422
2004-05-08 06:08:29 +00:00
Brian Gaeke 7a66e5fff9 Flesh out GEP support
llvm-svn: 13421
2004-05-08 05:27:20 +00:00
Brian Gaeke d18b330605 Add ADD with immediate
llvm-svn: 13420
2004-05-08 05:26:55 +00:00
Brian Gaeke b56f1c9c10 Add forms of CMP, SUBCC, and a few branches, and some comments.
llvm-svn: 13419
2004-05-08 04:21:32 +00:00
Brian Gaeke f3a479f04a Add stub support for GEPs.
Add support for branches (based loosely on X86/InstSelectSimple).
Add support for not visiting phi nodes in the first pass.
Add support for loading bools.
Flesh out support for stores.

llvm-svn: 13418
2004-05-08 04:21:17 +00:00
Alkis Evlogimenos 2a54b5d3e1 Add required header
llvm-svn: 13417
2004-05-08 03:50:03 +00:00
Alkis Evlogimenos 54a89b7c72 Remove unneeded header
llvm-svn: 13416
2004-05-08 03:49:35 +00:00
Chris Lattner 5f667a6f58 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
Brian Gaeke 9a7b9d07f0 Allow the user to set the LLVMINTERP environment variable as a workaround, for
when they have to run a gccld shell script without having lli in their path.
This is intended to address Bug 289.

Also, emit the traditional syntax ${1+"$@"} for passing all of a shell script's
args to a subprocess. If you have arguments that have spaces in them, $* will
not preserve the quoting (i.e., the quoted string "foo bar" as an argument will
end up as two arguments "foo" "bar" to lli.)

llvm-svn: 13414
2004-05-07 21:47:36 +00:00
Brian Gaeke 584308b71a Add support for copying bool constants to registers.
Disable the code that copies long constants to registers - it looks fishy.
Implement some simple casts: integral, smaller than longs, and equal-width
 or narrowing only.

llvm-svn: 13413
2004-05-07 21:39:30 +00:00
Chris Lattner a2dc6bf6e6 Codegen floating point stores of constants into integer instructions. This
allows us to compile:

store float 10.0, float* %P

into:
        mov DWORD PTR [%EAX], 1092616192

instead of:

.CPItest_0:                                     # float 0x4024000000000000
.long   1092616192      # float 10
...
        fld DWORD PTR [.CPItest_0]
        fstp DWORD PTR [%EAX]

llvm-svn: 13409
2004-05-07 21:18:15 +00:00
Brian Gaeke 1edc9637d0 Add more casts. You can never have enough casts.
llvm-svn: 13408
2004-05-07 21:10:28 +00:00
Chris Lattner cecf3f94a4 Make comparisons against the null pointer as efficient as integer comparisons
against zero.  In particular, don't emit:

        mov %ESI, 0
        cmp %ECX, %ESI

instead, emit:

       test %ECX, %ECX

llvm-svn: 13407
2004-05-07 19:55:55 +00:00
Chris Lattner cf5822a2be PR implemented
llvm-svn: 13406
2004-05-07 19:23:05 +00:00
Chris Lattner 3553fe3a5b Bug fixed
llvm-svn: 13403
2004-05-07 18:40:38 +00:00
Chris Lattner 798b5e4a6f New testcase
llvm-svn: 13402
2004-05-07 18:38:59 +00:00
Chris Lattner 0a8ee61c51 New testcase for PR336
llvm-svn: 13401
2004-05-07 15:38:50 +00:00
Chris Lattner d9e5813821 Fix PR336: The instcombine pass asserts when visiting load instruction
llvm-svn: 13400
2004-05-07 15:35:56 +00:00
John Criswell e0727fe00d Regression test for PR#330.
llvm-svn: 13399
2004-05-07 13:57:19 +00:00
Chris Lattner c6fdf8ddb3 Add the enum corresponding to the source change I made earlier
llvm-svn: 13395
2004-05-07 02:27:32 +00:00
John Criswell 6956afa7c5 Bug fixed.
llvm-svn: 13392
2004-05-06 22:23:24 +00:00
John Criswell 2af0fd3ca8 Don't call getForwardedType() twice, as recommended by Chris.
llvm-svn: 13391
2004-05-06 22:15:47 +00:00
Chris Lattner 6aee736d1b Use the new commandline flag to allow us to call bugpoint like this:
bugpoint ... --tool-args -enable-correct-eh-support -regalloc=linearscan --args -- -foo

So that tool-args option gets the -enable-correct-eh-support -regalloc=linearscan flags instead of bugpoint.

llvm-svn: 13389
2004-05-06 22:05:35 +00:00
Chris Lattner a60f355c87 Implement the new cl::PositionalEatsArgs flag, refactor code a bit
llvm-svn: 13388
2004-05-06 22:04:31 +00:00
Chris Lattner b68bd76978 Add a new cl::PositionalEatsArgs flag
llvm-svn: 13387
2004-05-06 22:03:59 +00:00
John Criswell f6709bc579 Fix for PR#330.
When looking at getelementptr instructions, make sure to use a forwarded
type.  We want to do this because a DerivedType may drop its uses and then
refine its users, who may then use another user who hasn't been refined yet.
By getting the forwarded type, we always ensure that we're looking at a
Type that isn't in a halfway refined state.

Now, I should be able to put this stuff in PATypeHandle, but it doesn't work
for some reason.  This should do for now.

llvm-svn: 13386
2004-05-06 21:18:08 +00:00
Chris Lattner 8737169a6a Remove a really old comment
llvm-svn: 13385
2004-05-06 19:29:58 +00:00
Reid Spencer 432f53b47f Just testing the "Reid has CVS commit access" system
llvm-svn: 13384
2004-05-06 18:06:18 +00:00
Misha Brukman afdd8a0608 Give props to Vladimir Prus for the inst_iterator patch.
llvm-svn: 13383
2004-05-06 16:53:18 +00:00
Chris Lattner 991425ae70 numeric_limits::infinity() apparently does not work on all systems. As a
workaround, use the C HUGE_VAL macro instead.

llvm-svn: 13377
2004-05-06 16:25:59 +00:00
Alkis Evlogimenos 4c4497e834 Fix for gcc3.4: invalid use of forward delacred class on line 93
llvm-svn: 13370
2004-05-06 02:07:42 +00:00
Brian Gaeke e330adf842 Move the stuff that fixes the size, orientation & fonts of graphs to
the debugging functions that call "dot". These fixed settings have
various problems: for example, the fixed size that is set in the graph
traits classes is not appropriate for turning the dot file into a PNG,
and if TrueType font rendering is being used, the 'Courier' TrueType font
may not be installed. It seems easy enough to specify these things on the
command line, anyhow.

llvm-svn: 13366
2004-05-05 06:10:06 +00:00
Brian Gaeke 706bd5bf2b Apply simplification suggested by Chris: why assign() when operator = will do?
llvm-svn: 13364
2004-05-04 22:02:41 +00:00
John Criswell 987ad1945d Fixed inconsistent indentation.
llvm-svn: 13363
2004-05-04 21:46:05 +00:00
Brian Gaeke d26074eef1 Missing piece of fix for Bug 333
llvm-svn: 13362
2004-05-04 21:41:45 +00:00
Brian Gaeke e307f8a791 Bugs fixed
llvm-svn: 13360
2004-05-04 21:22:57 +00:00
Brian Gaeke 48ef3f0fa1 update command guide to have --tool-args
llvm-svn: 13359
2004-05-04 21:13:35 +00:00
Brian Gaeke 4a278f0b1b Add --tool-args flag which lets you pass arguments to llc or lli.
This is intended to address Bug 40.

llvm-svn: 13358
2004-05-04 21:09:16 +00:00
Brian Gaeke f2ff5dd442 Correctly mangle function names when they are used as part of a
constant pool member's name.
This is intended to address Bug 333.

Also, fix an anachronistic usage of "M" as a parameter of type Function *.

llvm-svn: 13357
2004-05-04 21:09:02 +00:00
Brian Gaeke b3a9a0fcbd Add "Args" optional argument to AbstractInterpreter factory methods, which
fills in a ToolArgs vector in the AbstractInterpreter if it is set. This
ToolArgs vector is used to pass additional arguments to LLI and/or LLC.
This is intended to address Bug 40.

Also, make -debug-only=toolrunner work for the LLC and CBE
AbstractInterpreters.

llvm-svn: 13356
2004-05-04 21:09:01 +00:00
Chris Lattner c6f601310f Remove unneeded check
llvm-svn: 13355
2004-05-04 19:35:11 +00:00
Chris Lattner 22df9a59b4 Improve signed division by power of 2 *dramatically* from this:
div:
        mov %EDX, DWORD PTR [%ESP + 4]
        mov %ECX, 64
        mov %EAX, %EDX
        sar %EDX, 31
        idiv %ECX
        ret

to this:

div:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %ECX, %EAX
        sar %ECX, 5
        shr %ECX, 26
        mov %EDX, %EAX
        add %EDX, %ECX
        sar %EAX, 6
        ret

Note that the intel compiler is currently making this:

div:
        movl      4(%esp), %edx                                 #3.5
        movl      %edx, %eax                                    #4.14
        sarl      $5, %eax                                      #4.14
        shrl      $26, %eax                                     #4.14
        addl      %edx, %eax                                    #4.14
        sarl      $6, %eax                                      #4.14
        ret                                                     #4.14

Which has one less register->register copy.  (hint hint alkis :)

llvm-svn: 13354
2004-05-04 19:33:58 +00:00
Misha Brukman bc1ccfd053 Provide visit(Module&) and visitModule(Module&) functionality.
llvm-svn: 13353
2004-05-04 18:30:38 +00:00
Brian Gaeke 600f2045a9 Add stub support for reading BBTraces.
llvm-svn: 13352
2004-05-04 17:11:14 +00:00
Brian Gaeke 9a1b8c73a8 Add BBTrace accessor method and data member.
llvm-svn: 13351
2004-05-04 17:11:13 +00:00
Chris Lattner ea309ff082 Bug fixed
llvm-svn: 13350
2004-05-04 17:04:09 +00:00
Chris Lattner 9490849028 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 1190a4de0b New testcase for PR332
llvm-svn: 13348
2004-05-04 17:00:10 +00:00
Brian Gaeke ba7b0d7a0e New header file containing profile info enums shared between the C++ analysis
libraries and the C runtime support library

llvm-svn: 13347
2004-05-04 16:57:57 +00:00
Brian Gaeke 34c13fbe94 Share ProfilingType enum with the C profiling runtime libraries.
llvm-svn: 13346
2004-05-04 16:53:07 +00:00
Brian Gaeke 495d9340e9 Share the profile info type enum with the C++ analysis libraries.
Add a documentation comment for write_profiling_data().

llvm-svn: 13345
2004-05-04 16:51:48 +00:00
Brian Gaeke 875d70b3c0 Constants for profile info type changed names to match the C++ ones.
llvm-svn: 13344
2004-05-04 16:51:47 +00:00
Brian Gaeke 6e72e2a6e9 Constants for profile info type changed names to match the C++ ones.
Edited comments.

llvm-svn: 13343
2004-05-04 16:51:46 +00:00
Chris Lattner 8c22ece232 Improve code generated for integer multiplications by 2,3,5,9
llvm-svn: 13342
2004-05-04 15:47:14 +00:00
Chris Lattner dd1a86d858 Minor efficiency tweak, suggested by Patrick Meredith
llvm-svn: 13341
2004-05-04 15:19:33 +00:00
Brian Gaeke 5237476f75 Fix typo
llvm-svn: 13340
2004-05-03 23:52:07 +00:00
Brian Gaeke 2157c9a49b Add initial implementation of basic block tracing runtime
llvm-svn: 13339
2004-05-03 23:51:50 +00:00
Brian Gaeke 417d555b6f Add basic block tracing functions as exported symbols.
llvm-svn: 13338
2004-05-03 23:49:17 +00:00
Brian Gaeke 213715bceb Add basic block tracing information as a type of "profiling" information.
llvm-svn: 13337
2004-05-03 23:49:16 +00:00
Brian Gaeke e96196081e 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 088dd3e121 Add initial implementation of basic-block tracing instrumentation pass.
llvm-svn: 13335
2004-05-03 22:06:32 +00:00
Chris Lattner 6e6baf6157 Initialize member out of paranoia
llvm-svn: 13319
2004-05-02 16:06:40 +00:00
Chris Lattner 6942946132 Fix a problem with double freeing memory. For some reason, CallGraph is not
acting like a normal pass.  :(

llvm-svn: 13318
2004-05-02 16:06:18 +00:00
Chris Lattner 929291aabb Plug a minor memory leak
llvm-svn: 13317
2004-05-02 07:31:34 +00:00
Chris Lattner be6f06818c Do not clone arbitrary condition instructions.
llvm-svn: 13316
2004-05-02 05:19:36 +00:00
Chris Lattner 51a6dbcb65 Do not infinitely "unroll" single BB loops.
llvm-svn: 13315
2004-05-02 05:02:03 +00:00
Chris Lattner 2ad4878d8e Add some stuff to the release notes.
llvm-svn: 13314
2004-05-02 04:19:15 +00:00
Brian Gaeke 19202cd08b Chris told me to take these assertions out a few days ago, but I forgot to
check this in.

llvm-svn: 13313
2004-05-02 01:04:52 +00:00
Chris Lattner 1e94ed606e Dont' merge terminators that are needed to select PHI node values.
llvm-svn: 13312
2004-05-02 01:00:44 +00:00
Chris Lattner 2e93c4275e 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 c9b34e5648 New testcase:
Turn "if (A < B && B < C)" into "if (A < B & B < C)"

llvm-svn: 13310
2004-05-01 23:35:21 +00:00
Chris Lattner 63d75af920 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 b643a9e675 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 4cbd160b45 Fix my missing parens
llvm-svn: 13307
2004-05-01 22:41:51 +00:00
Chris Lattner 88da6f7b52 Implement SimplifyCFG/branch-cond-prop.ll
llvm-svn: 13306
2004-05-01 22:36:37 +00:00
Chris Lattner 380affdc88 New testcase for case that simplifycfg should catch
llvm-svn: 13305
2004-05-01 22:36:24 +00:00
Chris Lattner 7b0a2046d4 Remove unused #include
llvm-svn: 13304
2004-05-01 21:29:16 +00:00
Chris Lattner acbf0c84de Iterate over the Machine CFG that Brian added instead of the LLVM CFG.
Look at all of the pretty minuses. :)

llvm-svn: 13303
2004-05-01 21:27:53 +00:00
Chris Lattner 8c0bc68910 Operate on the Machine CFG instead of on the LLVM CFG
llvm-svn: 13302
2004-05-01 21:24:39 +00:00
Chris Lattner c49a9a5d76 Stop LiveVariables from using BasicBlocks as part of the mapping, instead
use MachineBasicBlocks.  To do this, we traverse the Machine CFG instead of
the LLVM CFG, which is also *MUCH* more efficient by having fewer levels of
indirections and mappings.

llvm-svn: 13301
2004-05-01 21:24:24 +00:00
Chris Lattner 5e65763532 Stop LiveVariables from using BasicBlocks as part of the mapping, instead
use MachineBasicBlocks.

llvm-svn: 13300
2004-05-01 21:23:35 +00:00
Chris Lattner c89208483f Move the GraphTraits for MachineBasicBlocks to the MachineBasicBlock file.
llvm-svn: 13299
2004-05-01 21:05:34 +00:00
Chris Lattner 15a041ca88 Add comment about optimizations
llvm-svn: 13298
2004-05-01 11:40:07 +00:00
Chris Lattner 490e804a4e Add a constructor that got lost
llvm-svn: 13297
2004-05-01 11:17:13 +00:00
Brian Gaeke 2d7efbbb93 Generalize the strlen size_t hack, for the benefit of the other external
functions with wrappers that either take or return size_ts.

llvm-svn: 13296
2004-05-01 06:42:15 +00:00
Chris Lattner 77a51733e7 Fix broken link, again.
llvm-svn: 13295
2004-04-30 22:17:12 +00:00
Tanya Lattner f0fda31479 Sorry, now friend class name should be right!!
llvm-svn: 13294
2004-04-30 20:48:37 +00:00
Tanya Lattner 34f7cfe4d0 Fixed friend class name for ModuloScheduling.
llvm-svn: 13293
2004-04-30 20:47:59 +00:00
Tanya Lattner 717f2a51fd Fixed friend class name for ModuloSched
llvm-svn: 13292
2004-04-30 20:46:40 +00:00
Tanya Lattner 6ebf67f8b6 Removing MachineResource class.
llvm-svn: 13291
2004-04-30 20:40:38 +00:00
Chris Lattner e8b56f27b8 Fix a broken link
llvm-svn: 13290
2004-04-30 14:13:16 +00:00
Chris Lattner 652064e3b8 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
Brian Gaeke 63c3b3c8d7 Add machine-CFG graph traits specializations.
llvm-svn: 13288
2004-04-29 17:43:55 +00:00
Misha Brukman 372d5bc9ab Wrapped code and comments at 80 cols; doxygenified some comments.
llvm-svn: 13264
2004-04-29 04:05:30 +00:00
Misha Brukman a70ae90722 Reorder #includes as per style guide.
llvm-svn: 13263
2004-04-29 04:04:47 +00:00
Misha Brukman 40b4f6eca8 Added `zeroinitializer' keyword.
llvm-svn: 13253
2004-04-28 19:36:08 +00:00
Misha Brukman da546eac70 class AssemblyWriter:
* Make contained ostream pointer, not reference
* Allow setting of that ostream via setStream()

class CachedWriter:
* setStream() in turn calls setStream() on the AssemblyWriter

llvm-svn: 13247
2004-04-28 19:24:28 +00:00
Misha Brukman 2dc1944f14 * Make contained ostream not public.
* Remove various print methods that called the Value* method, just have one that
  all subclasses of Value will use anyway.
* Remove template for printing constant references
* Add methods to print char* and strings
* setStream now sets the stream on the contained AssemblyWriter

llvm-svn: 13246
2004-04-28 19:22:58 +00:00
Misha Brukman 7e66438579 Send text and numbers directly to CachedWriter's contained ostream.
llvm-svn: 13243
2004-04-28 18:52:43 +00:00
Misha Brukman 1846321345 Squelch compile-time warning (profile build).
llvm-svn: 13228
2004-04-28 15:32:09 +00:00
Misha Brukman 4685e26bc7 * Add ability to print out type as symbolic
* Add Module accessor to AssemblyWriter

llvm-svn: 13227
2004-04-28 15:31:21 +00:00
Misha Brukman d472aff18c * Add ability to get and set the output stream
* New feature: outputting a Type* as symbolic, controlled via the stream
  similarly to sending std::hex to change number format

llvm-svn: 13226
2004-04-28 15:30:33 +00:00
Brian Gaeke 4ba46506df Add pred./succ. list size methods.
llvm-svn: 13214
2004-04-28 04:46:35 +00:00
Brian Gaeke 4390e4a7fc Make RequiresFPRegKill() take a MachineBasicBlock arg.
In InsertFPRegKills(), just check the MachineBasicBlock for successors
instead of its corresponding BasicBlock.

llvm-svn: 13213
2004-04-28 04:45:55 +00:00
Brian Gaeke 33ff118407 In InsertFPRegKills(), use the machine-CFG itself rather than the
LLVM CFG when trying to find the successors of BB.

llvm-svn: 13212
2004-04-28 04:34:16 +00:00
Brian Gaeke 24ec85689b Update the machine-CFG edges whenever we see a branch.
llvm-svn: 13211
2004-04-28 04:19:37 +00:00
Brian Gaeke 153cb8d18a Move private methods to end of class decl at Chris's request
llvm-svn: 13210
2004-04-28 04:15:06 +00:00
Brian Gaeke 2d875451d2 Fix thinkos that Chris caught for me.
Make pred mutators private.

llvm-svn: 13209
2004-04-28 03:59:48 +00:00
Brian Gaeke dc745e6dc1 Add machine-code CFG support: MachineBasicBlocks may now have their own
predecessors and successors

llvm-svn: 13208
2004-04-28 02:16:33 +00:00
Brian Gaeke 444a03b77a Integrate the rest of my random sparcv9 scribblings into this file
llvm-svn: 13204
2004-04-27 22:04:03 +00:00
Chris Lattner f011b7dfe6 Fix warning building in optimized mode
llvm-svn: 13190
2004-04-27 18:24:38 +00:00
Chris Lattner f1c9593a90 Fix warning
llvm-svn: 13189
2004-04-27 18:21:56 +00:00
Chris Lattner 2d3a7a6ff0 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
Brian Gaeke 8bcc86b6ae Because I like being able to instantiate the cfgprinter from external projects,
this header file is born.

llvm-svn: 13176
2004-04-26 16:27:53 +00:00
Brian Gaeke 104341f31e Add functions that return instances of these printer passes
llvm-svn: 13175
2004-04-26 16:27:08 +00:00
Brian Gaeke 1b07de4c2b Fix a typo in a comment.
llvm-svn: 13174
2004-04-26 16:26:21 +00:00
Chris Lattner f374b3f304 If an object is not in the scalar map then it must be a global from another
graph.

llvm-svn: 13173
2004-04-26 14:44:08 +00:00
Chris Lattner e20c334e65 Instcombine X/-1 --> 0-X
llvm-svn: 13172
2004-04-26 14:01:59 +00:00
Chris Lattner e24003a261 Add a new testcase for X/-1, fix bug that prevented tests from running right
llvm-svn: 13171
2004-04-26 14:01:47 +00:00
Brian Gaeke 03cac379bd Fix file header comments and include guards -- many files have been moved or
renamed since they were last spiffed up, or they just never had proper comments
in the first place.

llvm-svn: 13148
2004-04-25 07:04:49 +00:00
Brian Gaeke 42d321ab66 Add a getRegisterInfo() accessor just like on the X86 target.
llvm-svn: 13147
2004-04-25 06:32:28 +00:00
Brian Gaeke 4ec08db77c Regularize file header comment and include guard.
Include SparcV9RegisterInfo.h.
Add a getRegisterInfo() accessor and SparcV9RegisterInfo instance, just like
on the X86 target.

llvm-svn: 13146
2004-04-25 06:32:16 +00:00
Brian Gaeke f70544c583 Add MRegisterInfo subclass for the SparcV9 target (containing only stub
functions for now). This automatically turns on the printing of machine
registers using their own real names, instead of goofy things like %mreg(42),
and allows us to migrate code incrementally to the new interface as we see fit.

The register file description it uses is hand-written, so that the register
numbers will match the ones that the SparcV9 target already uses.
Perhaps someday we'll tablegen it.

llvm-svn: 13145
2004-04-25 06:32:05 +00:00
Misha Brukman 7426c893f0 Standardize header comments of top-level Makefiles.
llvm-svn: 13143
2004-04-24 00:10:56 +00:00
Misha Brukman fc993c39e7 Aggregating function arguments is now an option. Default is `no', as before.
llvm-svn: 13142
2004-04-23 23:54:34 +00:00
Misha Brukman 3596f0a180 * 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
Brian Gaeke ced65e8792 Fix a typo.
llvm-svn: 13136
2004-04-23 21:45:02 +00:00
Chris Lattner 83cd87efcd 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
Chris Lattner 05ef97f994 Eliminate all of the SCEV Expansion code which is really part of the
IndVars pass, not part of SCEV *analysis*.

llvm-svn: 13134
2004-04-23 21:29:03 +00:00
Chris Lattner 0eab307e3c Remove the SCEV::expandCodeFor method, add a new SCEVVisitor class.
llvm-svn: 13133
2004-04-23 21:28:25 +00:00
Chris Lattner 02cea4afd3 Teach bugpoint to be a little bit smarter and avoid repeating work
llvm-svn: 13132
2004-04-23 20:36:51 +00:00
Brian Gaeke 99e3e94012 Merged this file into the SparcV9 target.
llvm-svn: 13128
2004-04-23 18:17:03 +00:00
Brian Gaeke 0b65f8f582 Merge TargetRegInfo.h into SparcV9RegInfo.h, which is its only subclass.
This prepares us to be able to de-virtualize and de-abstract it, and
take the register allocator bits out and move them into the register allocator
proper...

llvm-svn: 13127
2004-04-23 18:15:48 +00:00
Brian Gaeke 71509a98c5 Include SparcV9RegInfo.h instead of TargetRegInfo.h.
llvm-svn: 13126
2004-04-23 18:15:47 +00:00
Brian Gaeke a411e07db0 Include SparcV9RegInfo.h instead of TargetRegInfo.h. This serves as a bit of
documentation that this module needs to be made independent of the
register file description of the current target.

llvm-svn: 13125
2004-04-23 18:15:46 +00:00
Brian Gaeke fbd43e43a7 Get rid of the old byte-at-a-time emission code used when the Sparc JIT was
being tested on X86, as per Chris's request.

llvm-svn: 13124
2004-04-23 18:10:38 +00:00
Brian Gaeke ad373c8576 Go back to the interpreter main loop after performing intrinsic lowering,
because 1) the first instruction might not be a call site, and
2) CS and SF.Caller were not getting set to point to the new call site
anyway (resulting in a crash on e.g. call %llvm.memset).

llvm-svn: 13122
2004-04-23 18:05:28 +00:00
Brian Gaeke 11550c1deb mmap of a zero length file returns null on some platforms, so hack around it.
llvm-svn: 13121
2004-04-23 17:38:17 +00:00
Brian Gaeke 6e102a7edd Use emitWordAt() to emit forward-branch fixups.
llvm-svn: 13120
2004-04-23 17:11:16 +00:00
Brian Gaeke fe277c2809 Emit SPARC machine code a word at a time instead of a byte at a time.
Use emitWordAt() to emit forward-branch fixups.

llvm-svn: 13119
2004-04-23 17:11:15 +00:00
Brian Gaeke 0c4fb283f3 Implement emitWordAt() for the JIT emitter.
llvm-svn: 13118
2004-04-23 17:11:14 +00:00
Brian Gaeke 4aaa9c603a Implement emitWordAt() for the debug emitter and the file printer emitter. (I
am not so sure about the file printer emitter, but the debug emitter change
should be harmless.)

llvm-svn: 13117
2004-04-23 17:11:13 +00:00
Brian Gaeke 1ed0cdbd04 Add emitWordAt() - a quick and dirty interface that the machine-dependent
emitters can use to emit "relocations".

llvm-svn: 13116
2004-04-23 17:11:12 +00:00
Misha Brukman 2ccac826e4 Add command-line option to select whether to isolate or delete function from
module. Default is `isolate' as before.

llvm-svn: 13113
2004-04-22 23:07:39 +00:00
Misha Brukman 98aa516a9c 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 e0682426f0 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
Misha Brukman 2de9ce4f51 Add a boolean flag to delete this function from module, leaving the rest behind.
Useful in manual debugging when bugpoint isn't quite up to snuff.

llvm-svn: 13110
2004-04-22 22:51:37 +00:00
Misha Brukman 324e9e06d8 Add a space before result for readability on the command line.
llvm-svn: 13109
2004-04-22 20:02:09 +00:00
Chris Lattner c27302c79f Disable a previous patch that was causing indvars to loop infinitely :(
llvm-svn: 13108
2004-04-22 15:12:36 +00:00
Chris Lattner 8f02e9c5f7 Add an ugly cast
llvm-svn: 13107
2004-04-22 15:00:36 +00:00
Chris Lattner c1a682dda0 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 334bee87f4 Add a method
llvm-svn: 13105
2004-04-22 14:56:51 +00:00
Chris Lattner af532f27e7 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 fb9a299f68 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 dc7cc35088 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
Chris Lattner be8bb804c5 Fix an incredibly nasty iterator invalidation problem. I am too spoiled by ilists :)
Eventually it would be nice if CallGraph maintained an ilist of CallGraphNode's instead
of a vector of pointers to them, but today is not that day.

llvm-svn: 13100
2004-04-21 20:44:33 +00:00
Chris Lattner 15572abd14 bug fixed
llvm-svn: 13099
2004-04-21 18:52:06 +00:00
Chris Lattner ee80c45d46 new testcase for PR326
llvm-svn: 13098
2004-04-21 18:49:35 +00:00
Misha Brukman 0784a601c2 Add doxygenified comments to functions.
llvm-svn: 13097
2004-04-21 18:36:43 +00:00
Misha Brukman 3bcead7201 I'm allergic to the word `stuff'.
llvm-svn: 13096
2004-04-21 18:27:56 +00:00
Brian Gaeke 376ac1bed5 Make SparcV9RegInfo::getRegType() return the right answer for registers
of IntCC, FloatCC, and Special types.

Make SparcV9RegInfo::getRegClassIDOfRegType() return the right answer
if you ask for the class corresponding to SpecialRegType.

llvm-svn: 13095
2004-04-21 17:53:58 +00:00
Alkis Evlogimenos f68f40ea42 Include cerrno (gcc-3.4 fix)
llvm-svn: 13091
2004-04-21 16:11:40 +00:00
Alkis Evlogimenos 07f7574ba3 Declare iterator as public since it is defined as such (gcc-3.4 fix)
llvm-svn: 13090
2004-04-21 16:10:40 +00:00
Chris Lattner a9691fe70d Fix typeo
llvm-svn: 13089
2004-04-21 14:23:18 +00:00
Chris Lattner c87784f1fc REALLY fix PR324: don't delete linkonce functions until after the SCC traversal
is done, which avoids invalidating iterators in the SCC traversal routines

llvm-svn: 13088
2004-04-20 22:06:53 +00:00
Chris Lattner 99504890b7 Pass the callgraph not the module
llvm-svn: 13087
2004-04-20 21:52:26 +00:00
Chris Lattner a45086a45e Allow getting the module from a call graph
llvm-svn: 13086
2004-04-20 21:52:12 +00:00
Chris Lattner 0a985ac82c Change it to take a callgraph, from which we can get a module
llvm-svn: 13085
2004-04-20 21:52:07 +00:00
Chris Lattner 8d0838130c Add the ability for SCC passes to initialize and finalize themselves
llvm-svn: 13084
2004-04-20 21:30:06 +00:00
Chris Lattner c1aa21f5a7 Fix PR325
llvm-svn: 13081
2004-04-20 20:26:03 +00:00
Chris Lattner 514934051a Fix PR324 and testcase: Inline/2004-04-20-InlineLinkOnce.llx
llvm-svn: 13080
2004-04-20 20:20:59 +00:00
Chris Lattner 40123bff5b New testcase, distilled from PR324
llvm-svn: 13079
2004-04-20 20:15:01 +00:00
Brian Gaeke a2f66db6c4 Make it legal to ask for the type of a specialreg
llvm-svn: 13078
2004-04-20 20:12:57 +00:00
Brian Gaeke 86a6c75a7e Add some PRs which were fixed, but not previously mentioned in the rel. notes.
llvm-svn: 13077
2004-04-20 18:18:46 +00:00
Chris Lattner 2b2d7a99be Add support for the select instruction
llvm-svn: 13076
2004-04-20 16:43:21 +00:00
Brian Gaeke 6c272a93bb Make it legal to request a load or store of %fsr.
llvm-svn: 13073
2004-04-19 19:12:12 +00:00
Brian Gaeke 627abf14bb Fix typo.
llvm-svn: 13072
2004-04-19 19:09:24 +00:00
Brian Gaeke 755651df27 Regularize include guards and remove some excess whitespace.
llvm-svn: 13071
2004-04-19 18:53:44 +00:00
Brian Gaeke 2fd2536ea8 Tighten up SparcV9FloatCCRegClass::getRegName()'s assertion - if you ask it for
the name of %fsr (as the comment in SparcV9RegClassInfo.h used to suggest)
you would walk off the end of the FloatCCRegName array.

llvm-svn: 13070
2004-04-19 18:53:43 +00:00
Brian Gaeke 85cb77737c Regularize include guards, remove some excess whitespace and fix some comments.
Remove the extra %fsr register from SparcV9FloatCCRegClass.

llvm-svn: 13069
2004-04-19 18:53:42 +00:00
Chris Lattner f48f777d4c Initial checkin of a simple loop unswitching pass. It still needs work,
but it's a start, and seems to do it's basic job.

llvm-svn: 13068
2004-04-19 18:07:02 +00:00
Chris Lattner ceea37590f New testcase
llvm-svn: 13067
2004-04-19 18:06:34 +00:00
Chris Lattner 1c9fb0007e Add accessor for a Loop Unswitching pass
llvm-svn: 13066
2004-04-19 06:28:37 +00:00
Chris Lattner 46f888dd80 Eliminate a poorly conceived method
llvm-svn: 13065
2004-04-19 06:26:46 +00:00
Chris Lattner 663ebc3ec6 It's not just a printer, it's actually an analysis too
llvm-svn: 13064
2004-04-19 03:42:32 +00:00
Misha Brukman ce89b392c6 As per Chris, greatly simplify handling of external functions by using the
wrapper idea uniformly: we can use Value::replaceAllUsesWith() instead of
special-casing by class of user.

llvm-svn: 13063
2004-04-19 03:36:47 +00:00
Misha Brukman d2493e1565 * Remove note about "UNSUPPORTED: " feature that just became supported
* Fix usage of <p> tag and some grammar

llvm-svn: 13062
2004-04-19 03:28:39 +00:00
Misha Brukman 8a32c6d91b * Reorder #includes
* Wrap a long line

llvm-svn: 13061
2004-04-19 03:12:35 +00:00
Misha Brukman 4825e215c0 Display sample bugpoint output with the `code' stylesheet class.
llvm-svn: 13060
2004-04-19 03:07:29 +00:00
Chris Lattner 5414021060 * Improve file header comment
* Remove #include
* Add some methods to update loop/loopinfo
* Stop explicitly holding the loop depth in the Loop class.  Instead, just
  dynamically calculate it.  This makes it easier to update LoopInfo as a
  result of transformations.

llvm-svn: 13059
2004-04-19 03:03:19 +00:00
Chris Lattner 32447c55fe Remove code to update loop depths
llvm-svn: 13058
2004-04-19 03:02:09 +00:00
Chris Lattner bc02177fdc Add #include
llvm-svn: 13057
2004-04-19 03:01:23 +00:00
Misha Brukman e70502328e Add notes about PRs 38 and 290 being fixed.
llvm-svn: 13056
2004-04-19 03:01:01 +00:00
Misha Brukman 017f2f3405 Wrap (some) lines to 80 cols.
llvm-svn: 13055
2004-04-19 02:56:49 +00:00
Misha Brukman 8301864215 Finally implement rewriting global initializers which use external functions
by creating an internal wrapper function with same signature as the external
function, and use it instead of the "real" function.

The wrapper then calls the external function using the same JIT function
resolution API that has been used before for rewriting instructions, since the
wrapper has an explicit call instruction which we can rewrite.

llvm-svn: 13054
2004-04-19 01:12:01 +00:00
Chris Lattner 732b5d5bba Provide an interface that is more convenient for iterating over the blocks
in a loop.

llvm-svn: 13052
2004-04-18 23:37:03 +00:00
Chris Lattner fc44a25bcb Move isLoopInvariant to the Loop class
llvm-svn: 13051
2004-04-18 22:46:08 +00:00
Chris Lattner 26ba2f5fe8 Add new method
llvm-svn: 13050
2004-04-18 22:45:27 +00:00
Chris Lattner d4d66c86c0 Add new method.
llvm-svn: 13049
2004-04-18 22:45:16 +00:00
Chris Lattner 827826320d Correct rewriting of exit blocks after my last patch
llvm-svn: 13048
2004-04-18 22:27:10 +00:00
Chris Lattner d6ce359d3b Fix computation of exit blocks
llvm-svn: 13047
2004-04-18 22:21:41 +00:00
Chris Lattner 35eaa55cfc Loop exit sets are no longer explicitly held, they are dynamically computed on demand.
llvm-svn: 13046
2004-04-18 22:15:13 +00:00
Chris Lattner d72c3eb54e Change the ExitBlocks list from being explicitly contained in the Loop
structure to being dynamically computed on demand.  This makes updating
loop information MUCH easier.

llvm-svn: 13045
2004-04-18 22:14:10 +00:00
Chris Lattner bf3c8763c0 Spiff is no longer in our tree
llvm-svn: 13041
2004-04-18 18:26:38 +00:00
Chris Lattner d15250240c Reduce the unrolling limit
llvm-svn: 13040
2004-04-18 18:06:14 +00:00
Chris Lattner 30ae18155d If the preheader of the loop was the entry block of the function, make sure
that the exit block of the loop becomes the new entry block of the function.

This was causing a verifier assertion on 252.eon.

llvm-svn: 13039
2004-04-18 17:38:42 +00:00
Chris Lattner 230bcb6b35 Be much more careful about how we update instructions outside of the loop
using instructions inside of the loop.  This should fix the MishaTest failure
from last night.

llvm-svn: 13038
2004-04-18 17:32:39 +00:00
Chris Lattner 3796974563 Another testcase
llvm-svn: 13037
2004-04-18 06:55:57 +00:00
Chris Lattner e375a4fdc2 Implement method
llvm-svn: 13036
2004-04-18 06:54:48 +00:00
Chris Lattner 5f46b7044c Add a new method
llvm-svn: 13035
2004-04-18 06:54:34 +00:00
Chris Lattner 4d52e1e401 After unrolling our single basic block loop, fold it into the preheader and exit
block.  The primary motivation for doing this is that we can now unroll nested loops.

This makes a pretty big difference in some cases.  For example, in 183.equake,
we are now beating the native compiler with the CBE, and we are a lot closer
with LLC.

I'm now going to play around a bit with the unroll factor and see what effect
it really has.

llvm-svn: 13034
2004-04-18 06:27:43 +00:00
Chris Lattner f2cc841619 Fix a bug: this does not preserve the CFG!
While we're at it, add support for updating loop information correctly.

llvm-svn: 13033
2004-04-18 05:38:37 +00:00
Chris Lattner 1472c63fb9 Add a new method, add a check missing that caused a segfault if a loop didn't
have a canonical indvar

llvm-svn: 13032
2004-04-18 05:38:05 +00:00
Chris Lattner c9de38d316 Allow clients to delete loops, add a new method
llvm-svn: 13031
2004-04-18 05:37:42 +00:00
Chris Lattner bf9ba24155 Move loop optimization passes up, add loop unroller
llvm-svn: 13030
2004-04-18 05:21:01 +00:00
Chris Lattner e4ce5dbd1d Add prototype
llvm-svn: 13029
2004-04-18 05:20:32 +00:00
Chris Lattner 946b255977 Initial checkin of a simple loop unroller. This pass is extremely basic and
limited.  Even in it's extremely simple state (it can only *fully* unroll single
basic block loops that execute a constant number of times), it already helps improve
performance a LOT on some benchmarks, particularly with the native code generators.

llvm-svn: 13028
2004-04-18 05:20:17 +00:00
Chris Lattner c14da9600b Make the tail duplication threshold accessible from the command line instead of hardcoded
llvm-svn: 13025
2004-04-18 00:52:43 +00:00
Chris Lattner ca96cee67b Fix a memory leak. We leaked the vector holding the entries in switch tables.
llvm-svn: 13023
2004-04-17 23:49:15 +00:00
Chris Lattner bc4118f316 New testcase
llvm-svn: 13020
2004-04-17 23:00:51 +00:00
Chris Lattner dd73047673 Add the ability to compute exit values for complex loop using unanalyzable
operations.  This allows us to compile this testcase:

int main() {
        int h = 1;
         do h = 3 * h + 1; while (h <= 256);
        printf("%d\n", h);
        return 0;
}

into this:

int %main() {
entry:
        call void %__main( )
        %tmp.6 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([4 x sbyte]*  %.str_1, long 0, long 0), int 364 )        ; <int> [#uses=0]
        ret int 0
}

This testcase was taken directly from 256.bzip2, believe it or not.

This code is not as general as I would like.  Next up is to refactor it
a bit to handle more cases.

llvm-svn: 13019
2004-04-17 22:58:41 +00:00
Chris Lattner a814080025 If the loop executes a constant number of times, try a bit harder to replace
exit values.

llvm-svn: 13018
2004-04-17 18:44:09 +00:00
Chris Lattner 4021d1af5a Add the ability to compute trip counts that are only controlled by constants
even if the loop is using expressions that we can't compute as a closed-form.
This allows us to calculate that this function always returns 55:

int test() {
  double X;
  int Count = 0;
  for (X = 100; X > 1; X = sqrt(X), ++Count)
    /*empty*/;
  return Count;
}

And allows us to compute trip counts for loops like:

        int h = 1;
         do h = 3 * h + 1; while (h <= 256);

(which occurs in bzip2), and for this function, which occurs after inlining
and other optimizations:

int popcount()
{
   int x = 666;
  int result = 0;
  while (x != 0) {
    result = result + (x & 0x1);
    x = x >> 1;
  }
  return result;
}

We still cannot compute the exit values of result or h in the two loops above,
which means we cannot delete the loop, but we are getting closer.  Being able to
compute a constant trip count for these two loops will allow us to unroll them
completely though.

llvm-svn: 13017
2004-04-17 18:36:24 +00:00