Commit Graph

1762 Commits

Author SHA1 Message Date
Chris Lattner 86102b8ad5 This is a bulk commit that implements the following primary improvements:
* We can now fold cast instructions into select instructions that
    have at least one constant operand.
  * We now optimize expressions more aggressively based on bits that are
    known to be zero.  These optimizations occur a lot in code that uses
    bitfields even in simple ways.
  * We now turn more cast-cast sequences into AND instructions.  Before we
    would only do this if it if all types were unsigned.  Now only the
    middle type needs to be unsigned (guaranteeing a zero extend).
  * We transform sign extensions into zero extensions in several cases.

This corresponds to these test/Regression/Transforms/InstCombine testcases:
  2004-11-22-Missed-and-fold.ll
  and.ll: test28-29
  cast.ll: test21-24
  and-or-and.ll
  cast-cast-to-and.ll
  zeroext-and-reduce.ll

llvm-svn: 19220
2005-01-01 16:22:27 +00:00
Chris Lattner 3215bb6049 Implement SimplifyCFG/DeadSetCC.ll
SimplifyCFG is one of those passes that we use for final cleanup: it should
not rely on other passes to clean up its garbage.  This fixes the "why are
trivially dead setcc's in the output of gccas" problem.

llvm-svn: 19212
2005-01-01 16:02:12 +00:00
Chris Lattner 13516fe2e7 Fix PR491 and testcase Transforms/DeadStoreElimination/2004-12-28-PartialStore.ll
llvm-svn: 19180
2004-12-29 04:36:02 +00:00
Chris Lattner b17f3e13ec Adjust to new interfaces
llvm-svn: 18958
2004-12-15 07:22:25 +00:00
Chris Lattner 9ad0d55025 Constant exprs are not efficiently negatable in practice. This disables
turning X - (constantexpr) into X + (-constantexpr) among other things.

llvm-svn: 18935
2004-12-14 20:08:06 +00:00
Brian Gaeke f9639d2a74 Fix link error in PPC optimized build of 'opt'.
llvm-svn: 18913
2004-12-13 21:28:39 +00:00
Chris Lattner 8f430a3b59 Get rid of getSizeOf, using ConstantExpr::getSizeOf instead.
do not insert a prototype for malloc of: void* malloc(uint): on 64-bit u
targets this is not correct.  Instead of prototype it as void *malloc(...),
and pass the correct intptr_t through the "...".

Finally, fix Regression/CodeGen/SparcV9/2004-12-13-MallocCrash.ll, by not
forming constantexpr casts from pointer to uint.

llvm-svn: 18908
2004-12-13 20:00:02 +00:00
Chris Lattner a199e3c1e2 Change indentation of a whole bunch of code, no real changes here.
llvm-svn: 18843
2004-12-12 23:49:37 +00:00
Chris Lattner 14d07db44d More substantial simplifications and speedups. This makes ADCE about 20% faster
in some cases.

llvm-svn: 18842
2004-12-12 23:40:17 +00:00
Chris Lattner 9115eb3024 More minor microoptimizations
llvm-svn: 18841
2004-12-12 22:44:30 +00:00
Chris Lattner d4298781c1 Remove some more set operations
llvm-svn: 18840
2004-12-12 22:22:18 +00:00
Chris Lattner a538439bf0 Reduce number of set operations.
llvm-svn: 18839
2004-12-12 22:16:13 +00:00
Chris Lattner bf5b7cf638 Optimize div/rem + select combinations more.
In particular, implement div.ll:test10 and rem.ll:test4.

llvm-svn: 18838
2004-12-12 21:48:58 +00:00
Chris Lattner 745196a5fc Properly implement copying of a global, fixing the 255.vortex & povray
failures from last night.

llvm-svn: 18832
2004-12-12 19:34:41 +00:00
Chris Lattner 88deefa303 Simplify code and do not invalidate iterators.
This fixes a crash compiling TimberWolfMC that was exposed due to recent
optimizer changes.

llvm-svn: 18831
2004-12-12 18:23:20 +00:00
Chris Lattner 1cbd5be7a1 Though the previous xform applies to literally dozens (hundreds?) of variables
in SPEC, the subsequent optimziations that we are after don't play with
with FP values, so disable this xform for them.  Really we just don't want
stuff like:

double G;   (always 0 or 412312.312)
  = G;

turning into:

bool G_b;
  = G_b ? 412312.312 : 0;

We'd rather just do the load.

-Chris

llvm-svn: 18819
2004-12-12 06:03:06 +00:00
Chris Lattner 40e4cec9ee If a variable can only hold two values, and is not already a bool, shrink it
down to actually BE a bool.  This allows simple value range propagation
stuff work harder, deleting comparisons in bzip2 in some hot loops.

This implements GlobalOpt/integer-bool.ll, which is the essence of the
loop condition distilled into a testcase.

llvm-svn: 18817
2004-12-12 05:53:50 +00:00
Chris Lattner cbc0161d1f If one side of and/or is known to be 0/-1, it doesn't matter
if the other side is overdefined.

This allows us to fold conditions like:  if (X < Y || Y > Z) in some cases.

llvm-svn: 18807
2004-12-11 23:15:19 +00:00
Chris Lattner 263b0a1669 Only cound if we actually made a change.
llvm-svn: 18800
2004-12-11 17:00:14 +00:00
Chris Lattner ffefea0772 The split bb is really the exit of the old function
llvm-svn: 18799
2004-12-11 16:59:54 +00:00
Chris Lattner 2f687fd9d6 Two bug fixes:
1. Actually increment the Statistic for the GV elim optzn
 2. When resolving undef branches, only resolve branches in executable blocks,
    avoiding marking a bunch of completely dead blocks live.  This has a big
    impact on the quality of the generated code.

With this patch, we positively rip up vortex, compiling Ut_MoveBytes to a
single memcpy call. In vortex we get this:

     12 ipsccp           - Number of globals found to be constant
    986 ipsccp           - Number of arguments constant propagated
   1378 ipsccp           - Number of basic blocks unreachable
   8919 ipsccp           - Number of instructions removed

llvm-svn: 18796
2004-12-11 06:05:53 +00:00
Chris Lattner 8525ebe465 Do not delete the entry block to a function.
llvm-svn: 18795
2004-12-11 05:32:19 +00:00
Chris Lattner 91dbae6fee Implement Transforms/SCCP/ipsccp-gvar.ll, by tracking values stored to
non-address-taken global variables.

llvm-svn: 18790
2004-12-11 05:15:59 +00:00
Chris Lattner 99e1295645 Fix a bug where we could delete dead invoke instructions with uses.
In functions where we fully constant prop the return value, replace all
ret instructions with 'ret undef'.

llvm-svn: 18786
2004-12-11 02:53:57 +00:00
Chris Lattner bae4b64553 Implement SCCP/ipsccp-conditional.ll, by totally deleting dead blocks.
llvm-svn: 18781
2004-12-10 22:29:08 +00:00
Chris Lattner 7285f43836 Fix SCCP/2004-12-10-UndefBranchBug.ll
llvm-svn: 18776
2004-12-10 20:41:50 +00:00
Chris Lattner 4fc998da2e Fix Regression/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll,
and the failure on make_dparser last night.

llvm-svn: 18766
2004-12-10 17:42:31 +00:00
Chris Lattner b439464c61 This is the initial implementation of IPSCCP, as requested by Brian.
This implements SCCP/ipsccp-basic.ll, rips apart Olden/mst (as described in
PR415), and does other nice things.

There is still more to come with this, but it's a start.

llvm-svn: 18752
2004-12-10 08:02:06 +00:00
Chris Lattner 36d39cecb4 note to self: Do not check in debugging code!
llvm-svn: 18693
2004-12-09 07:15:52 +00:00
Chris Lattner f17a2fb849 Implement trivial sinking for load instructions. This causes us to sink 567 loads in spec
llvm-svn: 18692
2004-12-09 07:14:34 +00:00
Chris Lattner 39c98bb31c Do extremely simple sinking of instructions when they are only used in a
successor block.  This turns cases like this:

x = a op b
if (c) {
  use x
}

into:

if (c) {
  x = a op b
  use x
}

This triggers 3965 times in spec, and is tested by
Regression/Transforms/InstCombine/sink_instruction.ll

This appears to expose a bug in the X86 backend for 177.mesa, which I'm
looking in to.

llvm-svn: 18677
2004-12-08 23:43:58 +00:00
Alkis Evlogimenos a1291a0679 Fix this regression and remove the XFAIL from this test.
llvm-svn: 18674
2004-12-08 23:10:30 +00:00
Chris Lattner 8f30caf549 Fix Transforms/InstCombine/2004-12-08-RemInfiniteLoop.ll
llvm-svn: 18670
2004-12-08 22:20:34 +00:00
Chris Lattner 674ce86cd0 Add support for compilers without argument dependent name lookup, contributed
by Bjørn Wennberg

llvm-svn: 18627
2004-12-08 16:12:20 +00:00
Chris Lattner 407000c497 Remove unneeded class qualifier, contributed by Bjørn Wennberg
llvm-svn: 18625
2004-12-08 16:05:02 +00:00
Reid Spencer 9273d480ad For PR387:\
Add doInitialization method to avoid overloaded virtuals

llvm-svn: 18602
2004-12-07 08:11:36 +00:00
Chris Lattner 9019e5cfa0 Implement stripping of debug symbols, making the --strip-debug options in
gccas/gccld more than just a noop.

llvm-svn: 18456
2004-12-03 16:22:08 +00:00
Chris Lattner e8ebcb3300 Initial reimplementation of the -strip pass, with a stub for implementing
-S

llvm-svn: 18440
2004-12-02 21:25:03 +00:00
Chris Lattner a4c9808603 This pass is moving to lib IPO
llvm-svn: 18439
2004-12-02 21:24:40 +00:00
Chris Lattner c0677c081d Implement a FIXME by checking to make sure that a malloc is not being used
in scary and unknown ways before we promote it.  This fixes the miscompilation
of 188.ammp that has been plauging us since a globalopt patch went in.

Thanks a ton to Tanya for helping me diagnose the problem!

llvm-svn: 18418
2004-12-02 07:11:07 +00:00
Chris Lattner 3b18139b3c Fix a minor bug where we set a var to initialized on malloc, not on store.
This doesn't fix anything that I'm aware of, just noticed it by inspection

llvm-svn: 18417
2004-12-02 06:25:58 +00:00
Chris Lattner 951673a94c This pass is completely broken.
llvm-svn: 18387
2004-11-30 17:09:06 +00:00
Chris Lattner 019445715e Squelch warning
llvm-svn: 18381
2004-11-30 07:47:34 +00:00
Chris Lattner 868ae13dc0 Fix test/Regression/Transforms/LICM/2004-09-14-AliasAnalysisInvalidate.llx
This only fails on darwin or on X86 under valgrind.

llvm-svn: 18377
2004-11-30 07:01:15 +00:00
Chris Lattner fd8cbc257e Alkis noticed that this variable is dead. Thanks!
llvm-svn: 18369
2004-11-30 04:01:44 +00:00
Chris Lattner 389cfac0d1 If we have something like this:
if (x) {
    code
    ...
  } else {
    code
    ...
  }

Turn it into:

  code
  if (x) {
    ...
  } else {
    ...
  }

This reduces code size and in some common cases allows us to completely
eliminate the conditional.  This turns several if/then/else blocks in loops
into straightline code in 179.art, turning the loops into single basic blocks
(good for modsched even!).

Maybe now brg will leave me alone ;-)

llvm-svn: 18366
2004-11-30 00:29:14 +00:00
Chris Lattner 6e455608e2 Allow hoisting loads of globals and alloca's in conditionals.
llvm-svn: 18363
2004-11-29 21:26:12 +00:00
Reid Spencer 279fa256a2 Fix for PR454:
* Make sure we handle signed to unsigned conversion correctly
* Move this visitSetCondInst case to its own method.

llvm-svn: 18312
2004-11-28 21:31:15 +00:00
Chris Lattner 6ea2888832 Make DSE potentially more aggressive by being more specific about alloca sizes.
llvm-svn: 18309
2004-11-28 20:44:37 +00:00
Chris Lattner 14f3cdc227 Implement Regression/Transforms/InstCombine/getelementptr_cast.ll, which
occurs many times in crafty

llvm-svn: 18273
2004-11-27 17:55:46 +00:00