Commit Graph

2837 Commits

Author SHA1 Message Date
Chris Lattner
2ba3b62149 Enable Load PRE. This teaches GVN to push partially redundant loads up the
CFG when there is exactly one predecessor where the load is not available.
This is designed to not increase code size but still eliminate partially
redundant loads.  This fires 1765 times on 403.gcc even though it doesn't
do critical edge splitting yet (the most common reason for it to fail).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61027 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 05:28:29 +00:00
Owen Anderson
c34d112362 Ifdef out some code that I didn't mean to enable by default yet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61024 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 03:52:17 +00:00
Chris Lattner
f33131685b make GVN try to rename inputs to the resultant replaced values, which
cleans up the generated code a bit.  This should have the added benefit of
not randomly renaming functions/globals like my previous patch did. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61023 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 03:46:38 +00:00
Owen Anderson
255dafc5de Add support for slow-path GVN with full phi construction for scalars. This is disabled for now, as it actually pessimizes code in the abscence
of phi translation for load elimination.  This slow down GVN a bit, by about 2% on 403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61021 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-15 02:03:00 +00:00
Chris Lattner
528f16b9fa eliminate warning when asserts disabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61012 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-14 21:36:23 +00:00
Owen Anderson
cbe1d94031 Generalize GVN's phi construciton routine to work for things other than loads.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61009 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-14 19:10:35 +00:00
Bill Wendling
8295e49e76 Temporarily revert r60973. It's inexplicably causing a failure when self-hosting LLVM:
llvm[2]: Linking Release executable opt (without symbols)
...
Undefined symbols:
  "llvm::APFloat::IEEEsingle", referenced from:
      __ZN4llvm7APFloat10IEEEsingleE$non_lazy_ptr in libLLVMCore.a(Constants.o)
      __ZN4llvm7APFloat10IEEEsingleE$non_lazy_ptr in libLLVMCore.a(AsmWriter.o)
      __ZN4llvm7APFloat10IEEEsingleE$non_lazy_ptr in libLLVMCore.a(ConstantFold.o)
  "llvm::APFloat::IEEEdouble", referenced from:
      __ZN4llvm7APFloat10IEEEdoubleE$non_lazy_ptr in libLLVMCore.a(Constants.o)
      __ZN4llvm7APFloat10IEEEdoubleE$non_lazy_ptr in libLLVMCore.a(AsmWriter.o)
      __ZN4llvm7APFloat10IEEEdoubleE$non_lazy_ptr in libLLVMCore.a(ConstantFold.o)
ld: symbol(s) not found

This is in release mode. To replicate, compile llvm and llvm-gcc in optimized
mode. Then build llvm, in optimized mode, with the newly created compiler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60977 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-13 09:28:44 +00:00
Chris Lattner
879922932f make RLE preserve the name of the load that it replaces. This is just
a pretification of the IR.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60973 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-13 07:22:47 +00:00
Chris Lattner
bc99be10b8 Teach GVN to invalidate some memdep information when it does an RAUW
of a pointer.  This allows is to catch more equivalencies.  For example,
the type_lists_compatible_p function used to require two iterations of
the gvn pass (!) to delete its 18 redundant loads because the first pass
would CSE all the addressing computation cruft, which would unblock the
second memdep/gvn passes from recognizing them.  This change allows
memdep/gvn to catch all 18 when run just once on the function (as is 
typical :) instead of just 3.

On all of 403.gcc, this bumps up the # reundandancies found from:

     63 gvn    - Number of instructions PRE'd
 153991 gvn    - Number of instructions deleted
  50069 gvn    - Number of loads deleted
to:
     63 gvn    - Number of instructions PRE'd
 154137 gvn    - Number of instructions deleted
  50185 gvn    - Number of loads deleted

+120 loads deleted isn't bad.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60799 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 22:06:23 +00:00
Chris Lattner
1559b3625b rename getNonLocalDependency -> getNonLocalCallDependency, and remove
pointer stuff from it, simplifying the code a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60783 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 19:38:05 +00:00
Chris Lattner
91bcf6450a Switch GVN::processNonLocalLoad to using the new
MemDep::getNonLocalPointerDependency method.  There are
some open issues with this (missed optimizations) and
plenty of future work, but this does allow GVN to eliminate
*slightly* more loads (49246 vs 49033).

Switching over now allows simplification of the other code
path in memdep.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60780 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 19:25:07 +00:00
Chris Lattner
ae1993114f random cleanups, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60779 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 19:21:47 +00:00
Chris Lattner
46a879ebd3 Fix a really subtle off-by-one bug that Duncan noticed with valgrind
on test/CodeGen/Generic/2007-06-06-CriticalEdgeLandingPad.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60739 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 04:47:21 +00:00
Chris Lattner
20fa76ef6f remove DebugIterations option. Despite the accusations,
jump threading has been shown to only expose problems not
have bugs itself.  I'm sure it's completely bug free! ;-)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60725 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-08 22:44:07 +00:00
Devang Patel
042b877e84 Fix spelling.
Thanks Duncan!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60702 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-08 17:07:24 +00:00
Devang Patel
6d9896f153 Undo previous patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60701 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-08 17:02:37 +00:00
Chris Lattner
f760be1c7f don't bother touching volatile stores, they will just return clobber on
everything interesting anyway.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60640 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-07 00:25:15 +00:00
Chris Lattner
5e600e67b1 Reimplement the inner loop of DSE. It now uniformly uses getDependence(),
doesn't do its own local caching, and is slightly more aggressive about
free/store dse (see testcase).  This eliminates the last external client 
of MemDep::getDependenceFrom().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60619 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-06 00:53:22 +00:00
Dale Johannesen
203af58aea Make LoopStrengthReduce smarter about hoisting things out of
loops when they can be subsumed into addressing modes.

Change X86 addressing mode check to realize that
some PIC references need an extra register.
(I believe this is correct for Linux, if not, I'm sure
someone will tell me.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60608 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 21:47:27 +00:00
Chris Lattner
b51deb929c Make a few major changes to memdep and its clients:
1. Merge the 'None' result into 'Normal', making loads
   and stores return their dependencies on allocations as Normal.
2. Split the 'Normal' result into 'Clobber' and 'Def' to
   distinguish between the cases when memdep knows the value is
   produced from when we just know if may be changed.
3. Move some of the logic for determining whether readonly calls
   are CSEs into memdep instead of it being in GVN.  This still
   leaves verification that the arguments are hte same to GVN to
   let it know about value equivalences in different contexts.
4. Change memdep's call/call dependency analysis to use 
   getModRefInfo(CallSite,CallSite) instead of doing something 
   very weak.  This only really matters for things like DSA, but
   someday maybe we'll have some other decent context sensitive
   analyses :)
5. This reimplements the guts of memdep to handle the new results.
6. This simplifies GVN significantly:
   a) readonly call CSE is slightly simpler
   b) I eliminated the "getDependencyFrom" chaining for load 
      elimination and load CSE doesn't have to worry about 
      volatile (they are always clobbers) anymore.
   c) GVN no longer does any 'lastLoad' caching, leaving it to 
      memdep.
7. The logic in DSE is simplified a bit and sped up.  A potentially
   unsafe case was eliminated.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60607 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 21:04:20 +00:00
Anton Korobeynikov
64b535608e Revert invalid r60393. It causes llvm-gcc bootstrap fails in release builds.
See PR3160 for details

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60604 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 19:38:49 +00:00
Chris Lattner
7f7c736682 Fix test/Transforms/GVN/pre-load.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60594 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 17:04:12 +00:00
Chris Lattner
72bc70d499 Make IsValueFullyAvailableInBlock safe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60588 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 07:49:08 +00:00
Devang Patel
3831005eb1 Rewrite code that 1) filters loops and 2) calculates new loop bounds.
This fixes many bugs. I will add more test cases in a separate check-in.

Some day, the code that manipulates CFG and updates dom. info could use refactoring help.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60554 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 21:38:42 +00:00
Chris Lattner
3cda3cdab1 Start simplifying a switch that has a successor that is a switch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60534 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 06:31:07 +00:00
Chris Lattner
77ee977fcf add a debugging option to help track down j-t problems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60514 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04 00:07:59 +00:00
Dale Johannesen
308f24d452 Remove an unused field.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60508 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 22:43:56 +00:00
Dale Johannesen
544e0d0e52 Fix a misspelled function name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60506 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 20:56:12 +00:00
Chris Lattner
29874e0dc6 Factor some code into a new FoldSingleEntryPHINodes method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60501 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 19:44:02 +00:00
Dale Johannesen
67c7989294 Fix a really wrong comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60494 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 19:25:46 +00:00
Chris Lattner
421fa9e32e Teach jump threading some more simple tricks:
1) have it fold "br undef", which does occur with
   surprising frequency as jump threading iterates.
2) teach j-t to delete dead blocks.  This removes the successor
   edges, reducing the in-edges of other blocks, allowing 
   recursive simplification.
3) Fold things like:
     br COND, BBX, BBY
  BBX:
     br COND, BBZ, BBW

   which also happens because jump threading iterates.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60470 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-03 07:48:08 +00:00
Dale Johannesen
fb10cd4901 Minor rewrite per review feedback.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60442 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 21:17:11 +00:00
Dale Johannesen
eccdd08d4c Make the code do what the comment says it does.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60431 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 18:40:09 +00:00
Chris Lattner
c89c6a964c Implement PRE of loads in the GVN pass with a pretty cheap and
straight-forward implementation.  This does not require any extra
alias analysis queries beyond what we already do for non-local loads.

Some programs really really like load PRE.  For example, SPASS triggers
this ~1000 times, ~300 times in 255.vortex, and ~1500 times on 403.gcc.

The biggest limitation to the implementation is that it does not split
critical edges.  This is a huge killer on many programs and should be
addressed after the initial patch is enabled by default.

The implementation of this should incidentally speed up rejection of 
non-local loads because it avoids creating the repl densemap in cases 
when it won't be used for fully redundant loads.

This is currently disabled by default.
Before I turn this on, I need to fix a couple of miscompilations in
the testsuite, look at compile time performance numbers, and look at
perf impact.  This is pretty close to ready though.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60408 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 08:16:11 +00:00
Bill Wendling
286a054908 Remove some errors that crept in. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60403 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 06:24:20 +00:00
Bill Wendling
d16c6e9993 Merge two if-statements into one.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60402 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 06:22:04 +00:00
Bill Wendling
29976b9e12 More styalistic changes. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60401 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 06:18:11 +00:00
Bill Wendling
3bdcda82a5 - Remove the buggy -X/C -> X/-C transform. This isn't valid when X isn't a
constant. If X is a constant, then this is folded elsewhere.

- Added a note to Target/README.txt to indicate that we'd like to implement
  this when we're able.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60399 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 05:12:47 +00:00
Bill Wendling
a8bb13f989 Improve comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60398 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 05:09:00 +00:00
Bill Wendling
dda74e0702 - Reduce nesting.
- No need to do a swap on a canonicalized pattern.

No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60397 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 05:06:43 +00:00
Chris Lattner
f8828eb41b some random comment improvements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60395 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 04:52:26 +00:00
Owen Anderson
912c49d169 Fix an issue that Chris noticed, where local PRE was not properly instantiating
a new value numbering set after splitting a critical edge.  This increases
the number of instances of PRE on 403.gcc from ~60 to ~570.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60393 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 04:09:22 +00:00
Dale Johannesen
589bf0865c Consider only references to an IV within the loop when
figuring out the base of the IV.  This produces better
code in the example.  (Addresses use (IV) instead of 
(BASE,IV) - a significant improvement on low-register
machines like x86).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60374 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 22:00:01 +00:00
Bill Wendling
57036da328 Don't rebuild RHSNeg. Just use the one that's already there.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60370 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 21:06:30 +00:00
Bill Wendling
69fffa5437 Document what this check is doing. Also, no need to cast to ConstantInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60369 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 21:03:43 +00:00
Bill Wendling
c25c68305c Use a simple comparison. Overflow on integer negation can only occur when the
integer is "minint".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60366 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 19:46:27 +00:00
Bill Wendling
d54d86038d Generalize the FoldOrWithConstant method to fold for any two constants which
don't have overlapping bits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60344 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 08:32:40 +00:00
Bill Wendling
a698a472f2 Reduce copy-and-paste code by splitting out the code into its own function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60343 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 08:23:25 +00:00
Bill Wendling
03aae5f7e1 Use m_Specific() instead of double matching.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60341 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 08:09:47 +00:00
Bill Wendling
9c531a0f07 Move pattern check outside of the if-then statement. This prevents us from fiddling with constants unless we have to.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60340 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-01 07:47:02 +00:00