102469 Commits

Author SHA1 Message Date
Sanjay Patel
7c77a6cf1a [DAGCombiner] shrink/widen a vselect to match its condition operand size (PR14657)
We discussed shrinking/widening of selects in IR in D26556, and I'll try to get back to that
patch eventually. But I'm hoping that this transform is less iffy in the DAG where we can check
legality of the select that we want to produce.

A few things to note:

1. We can't wait until after legalization and do this generically because (at least in the x86
   tests from PR14657), we'll have PACKSS and bitcasts in the pattern.
2. This might benefit more of the SSE codegen if we lifted the legal-or-custom requirement, but
   that requires a closer look to make sure we don't end up worse.
3. There's a 'vblendv' opportunity that we're missing that results in andn/and/or in some cases. 
   That should be fixed next.
4. I'm assuming that AVX1 offers the worst of all worlds wrt uneven ISA support with multiple 
   legal vector sizes, but if there are other targets like that, we should add more tests.
5. There's a codegen miracle in the multi-BB tests from PR14657 (the gcc auto-vectorization tests):
   despite IR that is terrible for the target, this patch allows us to generate the optimal loop
   code because something post-ISEL is hoisting the splat extends above the vector loops.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301781 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 22:44:51 +00:00
Sanjoy Das
21ade9ba1e Rename isKnownNotFullPoison to programUndefinedIfPoison; NFC
Summary:
programUndefinedIfPoison makes more sense, given what the function
does; and I'm about to add a function with a name similar to
isKnownNotFullPoison (so do the rename to avoid confusion).

Reviewers: broune, majnemer, bjarke.roune

Reviewed By: broune

Subscribers: mcrosier, llvm-commits, mzolotukhin

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301776 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 19:41:19 +00:00
Amaury Sechet
bcb9816097 Do not legalize large add with addc/adde, introduce addcarry and do it with uaddo/addcarry
Summary: As per discution on how to get better codegen an large int legalization, it became clear that using a glue for the carry was preventing several desirable optimizations. Passing the carry down as a value allow for more flexibility.

Reviewers: jyknight, nemanjai, mkuper, spatel, RKSimon, zvi, bkramer

Subscribers: igorb, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301775 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 19:24:09 +00:00
Craig Topper
c07d5e69ae [APInt] Replace calls to setBits with more specific calls to setBitsFrom and setLowBits where possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301768 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 07:44:58 +00:00
Craig Topper
78c3b9ec3d [X86] Clear KnownBits instead of reconstructing it. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301767 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 07:44:55 +00:00
Zvi Rackover
c6bea6e868 InstructionSimplify: Canonicalize shuffle operands. NFC-ish.
Summary:
 Apply canonicalization rules:
    1. Input vectors with no elements selected from can be replaced with undef.
    2. If only one input vector is constant it shall be the second one.

This allows constant-folding to cover more ad-hoc simplifications that
were in place and avoid duplication for RHS and LHS checks.

There are more rules we may want to add in the future when we see a
justification. e.g. mask elements that select undef elements can be
replaced with undef.

Reviewers: spatel, RKSimon, andreadb, davide

Reviewed By: spatel, RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301766 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 06:25:04 +00:00
Zvi Rackover
f24bed9225 InstructionSimplify: One getShuffleMask() replacing multiple getMaskValue(). NFC.
Summary: This is a preparatory step for D32338.

Reviewers: RKSimon, spatel

Reviewed By: RKSimon, spatel

Subscribers: spatel, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301765 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 06:10:54 +00:00
Zvi Rackover
778f5177f0 InstructionSimplify: Simplify a shuffle with a undef mask to undef
Summary:
Following the discussion in pr32486, adding the simplification:
 shuffle %x, %y, undef -> undef

Reviewers: spatel, RKSimon, andreadb, davide

Reviewed By: spatel

Subscribers: jroelofs, davide, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301764 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 06:06:26 +00:00
Simon Atanasyan
258bb897bd [mips] Emit R_MICROMIPS_TLS_GOTTPREL relocation for %gottprel in case of microMIPS
In case of microMIPS mode %gottprel operator should emit microMIPS
relocation R_MICROMIPS_TLS_GOTTPREL, not R_MIPS_TLS_GOTTPREL.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301763 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 04:27:23 +00:00
Craig Topper
70629e6c18 [ConstantRange] Fix a couple cases where we were possibly throwing away an APInt allocation we could reuse. NFC
This uses setAllBits to replace getMaxValue and operator=(uint64_t) instead of constructing an APInt from uint64_t.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301761 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-30 00:44:05 +00:00
Dimitry Andric
99767332b8 Include <cstdio> in PrettyStackTrace.cpp, since it uses vsnprintf(3).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301760 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 23:45:30 +00:00
Craig Topper
8f3c59afe4 [ConstantRange] Use APInt::getOneBitSet to shorten some code. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301753 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 17:59:41 +00:00
Craig Topper
ecc4d6088d [ConstantRange] Replace getMaxValue+zext with getLowBitsSet. Replace zero-init+setBit with getOneBitSet. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301752 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 17:46:13 +00:00
Craig Topper
0427e63e86 [ConstantRange] Use APInt::operator-= to remove temporary APInts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301751 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 17:46:11 +00:00
Daniel Sanders
f31ac9d1e8 [globalisel][tablegen] Compute available feature bits correctly.
Summary:
Predicate<> now has a field to indicate how often it must be recomputed.
Currently, there are two frequencies, per-module (RecomputePerFunction==0)
and per-function (RecomputePerFunction==1). Per-function predicates are
currently recomputed more frequently than necessary since the only predicate
in this category is cheap to test. Per-module predicates are now computed in
getSubtargetImpl() while per-function predicates are computed in selectImpl().

Tablegen now manages the PredicateBitset internally. It should only be
necessary to add the required includes.

Also fixed a problem revealed by the test case where
constrainSelectedInstRegOperands() would attempt to tie operands that
BuildMI had already tied.

Reviewers: ab, qcolombet, t.p.northover, rovka, aditya_nandakumar

Reviewed By: rovka

Subscribers: kristof.beyls, igorb, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301750 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 17:30:09 +00:00
Craig Topper
8b69610574 [KnownBits] Add methods for determining if the known bits represent a negative/nonnegative number and add methods for changing the negative/nonnegative state
Summary: This patch adds isNegative, isNonNegative for querying whether the sign bit is known. It also adds makeNegative and makeNonNegative for controlling the sign bit.

Reviewers: RKSimon, spatel, davide

Reviewed By: RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301747 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 16:43:11 +00:00
Simon Dardis
d9e74d6d4a [mips][FastISel] Fix a nullptr deference.
r301392 introduced a potential nullptr deference causing compilation
failures.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301746 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 16:31:40 +00:00
Craig Topper
5529b11227 [ConstantRange] Use ternary operator instead of 'if' to avoid copying an APInt and then possibly copying over it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301741 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 07:24:13 +00:00
Craig Topper
9a418e88ed [ConstantRange] Add std::move to a bunch of places that pass local APInts to ConstantRange constructor.
The ConstantRange constructor takes APInt by value so without these moves we are making copies.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301740 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 06:40:47 +00:00
Craig Topper
c8cc907e2b [ConstantRange] Remove a temporary APInt I meant to delete in r300621. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301737 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 05:24:34 +00:00
Craig Topper
8c828d31ce [ConstantRange] Improve the efficiency of one of the ConstantRange constructors.
We were default constructing the Lower/Upper APInts. Then creating min or max value, then doing a move assignment to Lower and copy assignment to upper. The copy assignment operator in particular has an out of line function call that has to examine whether or not a previous allocation exists that can be reused which of course it can't in this case.

The new code creates the min/max value first, move constructs Lower from it then copy constructs Upper from Lower.

This also seems to have convinced a self host build that this constructor can be inlined more readily into other methods in ConstantRange.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301736 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 05:08:52 +00:00
Matt Arsenault
23450e5997 AMDGPU: Fix copies from physical registers in SIFixSGPRCopies
This would assert when there were multiple defs of
a physical register.

We just need to move all of the users of it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301730 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 01:26:34 +00:00
Zachary Turner
40d2ca9f43 [llvm-pdbdump] Abstract some of the YAML/Raw printing code.
There is a lot of duplicate code for printing line info between
YAML and the raw output printer.  This introduces a base class
that can be shared between the two, and makes some minor
cleanups in the process.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301728 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 01:13:21 +00:00
Akira Hatanaka
e85d77f956 [ObjCARC] Do not move a release between a call and a
retainAutoreleasedReturnValue that retains the returned value.

This commit fixes a bug in ARC optimizer where it moves a release
between a call and a retainAutoreleasedReturnValue, causing the returned
object to be released before the retainAutoreleasedReturnValue can
retain it.

This commit accomplishes that by doing a lookahead and checking whether
the call prevents the release from moving upwards. In the long term, we
should treat the region between the retainAutoreleasedReturnValue and
the call as a critical section and disallow moving anything there
(possibly using operand bundles).

rdar://problem/20449878

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301724 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 00:23:11 +00:00
Davide Italiano
4917282645 [LoopUnswitch] Make DEBUG output more readable (part 2).
I fixed my miscompile in r301722 and I hope I don't have to take
a look at this code again now that Chandler has a new LoopUnswitch
pass, but maybe this could be of use for somebody else in the
meanwhile.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301723 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 00:18:26 +00:00
Davide Italiano
bbc33ba775 [LoopUnswitch] Don't remove instructions with side effects.
This fixes PR32818.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301722 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-29 00:12:18 +00:00
Duncan P. N. Exon Smith
acacdfca61 Fuzzer: Mark test/cxxstring.test UNSUPPORTED: windows
This has been mysteriously failing since r301593, which cleaned up the
types of things like size_t and SIZE_MAX for freestanding targets.  Reid
and Kostya suggested marking it as UNSUPPORTED on windows, given that no
one has been able to reproduce locally.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301719 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 23:59:53 +00:00
Zachary Turner
a769999502 [llvm-readobj] Use LLVMDebugInfoCodeView to parse line tables.
The llvm-readobj parsing code currently exists in our CodeView
library, so we use that to parse instead of re-writing the logic
in the tool.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301718 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 23:41:36 +00:00
Hans Wennborg
acde1f9265 Remove set but unused variable in BitcodeReader.cpp. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301713 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 23:11:16 +00:00
Hans Wennborg
dfc1ffb1c9 Revert r301697 "[IR] Make add/remove Attributes use AttrBuilder instead of AttributeList"
This broke the Clang build. (Clang-side patch missing?)

Original commit message:

> [IR] Make add/remove Attributes use AttrBuilder instead of
> AttributeList
>
> This change cleans up call sites and avoids creating temporary
> AttributeList objects.
>
> NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301712 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 23:01:32 +00:00
Matt Arsenault
754511fb00 InferAddressSpaces: Search constant expressions for addrspacecasts
These are pretty common when using local memory, and the 64-bit generic
addressing is much more expensive to compute.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301711 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 22:52:41 +00:00
Adrian Prantl
841400b968 Remove line and file from DINamespace.
Fixes the issue highlighted in
http://lists.llvm.org/pipermail/cfe-dev/2014-June/037500.html.

The DW_AT_decl_file and DW_AT_decl_line attributes on namespaces can
prevent LLVM from uniquing types that are in the same namespace. They
also don't carry any meaningful information.

rdar://problem/17484998
Differential Revision: https://reviews.llvm.org/D32648

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301706 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 22:25:46 +00:00
Matt Arsenault
e91b6db85f InferAddressSpaces: Avoid looking up deleted values
While looking at pure addressing expressions, it's possible
for the value to appear later in Postorder.

I haven't been able to come up with a testcase where this
exhibits an actual issue, but if you insert a dump before
the value map lookup, a few testcases crash.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301705 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 22:18:19 +00:00
Matt Arsenault
afc9030f67 InferAddressSpaces: Infer from just addrspacecasts
Eliminates some more cases where some subset of the addressing
computation remains flat. Some cases with addrspacecasts
in nested constant expressions are still left behind however.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301704 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 22:18:08 +00:00
Michael Zolotukhin
3456f7f5be [SCEV] Use early exit in createAddRecFromPHI. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301703 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 22:14:27 +00:00
Daniel Berlin
3df4f544fe LoopRotate: Fix use after scope bug
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301702 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 22:05:55 +00:00
Krzysztof Parzyszek
737d3b6aab [RDF] Correctly calculate lane masks for defs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301700 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:57:53 +00:00
Krzysztof Parzyszek
013513893f Properly handle PHIs with subregisters in UnreachableBlockElim
When a PHI operand has a subregister, create a COPY instead of simply
replacing the PHI output with the input it.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301699 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:56:33 +00:00
Krzysztof Parzyszek
653d636507 [Hexagon] Do not move a block if it is on a fall-through path
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301698 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:54:11 +00:00
Reid Kleckner
fde3916ada [IR] Make add/remove Attributes use AttrBuilder instead of AttributeList
This change cleans up call sites and avoids creating temporary
AttributeList objects.

NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301697 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:48:28 +00:00
Craig Topper
e490ed5993 [ConstantRange] Use APInt::isNullValue rather than APInt::isMinValue where it would make more sense to thing of 0 as 0 rather than the minimum unsigned value. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301696 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:48:09 +00:00
Craig Topper
00cdeeedba [ConstantRange] Use const references to prevent a couple APInt copies. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301694 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:48:03 +00:00
Davide Italiano
50ddb71dad [LoopUnswitch] Make DEBUG output more readable.
While debugging a miscompile I realized loopunswitch doesn't
put newlines when printing the instruction being replacement.
Ending up with a single line with many instruction replaced isn't
the best for readability and/or mental sanity.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301692 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:30:50 +00:00
Sam Clegg
e4f76f4742 [WebAssembly] Add size of section header to data relocation offsets.
Also, add test for data relocations and fix addend to
be signed.

Subscribers: jfb, dschuff

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301690 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:22:38 +00:00
Matt Arsenault
ba657060a1 [ValueTracking] Teach isSafeToSpeculativelyExecute() about the speculatable attribute
Patch by Tom Stellard

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301688 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:13:09 +00:00
Sam Clegg
649003c411 [WebAssembly] Write initial memory in pages not bytes
Subscribers: jfb, dschuff

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301687 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 21:12:09 +00:00
Reid Kleckner
52b0228949 Make getParamAlignment use argument numbers
The method is called "get *Param* Alignment", and is only used for
return values exactly once, so it should take argument indices, not
attribute indices.

Avoids confusing code like:
  IsSwiftError = CS->paramHasAttr(ArgIdx, Attribute::SwiftError);
  Alignment  = CS->getParamAlignment(ArgIdx + 1);

Add getRetAlignment to handle the one case in Value.cpp that wants the
return value alignment.

This is a potentially breaking change for out-of-tree backends that do
their own call lowering.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301682 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 20:34:27 +00:00
Matthias Braun
6ee52fe873 GlobalISel: Followup for r301679
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301681 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 20:31:49 +00:00
Matt Arsenault
ea376dae25 Add speculatable function attribute
This attribute tells the optimizer that the function may be speculated.

Patch by Tom Stellard

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301680 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 20:25:27 +00:00
Matthias Braun
81de60661c TargetLowering: Add finalizeLowering() function; NFC
Adds a new method finalizeLowering to TargetLoweringBase. This is in
preparation for an upcoming commit.

This function is meant for target specific adjustments to
MachineFrameInfo or register reservations.

Move the freezeRegisters() and the hasCopyImplyingStackAdjustment()
handling into the new function to prove the concept. As an added bonus
GlobalISel no longer missed the hasCopyImplyingStackAdjustment()
handling with this.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301679 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 20:25:05 +00:00