15020 Commits

Author SHA1 Message Date
Rong Xu
18e6fc32c0 [PGO] Fix incorrect Twine usage in emitting optimization remarks.
Should not store Twine objects to local variables. This is fixed the test
failures with r267815 in VS2015 X64 build.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267908 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 17:49:56 +00:00
Rong Xu
2e8a2bbbd1 Minor format change and fixing typos in the comments. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267905 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 17:31:22 +00:00
Arch D. Robison
e95eedcc04 [SLPVectorizer] Extend SLP Vectorizer to deal with aggregates.
The refactoring portion part was done as r267748.

http://reviews.llvm.org/D14185



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267899 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 16:11:45 +00:00
Chad Rosier
c831d1b1ef [GVN] Minor code cleanup. NFC.
Differential Revision: http://reviews.llvm.org/D18828
Patch by Aditya Kumar!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267898 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 16:00:15 +00:00
Geoff Berry
a7480ba29a [EarlyCSE] Change LoadValue field Value *Data to Instruction *Inst. NFC.
Made in preparation for adding MemorySSA support to EarlyCSE.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267893 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 15:22:37 +00:00
Geoff Berry
629af37374 [EarlyCSE] Sort includes. NFC.
Reviewers: mcrosier

Subscribers: mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267890 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 14:59:27 +00:00
Ahmed Bougacha
c775e31867 [InstCombine] Remove trailing whitespace. NFC.
r267873.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267887 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 14:36:07 +00:00
Simon Pilgrim
fa0eab1450 [InstCombine][SSE] Add MOVMSK support to SimplifyDemandedUseBits
The MOVMSK instructions copies a vector elements' sign bits to the low bits of a scalar register and zeros the high bits.

This patch adds MOVMSK support to SimplifyDemandedUseBits so that its aware that the upper bits are known to be zero. It also removes the call to MOVMSK if none of the lower bits are actually required and just returns zero.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267873 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-28 12:22:53 +00:00
Rong Xu
1564d12c82 [PGO] Promote indirect calls to conditional direct calls with value-profile
This patch implements the transformation that promotes indirect calls to
conditional direct calls when the indirect-call value profile meta-data is
available.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267815 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 23:20:27 +00:00
Sanjay Patel
0d170a8dbc [SimplifyCFG] propagate branch metadata when creating select
There's no existing test for this path, and I don't know how to expose
it in a regression test, but I'm assuming there's some reason this
path exists. 



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267813 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 23:14:12 +00:00
Rong Xu
66f1b7d0e9 [PGO] Prohibit address recording if the function is both internal and COMDAT
Differential Revision: http://reviews.llvm.org/D19515


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267792 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 21:17:30 +00:00
Ahmed Bougacha
a1d8280553 [LIR] Set attributes on memset_pattern16.
"inferattrs" will deduce the attribute, but it will be too late for
many optimizations. Set it ourselves when creating the call.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267762 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 19:04:50 +00:00
Ahmed Bougacha
a08b12b7a1 [LIR] Reuse variable. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267761 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 19:04:46 +00:00
Ahmed Bougacha
18fc933b03 [InferAttrs] Mark memset_pattern16 params nocapture.
Differential Revision: http://reviews.llvm.org/D19471

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267760 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 19:04:43 +00:00
Ahmed Bougacha
76739f43a9 [TLI] Unify LibFunc attribute inference. NFCI.
Now the pass is just a tiny wrapper around the util. This lets us reuse
the logic elsewhere (done here for BuildLibCalls) instead of duplicating
it.

The next step is to have something like getOrInsertLibFunc that also
sets the attributes.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267759 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 19:04:40 +00:00
Ahmed Bougacha
8a8efec992 [TLI] Unify LibFunc signature checking. NFCI.
I tried to be as close as possible to the strongest check that
existed before; cleaning these up properly is left for future work.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267758 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 19:04:35 +00:00
Matthew Simpson
facf17cd03 [LV] Reallow positive-stride interleaved load groups with gaps
We previously disallowed interleaved load groups that may cause us to
speculatively access memory out-of-bounds (r261331). We did this by ensuring
each load group had an access corresponding to the first and last member.
Instead of bailing out for these interleaved groups, this patch enables us to
peel off the last vector iteration, ensuring that we execute at least one
iteration of the scalar remainder loop. This solution was proposed in the
review of the previous patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267751 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 18:21:36 +00:00
Arch D. Robison
9841605a5a [SLPVectorizer] Refactor where MinVecRegSize and MaxVecRegSize live.
This is the first of two commits for extending SLP Vectorizer to deal with aggregates.
This commit merely refactors existing logic.

http://reviews.llvm.org/D14185



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267748 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 17:46:25 +00:00
Matthew Simpson
d0229876a9 [TTI] Add hook for vector extract with extension
This change adds a new hook for estimating the cost of vector extracts followed
by zero- and sign-extensions. The motivating example for this change is the
SMOV and UMOV instructions on AArch64. These instructions move data from vector
to general purpose registers while performing the corresponding extension
(sign-extend for SMOV and zero-extend for UMOV) at the same time. For these
operations, TargetTransformInfo can assume the extensions are free and only
report the cost of the vector extract. The SLP vectorizer has been updated to
make use of the new hook.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267725 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 15:20:21 +00:00
Teresa Johnson
40978a4477 [ThinLTO] Refine fix to avoid renaming of uses in inline assembly.
Summary:
Refine the workaround from r266877 that attempts to prevent
renaming of locals in inline assembly, so that in addition to looking
for a llvm.used local value, that there is at least one inline assembly
call in the module. Otherwise, debug functions added to the llvm.used
can block importing/exporting unnecessarily.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267717 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 14:19:38 +00:00
Artur Pilipenko
aeb3be1dd2 isSafeToLoadUnconditionally support queries without a context
This is required to use this function from isSafeToSpeculativelyExecute

Reviewed By: hfinkel

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267692 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 11:00:48 +00:00
Adam Nemet
8d171c8f85 [LoopDist] Add llvm.loop.distribute.enable loop metadata
Summary:
D19403 adds a new pragma for loop distribution.  This change adds
support for the corresponding metadata that the pragma is translated to
by the FE.

As part of this I had to rethink the flag -enable-loop-distribute.  My
goal was to be backward compatible with the existing behavior:

  A1. pass is off by default from the optimization pipeline
  unless -enable-loop-distribute is specified

  A2. pass is on when invoked directly from opt (e.g. for unit-testing)

The new pragma/metadata overrides these defaults so the new behavior is:

  B1. A1 + enable distribution for individual loop with the pragma/metadata

  B2. A2 + disable distribution for individual loop with the pragma/metadata

The default value whether the pass is on or off comes from the initiator
of the pass.  From the PassManagerBuilder the default is off, from opt
it's on.

I moved -enable-loop-distribute under the pass.  If the flag is
specified it overrides the default from above.

Then the pragma/metadata can further modifies this per loop.

As a side-effect, we can now also use -enable-loop-distribute=0 from opt
to emulate the default from the optimization pipeline.  So to be precise
this is the new behavior:

  C1. pass is off by default from the optimization pipeline
  unless -enable-loop-distribute or the pragma/metadata enables it

  C2. pass is on when invoked directly from opt
  unless -enable-loop-distribute=0 or the pragma/metadata disables it

Reviewers: hfinkel

Subscribers: joker.eph, mzolotukhin, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267672 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 05:28:18 +00:00
Vaivaswatha Nagaraj
bd93c15ac5 [Cloning] cloneLoopWithPreheader(): add assert to ensure no sub-loops
Summary:
cloneLoopWithPreheader() does not update LoopInfo for sub-loop of
the original loop being cloned. Add assert to ensure no sub-loops for loop being cloned.

Reviewers: anemet, ashutosh.nema, hfinkel

Subscribers: mzolotukhin, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267671 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 05:25:09 +00:00
Evgeny Stupachenko
a27504ef06 The patch fixes PR27392.
Summary:
 It is incorrect to compare TripCount (which is BECount + 1)
  with extraiters (or Count) to check if we should enter unrolled
  loop or not, because TripCount can potentially overflow
  (when BECount is max unsigned integer).
 While comparing BECount with (Count - 1) is overflow safe and
  therefore correct.

Reviewer: hfinkel

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

From: Evgeny Stupachenko <evstupac@gmail.com>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267662 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 03:04:54 +00:00
Sanjoy Das
23165eebbb Fix typo in comment; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267653 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 01:44:31 +00:00
Mehdi Amini
3b7741bb2b ThinLTO: do not promote GlobalVariable that have a specific section.
Differential Revision: http://reviews.llvm.org/D18298

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267646 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 00:32:13 +00:00
Matt Arsenault
3082da881d SLSR: Use UnknownAddressSpace instead of 0 for pure arithmetic.
In the case where isLegalAddressingMode is used for cases
not related to addressing modes, such as pure adds and muls,
it should not be using address space 0. LSR already passes -1
as the address space in these cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267645 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 00:32:09 +00:00
Adam Nemet
7f794cf472 [LoopDist] Split main class. NFC
This splits out the per-loop functionality from the Pass class.

With this the fact whether the loop is forced-distribute with the new
metadata/pragma can be cached in the per-loop class rather than passed
around.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267643 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 00:31:03 +00:00
Justin Bogner
c943cfacc2 PM: Port Reassociate to the new pass manager
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267631 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 23:39:29 +00:00
Justin Bogner
b7e074989d Reassociate: Convert another functor into a lambda. NFC
Also move the explanatory comment with it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267628 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 23:32:00 +00:00
Sanjay Patel
b4a90e614d [SimplifyCFG] propagate branch metadata when creating select
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267624 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 23:15:48 +00:00
Sanjay Patel
d926422b16 [LowerExpectIntrinsic] make default likely/unlikely ratio bigger
We need the default ratio to be sufficiently large that it triggers transforms 
based on block frequency info (BFI) and plays well with the recently introduced
BranchProbability used by CGP.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267615 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 22:23:38 +00:00
Justin Bogner
7fd37fa92d Reassociate: Simplify using lambdas. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267614 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 22:22:18 +00:00
David Majnemer
de19e3a88c Revert "[SimplifyLibCalls] sprintf doesn't copy null bytes"
The destination buffer that sprintf uses is restrict qualified, we do
not need to worry about derived pointers referenced via format
specifiers.

This reverts commit r267580.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267605 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 21:04:47 +00:00
Elena Demikhovsky
b7f92d0916 Masked Store in Loop Vectorizer - bugfix
Fixed a bug in loop vectorization with conditional store.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267597 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 20:18:04 +00:00
Justin Bogner
c3ce5d9c39 PM: Port Internalize to the new pass manager
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267596 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 20:15:52 +00:00
David Majnemer
783db05d7b [SimplifyLibCalls] sprintf doesn't copy null bytes
sprintf doesn't read or copy the terminating null byte from it's string
operands.  sprintf will append it's own after processing all of the
format specifiers.

This fixes PR27526.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267580 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 18:16:49 +00:00
Dehao Chen
0002560113 Tune basic block annotation algorithm.
Summary:
Instead of using maximum IR weight as the basic block weight, this patch uses the voting algorithm to find the most likely weight for the basic block. This can effectively avoid the cases when some IRs are annotated incorrectly due to code motion of the profiled binary.

This patch also updates propagate.ll unittest to include discriminator in the input file so that it is testing something meaningful.

Reviewers: davidxl, dnovillo

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267519 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 04:59:11 +00:00
Hal Finkel
1ccb72c441 [SimplifyCFG] Preserve !llvm.mem.parallel_loop_access when merging
When SimplifyCFG merges identical instructions from both sides of a diamond, it
can preserve !llvm.mem.parallel_loop_access (as it does with most of the other
metadata). There's no real data or control dependency change in this case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267515 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 02:06:06 +00:00
Hal Finkel
681428ed7d [LoopVectorize] Don't consider conditional-load dereferenceability for marked parallel loops
I really thought we were doing this already, but we were not. Given this input:

void Test(int *res, int *c, int *d, int *p) {
  for (int i = 0; i < 16; i++)
    res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
}

we did not vectorize the loop. Even with "assume_safety" the check that we
don't if-convert conditionally-executed loads (to protect against
data-dependent deferenceability) was not elided.

One subtlety: As implemented, it will still prefer to use a masked-load
instrinsic (given target support) over the speculated load. The choice here
seems architecture specific; the best option depends on how expensive the
masked load is compared to a regular load. Ideally, using the masked load still
reduces unnecessary memory traffic, and so should be preferred. If we'd rather
do it the other way, flipping the order of the checks is easy.

The LangRef is updated to make explicit that llvm.mem.parallel_loop_access also
implies that if conversion is okay.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267514 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 02:00:36 +00:00
David Majnemer
562c999e14 [SROA] Don't falsely report that changes have occured
We would report that the function changed despite creating no new
allocas or performing any promotion.

This fixes PR27316.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267507 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 01:05:00 +00:00
Justin Bogner
1a9ed3005a PM: Port GlobalOpt to the new pass manager
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267499 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 00:28:01 +00:00
Justin Bogner
183519d6d0 PM: Convert the logic for GlobalOpt into static functions. NFC
Pass all of the state we need around as arguments, so that these
functions are easier to reuse. There is one part of this that is
unusual: we pass around a functor to look up a DomTree for a function.
This will be a necessary abstraction when we try to use this code in
both the legacy and the new pass manager.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267498 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 00:27:56 +00:00
Arch D. Robison
1ca1fcaa5b Optimize store of "bitcast" from vector to aggregate.
This patch is what was the "instcombine" portion of D14185, with an additional 
test added (see julia_pseudovec in test/Transforms/InstCombine/insert-val-extract-elem.ll). 
The patch causes instcombine to replace sequences of extractelement-insertvalue-store 
that act essentially like a bitcast followed by a store.

Differential review: http://reviews.llvm.org/D14260



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267482 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25 22:22:39 +00:00
Teresa Johnson
4668002971 [ThinLTO] Introduce typedef for commonly-used map type (NFC)
Add a typedef for the std::map<GlobalValue::GUID, GlobalValueSummary *>
map that is passed around to identify summaries for values defined in a
particular module. This shortens up declarations in a variety of places.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267471 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25 21:09:51 +00:00
Etienne Bergeron
68aaa747f9 Cleanup redundant expression in InstCombineAndOrXor.
Summary:
The expression is redundant on both side of operator |.

detected by : http://reviews.llvm.org/D19451

Reviewers: rnk, majnemer

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267458 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25 20:15:33 +00:00
Chad Rosier
3ac68db42d [ValueTracking] Improve isImpliedCondition when the dominating cond is false.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267430 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25 17:23:36 +00:00
Anna Thomas
2eaeff8313 Test commit: modified comment. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267406 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25 13:58:05 +00:00
James Molloy
c8f01da286 [GlobalOpt] Allow constant globals to be SRA'd
The current logic assumes that any constant global will never be SRA'd. I presume this is because normally constant globals can be pushed into their uses and deleted. However, that sometimes can't happen (which is where you really want SRA, so the elements that can be eliminated, are!).

There seems to be no reason why we can't SRA constants too, so let's do it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267393 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25 10:48:29 +00:00
Mehdi Amini
3f9946eb0d Run GlobalOpt before emitting the bitcode for ThinLTO
This is motivated by reducing the size of the IR and thus reduce
compile time.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267385 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-25 08:47:49 +00:00