Commit Graph

3870 Commits

Author SHA1 Message Date
Dan Gohman
9a09ca348f Initialize BasicAA's AliasCache to set it to use fewer buckets by
default, since it usually has very few elements. This speeds up
alias queries in many cases, because AliasCache.clear() doesn't
have to visit as many buckets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132862 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-10 22:30:30 +00:00
John McCall
e669d83a21 Teach the CallGraph to ignore calls to intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132797 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-09 19:46:27 +00:00
Dan Gohman
5f1312c36e Reapply r131781, now that the GVN bug with partially-aliasing loads
is disabled.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132632 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 06:50:18 +00:00
Dan Gohman
a3351a0e5d Disable the main feature of 130180, the elimination of loads that are
redundant with partially-aliasing loads.

When computing what portion of a clobbering load value is needed,
it doesn't consider phi-translation which may have occurred
between the clobbing load and the redundant load.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132631 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 06:48:50 +00:00
Dan Gohman
9a9d218ed0 Revert r131781 again. Apparently there is more going on here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132625 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 05:11:22 +00:00
Nick Lewycky
404b53e38c Fold assert-only-used variable into the assert.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132620 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 02:07:10 +00:00
Andrew Trick
b4528c3d7e Missing include of climits in the new BranchProbability pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132616 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 01:30:52 +00:00
Andrew Trick
9e76422b96 New BranchProbabilityInfo analysis. Patch by Jakub Staszak!
BranchProbabilityInfo provides an interface for IR passes to query the
likelihood that control follows a CFG edge. This patch provides an
initial implementation of static branch predication that will populate
BranchProbabilityInfo for branches with no external profile
information using very simple heuristics. It currently isn't hooked up
to any external profile data, so static prediction does all the work.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132613 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 01:16:30 +00:00
Dan Gohman
c122c625ce Reapply r131781 (revert r131809), now that some BasicAA shortcomings
it exposed are fixed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132611 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 00:46:31 +00:00
Dan Gohman
1fc18d71de Fix BasicAA's recursion detection so that it doesn't pessimize
queries in the case of a DAG, where a query reaches a node
visited earlier, but it's not on a cycle. This avoids
MayAlias results in cases where BasicAA is expected to
return MustAlias or PartialAlias in order to protect TBAA.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132609 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-04 00:31:50 +00:00
Dan Gohman
965fefa1ad When merging MustAlias and PartialAlias, chose PartialAlias instead
of conservatively choosing MayAlias.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132579 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 20:17:36 +00:00
Hans Wennborg
68df608fd1 Test commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132558 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 17:15:37 +00:00
Devang Patel
da174c1d3b A typedef's context is not the same as type's context. It is the context of typedef decl itself. Use extra parameter to communicate this to DIBuilder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132556 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-03 17:04:51 +00:00
Eli Friedman
7c6a5a2c39 When marking a block as being unanalyzable, use "Clobber" on the terminator instead of the first instruction in the block. This is a bit of a hack; "Clobber" isn't really the right marking in the first place. memdep doesn't really have any way of properly expressing "unanalyzable" at the moment. Using it on the terminator is much less ambiguous than using it on an arbitrary instruction, though.
In the given testcase, the "Clobber" was pointing to a load, and GVN was incorrectly assuming that meant that the "Clobber" load overlapped the load being analyzed (when they are actually unrelated).

The included testcase tests both this commit and r132434.

Part two of rdar://9429882.  (r132434 was mislabeled.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132442 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-02 00:08:52 +00:00
Eli Friedman
fc09797426 In MemoryDependenceAnalysis::getNonLocalPointerDepFromBB, if a given block is is deemed unanalyzable (and we execute one of the "goto PredTranslationFailure" statements), make sure we don't put information about the predecessors of that block into the returned data structures; this can lead to, among other things, extraneous results (which will confuse passes using memdep). Fixes an assert in GVN compiling ruby. Part of rdar://problem/9521954 .
Testcase coming up soon.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132434 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 23:16:53 +00:00
Andrew Trick
cf31f91931 SCEV: missing null check fix for r132360, dragonegg crash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132416 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 19:14:56 +00:00
Andrew Trick
b1ce4c09dd scev: Better sign-extend removal. Normalize postincrement recurrences
so that their sign extended forms are congruent when no overflow occurs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132360 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 21:17:47 +00:00
Eli Friedman
69388e5a4a llvm.memcpy.* has two distinct associated address spaces; the source address space, and the destination address space. Fix up the interface on MemIntrinsic and MemTransferInst to make this clear, and fix InstructionDereferencesPointer in LazyValueInfo.cpp to use the interface properly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132356 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 20:40:16 +00:00
Dan Gohman
cc1ffc6652 Update this comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132202 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 18:42:33 +00:00
Chad Rosier
62660310d9 Renamed llvm.x86.sse42.crc32 intrinsics; crc64 doesn't exist.
crc32.[8|16|32] have been renamed to .crc32.32.[8|16|32] and
crc64.[8|16|32] have been renamed to .crc32.64.[8|64].




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-26 23:13:19 +00:00
Eli Friedman
b176399339 Change condition for determining whether a function is small for inlining metrics so that very long functions
with few basic blocks are not re-analyzed.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131994 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 20:22:24 +00:00
Dan Gohman
9adf151b3d Make DecomposeGEPExpression check SimplifyInstruction only
after checking for a GEP, so that it matches what GetUnderlyingObject
does. This fixes an obscure bug turned up by bugpoint in the testcase
for PR9931.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131971 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 18:24:08 +00:00
Chris Lattner
c10ecd8f23 fix a really nasty basicaa mod/ref calculation bug that was causing miscompilation of
UnitTests/ObjC/messages-2.m with the recent optimizer improvements.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131897 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-23 05:15:43 +00:00
Chris Lattner
b3f0673d52 Teach valuetracking that byval arguments with a specified alignment are
aligned.

Teach memcpyopt to not give up all hope when confonted with an underaligned
memcpy feeding an overaligned byval.  If the *source* of the memcpy can be
determined to be adequeately aligned, or if it can be forced to be, we can
eliminate the memcpy.

This addresses PR9794.  We now compile the example into:

define i32 @f(%struct.p* nocapture byval align 8 %q) nounwind ssp {
entry:
  %call = call i32 @g(%struct.p* byval align 8 %q) nounwind
  ret i32 %call
}

in both x86-64 and x86-32 mode.  We still don't get a tailcall though,
because tailcalls apparently can't handle byval.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131884 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-23 00:03:39 +00:00
Chris Lattner
805fa97a0f implement PR9315, constant folding exp2 in terms of pow (since hosts without
C99 runtimes don't have exp2).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131872 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 22:22:35 +00:00
Evan Cheng
cb559c1270 Teach ValueTracking about x86 crc32 intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131861 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-22 18:25:30 +00:00
Duncan Sands
d22920aae8 Revert commit 131781, to see if it fixes the x86-64 dragonegg buildbot.
Original log message:
When BasicAA can determine that two pointers have the same base but
differ by a dynamic offset, return PartialAlias instead of MayAlias.
See the comment in the code for details. This fixes PR9971.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131809 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-21 20:54:46 +00:00
Dan Gohman
424b777171 When BasicAA can determine that two pointers have the same base but
differ by a dynamic offset, return PartialAlias instead of MayAlias.
See the comment in the code for details. This fixes PR9971.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131781 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-21 01:05:08 +00:00
Andrew Trick
f85092c255 indvars: Prototyping Sign/ZeroExtend elimination without canonical IVs.
No functionality enabled by default. Use -disable-iv-rewrite.
Extended IVUsers to keep track of the phi that represents the users' IV.
Added the WidenIV transform to replace a narrow IV with a wide IV
by doing a one-for-one replacement of IV users instead of expanding the
SCEV expressions. [sz]exts are removed and truncs are inserted.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131744 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-20 18:25:42 +00:00
Owen Anderson
e1edb17bc3 @llvm.lifetime.begin acts as a load, not @llvm.lifetime.end.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131437 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-17 00:05:49 +00:00
Rafael Espindola
ac53b0a48a Extra refactoring noticed by Eli Friedman.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131405 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-16 15:48:45 +00:00
Julien Lerouge
eea6c95d5d Fix a source of non determinism in FindUsedTypes, use a SetVector instead of a
set.

rdar://9423996


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131283 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-13 05:20:42 +00:00
Dan Gohman
77a2c4c1e5 Change a few std::maps to DenseMaps.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131088 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-09 18:44:09 +00:00
Duncan Sands
e864b5b840 The comparision "max(x,y)==x" is equivalent to "x>=y". Since the max is
often expressed as "x >= y ? x : y", there is a good chance we can extract
the existing "x >= y" from it and use that as a replacement for "max(x,y)==x".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131049 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-07 16:56:49 +00:00
Eli Friedman
b6e7cd655c PR9838: Fix transform introduced in r127064 to not trigger when only one side of the icmp is an exact shift.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130954 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-05 21:59:18 +00:00
Hongbin Zheng
f262e16161 Minor change: Fix the typo in RegionPass.h and RegionPass.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130920 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-05 13:59:38 +00:00
Duncan Sands
8140ad32ce Add variations on: max(x,y) >= min(x,z) folds to true. This isn't that common,
but according to my super-optimizer there are only two missed simplifications
of -instsimplify kind when compiling bzip2, and this is one of them.  It amuses
me to have bzip2 be perfectly optimized as far as instsimplify goes!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130840 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-04 16:05:05 +00:00
Andrew Trick
37da408758 indvars: Added DisableIVRewrite and WidenIVs.
This adds functionality to remove size/zero extension during indvars
without generating a canonical IV and rewriting all IV users. It's
disabled by default so should have no effect on codegen. Work in progress.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130829 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-04 02:10:13 +00:00
Duncan Sands
ad20681cde Implement some basic simplifications involving min/max, for example
max(a,b) >= a -> true.  According to my super-optimizer, these are
by far the most common simplifications (of the -instsimplify kind)
that occur in the testsuite and aren't caught by -std-compile-opts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130780 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-03 19:53:10 +00:00
Devang Patel
464f4ef2bd Use llvm.dbg.cu named metadata to collect compile units.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130756 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-03 16:18:28 +00:00
Duncan Sands
448a6d3cc2 Fix PR9579: when simplifying a compare to "true" or "false", and it was
a vector compare, generate a vector result rather than i1 (and crashing).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130706 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-02 18:51:41 +00:00
Duncan Sands
f24ed77d24 Move some rem transforms out of instcombine and into instsimplify.
This automagically provides a transform noticed by my super-optimizer
as occurring quite often: "rem x, (select cond, x, 1)" -> 0.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130694 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-02 16:27:02 +00:00
Chris Lattner
4034e14985 teach GVN to widen integer loads when they are overaligned, when doing an
wider load would allow elimination of subsequent loads, and when the wider
load is still a native integer type.  This eliminates a ton of loads on 
various benchmarks involving struct fields, though it is somewhat hobbled
by clang not being very aggressive about field alignment.

This is yet another step along the way towards resolving PR6627.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130390 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-28 07:29:08 +00:00
Dan Gohman
1d7e818a38 Teach BasicAA about arm.neon.vld1 and vst1.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130327 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-27 20:44:28 +00:00
Dan Gohman
bddc1ca18a When analyzing functions known to only access argument pointees,
only check arguments with pointer types. Update the documentation
of IntrReadArgMem reflect this.

While here, add support for TBAA tags on intrinsic calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130317 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-27 18:39:03 +00:00
Andrew Trick
a2a162077c Corrects an old, old typo in a case that doesn't seem to be reached in practice.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130316 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-27 18:17:36 +00:00
Andrew Trick
104f4adeac Test case and comment for PR9633.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130294 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-27 05:42:17 +00:00
Andrew Trick
3f95c88162 Fix for PR9633 [indvars] Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Added a type check in ScalarEvolution::computeSCEVAtScope to handle the case in which operands of an
AddRecExpr in the current scope are folded.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130271 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-27 01:21:25 +00:00
Chris Lattner
cb5fd743a9 Enhance memdep to return clobber relation between noalias loads when
an earlier load could be widened to encompass a later load.  For example,
if we see:

  X = load i8* P, align 4
  Y = load i8* (P+3), align 1

and we have a 32-bit native integer type, we can widen the former load
to i32 which then makes the second load redundant.  GVN can't actually
do anything with this load/load relation yet, so this isn't testable, but 
it is the next step to resolving PR6627, and a fairly general class of 
"merge neighboring loads" missed optimizations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130250 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-26 22:42:01 +00:00
Chris Lattner
d5c7f7cb5e use AA::isMustAlias to simplify some calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130248 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-26 21:53:34 +00:00