Commit Graph

20296 Commits

Author SHA1 Message Date
Chris Lattner 7cd3c2d151 change proto slightly
llvm-svn: 23420
2005-09-24 08:23:53 +00:00
Chris Lattner cc1d38160d memoize translations
llvm-svn: 23419
2005-09-24 00:50:51 +00:00
Chris Lattner 6736a6cdd2 Teach the dag isel generator how to construct arbitrary immediates. The
generated isel now tries li then lis, then lis+ori.

llvm-svn: 23418
2005-09-24 00:41:58 +00:00
Chris Lattner 0afb14cade Teach the DAG isel generator to emit code that creates nodes.
Fix a few corner cases parsing things like (i32 imm:$foo)

llvm-svn: 23417
2005-09-24 00:40:24 +00:00
Chris Lattner cd093e868e Emit better code (no more copies for var references), and support DAG patterns
(e.g. things like rotates).

llvm-svn: 23416
2005-09-23 23:16:51 +00:00
Chris Lattner 8ffb99b4fe Fix a fixme by passing around SDOperand's instead of SDNode*'s
llvm-svn: 23415
2005-09-23 21:53:45 +00:00
Chris Lattner cc8a564cb1 Emit code that matches the incoming DAG pattern and checks predicates.
This does not check that types match yet, but PPC only has one integer type
;-).

This also doesn't have the code to build the resultant dag.

llvm-svn: 23414
2005-09-23 21:33:23 +00:00
Chris Lattner 323a47970e emit information about the order patterns are to be matched.
llvm-svn: 23413
2005-09-23 20:52:47 +00:00
Chris Lattner abb430bad2 start filling in the switch stmt
llvm-svn: 23412
2005-09-23 19:36:15 +00:00
Chris Lattner 499e33646e remove some debugging code
llvm-svn: 23411
2005-09-23 18:49:09 +00:00
Chris Lattner c59a371d45 Fold two consequtive branches that share a common destination between them.
This implements SimplifyCFG/branch-fold.ll, and is useful on ?:/min/max heavy
code

llvm-svn: 23410
2005-09-23 18:47:20 +00:00
Chris Lattner 62f565d198 new testcase
llvm-svn: 23409
2005-09-23 18:43:57 +00:00
Chris Lattner 3a978bf66d simplify some logic further
llvm-svn: 23408
2005-09-23 07:23:18 +00:00
Chris Lattner cc14ebc17b pull a bunch of logic out of SimplifyCFG into a helper fn
llvm-svn: 23407
2005-09-23 06:39:30 +00:00
Chris Lattner 1e3d3148bb speed up Archive::isBytecodeArchive in the case when the archive doesn't have
an llvm-ranlib symtab.  This speeds up gccld -native on an almost empty .o file
from 1.63s to 0.18s.

llvm-svn: 23406
2005-09-23 06:22:58 +00:00
Chris Lattner f20941116b Speed up isBytecodeLPath from 20s to .01s in common cases. This makes -native
not completely painful to use.  Once we decide a directory has a bytecode
library, we know it this function returns true, no need to scan entire directories.

llvm-svn: 23405
2005-09-23 06:11:24 +00:00
Chris Lattner 9b9b510084 1. Do not use .c_str() to keep a persistent handle on a temporary string.
2. Concatenate -lfoo and -L/bar options into a single option instead of
   passing "-L /bar" (for example) which doesn't work on Darwin.
3. Send -v output to stderr instead of stdout

llvm-svn: 23404
2005-09-23 06:05:46 +00:00
Chris Lattner 59a05bdde6 Turn (X^C1) == C2 into X == C1^C2 iff X&~C1 = 0 (and move a function)
This happens all the time on PPC for bool values, e.g. eliminating a xori
in inverted-bool-compares.ll.

This should be added to the dag combiner as well.

llvm-svn: 23403
2005-09-23 00:55:52 +00:00
Chris Lattner c619d43155 new testcase
llvm-svn: 23402
2005-09-23 00:53:06 +00:00
Chris Lattner 5ff606401b Testcase for PR629
llvm-svn: 23401
2005-09-21 06:53:56 +00:00
Chris Lattner b1f8982ff0 Expose the LiveInterval interfaces as public headers.
llvm-svn: 23400
2005-09-21 04:19:09 +00:00
Chris Lattner 993a2ec38c Recommend what I actually test
llvm-svn: 23398
2005-09-21 03:56:26 +00:00
Chris Lattner 6c70106053 Start threading across blocks with code in them, so long as the code does
not define a value that is used outside of it's block.  This catches many
more simplifications, e.g. 854 in 176.gcc, 137 in vpr, etc.

This implements branch-phi-thread.ll:test3.ll

llvm-svn: 23397
2005-09-20 01:48:40 +00:00
Chris Lattner cb6d8173d2 make this test harder: add a case where instructions are in the bb to be
threaded over

llvm-svn: 23396
2005-09-20 01:43:41 +00:00
Chris Lattner f0bd8d0107 Implement merging of blocks with the same condition if the block has multiple
predecessors.  This implements branch-phi-thread.ll::test1

llvm-svn: 23395
2005-09-20 00:43:16 +00:00
Chris Lattner 168d2e5343 new testcase
llvm-svn: 23394
2005-09-20 00:41:55 +00:00
Chris Lattner 049cb4482f Reject a case we don't handle yet
llvm-svn: 23393
2005-09-19 23:57:04 +00:00
Chris Lattner a160924d57 remove debugging code :-/
llvm-svn: 23392
2005-09-19 23:50:15 +00:00
Chris Lattner 748f903046 Implement SimplifyCFG/branch-phi-thread.ll, the most trivial case of threading
control across branches with determined outcomes.  More generality to follow.
This triggers a couple thousand times in specint.

llvm-svn: 23391
2005-09-19 23:49:37 +00:00
Chris Lattner b2a9e8115b new testcase.
llvm-svn: 23390
2005-09-19 23:48:04 +00:00
Nate Begeman c760f80fed Stub out the rest of the DAG Combiner. Just need to fill in the
select_cc bits and then wrap it in a convenience function for  use with
regular select.

llvm-svn: 23389
2005-09-19 22:34:01 +00:00
Chris Lattner 2f838f2192 Teach the local spiller to turn stack slot loads into register-register copies
when possible, avoiding the load (and avoiding the copy if the value is already
in the right register).

This patch came about when I noticed code like the following being generated:

  store R17 -> [SS1]
  ...blah...
  R4 = load [SS1]

This was causing an LSU reject on the G5.  This problem was due to the register
allocator folding spill code into a reg-reg copy (producing the load), which
prevented the spiller from being able to rewrite the load into a copy, despite
the fact that the value was already available in a register.  In the case
above, we now rip out the R4 load and replace it with a R4 = R17 copy.

This speeds up several programs on X86 (which spills a lot :) ), e.g.
smg2k from 22.39->20.60s, povray from 12.93->12.66s, 168.wupwise from
68.54->53.83s (!), 197.parser from 7.33->6.62s (!), etc.  This may have a larger
impact in some cases on the G5 (by avoiding LSU rejects), though it probably
won't trigger as often (less spilling in general).

Targets that implement folding of loads/stores into copies should implement
the isLoadFromStackSlot hook to get this.

llvm-svn: 23388
2005-09-19 06:56:21 +00:00
Chris Lattner de3c87a2ab Implement the isLoadFromStackSlot interface
llvm-svn: 23387
2005-09-19 05:23:44 +00:00
Chris Lattner b4b2530a1a Refactor this code a bit and make it more general. This now compiles:
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus2 (unsigned int x) { b.j += x; }

To:

_plus2:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r4, 0(r2)
        slwi r3, r3, 6
        add r3, r4, r3
        rlwimi r3, r4, 0, 26, 14
        stw r3, 0(r2)
        blr


instead of:

_plus2:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r4, 0(r2)
        rlwinm r5, r4, 26, 21, 31
        add r3, r5, r3
        rlwimi r4, r3, 6, 15, 25
        stw r4, 0(r2)
        blr

by eliminating an 'and'.

I'm pretty sure this is as small as we can go :)

llvm-svn: 23386
2005-09-18 07:22:02 +00:00
Chris Lattner 797dee7705 Compile
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus2 (unsigned int x) {
  b.j += x;
}

to:

plus2:
        mov %EAX, DWORD PTR [b]
        mov %ECX, %EAX
        and %ECX, 131008
        mov %EDX, DWORD PTR [%ESP + 4]
        shl %EDX, 6
        add %EDX, %ECX
        and %EDX, 131008
        and %EAX, -131009
        or %EDX, %EAX
        mov DWORD PTR [b], %EDX
        ret

instead of:

plus2:
        mov %EAX, DWORD PTR [b]
        mov %ECX, %EAX
        shr %ECX, 6
        and %ECX, 2047
        add %ECX, DWORD PTR [%ESP + 4]
        shl %ECX, 6
        and %ECX, 131008
        and %EAX, -131009
        or %ECX, %EAX
        mov DWORD PTR [b], %ECX
        ret

llvm-svn: 23385
2005-09-18 06:30:59 +00:00
Chris Lattner 01f56c68e9 Generalize this transform, using MaskedValueIsZero, allowing us to compile:
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus3 (unsigned int x) { b.k += x; }

To:

plus3:
        mov %EAX, DWORD PTR [%ESP + 4]
        shl %EAX, 17
        add DWORD PTR [b], %EAX
        ret

instead of:

plus3:
        mov %EAX, DWORD PTR [%ESP + 4]
        shl %EAX, 17
        mov %ECX, DWORD PTR [b]
        add %EAX, %ECX
        and %EAX, -131072
        and %ECX, 131071
        or %ECX, %EAX
        mov DWORD PTR [b], %ECX
        ret

llvm-svn: 23384
2005-09-18 06:02:59 +00:00
Chris Lattner 4ebc8ab4e0 fix typeo
llvm-svn: 23383
2005-09-18 05:25:20 +00:00
Chris Lattner e5b23a6d67 Remove unintentionally committed code
llvm-svn: 23382
2005-09-18 05:12:51 +00:00
Chris Lattner 27cb9dbd35 implement shift.ll:test25. This compiles:
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus3 (unsigned int x) {
  b.k += x;
}

to:

_plus3:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r3, 0(r2)
        rlwinm r4, r3, 0, 0, 14
        add r4, r4, r3
        rlwimi r4, r3, 0, 15, 31
        stw r4, 0(r2)
        blr

instead of:

_plus3:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r4, 0(r2)
        srwi r5, r4, 17
        add r3, r5, r3
        slwi r3, r3, 17
        rlwimi r3, r4, 0, 15, 31
        stw r3, 0(r2)
        blr

llvm-svn: 23381
2005-09-18 05:12:10 +00:00
Chris Lattner 1813aabcf2 new testcase
llvm-svn: 23380
2005-09-18 05:10:39 +00:00
Chris Lattner af517574ce Implement add.ll:test29. Codegening:
struct S { unsigned int i : 6, j : 11, k : 15; } b;
void plus1 (unsigned int x) {
  b.i += x;
}

as:
_plus1:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r4, 0(r2)
        add r3, r4, r3
        rlwimi r3, r4, 0, 0, 25
        stw r3, 0(r2)
        blr

instead of:

_plus1:
        lis r2, ha16(L_b$non_lazy_ptr)
        lwz r2, lo16(L_b$non_lazy_ptr)(r2)
        lwz r4, 0(r2)
        rlwinm r5, r4, 0, 26, 31
        add r3, r5, r3
        rlwimi r3, r4, 0, 0, 25
        stw r3, 0(r2)
        blr

llvm-svn: 23379
2005-09-18 04:24:45 +00:00
Chris Lattner 9136c832c4 new testcase
llvm-svn: 23378
2005-09-18 04:22:59 +00:00
Chris Lattner 027eaf01cf remove debug output
llvm-svn: 23377
2005-09-18 03:50:25 +00:00
Chris Lattner 1521298993 Implement or.ll:test21. This teaches instcombine to be able to turn this:
struct {
   unsigned int bit0:1;
   unsigned int ubyte:31;
} sdata;

void foo() {
  sdata.ubyte++;
}

into this:

foo:
        add DWORD PTR [sdata], 2
        ret

instead of this:

foo:
        mov %EAX, DWORD PTR [sdata]
        mov %ECX, %EAX
        add %ECX, 2
        and %ECX, -2
        and %EAX, 1
        or %EAX, %ECX
        mov DWORD PTR [sdata], %EAX
        ret

llvm-svn: 23376
2005-09-18 03:42:07 +00:00
Chris Lattner c6d63a9832 new testcase
llvm-svn: 23375
2005-09-18 03:39:02 +00:00
Chris Lattner 4d9cf68023 Implement hook for ppc
llvm-svn: 23374
2005-09-17 01:03:26 +00:00
Chris Lattner 6db5887db5 add a new callback
llvm-svn: 23373
2005-09-17 01:02:45 +00:00
Nate Begeman 24a7eca282 More DAG combining. Still need the branch instructions, and select_cc
llvm-svn: 23371
2005-09-16 00:54:12 +00:00
Chris Lattner 7884fffb00 Fix a minor bug, add comments
llvm-svn: 23370
2005-09-16 00:29:46 +00:00
Chris Lattner 59e96143a2 teach the type inference code how to infer types for instructions and node
xforms.  Run type inference on result patterns, so we always have fully typed
results (and to catch errors in .td files).

llvm-svn: 23369
2005-09-15 22:23:50 +00:00
Chris Lattner fedd9a5e1d put instructions into a map instead of a vector for quick lookup
llvm-svn: 23368
2005-09-15 21:57:35 +00:00
Chris Lattner f38ce8f756 when parsing instructions remember information about the types taken and
returned.

llvm-svn: 23367
2005-09-15 21:51:12 +00:00
Chris Lattner 0ebec06671 disable this for now
llvm-svn: 23366
2005-09-15 21:44:00 +00:00
Chris Lattner a0a986c9ae Start parsing "Pattern" nodes
llvm-svn: 23365
2005-09-15 21:42:00 +00:00
Chris Lattner f79ad4cb32 rename a couple of methods, add structure for pattern parsing
llvm-svn: 23364
2005-09-15 02:38:02 +00:00
Chris Lattner a155256a71 Verify that xform functions only occur in logical places
llvm-svn: 23363
2005-09-14 23:05:13 +00:00
Chris Lattner 991c7c973a Promote xform fns to be explicit nodes in result patterns, and clean off
predicates since they will have already matched at this point.

llvm-svn: 23362
2005-09-14 23:01:59 +00:00
Chris Lattner bc7aabce12 start building the instruction dest pattern correctly. Change the xform
functions to preserve the Record for the xform instead of making it into a
function name.

llvm-svn: 23361
2005-09-14 22:55:26 +00:00
Chris Lattner e389c6154e catch unnamed inputs
llvm-svn: 23360
2005-09-14 22:06:36 +00:00
Chris Lattner 030f876cf2 check that there are no unexpected operands
llvm-svn: 23359
2005-09-14 21:59:34 +00:00
Chris Lattner 3ced3f8b82 force all instruction operands to be named.
llvm-svn: 23358
2005-09-14 21:13:50 +00:00
Chris Lattner 9e4a4ee3dc Give all operands names
llvm-svn: 23357
2005-09-14 21:11:13 +00:00
Chris Lattner 2e84be22a8 give all operands names
llvm-svn: 23356
2005-09-14 21:10:24 +00:00
Chris Lattner f02994d782 Check that operands have unique names. REJECT instructions with broken operand
lists: only don't parse them if they are entirely missing (sparcv9).

llvm-svn: 23355
2005-09-14 21:05:02 +00:00
Chris Lattner 24ae3494f0 fix a broke range check
llvm-svn: 23354
2005-09-14 21:04:12 +00:00
Chris Lattner 3ba60bf644 Parse significantly more of the instruction pattern, now collecting and
verifying information about the operands.

llvm-svn: 23353
2005-09-14 20:53:42 +00:00
Chris Lattner f006d15e7f Fix some issues exposed by more testing. XORIS had the wrong operands
specified.  The various *imm operands defined by PPC are really all i32,
even though the actual immediate is restricted to a smaller value in it.

llvm-svn: 23352
2005-09-14 20:53:05 +00:00
Chris Lattner 22e60c99ce Verify that set destinations occur first in the instruction operand list.
llvm-svn: 23351
2005-09-14 18:19:25 +00:00
Chris Lattner 6b013fc923 Fix some bugs noticed by new checking code
llvm-svn: 23350
2005-09-14 18:18:39 +00:00
Chris Lattner fcffc98b05 add an accessor
llvm-svn: 23349
2005-09-14 18:02:53 +00:00
Chris Lattner a393e4d4b3 Fix the regression last night compiling povray
llvm-svn: 23348
2005-09-14 17:32:56 +00:00
Chris Lattner b42e962d23 fix a major regression from my patch this afternoon
llvm-svn: 23347
2005-09-14 06:06:45 +00:00
Chris Lattner 1c8d6ce015 remove some code that isn't ready for prime time
llvm-svn: 23346
2005-09-14 06:03:10 +00:00
Chris Lattner 3361eab530 Switch to a slightly more structured representation for instructions
llvm-svn: 23345
2005-09-14 04:03:16 +00:00
Chris Lattner 4cfcb544bf Add some more checking/verification code
llvm-svn: 23344
2005-09-14 02:11:12 +00:00
Chris Lattner 4c7b604091 start parsing instructions into patterns, start doing many more checks of
'set's.

llvm-svn: 23343
2005-09-14 00:09:24 +00:00
Chris Lattner b011cb2746 we don't need this proto any longer
llvm-svn: 23342
2005-09-13 22:05:21 +00:00
Chris Lattner bb9b01644e don't emit the namespace inside the class!
llvm-svn: 23341
2005-09-13 22:05:02 +00:00
Chris Lattner 70a7234111 Emit code suitable for emission into the ISel class, allowing us to use/define
methods.

llvm-svn: 23340
2005-09-13 22:03:37 +00:00
Chris Lattner 03e08eefc7 move the #include for the generated code into the isel class body so we
can use/define class methods

llvm-svn: 23339
2005-09-13 22:03:06 +00:00
Chris Lattner 3556d849da continue xform function parsing
llvm-svn: 23338
2005-09-13 21:59:15 +00:00
Chris Lattner 2617de498d Start parsing node transformation information
llvm-svn: 23337
2005-09-13 21:51:00 +00:00
Chris Lattner ae939eb6bb Add a new Record::getValueAsCode method to mirror the other getValueAs*
methods.  Use it to simplify some code.

llvm-svn: 23336
2005-09-13 21:44:28 +00:00
Chris Lattner f365e25a5c completely eliminate TreePattern::PatternType
llvm-svn: 23335
2005-09-13 21:20:49 +00:00
Chris Lattner 0f965a615e Change the arg lowering code to use copyfromreg from vregs associated
with incoming arguments instead of the pregs themselves.  This fixes
the scheduler from causing problems by moving a copyfromreg for an argument
to after a select_cc node (now it can, and bad things won't happen).

llvm-svn: 23334
2005-09-13 19:33:40 +00:00
Chris Lattner ee8113293e This has been moved to the target-indep code
llvm-svn: 23333
2005-09-13 19:32:18 +00:00
Chris Lattner fb96e50b8c This code is no longer needed, it is moved to the target-indep code
llvm-svn: 23332
2005-09-13 19:31:44 +00:00
Chris Lattner d4382f0afa If a function has liveins, and if the target requested that they be plopped
into particular vregs, emit copies into the entry MBB.

llvm-svn: 23331
2005-09-13 19:30:54 +00:00
Chris Lattner 64685b4ca2 Majik numbers are bad
llvm-svn: 23330
2005-09-13 19:03:13 +00:00
Chris Lattner aa6cbd90c5 Remove some dead vectors
llvm-svn: 23329
2005-09-13 18:47:49 +00:00
Chris Lattner 2a8932960d Add a simple xform to simplify array accesses with casts in the way.
This is useful for 178.galgel where resolution of dope vectors (by the
optimizer) causes the scales to become apparent.

llvm-svn: 23328
2005-09-13 18:36:04 +00:00
Chris Lattner fd018c8dfe Fix an issue where LSR would miss rewriting a use of an IV expression by a PHI node that is not the original PHI.
This fixes up a dot-product loop in galgel, speeding it up from 18.47s to
16.13s.

llvm-svn: 23327
2005-09-13 02:09:55 +00:00
Duraid Madina a78635c1f0 fails since linux-itanium headers are Different
llvm-svn: 23326
2005-09-13 01:03:53 +00:00
Chris Lattner 567b81f0d2 Add a helper function, allowing us to simplify some code a bit, changing
indentation, no functionality change

llvm-svn: 23325
2005-09-13 00:40:14 +00:00
Chris Lattner 219175c84d Implement a simple xform to turn code like this:
if () { store A -> P; } else { store B -> P; }

into a PHI node with one store, in the most trival case.  This implements
load.ll:test10.

llvm-svn: 23324
2005-09-12 23:23:25 +00:00
Chris Lattner 42a6cefa49 new testcase
llvm-svn: 23323
2005-09-12 23:22:17 +00:00
Chris Lattner e0bfdf1485 Another load-peephole optimization: do gcse when two loads are next to
each other.  This implements InstCombine/load.ll:test9

llvm-svn: 23322
2005-09-12 22:21:03 +00:00
Chris Lattner 20c1cc0741 new testcase
llvm-svn: 23321
2005-09-12 22:19:46 +00:00
Chris Lattner b990f7d8ed Implement a trivial form of store->load forwarding where the store and the
load are exactly consequtive.  This is picked up by other passes, but this
triggers thousands of times in fortran programs that use static locals
(and is thus a compile-time speedup).

llvm-svn: 23320
2005-09-12 22:00:15 +00:00
Chris Lattner 4cd474ebbd new testcase
llvm-svn: 23319
2005-09-12 21:59:22 +00:00
Chris Lattner 8048b85e8f Fix a regression from last night, which caused this pass to create invalid
code for IV uses outside of loops that are not dominated by the latch block.
We should only convert these uses to use the post-inc value if they ARE
dominated by the latch block.

Also use a new LoopInfo method to simplify some code.

This fixes Transforms/LoopStrengthReduce/2005-09-12-UsesOutOutsideOfLoop.ll

llvm-svn: 23318
2005-09-12 17:11:27 +00:00
Chris Lattner 2ee807c70f relax pattern match on name
llvm-svn: 23317
2005-09-12 17:09:40 +00:00
Chris Lattner 7efb86dc11 new testcase
llvm-svn: 23316
2005-09-12 17:08:15 +00:00
Chris Lattner b35df5f5bc Add a new getLoopLatch() method.
llvm-svn: 23315
2005-09-12 17:03:55 +00:00
Chris Lattner 589e605f42 new method
llvm-svn: 23314
2005-09-12 17:03:16 +00:00
Chris Lattner a67648396a _test:
li r2, 0
LBB_test_1:     ; no_exit.2
        li r5, 0
        stw r5, 0(r3)
        addi r2, r2, 1
        addi r3, r3, 4
        cmpwi cr0, r2, 701
        blt cr0, LBB_test_1     ; no_exit.2
LBB_test_2:     ; loopexit.2.loopexit
        addi r2, r2, 1
        stw r2, 0(r4)
        blr
[zion ~/llvm]$ cat > ~/xx
Uses of IV's outside of the loop should use hte post-incremented version
of the IV, not the preincremented version.  This helps many loops (e.g. in sixtrack)
which used to generate code like this (this is the code from the
dont-hoist-simple-loop-constants.ll testcase):

_test:
        li r2, 0                 **** IV starts at 0
LBB_test_1:     ; no_exit.2
        or r5, r2, r2            **** Copy for loop exit
        li r2, 0
        stw r2, 0(r3)
        addi r3, r3, 4
        addi r2, r5, 1
        addi r6, r5, 2           **** IV+2
        cmpwi cr0, r6, 701
        blt cr0, LBB_test_1     ; no_exit.2
LBB_test_2:     ; loopexit.2.loopexit
        addi r2, r5, 2       ****  IV+2
        stw r2, 0(r4)
        blr

And now generated code like this:

_test:
        li r2, 1               *** IV starts at 1
LBB_test_1:     ; no_exit.2
        li r5, 0
        stw r5, 0(r3)
        addi r2, r2, 1
        addi r3, r3, 4
        cmpwi cr0, r2, 701     *** IV.postinc + 0
        blt cr0, LBB_test_1
LBB_test_2:     ; loopexit.2.loopexit
        stw r2, 0(r4)          *** IV.postinc + 0
        blr

llvm-svn: 23313
2005-09-12 06:04:47 +00:00
Chris Lattner 2bb00dda5a new testcase
llvm-svn: 23312
2005-09-12 05:50:15 +00:00
Chris Lattner d0c7a5eeb7 Regenerate
llvm-svn: 23311
2005-09-12 05:30:06 +00:00
Chris Lattner 564d240799 Rearrange two rules, which apparently makes some versions of bison happier.
llvm-svn: 23310
2005-09-12 05:29:43 +00:00
Chris Lattner ecd98d5d77 Make sure to disable 64-bit extensions for this test
llvm-svn: 23309
2005-09-11 03:50:38 +00:00
Jeff Cohen e19ca3ab0c Fix more Visual Studio build problems.
llvm-svn: 23308
2005-09-10 02:33:17 +00:00
Jeff Cohen 0dce12dd90 Fix miscellaneous Visual Studio build problems.
llvm-svn: 23307
2005-09-10 02:00:02 +00:00
Chris Lattner 530fe6ab30 implement Transforms/LoopStrengthReduce/dont-hoist-simple-loop-constants.ll.
We used to emit this code for it:

_test:
        li r2, 1     ;; Value tying up a register for the whole loop
        li r5, 0
LBB_test_1:     ; no_exit.2
        or r6, r5, r5
        li r5, 0
        stw r5, 0(r3)
        addi r5, r6, 1
        addi r3, r3, 4
        add r7, r2, r5  ;; should be addi r7, r5, 1
        cmpwi cr0, r7, 701
        blt cr0, LBB_test_1     ; no_exit.2
LBB_test_2:     ; loopexit.2.loopexit
        addi r2, r6, 2
        stw r2, 0(r4)
        blr

now we emit this:

_test:
        li r2, 0
LBB_test_1:     ; no_exit.2
        or r5, r2, r2
        li r2, 0
        stw r2, 0(r3)
        addi r3, r3, 4
        addi r2, r5, 1
        addi r6, r5, 2   ;; whoa, fold those adds!
        cmpwi cr0, r6, 701
        blt cr0, LBB_test_1     ; no_exit.2
LBB_test_2:     ; loopexit.2.loopexit
        addi r2, r5, 2
        stw r2, 0(r4)
        blr

more improvement coming.

llvm-svn: 23306
2005-09-10 01:18:45 +00:00
Chris Lattner 0c7728e4d6 new testcase
llvm-svn: 23305
2005-09-10 01:14:37 +00:00
Chris Lattner 4309c3a785 PowerPC cannot truncstore i1 natively
llvm-svn: 23304
2005-09-10 00:21:06 +00:00
Chris Lattner 2d454bf5be Allow targets to say they don't support truncstore i1 (which includes a mask
when storing to an 8-bit memory location), as most don't.

llvm-svn: 23303
2005-09-10 00:20:18 +00:00
Chris Lattner bd39c1a4c6 Add a missing #include, patch courtesy of Baptiste Lepilleur.
llvm-svn: 23302
2005-09-09 23:53:39 +00:00
Chris Lattner 331b311f7b Fix a problem duraid encountered on itanium where this folding:
select (x < y), 1, 0 -> (x < y) incorrectly: the setcc returns i1 but the
select returned i32.  Add the zero extend as needed.

llvm-svn: 23301
2005-09-09 23:00:07 +00:00
Chris Lattner 16e5cb87ba Fix a crash viewing dags that have target nodes in them
llvm-svn: 23300
2005-09-09 22:35:03 +00:00
Chris Lattner 0f2146bb5d I forgot that we always spill fp values as 64-bits. Implement spill folding
for FP as well.  This triggers a couple dozen times on 177.mesa (for example).

llvm-svn: 23299
2005-09-09 21:59:44 +00:00
Chris Lattner 712e78ee28 Fix a problem that Nate noticed, where spill code was not getting coallesced
with copies, leading to code like this:

       lwz r4, 380(r1)
       or r10, r4, r4    ;; Last use of r4

By teaching the PPC backend how to fold spills into copies, we now get this
code:

       lwz r10, 380(r1)

wow. :)

This reduces a testcase nate sent me from 1505 instructions to 1484.

Note that this could handle FP values but doesn't currently, for reasons
mentioned in the patch

llvm-svn: 23298
2005-09-09 21:46:49 +00:00
Chris Lattner f540c1a2e8 code cleanup
llvm-svn: 23297
2005-09-09 20:51:08 +00:00
Chris Lattner 1410003751 Use continue in the use-processing loop to make it clear what the early exits
are, simplify logic, and cause things to not be nested as deeply.  This also
uses MRI->areAliases instead of an explicit loop.

No functionality change, just code cleanup.

llvm-svn: 23296
2005-09-09 20:29:51 +00:00
Nate Begeman 049b748c76 Last round of 2-node folds from SD.cpp. Will move on to 3 node ops such
as setcc and select next.

llvm-svn: 23295
2005-09-09 19:49:52 +00:00
Chris Lattner ce3662f2a2 remove debugging code *slaps head*
llvm-svn: 23294
2005-09-09 19:19:20 +00:00
Chris Lattner c9053083eb When spilling a live range that is used multiple times by one instruction,
only add a reload live range once for the instruction.  This is one step
towards fixing a regalloc pessimization that Nate notice, but is later undone
by the spiller (so no code is changed).

llvm-svn: 23293
2005-09-09 19:17:47 +00:00
Chris Lattner c37a2f13c4 Teach the code generator that rlwimi is commutable if the rotate amount
is zero.  This lets the register allocator elide some copies in some cases.

This implements CodeGen/PowerPC/rlwimi-commute.ll

llvm-svn: 23292
2005-09-09 18:17:41 +00:00
Jim Laskey 48356a50f3 Added targets to speed up build of llc.
llvm-svn: 23291
2005-09-09 17:50:20 +00:00
Chris Lattner db9f4b9db4 New testcase, neither should require a register-register copy
llvm-svn: 23290
2005-09-09 17:48:57 +00:00
Chris Lattner ce2173d098 add an accessor to provide more checking
llvm-svn: 23289
2005-09-09 01:15:01 +00:00
Chris Lattner 7a82c06f34 use new accessors to simplify code. Add checking to make sure top-level instr
definitions are void

llvm-svn: 23288
2005-09-09 01:11:44 +00:00
Chris Lattner 91d8672be1 add some accessors
llvm-svn: 23287
2005-09-09 01:11:17 +00:00
Chris Lattner 39b4d83f6a Introduce two new concepts:
1. Add support for defining Pattern's, which can match expressions when there
   is no instruction that directly implements something.  Instructions usually
   implicitly define patterns.
2. Add support for defining SDNodeXForm's, which are node transformations.
   This seperates the concept of a node xform out from the existing predicate
   support.

Using this new stuff, we add a few instruction patterns, one for testing, and
two for OR/XOR by an arbitrary immediate.

llvm-svn: 23286
2005-09-09 00:39:56 +00:00
Chris Lattner debd6e95ab Fix incorrect comment
llvm-svn: 23285
2005-09-08 23:26:30 +00:00
Chris Lattner d7d31f3b06 Implement a complete type inference system for dag patterns, based on the
constraints defined in the DAG node definitions in the .td files.  This
allows us to infer (and check!) the types for all nodes in the current
ppc .td file.  For example, instead of:

Inst pattern EQV:       (set GPRC:i32:$rT, (xor (xor GPRC:i32:$rA, GPRC:i32:$rB), (imm)<<Predicate_immAllOnes>>))

we now fully infer:

Inst pattern EQV:       (set:void GPRC:i32:$rT, (xor:i32 (xor:i32 GPRC:i32:$rA, GPRC:i32:$rB), (imm:i32)<<Predicate_immAllOnes>>))

from:  (set GPRC:$rT, (not (xor GPRC:$rA, GPRC:$rB)))
llvm-svn: 23284
2005-09-08 23:22:48 +00:00
Chris Lattner 4b09f3c6f5 whitespace/comment changes, no functionality diffs
llvm-svn: 23283
2005-09-08 23:17:26 +00:00
Chris Lattner cee994b464 Compute the value types that are natively supported by a target.
llvm-svn: 23282
2005-09-08 21:43:21 +00:00
Chris Lattner 1c33104010 Parse information about type constraints on SDNodes
llvm-svn: 23281
2005-09-08 21:27:15 +00:00
Chris Lattner a3b89dfcef use node info in the one place we currently use it
llvm-svn: 23280
2005-09-08 21:04:46 +00:00
Chris Lattner 35bcd1488a start parsing SDNode info records
llvm-svn: 23279
2005-09-08 21:03:01 +00:00
Nate Begeman 85c1cc4523 Move yet more folds over to the dag combiner from sd.cpp
llvm-svn: 23278
2005-09-08 20:18:10 +00:00
Chris Lattner 0ec8fa0880 Add a bunch of stuff needed for node type inference. Move 'BLR' down with
the rest of the instructions, add comment markers to seperate portions of
the file into logical parts

llvm-svn: 23277
2005-09-08 19:50:41 +00:00
Chris Lattner 07f1e4597e Fix indentation
llvm-svn: 23276
2005-09-08 19:47:28 +00:00
Chris Lattner bd6b164965 regenerate
llvm-svn: 23275
2005-09-08 18:48:47 +00:00
Chris Lattner 972cccd77a Add support for automatically created anonymous definitions.
This implements Regression/TableGen/AnonDefinitionOnDemand.td

llvm-svn: 23274
2005-09-08 18:48:23 +00:00
Chris Lattner 1872ea3227 x and X should be structurally identical
llvm-svn: 23273
2005-09-08 18:47:43 +00:00
Chris Lattner 808c642e62 new expression type
llvm-svn: 23272
2005-09-08 18:47:21 +00:00
Chris Lattner 5a699e621f regenerate
llvm-svn: 23271
2005-09-08 18:22:57 +00:00
Chris Lattner 8a41b214b3 Tabs to spaces.
llvm-svn: 23270
2005-09-08 18:22:35 +00:00
Chris Lattner 399f59f643 Keep names even when inlining. This allows us to realize that ADDI is:
(set GPRC:i32:$rD, (add GPRC:i32:$rA, (imm)<<Predicate_immSExt16>>:$imm))

not:

(set GPRC:i32:$rD, (add GPRC:i32:$rA, (imm)<<Predicate_immSExt16>>))

(we keep the ":$imm")

llvm-svn: 23269
2005-09-08 17:45:12 +00:00
Chris Lattner 76cb006e2c add patterns for x?oris?
llvm-svn: 23268
2005-09-08 17:40:49 +00:00
Chris Lattner 2d8032b54c add patterns to the addi/addis/mulli etc instructions. Define predicates
for matching signed 16-bit and shifted 16-bit ppc immediates

llvm-svn: 23267
2005-09-08 17:33:10 +00:00
Chris Lattner cf9b0e6673 Add patterns for some new instructions, allowing the use of the ineg fragment.
llvm-svn: 23266
2005-09-08 17:01:54 +00:00
Chris Lattner f18935a598 add some missing PPC backend files
llvm-svn: 23265
2005-09-07 23:57:00 +00:00
Chris Lattner a0d936cdc5 Add tblgen fpcmp and the nightly tester to the utils folder
llvm-svn: 23264
2005-09-07 23:53:49 +00:00
Chris Lattner 7c8dba750c ignore generated files
llvm-svn: 23263
2005-09-07 23:47:44 +00:00
Chris Lattner 498915dafa Remove some cases handled by the generated portion of the isel
llvm-svn: 23262
2005-09-07 23:45:15 +00:00
Chris Lattner d2a5b366f5 Initial cut of the dag isel generator. This is still very much a work in
progress.  It correctly parses instructions and pattern fragments and glues
together pattern fragments into instructions.

The only code it generates currently is some boilerplate code for things
like the EntryNode.

llvm-svn: 23261
2005-09-07 23:44:43 +00:00
Nate Begeman 2cc2c9a79c Another round of dag combiner changes. This fixes some missing XOR folds
as well as fixing how we replace old values with new values.

llvm-svn: 23260
2005-09-07 23:25:52 +00:00
Chris Lattner 5d16dbd5bb Fix a bug that Tzu-Chien Chiu noticed: live interval analysis does NOT
preserve livevar

llvm-svn: 23259
2005-09-07 17:34:39 +00:00
Nate Begeman 6791d63e55 Implement a common missing fold, (add (add x, c1), c2) -> (add x, c1+c2).
This restores all of stanford to being identical with and without the dag
combiner with the add folding turned off in sd.cpp.

llvm-svn: 23258
2005-09-07 16:09:19 +00:00
Chris Lattner 5ea0ee7b19 On non-apple systems, when using -march=ppc32, do not print:
'' is not a recognized processor for this target (ignoring processor)

Default to "generic" instead of "" for the default CPU.

llvm-svn: 23257
2005-09-07 05:45:33 +00:00
Chris Lattner 8d0e9d90aa Print:
'' is not a recognized processor for this target (ignoring processor)

instead of:

 is not a recognized processor for this target (ignoring processor)

llvm-svn: 23256
2005-09-07 05:44:14 +00:00
Chris Lattner fe883adfd2 Fix a bug nate ran into with replacealluseswith. In the recursive cse case,
we were losing a node, causing an assertion to fail.  Now we eagerly delete
discovered CSE's, and provide an optional vector to keep track of these
discovered equivalences.

llvm-svn: 23255
2005-09-07 05:37:01 +00:00
Chris Lattner 3852fd0e49 Add a new argument to ReplaceAllUsesWith to keep track of nodes deleted by
this method

llvm-svn: 23254
2005-09-07 05:36:18 +00:00
Nate Begeman 007c650699 Add an option to the DAG Combiner to enable it for beta runs, and turn on
that option for PowerPC's beta.

llvm-svn: 23253
2005-09-07 00:15:36 +00:00
Chris Lattner c59a1dbce2 Rename a class. These files are being migrated to the new isel and I want to
reuse the names

llvm-svn: 23252
2005-09-06 22:51:34 +00:00
Nate Begeman a53a310d8c Test the new 64bit i64<->fp functionality
llvm-svn: 23251
2005-09-06 22:23:15 +00:00
Nate Begeman 6095214bf0 Implement i64<->fp using the fctidz/fcfid instructions on PowerPC when we
are allowed to generate 64-bit-only PowerPC instructions for 32 bit hosts,
such as the PowerPC 970.

This speeds up 189.lucas from 81.99 to 32.64 seconds.

llvm-svn: 23250
2005-09-06 22:03:27 +00:00
Chris Lattner 784e44443d regenerate
llvm-svn: 23249
2005-09-06 21:23:27 +00:00
Chris Lattner ab9eba1014 Tighten up the specification to allow TableGen/nested-comment.td to pass
(fixing a bug where / in a /* */ comment would cause it to not close).

llvm-svn: 23248
2005-09-06 21:23:09 +00:00
Chris Lattner 23e2499ee4 new testcase: tblgen should grok this.
llvm-svn: 23247
2005-09-06 21:22:15 +00:00
Andrew Lenharth a63a066205 Fix up the AssertXext problem, as well as adding it at calls
llvm-svn: 23246
2005-09-06 17:00:23 +00:00
Nate Begeman e9e2c6d314 Add note about future optimization noted in the ppc compiler writer's guide
llvm-svn: 23245
2005-09-06 15:30:48 +00:00
Nate Begeman 2dded8302a Add accessor for 64bit flag, so that we can tell when it is safe to
generate the fun in-register fp<->long instructions.

llvm-svn: 23244
2005-09-06 15:30:12 +00:00
Nate Begeman d23739d020 Next round of DAGCombiner changes. This version now passes all the tests
I have run so far when run before Legalize.  It still needs to pick up the
SetCC folds, and nodes that use SetCC.

llvm-svn: 23243
2005-09-06 04:43:02 +00:00
Chris Lattner f1705fdda4 Add a requirement, patch contributed by Henrik Bach.
llvm-svn: 23242
2005-09-06 04:07:15 +00:00
Andrew Lenharth c8bd5bda59 revert part of the last change, should fix regressions
llvm-svn: 23241
2005-09-04 06:12:19 +00:00
Chris Lattner aa833d4571 explicitly specify an operands list for patterns with inputs (e.g. neg)
llvm-svn: 23240
2005-09-03 01:28:40 +00:00
Chris Lattner 8ae9525bd0 include the dag isel fragment
llvm-svn: 23239
2005-09-03 01:17:22 +00:00
Chris Lattner 0442dcfabc ask for a dag isel
llvm-svn: 23238
2005-09-03 01:15:41 +00:00
Chris Lattner 33f98bdddf allow for a target to ask for a dag isel
llvm-svn: 23237
2005-09-03 01:15:25 +00:00
Chris Lattner 90d000417f Add an option and stuff implementation of a dag isel emitter
llvm-svn: 23236
2005-09-03 01:14:03 +00:00
Chris Lattner 821628ff2a Fix a checking failure in gs
llvm-svn: 23235
2005-09-03 01:04:40 +00:00
Chris Lattner 5f12cf14be Change the isel to not break out of the big giant switch. Instead, the
switch should never be exited, so its bottom is now unreachable.

llvm-svn: 23234
2005-09-03 00:53:47 +00:00
Chris Lattner 9220f92c41 rearrange logical ops to group them together more consistently.
Define the PatFrag class which can be used to define subpatterns to match
things with.  Define 'not', and use it to define the patterns for andc,
nand, etc.

llvm-svn: 23233
2005-09-03 00:21:51 +00:00
Chris Lattner dcbb561b76 Add AND/OR/XOR
llvm-svn: 23232
2005-09-02 22:35:53 +00:00
Nate Begeman 7cea6ef16e Next round of DAG Combiner changes. Just need to support multiple return
values, and then we should be able to hook it up.

llvm-svn: 23231
2005-09-02 21:18:40 +00:00
Chris Lattner 3a1002d529 Add some initial patterns to simple binary instructions, though they
currently don't do anything.  This elides patterns for binary operators
that ping on the carry flag, since we don't model it yet.

This patch also removes PPC::SUB, because it is dead.

llvm-svn: 23230
2005-09-02 21:18:00 +00:00
Chris Lattner 1a570f1fe4 Clean up some code from the last checkin
llvm-svn: 23229
2005-09-02 20:32:45 +00:00
Chris Lattner 630226697f Fix a bug in legalize where it would emit two calls to libcalls that return
i64 values on targets that need that expanded to 32-bit registers.  This fixes
PowerPC/2005-09-02-LegalizeDuplicatesCalls.ll and speeds up 189.lucas from
taking 122.72s to 81.96s on my desktop.

llvm-svn: 23228
2005-09-02 20:26:58 +00:00
Chris Lattner 63fab495bb Test that converting from double to int64 results in one libcall, not one
and a dead one.  This is a legalize bug

llvm-svn: 23227
2005-09-02 20:24:10 +00:00
Chris Lattner 06e237f253 turn on dag isel by default
llvm-svn: 23226
2005-09-02 19:53:54 +00:00
Chris Lattner b95b280bee Make sure to auto-cse nullary ops
llvm-svn: 23224
2005-09-02 19:36:17 +00:00
Chris Lattner 5ba7b615ed add a map for nullary ops
llvm-svn: 23223
2005-09-02 19:35:42 +00:00
Jim Laskey 27d628dfc9 Add help support for -mcpu and -mattr.
llvm-svn: 23222
2005-09-02 19:27:43 +00:00
Chris Lattner 1e89e36dcd Fix some buggy logic where we would try to remove nodes with two operands
from the binary ops map, even if they had multiple results.  This latent bug
caused a few failures with the dag isel last night.

To prevent stuff like this from happening in the future, add some really
strict checking to make sure that the CSE maps always match up with reality!

llvm-svn: 23221
2005-09-02 19:15:44 +00:00
Andrew Lenharth 9690a4f321 Pull out Lowering in preperation for multiple ISels. Oh, and get rid of some stuff
llvm-svn: 23220
2005-09-02 18:46:02 +00:00
Chris Lattner b0b4ec5655 Don't create zero sized stack objects even for array allocas with a zero
number of elements.

llvm-svn: 23219
2005-09-02 18:41:28 +00:00
Chris Lattner aa3b1fcc58 Decouple fsqrt from gpul optimizations, implementing fsqrt.ll.
Remove the -enable-gpopt option which is subsumed by feature flags.

llvm-svn: 23218
2005-09-02 18:33:05 +00:00
Chris Lattner ffb99034cf new testcase to ensure fsqrt is generated for correct subtargets only, and
that the fsqrt feature works.

llvm-svn: 23217
2005-09-02 18:32:22 +00:00
Chris Lattner 38ad3f6948 Move a bunch of non-deprecated methods above the "deprecated line"
llvm-svn: 23216
2005-09-02 18:16:20 +00:00
Chris Lattner b6cde17d29 Fix the release build, noticed by Eric van Riet Paap
llvm-svn: 23215
2005-09-02 07:09:28 +00:00
Chris Lattner b5e381a8cf Fix a problem that Dan Berlin noticed, where reassociation would not succeed
in building maximal expressions before simplifying them.  In particular, i
cases like this:

X-(A+B+X)

the code would consider A+B+X to be a maximal expression (not understanding
that the single use '-' would be turned into a + later), simplify it (a noop)
then later get simplified again.

Each of these simplify steps is where the cost of reassociation comes from,
so this patch should speed up the already fast pass a bit.

Thanks to Dan for noticing this!

llvm-svn: 23214
2005-09-02 07:07:58 +00:00
Chris Lattner 9fe263aa75 Avoid creating garbage instructions, just move the old add instruction
to where we need it when converting -(A+B+C) -> -A + -B + -C.

llvm-svn: 23213
2005-09-02 06:38:04 +00:00
Chris Lattner b944d5a491 new testcase for recent bugfix
llvm-svn: 23212
2005-09-02 06:12:12 +00:00
Chris Lattner d1325da091 add some assertions and fix problems where reassociate could access the
Ops vector out of range

llvm-svn: 23211
2005-09-02 05:23:22 +00:00
Jeff Cohen a6dde9962d Fix VC++ build errors
llvm-svn: 23210
2005-09-02 02:51:42 +00:00
Chris Lattner 763a3a0fa7 Restore this patch now that the latent bug has been fixed
llvm-svn: 23209
2005-09-02 01:24:55 +00:00
Chris Lattner d9af1aab51 Make sure to legalize assert[zs]ext's operand correctly
llvm-svn: 23208
2005-09-02 01:15:01 +00:00
Chris Lattner 06d440f2ee Revert the previous patch which causes a mysterious regression in toast.
llvm-svn: 23207
2005-09-02 00:47:05 +00:00
Chris Lattner 7138f91424 Teach live intervals to not crash on dead livein regs
llvm-svn: 23206
2005-09-02 00:20:32 +00:00
Chris Lattner a66403dbf7 For values that are live across basic blocks and need promotion, use ANY_EXTEND
instead of ZERO_EXTEND to eliminate extraneous extensions.  This eliminates
dead zero extensions on formal arguments and other cases on PPC, implementing
the newly tightened up test/Regression/CodeGen/PowerPC/small-arguments.ll test.

llvm-svn: 23205
2005-09-02 00:19:37 +00:00
Chris Lattner 7753f175e6 legalize ANY_EXTEND appropriately
llvm-svn: 23204
2005-09-02 00:18:10 +00:00
Chris Lattner 8c393c218b Add support for ANY_EXTEND and add a few minor folds for it
llvm-svn: 23203
2005-09-02 00:17:32 +00:00
Chris Lattner 210975cfbb Handle any_extend like zext
llvm-svn: 23202
2005-09-02 00:16:09 +00:00
Chris Lattner 2493f0e5fd Handle ANY_EXTEND like ZERO_EXTEND. Simplify the extend/truncate code on
the observation that it only has to handle i1 -> i64 and i64 -> i1.

llvm-svn: 23201
2005-09-02 00:15:30 +00:00
Chris Lattner 969af57d65 Add a new ANY_EXTEND node, which operates like an extension but has undefined
top bits.

llvm-svn: 23200
2005-09-02 00:14:40 +00:00
Chris Lattner 97ac77fd91 This should permit NOT and's, not even dead ones.
llvm-svn: 23199
2005-09-02 00:13:56 +00:00
Chris Lattner 9ee867b93b Implement small-arguments.ll:test3 by teaching the DAG optimizer that
the results of calls to functions returning small values are properly
sign/zero extended.

llvm-svn: 23198
2005-09-01 23:44:32 +00:00
Chris Lattner 907123b1ab Another case that shouldn't have sign extends: functions returning short
are known to return properly sign extended values, no need for an explicit
extension.

llvm-svn: 23197
2005-09-01 23:43:58 +00:00
Nate Begeman d78d975437 Fix some code in the current node combining code, spotted when it was moved
over to DAGCombiner.cpp

1. Don't assume that SetCC returns i1 when folding (xor (setcc) constant)
2. Don't duplicate code in folding AND with AssertZext that is handled by
   MaskedValueIsZero

llvm-svn: 23196
2005-09-01 23:25:49 +00:00
Nate Begeman 2504fe2613 Implement first round of feedback from chris (there's still a couple things
left to do).

llvm-svn: 23195
2005-09-01 23:24:04 +00:00
Chris Lattner 68d15fdfea Align functions to 16-byte boundaries, to eliminate noise in performance measurements. This improves the performance of 'treeadd' by about 20% with the dag
isel, restoring it to the pattern-isel level (which happens to get the alignment right).

llvm-svn: 23194
2005-09-01 23:08:50 +00:00
Chris Lattner e40a3ccd60 Local labels on darwin apparently start with just 'L', not .L like other
platforms.  This reduces executable size and makes shark realize the actual
bounds of functions instead of showing each MBB as a function :)

llvm-svn: 23193
2005-09-01 21:48:35 +00:00
Jim Laskey 19058c3989 1. Use SubtargetFeatures in llc/lli.
2. Propagate feature "string" to all targets.

3. Implement use of SubtargetFeatures in PowerPCTargetSubtarget.

llvm-svn: 23192
2005-09-01 21:38:21 +00:00
Jim Laskey 3fee6a51a9 This new class provides support for platform specific "features". The intent
is to manage processor specific attributes from the command line.  See examples
of use in llc/lli and PowerPCTargetSubtarget.

llvm-svn: 23191
2005-09-01 21:36:18 +00:00
Chris Lattner a305d28cf6 Implement dynamic allocas correctly. In particular, because we were copying
directly out of R1 (without using a CopyFromReg, which uses a chain), multiple
allocas were getting CSE'd together, producing bogus code.  For this:

int %foo(bool %X, int %A, int %B) {
        br bool %X, label %T, label %F
F:
        %G = alloca int
        %H = alloca int
        store int %A, int* %G
        store int %B, int* %H
        %R = load int* %G
        ret int %R
T:
        ret int 0
}

We were generating:

_foo:
        stwu r1, -16(r1)
        stw r31, 4(r1)
        or r31, r1, r1
        stw r1, 12(r31)
        cmpwi cr0, r3, 0
        bne cr0, .LBB_foo_2     ; T
.LBB_foo_1:     ; F
        li r2, 16
        subf r2, r2, r1   ;; One alloca
        or r1, r2, r2
        or r3, r1, r1
        or r1, r2, r2
        or r2, r1, r1
        stw r4, 0(r3)
        stw r5, 0(r2)
        lwz r3, 0(r3)
        lwz r1, 12(r31)
        lwz r31, 4(r31)
        lwz r1, 0(r1)
        blr
.LBB_foo_2:     ; T
        li r3, 0
        lwz r1, 12(r31)
        lwz r31, 4(r31)
        lwz r1, 0(r1)
        blr

Now we generate:

_foo:
        stwu r1, -16(r1)
        stw r31, 4(r1)
        or r31, r1, r1
        stw r1, 12(r31)
        cmpwi cr0, r3, 0
        bne cr0, .LBB_foo_2     ; T
.LBB_foo_1:     ; F
        or r2, r1, r1
        li r3, 16
        subf r2, r3, r2  ;; Alloca 1
        or r1, r2, r2
        or r2, r1, r1
        or r6, r1, r1
        subf r3, r3, r6  ;; Alloca 2
        or r1, r3, r3
        or r3, r1, r1
        stw r4, 0(r2)
        stw r5, 0(r3)
        lwz r3, 0(r2)
        lwz r1, 12(r31)
        lwz r31, 4(r31)
        lwz r1, 0(r1)
        blr
.LBB_foo_2:     ; T
        li r3, 0
        lwz r1, 12(r31)
        lwz r31, 4(r31)
        lwz r1, 0(r1)
        blr

This fixes Povray and SPASS with the dag isel, the last two failing cases.
Tommorow we will hopefully turn it on by default! :)

llvm-svn: 23190
2005-09-01 21:31:30 +00:00
Chris Lattner 293b3a68e0 Fix a bug where we were useing HA to get the high part, which seems like it
could cause a miscompile.  Fixing this didn't fix the two programs that fail
though.  :(

This also changes the implementation to follow the pattern selector more
closely, causing us to select 0 to li instead of lis.

llvm-svn: 23189
2005-09-01 19:38:28 +00:00
Chris Lattner 34182aff7f Do not select the operands being passed into SelectCC. IT does this itself
and selecting early prevents folding immediates into the cmpw* instructions

llvm-svn: 23188
2005-09-01 19:20:44 +00:00
Chris Lattner 975f5c9f46 It is NDEBUG not _NDEBUG
llvm-svn: 23186
2005-09-01 18:44:10 +00:00
Nate Begeman e8f78d1aab Add the rest of the currently implemented visit routines to the switch
statement in visit().

llvm-svn: 23185
2005-09-01 00:33:32 +00:00
Nate Begeman 21158fc485 First pass at the DAG Combiner. It isn't used anywhere yet, but it should
be mostly functional.  It currently has all folds from SelectionDAG.cpp
that do not involve a condition code.

llvm-svn: 23184
2005-09-01 00:19:25 +00:00
Nate Begeman 13990fc286 Add regression test for efficient codegen of i32 x i32 -> hi32(i64) as
mulhs.

llvm-svn: 23183
2005-09-01 00:04:03 +00:00
Chris Lattner b3d2e7905f remove an inappropriate comment
llvm-svn: 23182
2005-08-31 22:49:51 +00:00
Chris Lattner d4d10fff99 If a function has live ins/outs, print them
llvm-svn: 23181
2005-08-31 22:34:59 +00:00
Chris Lattner da2e04c69d Move FCTIWZ handling out of the instruction selectors and into legalization,
getting them out of the business of making stack slots.

llvm-svn: 23180
2005-08-31 21:09:52 +00:00
Chris Lattner 6bad1fb19e Remove dead code
llvm-svn: 23179
2005-08-31 20:25:15 +00:00
Chris Lattner e675a08e10 Move SHL,SHR i64 -> legalizer
llvm-svn: 23178
2005-08-31 20:23:54 +00:00
Chris Lattner 3a04a4b767 Remove code that is now dead from the pattern isel.
llvm-svn: 23177
2005-08-31 19:11:36 +00:00
Chris Lattner 2f03896a0f lower sra_parts on the dag, implementing it for the dag isel, and exposing
the ops to dag optimization.

llvm-svn: 23176
2005-08-31 19:09:57 +00:00
Chris Lattner 8a1a5f2818 Allow targets to custom expand shifts that are too large for their registers
llvm-svn: 23173
2005-08-31 19:01:53 +00:00
Chris Lattner 0e6b11da03 Add a testcase for nate's patch
llvm-svn: 23172
2005-08-31 18:19:50 +00:00
Chris Lattner 2bd2af8ecd add assert zext/sext to the dag isel
llvm-svn: 23171
2005-08-31 18:08:46 +00:00
Chris Lattner 46ff6aa993 Handle AssertSext/AssertZext nodes, fixing the regressions last night.
llvm-svn: 23170
2005-08-31 17:48:04 +00:00
Jeff Cohen d8c84e3c7e Fix VC++ precedence warnings
llvm-svn: 23169
2005-08-31 02:47:06 +00:00
Nate Begeman e3287b85b7 Enable generation of AssertSext and AssertZext in the PPC backend.
llvm-svn: 23168
2005-08-31 01:58:39 +00:00
Chris Lattner f4d594370b Fix 'ret long' to return the high and lo parts in the right registers. This
fixes crafty and probably others.

llvm-svn: 23167
2005-08-31 01:34:29 +00:00
Nate Begeman 539e7c892c Sigh, not my day. Fix typo.
llvm-svn: 23166
2005-08-31 00:43:49 +00:00
Nate Begeman d513d8a662 Fix a mistake in my previous patch pointed out by sabre; the AssertZext
case in MaskedValueIsZero was wrong.

llvm-svn: 23165
2005-08-31 00:43:08 +00:00