1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

3566 Commits

Author SHA1 Message Date
Jay Foad
789e8ac4f7 PR5207: Rename overloaded APInt methods set(), clear(), flip() to
setAllBits(), setBit(unsigned), etc.

llvm-svn: 120564
2010-12-01 08:53:58 +00:00
Chris Lattner
58b829f94c move GetPointerBaseWithConstantOffset out of GVN into ValueTracking.h
llvm-svn: 120476
2010-11-30 22:25:26 +00:00
Jay Foad
c663d7e4f6 PR5207: Make APInt::set(), APInt::clear() and APInt::flip() return void.
llvm-svn: 120413
2010-11-30 09:02:01 +00:00
Chris Lattner
84d3d220c1 strength reduce this.
llvm-svn: 120381
2010-11-30 01:56:13 +00:00
Chris Lattner
cbe6b88afe getLocationForDest should work for memset as well.
llvm-svn: 120380
2010-11-30 01:48:20 +00:00
Chris Lattner
083731f3d6 enhance basicaa to return "Mod" for a memcpy call when the
queried location doesn't overlap the source, and add a testcase.

llvm-svn: 120370
2010-11-30 00:43:16 +00:00
Chris Lattner
8ec1830a01 Teach basicaa that memset's modref set is at worst "mod" and never
contains "ref".

Enhance DSE to use a modref query instead of a store-specific hack
to generalize the "ignore may-alias stores" optimization to handle
memset and memcpy.

llvm-svn: 120368
2010-11-30 00:28:45 +00:00
Frits van Bommel
6610b43890 Teach ConstantFoldInstruction() how to fold insertvalue and extractvalue.
llvm-svn: 120316
2010-11-29 20:36:52 +00:00
Michael J. Spencer
d5ec932c3a Merge System into Support.
llvm-svn: 120298
2010-11-29 18:16:10 +00:00
Chandler Carruth
12806a53f3 Add some dead stores to pacify my least favorite GCC warning: may be
uninitialized. The warning is terrible, has incorrect source locations, and has
a huge false positive rate such as *all* of these.

If anyone has a better solution, please let me know. Alternatively, I'll
happily add -Wno-uninitialized to the -Werror build mode. Maybe I can even do
it *only* when building with GCC instead of Clang.

llvm-svn: 120281
2010-11-29 01:41:13 +00:00
Duncan Sands
97ada840ed Expand a little on the description of what InstructionSimplify does.
llvm-svn: 120016
2010-11-23 10:50:08 +00:00
Duncan Sands
809b3e3634 Clarify that constant folding of instructions applies when all operands
are constant.  There was in fact one exception to this (phi nodes) - so
remove that exception (InstructionSimplify handles this so there should
be no loss).

llvm-svn: 120015
2010-11-23 10:16:18 +00:00
Duncan Sands
73f0559779 If a GEP index simply advances by multiples of a type of zero size,
then replace the index with zero.

llvm-svn: 119974
2010-11-22 16:32:50 +00:00
Duncan Sands
ffcd1f61d9 Move the "gep undef" -> "undef" transform from instcombine to
InstructionSimplify.

llvm-svn: 119970
2010-11-22 13:42:49 +00:00
Benjamin Kramer
3fb7d5556c Initialize MemDep's TD member so buildbots don't trip over an uninitialized pointer (TD is passed to PHITransAddr).
I wonder why this didn't explode earlier.

llvm-svn: 119944
2010-11-21 15:21:46 +00:00
Duncan Sands
c2b128ad7d Add a rather pointless InstructionSimplify transform, inspired by recent constant
folding improvements: if P points to a type of size zero, turn "gep P, N" into "P".
More generally, if a gep index type has size zero, instcombine could replace the
index with zero, but that is not done here.

llvm-svn: 119942
2010-11-21 13:53:09 +00:00
Duncan Sands
4ef7e7f158 Fix spelling.
llvm-svn: 119941
2010-11-21 12:43:13 +00:00
Chris Lattner
1b3dffa2d1 apply Dan's fix for PR8268 which allows constant folding to handle indexes over
zero sized elements.  This allows us to compile:

  #include <string>
  void foo() { std::string s; }

into an empty function.

llvm-svn: 119933
2010-11-21 08:39:01 +00:00
Chris Lattner
a39a40d351 add "getLocation" method to AliasAnalysis for getting the source and
destination location of a memcpy/memmove.  I'm not clear about whether
TBAA works on these, so I'm leaving it out for now.  Dan, please revisit
this when convenient.

llvm-svn: 119928
2010-11-21 07:51:27 +00:00
Chris Lattner
3a0edfb37c implement PR8576, deleting dead stores with intervening may-alias stores.
llvm-svn: 119927
2010-11-21 07:34:32 +00:00
Benjamin Kramer
9141603779 Simplify code. No change in functionality.
llvm-svn: 119908
2010-11-20 18:43:35 +00:00
Benjamin Kramer
821c39433d Silence warning about an uninitialized variable.
llvm-svn: 119800
2010-11-19 11:37:26 +00:00
Duncan Sands
56aefef080 Remove threading of Xor over selects and phis, with an explanation
of why such threading is pointless.

llvm-svn: 119798
2010-11-19 09:20:39 +00:00
Duncan Sands
4562d3b919 Factor code for testing whether replacing one value with another
preserves LCSSA form out of ScalarEvolution and into the LoopInfo
class.  Use it to check that SimplifyInstruction simplifications
are not breaking LCSSA form.  Fixes PR8622.

llvm-svn: 119727
2010-11-18 19:59:41 +00:00
Dan Gohman
87b78a4726 Strip trailing whitespace.
llvm-svn: 119706
2010-11-18 17:06:31 +00:00
Dan Gohman
99ac1c6b83 Use llvm_unreachable for "impossible" situations.
llvm-svn: 119705
2010-11-18 17:05:57 +00:00
Dan Gohman
ec75e876ab Add support for PHI-translating sext, zext, and trunc instructions,
enabling more PRE. PR8586.

llvm-svn: 119704
2010-11-18 17:05:13 +00:00
Dan Gohman
3213622610 Introduce memoization for ScalarEvolution dominates and properlyDominates
queries, and SCEVExpander getRelevantLoop queries.

llvm-svn: 119595
2010-11-18 00:34:22 +00:00
Dan Gohman
ecff21cc67 Factor out the code for purging a SCEV from all the various memoization maps.
Some of these maps may merge in the future, but for now it's convenient to have
a utility function for them.

llvm-svn: 119587
2010-11-17 23:28:48 +00:00
Dan Gohman
8e594dfe39 Merge the implementations of isLoopInvariant and hasComputableLoopEvolution, and
memoize the results. This improves compile time in code which highly complex
expressions which get queried many times.

llvm-svn: 119584
2010-11-17 23:21:44 +00:00
Dan Gohman
fb6ea18d0a Make SCEV::getType() and SCEV::print non-virtual. Move SCEV::hasOperand
to ScalarEvolution. Delete SCEV::~SCEV. SCEV is no longer virtual.

llvm-svn: 119578
2010-11-17 22:27:42 +00:00
Dan Gohman
9bbb0fa515 Move SCEV::dominates and properlyDominates to ScalarEvolution.
llvm-svn: 119570
2010-11-17 21:41:58 +00:00
Dan Gohman
04df5af12b Move SCEV::isLoopInvariant and hasComputableLoopEvolution to be member
functions of ScalarEvolution, in preparation for memoization and
other optimizations.

llvm-svn: 119562
2010-11-17 21:23:15 +00:00
Duncan Sands
b5fd5f2124 Before replacing a phi node with a different value, it
needs to be checked that this won't break LCSSA form.
Change the existing checking method to a more direct one:
rather than seeing if all predecessors belong to the loop,
check that the replacing value is either not in any loop or
is in a loop that contains the phi node.

llvm-svn: 119556
2010-11-17 20:49:12 +00:00
Dan Gohman
4dc0a20aea Verify SCEVAddRecExpr's invariant in ScalarEvolution::getAddRecExpr
instead of in SCEVAddRecExpr's constructor, in preparation for an
upcoming change.

llvm-svn: 119554
2010-11-17 20:48:38 +00:00
Dan Gohman
a585073323 Fix ScalarEvolution's range memoization to avoid using a
default ctor with ConstantRange.

llvm-svn: 119550
2010-11-17 20:23:08 +00:00
Duncan Sands
2bd7e7c274 Move some those Xor simplifications which don't require creating new
instructions out of InstCombine and into InstructionSimplify.  While
there, introduce an m_AllOnes pattern to simplify matching with integers
and vectors with all bits equal to one.

llvm-svn: 119536
2010-11-17 18:52:15 +00:00
Duncan Sands
a5bd3ff0e4 Now that hasConstantValue has been made simpler, it may return the
phi node itself if it occurs in an unreachable basic block.  Protect
against this.  Hopefully this will fix some more buildbots.

llvm-svn: 119493
2010-11-17 10:23:23 +00:00
Duncan Sands
d3c1ca1f00 Previously SimplifyInstruction could report that an instruction
simplified to itself (this can only happen in unreachable blocks).
Change it to return null instead.  Hopefully this will fix some
buildbot failures.

llvm-svn: 119490
2010-11-17 08:35:29 +00:00
Duncan Sands
48517dac03 Fix a layering violation: hasConstantValue, which is part of the PHINode
class, uses DominatorTree which is an analysis.  This change moves all of
the tricky hasConstantValue logic to SimplifyInstruction, and replaces it
with a very simple literal implementation.  I already taught users of
hasConstantValue that need tricky stuff to use SimplifyInstruction instead.
I didn't update InlineFunction because the IR looks like it might be in a
funky state at the point it calls hasConstantValue, which makes calling
SimplifyInstruction dangerous since it can in theory do a lot of tricky
reasoning.  This may be a pessimization, for example in the case where
all phi node operands are either undef or a fixed constant.

llvm-svn: 119459
2010-11-17 04:30:22 +00:00
Duncan Sands
7376a19858 Have ScalarEvolution use SimplifyInstruction rather than hasConstantValue.
While there, add a note about an inefficiency I noticed.

llvm-svn: 119458
2010-11-17 04:18:45 +00:00
Dan Gohman
b10ff802a0 Memoize results from ScalarEvolution's getUnsignedRange and getSignedRange.
This fixes some extreme compile times on unrolled sha512 code.

llvm-svn: 119455
2010-11-17 02:44:44 +00:00
Duncan Sands
825c7d7f79 In which I discover the existence of loops. Threading an operation
over a phi node by applying it to each operand may be wrong if the
operation and the phi node are mutually interdependent (the testcase
has a simple example of this).  So only do this transform if it would
be correct to perform the operation in each predecessor of the block
containing the phi, i.e. if the other operands all dominate the phi.
This should fix the FFMPEG snow.c regression reported by İsmail Dönmez.

llvm-svn: 119347
2010-11-16 12:16:38 +00:00
Duncan Sands
ccdccb2776 Teach InstructionSimplify the trick of skipping incoming phi
values that are equal to the phi itself.

llvm-svn: 119161
2010-11-15 17:52:45 +00:00
Duncan Sands
63e80e0593 If dom tree information is available, make it possible to pass
it to get better phi node simplification.

llvm-svn: 119055
2010-11-14 18:36:10 +00:00
Duncan Sands
617030ad18 Teach InstructionSimplify about phi nodes. I chose to have it simply
offload the work to hasConstantValue rather than do something more
complicated (such handling mutually recursive phis) because (1) it is
not clear it is worth it; and (2) if it is worth it, maybe such logic
would be better placed in hasConstantValue.  Adjust some GVN tests
which are now cleaned up much further (eg: all phi nodes are removed).

llvm-svn: 119043
2010-11-14 13:30:18 +00:00
Duncan Sands
9a914e2b5e Boost the power of phi node constant folding slightly: if all
operands are the phi node itself or undef, then return undef.
This logic already existed at a higher level so in practice it
shouldn't make the slightest difference.  Note that this code
could be replaced by a call to PN->hasConstantValue().  However
since we bail out the moment we see a non-constant operand, it
is more efficient to have a specialized version of that logic.

llvm-svn: 119041
2010-11-14 12:53:18 +00:00
Duncan Sands
ab39985d42 Strip trailing whitespace.
llvm-svn: 119038
2010-11-14 11:23:23 +00:00
Duncan Sands
6ff5e53731 Fix typo pointed out by Trevor Harmon.
llvm-svn: 119001
2010-11-13 12:16:27 +00:00
Dan Gohman
ec55b3ac75 Re-disable TBAA for now; it broke MultiSource/Applications/JM/lencod,
at least.

llvm-svn: 118890
2010-11-12 11:21:08 +00:00