Commit Graph

173 Commits

Author SHA1 Message Date
Chad Rosier
cfe0cf017c Fix indent. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280270 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-31 18:37:52 +00:00
Elena Demikhovsky
1b2a8500af [Loop Vectorizer] Fixed memory confilict checks.
Fixed a bug in run-time checks for possible memory conflicts inside loop.
The bug is in Low <-> High boundaries calculation. The High boundary should be calculated as "last memory access pointer + element size".

Differential revision: https://reviews.llvm.org/D23176



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279930 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-28 08:53:53 +00:00
David Majnemer
ac0eb3d821 Use the range variant of transform instead of unpacking begin/end
No functionality change is intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278476 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-12 04:32:42 +00:00
Sean Silva
a4f9d70f9b Consistently use LoopAnalysisManager
One exception here is LoopInfo which must forward-declare it (because
the typedef is in LoopPassManager.h which depends on LoopInfo).

Also, some includes for LoopPassManager.h were needed since that file
provides the typedef.

Besides a general consistently benefit, the extra layer of indirection
allows the mechanical part of https://reviews.llvm.org/D23256 that
requires touching every transformation and analysis to be factored out
cleanly.

Thanks to David for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278079 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-09 00:28:52 +00:00
Sean Silva
20b343c051 Consistently use FunctionAnalysisManager
Besides a general consistently benefit, the extra layer of indirection
allows the mechanical part of https://reviews.llvm.org/D23256 that
requires touching every transformation and analysis to be factored out
cleanly.

Thanks to David for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278077 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-09 00:28:15 +00:00
Michael Kuperstein
e788186982 [LV, X86] Be more optimistic about vectorizing shifts.
Shifts with a uniform but non-constant count were considered very expensive to
vectorize, because the splat of the uniform count and the shift would tend to
appear in different blocks. That made the splat invisible to ISel, and we'd
scalarize the shift at codegen time.

Since r201655, CodeGenPrepare sinks those splats to be next to their use, and we
are able to select the appropriate vector shifts. This updates the cost model to
to take this into account by making shifts by a uniform cheap again.

Differential Revision: https://reviews.llvm.org/D23049


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277782 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-04 22:48:03 +00:00
Adam Nemet
957976efe6 [OptDiag,LV] Add hotness attribute to analysis remarks
The earlier change added hotness attribute to missed-optimization
remarks.  This follows up with the analysis remarks (the ones explaining
the reason for the missed optimization).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276192 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-20 21:44:26 +00:00
Adam Nemet
81c98a7118 [LAA] Don't hold on to DominatorTree in the analysis result
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275335 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 22:36:35 +00:00
Adam Nemet
e12bf89766 [LAA] Don't hold on to TargetLibraryInfo in the analysis result
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275334 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 22:36:27 +00:00
Adam Nemet
f5d4047fea [LAA] Don't hold on to DataLayout in the analysis result
In fact, don't even pass this to the ctor since we can get it from the
module.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275326 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 22:18:51 +00:00
Adam Nemet
703303a42c [LAA] Don't hold on to LoopInfo in the analysis result
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275325 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 22:18:48 +00:00
Adam Nemet
2ba3aa2758 [LAA] Don't hold on to AliasAnalysis in the analysis result
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275322 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 21:39:09 +00:00
David Majnemer
7615994d12 [LoopAccessAnalysis] Some minor cleanups
Use range-base for loops.
Use auto when appropriate.

No functional change is intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275213 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-12 20:31:46 +00:00
Xinliang David Li
fd5a3b4bf8 [PM] name the new PM LAA class LoopAccessAnalysis (LAA) /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274934 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08 21:21:44 +00:00
Xinliang David Li
e042fe59dc Rename LoopAccessAnalysis to LoopAccessLegacyAnalysis /NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274927 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08 20:55:26 +00:00
David Majnemer
a609ccd0b5 [LoopAccessAnalysis] Fix an integer overflow
We were inappropriately using 32-bit types to account for quantities
that can be far larger.

Fixed in PR28443.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274737 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-07 06:24:36 +00:00
Sean Silva
aa13ea4ca0 [PM] Avoid getResult on a higher level in LoopAccessAnalysis
Note that require<domtree> and require<loops> aren't needed because they
come in implicitly via the loop pass manager.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274712 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-07 01:01:53 +00:00
Xinliang David Li
10b22c8894 [PM] Port LoopAccessInfo analysis to new PM
It is implemented as a LoopAnalysis pass as 
discussed and agreed upon.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274452 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-02 21:18:40 +00:00
Xinliang David Li
6adce0835f [PM] refactor LoopAccessInfo code part-2
Differential Revision: http://reviews.llvm.org/D21636




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274334 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-01 05:59:55 +00:00
Adam Nemet
0954e3ab0f [LAA] Fix alphabetical sorting of headers. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274302 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-01 00:09:02 +00:00
Elena Demikhovsky
f7282f8ee5 Reverted patch 273864
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274115 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-29 10:01:06 +00:00
Elena Demikhovsky
1abadbff39 Fixed consecutive memory access detection in Loop Vectorizer.
It did not handle correctly cases without GEP.

The following loop wasn't vectorized:

for (int i=0; i<len; i++)

  *to++ = *from++;

I use getPtrStride() to find Stride for memory access and return 0 is the Stride is not 1 or -1.

Re-commit rL273257 - revision: http://reviews.llvm.org/D20789



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273864 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-27 11:19:23 +00:00
Xinliang David Li
42fe7e4c85 [PM]: LoopAccessInfo simple refactoring
To make definition of mov ctors easier.
Differential Revision: http://reviews.llvm.org/D21563



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273506 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 23:20:59 +00:00
Elena Demikhovsky
6f247766ed reverted the prev commit due to assertion failure
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273258 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 12:10:11 +00:00
Elena Demikhovsky
8ca9d2a8ad Fixed consecutive memory access detection in Loop Vectorizer.
It did not handle correctly cases without GEP.

The following loop wasn't vectorized:

for (int i=0; i<len; i++)
  *to++ = *from++;

I use getPtrStride() to find Stride for memory access and return 0 is the Stride is not 1 or -1.

Differential revision: http://reviews.llvm.org/D20789



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273257 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-21 11:32:01 +00:00
Adam Nemet
b7720e0f14 [LAA] Enable symbolic stride speculation for all LAA clients
This is a functional change for LLE and LDist.  The other clients (LV,
LVerLICM) already had this explicitly enabled.

The temporary boolean parameter to LAA is removed that allowed turning
off speculation of symbolic strides.  This makes LAA's caching interface
LAA::getInfo only take the loop as the parameter.  This makes the
interface more friendly to the new Pass Manager.

The flag -enable-mem-access-versioning is moved from LV to a LAA which
now allows turning off speculation globally.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273064 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 22:35:41 +00:00
Adam Nemet
d448b5e945 [LV] Move management of symbolic strides to LAA. NFCI
This is still NFCI, so the list of clients that allow symbolic stride
speculation does not change (yes: LV and LoopVersioningLICM, no: LLE,
LDist).  However since the symbolic strides are now managed by LAA
rather than passed by client a new bool parameter is used to enable
symbolic stride speculation.

The existing test Transforms/LoopVectorize/version-mem-access.ll checks
that stride speculation is performed for LV.

The previously added test Transforms/LoopLoadElim/symbolic-stride.ll
ensures that no speculation is performed for LLE.

The next patch will change the functionality and turn on symbolic stride
speculation in all of LAA's clients and remove the bool parameter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272970 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 22:57:55 +00:00
Adam Nemet
2e5ed34ad6 [LAA] Rename Strides to SymblicStrides in analyzeLoop. NFC
This is to facilitate to move of SymblicStrides from LV to LAA.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272879 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 08:27:03 +00:00
Adam Nemet
08e6f75e04 [LAA] Default getInfo to not speculate symbolic strides. NFC
Soon we won't be passing Strides to getInfo and then we'll have fewer
call sites to update.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272878 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 08:26:56 +00:00
Xinliang David Li
035a5a9202 Revert r272194 No need for it if loop Analysis Manager is used
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272243 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-09 03:22:39 +00:00
Xinliang David Li
8c60b4112d [PM] Refector LoopAccessInfo analysis code
This is the preparation patch to port the analysis to new PM

Differential Revision: http://reviews.llvm.org/D20560



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272194 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-08 20:15:37 +00:00
Andrey Turetskiy
a87b055656 [LAA] Improve non-wrapping pointer detection by handling loop-invariant case.
This fixes PR26314. This patch adds new helper “isNoWrap” with detection of
loop-invariant pointer case.

Patch by Roman Shirokiy.

Ref: https://llvm.org/bugs/show_bug.cgi?id=26314

Differential Revision: http://reviews.llvm.org/D17268


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272014 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 14:55:27 +00:00
Matthew Simpson
683b746f24 [LAA] Use load and store vectors (NFC)
Contributed-by: Aditya Kumar <hiraditya@msn.com>
Differential Revision: http://reviews.llvm.org/D20953

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271895 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06 14:15:41 +00:00
Matthew Simpson
204e3200ad [LAA] Check independence of strided accesses before forward case
This patch changes the order in which we attempt to prove the independence of
strided accesses. We previously did this after we knew the dependence distance
was positive. With this change, we check for independence before handling the
negative distance case. The patch prevents LAA from reporting forward
dependences for independent strided accesses.

This change was requested in the review of D19984.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270072 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 15:37:19 +00:00
Matthew Simpson
12427adbc9 [LAA] Rename forwarding conflict detection option (NFC)
This patch renames the option enabling the store-to-load forwarding conflict
detection optimization. This change was requested in the review of D20241.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269668 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 17:00:56 +00:00
Adam Nemet
095bb7d545 [LAA] Comment couldPreventStoreLoadForward. NFC
Also s/Cycles/Iters/ in NumCyclesForStoreLoadThroughMemory to make it
clear that this is not about clock cycles but loop cycles/iterations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269667 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 16:57:47 +00:00
Adam Nemet
24331f2d7f [LAA] clang-format the function couldPreventStoreLoadForward. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269666 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 16:57:42 +00:00
Matthew Simpson
5c1f23686d [LAA] Add option to disable conflict detection (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269654 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 14:14:49 +00:00
Adam Nemet
27aef5052b [LAA] Include MaxSafeDepDistBytes in the analysis print-out
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269508 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-13 22:49:13 +00:00
Adam Nemet
1903559e5a [LAA] Prepare the code to print more things in the summary. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269507 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-13 22:49:09 +00:00
Adam Nemet
a3a9c7ea20 [LAA] Use std::min. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269356 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12 21:41:53 +00:00
Silviu Baranga
c5b59c23b5 [LAA] Use re-written SCEV expressions when computing distances
This removes a redundant stride versioning step (we already
do it in getPtrStride, so it has no effect) and uses PSE to
get the SCEV expressions for the source and destination
(this might have changed when getPtrStride was called).

I discovered this through code inspection, and couldn't
produce a regression test for it.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269052 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-10 12:28:49 +00:00
Denis Zobnin
f459cb2831 [LAA] Rename "isStridedPtr" with "getPtrStride". NFC.
Changing misleading function name was approved in http://reviews.llvm.org/D17268.
Patch by Roman Shirokiy.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269021 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-10 05:55:16 +00:00
Adam Nemet
1b5ab63915 [LV] Hint at the new loop distribution pragma in optimization remark
When we encounter unsafe memory dependencies, loop distribution could
help.

Even though, the diagnostics is in LAA, it's only currently emitted in
the vectorizer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268987 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-09 23:03:44 +00:00
Adam Nemet
3c65ddccbc [LAA] Fix confusing debug message
This message used to be correct, when all we cared about was whether the
dependence was safe (i.e. NoDep) or unsafe.  With the current more
precise characterization, this is a forward dep.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268695 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-05 23:41:28 +00:00
David Majnemer
7f0d15f9a5 [ValueTracking, VectorUtils] Refactor getIntrinsicIDForCall
The functionality contained within getIntrinsicIDForCall is two-fold: it
checks if a CallInst's callee is a vectorizable intrinsic.  If it isn't
an intrinsic, it attempts to map the call's target to a suitable
intrinsic.

Move the mapping functionality into getIntrinsicForCallSite and rename
getIntrinsicIDForCall to getVectorIntrinsicIDForCall while
reimplementing it in terms of getIntrinsicForCallSite.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266801 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-19 19:10:21 +00:00
Silviu Baranga
5cb657f8dd [SCEV][LAA] Add tests for SCEV expression transformations performed during LAA
Summary:
Add a print method to Predicated Scalar Evolution which prints all interesting
transformations done by PSE.

Loop Access Analysis will now print this as part of the analysis output.
We now use this to check the exact expression transformations that were done
by PSE in LAA.

The additional checking also acts as white-box testing for the getAsAddRec method.

Reviewers: anemet, sanjoy

Subscribers: sanjoy, mzolotukhin, llvm-commits

Differential Revision: http://reviews.llvm.org/D18792

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266334 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 16:08:45 +00:00
Silviu Baranga
d8cc816f81 Re-commit [SCEV] Introduce a guarded backedge taken count and use it in LAA and LV
This re-commits r265535 which was reverted in r265541 because it
broke the windows bots. The problem was that we had a PointerIntPair
which took a pointer to a struct allocated with new. The problem
was that new doesn't provide sufficient alignment guarantees.
This pattern was already present before r265535 and it just happened
to work. To fix this, we now separate the PointerToIntPair from the
ExitNotTakenInfo struct into a pointer and a bool.

Original commit message:

Summary:
When the backedge taken codition is computed from an icmp, SCEV can
deduce the backedge taken count only if one of the sides of the icmp
is an AddRecExpr. However, due to sign/zero extensions, we sometimes
end up with something that is not an AddRecExpr.

However, we can use SCEV predicates to produce a 'guarded' expression.
This change adds a method to SCEV to get this expression, and the
SCEV predicate associated with it.

In HowManyGreaterThans and HowManyLessThans we will now add a SCEV
predicate associated with the guarded backedge taken count when the
analyzed SCEV expression is not an AddRecExpr. Note that we only do
this as an alternative to returning a 'CouldNotCompute'.

We use new feature in Loop Access Analysis and LoopVectorize to analyze
and transform more loops.

Reviewers: anemet, mzolotukhin, hfinkel, sanjoy

Subscribers: flyingforyou, mcrosier, atrick, mssimpso, sanjoy, mzolotukhin, llvm-commits

Differential Revision: http://reviews.llvm.org/D17201



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265786 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 14:29:09 +00:00
Silviu Baranga
89e8236bfb Revert r265535 until we know how we can fix the bots
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265541 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 14:06:32 +00:00
Silviu Baranga
39fbde60e1 [SCEV] Introduce a guarded backedge taken count and use it in LAA and LV
Summary:
When the backedge taken codition is computed from an icmp, SCEV can
deduce the backedge taken count only if one of the sides of the icmp
is an AddRecExpr. However, due to sign/zero extensions, we sometimes
end up with something that is not an AddRecExpr.

However, we can use SCEV predicates to produce a 'guarded' expression.
This change adds a method to SCEV to get this expression, and the
SCEV predicate associated with it.

In HowManyGreaterThans and HowManyLessThans we will now add a SCEV
predicate associated with the guarded backedge taken count when the
analyzed SCEV expression is not an AddRecExpr. Note that we only do
this as an alternative to returning a 'CouldNotCompute'.

We use new feature in Loop Access Analysis and LoopVectorize to analyze
and transform more loops.

Reviewers: anemet, mzolotukhin, hfinkel, sanjoy

Subscribers: flyingforyou, mcrosier, atrick, mssimpso, sanjoy, mzolotukhin, llvm-commits

Differential Revision: http://reviews.llvm.org/D17201

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265535 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 13:18:26 +00:00