Commit Graph

147751 Commits

Author SHA1 Message Date
Craig Topper
f84ee35832 [InstCombine] Add support for turning vector sdiv into udiv.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300435 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17 01:51:19 +00:00
Craig Topper
023ae40959 [InstCombine] Add test cases for missing support for turning vector sdiv into udiv. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300434 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17 01:51:16 +00:00
Davide Italiano
f763838a0b [LCSSA] Simplify a loop. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300433 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17 00:02:45 +00:00
Craig Topper
9563b95955 [InstCombine][ValueTracking] When computing known bits for Srem make sure we don't compute known bits for the LHS twice.
If we already called computeKnownBits for the RHS being a constant power of 2, we've already computed everything we can and should just stop. I think previously we would still recurse if we had determined the result was negative or had not determined the sign bit at all.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300432 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 21:46:12 +00:00
Davide Italiano
0bd8066c86 [LCSSA] Fix non-determinism due to iterating over a SmallPtrSet.
Use a SmallSetVector instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300431 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 21:07:04 +00:00
Craig Topper
bfe2c60567 [InstCombine] In SimplifyDemandedUseBits, don't bother to mask known bits of constants with DemandedMask.
Just because we didn't demand them doesn't mean they aren't known.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300430 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 20:55:58 +00:00
Benjamin Kramer
48452ec477 [X86] Remove special handling for 16 bit for A asm constraints.
Our 16 bit support is assembler-only + the terrible hack that is
.code16gcc. Simply using 32 bit registers does the right thing for the
latter.

Fixes PR32681.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300429 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 20:13:08 +00:00
Bryant Wong
8f7c2a67b8 MemorySSA: Stop tracking def-or-use blocks.
The tracking is unused, since MemoryPhis are not pruned as of r282419.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300428 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 19:45:51 +00:00
Sanjay Patel
c2b0974b93 [InstSimplify] improve getTrue/getFalse; NFCI
The ConstantInt version has the same assert, and using null/allOnes is likely less efficient.
The only advantage of these local variants (and there's probably a better way to achieve this?)
is to save typing "ConstantInt::" over and over.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300426 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 17:43:11 +00:00
Dimitry Andric
9c08b69245 Garbage collect HAVE_EXECINFO_H from config.h.cmake after r300062. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300425 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 17:22:44 +00:00
Sanjay Patel
997ed308f7 [Constants] simplify get true/false code; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300424 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 17:00:21 +00:00
Michael Zuckerman
aacdb999ef [X86][X86 intrinsics]Folding cmp(sub(a,b),0) into cmp(a,b) optimization
This patch adds new optimization (Folding cmp(sub(a,b),0) into cmp(a,b))
to instCombineCall pass and was written specific for X86 CMP intrinsics.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300422 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 13:26:08 +00:00
Craig Topper
2f3c5dbfdb [APInt] Fix a bug in lshr by a value more than 64 bits above the bit width.
This was throwing an assert because we determined the intra-word shift amount by subtracting the size of the full word shift from the total shift amount. But we failed to account for the fact that we clipped the full word shifts by total words first. To fix this just calculate the intra-word shift as the remainder of dividing by bits per word.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300405 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 01:03:51 +00:00
Dimitry Andric
df332423cf Use correct registers for "A" inline asm constraint
Summary:
In PR32594, inline assembly using the 'A' constraint on x86_64 causes
llvm to crash with a "Cannot select" stack trace.  This is because
`X86TargetLowering::getRegForInlineAsmConstraint` hardcodes that 'A'
means the EAX and EDX registers.

However, on x86_64 it means the RAX and RDX registers, and on 16-bit x86
(ia16?) it means the old AX and DX registers.

Add new register classes in `X86RegisterInfo.td` to support these cases,
and amend the logic in `getRegForInlineAsmConstraint` to cope with
different subtargets.  Also add a test case, derived from PR32594.

Reviewers: craig.topper, qcolombet, RKSimon, ab

Reviewed By: ab

Subscribers: ab, emaste, royger, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300404 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-15 22:15:01 +00:00
Sanjay Patel
c4cce50c34 [InstCombine] allow (X != C1 && X != C2) and similar patterns to match splat vector constants
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300402 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-15 17:55:06 +00:00
Sanjay Patel
55d1225376 [InstCombine] add tests to show missing transforms for vectors; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300401 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-15 17:50:45 +00:00
Eric Christopher
bbbafde8bf Tidy checking for the soft float attribute.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300394 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-15 06:14:52 +00:00
Eric Christopher
a051d980ff Cache the DataLayout rather than looking it up frequently.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300393 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-15 06:14:50 +00:00
Vedant Kumar
737d8b6809 [ProfileData] Unify getInstrProf*SectionName helpers
This is a version of D32090 that unifies all of the
`getInstrProf*SectionName` helper functions. (Note: the build failures
which D32090 would have addressed were fixed with r300352.)

We should unify these helper functions because they are hard to use in
their current form. E.g we recently introduced more helpers to fix
section naming for COFF files. This scheme doesn't totally succeed at
hiding low-level details about section naming, so we should switch to an
API that is easier to maintain.

This is not an NFC commit because it fixes llvm-cov's testing support
for COFF files (this falls out of the API change naturally). This is an
area where we lack tests -- I will see about adding one as a follow up.

Testing: check-clang, check-profile, check-llvm.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300381 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-15 00:09:57 +00:00
Sanjoy Das
78d2f5fa4d Generalize SCEV's unit testing helper a bit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300379 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 23:47:53 +00:00
Craig Topper
61f35170e7 [InstCombine] MakeAnd/Or/Xor handling to reuse previous APInt computations
When checking if we should return a constant, we create some temporary APInts to see if we know all bits. But the exact computations we do are needed in several other locations in the same code.

This patch moves them to named temporaries so we can reuse them.

Ideally we'd write directly to KnownZero/One, but we currently seem to only write those variables after all the simplifications checks and I didn't want to change that with this patch.

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




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300376 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 22:34:14 +00:00
Krzysztof Parzyszek
ce27c612e6 [RDF] No longer ignore implicit defs or uses on any instructions
This used to be a Hexagon-specific treatment, but is no longer needed
since it's switched to subregister liveness tracking.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300369 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 21:19:17 +00:00
Krzysztof Parzyszek
05d022e31e [RDF] Correctly enumerate reg units for reg masks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300368 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 21:17:36 +00:00
Reid Kleckner
1f8f049069 [IR] Make paramHasAttr to use arg indices instead of attr indices
This avoids the confusing 'CS.paramHasAttr(ArgNo + 1, Foo)' pattern.

Previously we were testing return value attributes with index 0, so I
introduced hasReturnAttr() for that use case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300367 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 20:19:02 +00:00
Kostya Serebryany
2bb40bf078 [libFuzzer] more trophies
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300366 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 20:11:16 +00:00
Sam Clegg
a70c36a148 [WebAssembly] Improve readobj and nm support for wasm
Now that the libObect support for wasm is better we can
have readobj and nm produce more useful output too.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300365 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 19:50:44 +00:00
Sanjay Patel
285779ca0f [InstCombine] (X != C1 && X != C2) --> (X | (C1 ^ C2)) != C2
...when C1 differs from C2 by one bit and C1 <u C2:
http://rise4fun.com/Alive/Vuo

And move related folds to a helper function. This reduces code duplication and
will make it easier to remove the scalar-only restriction as a follow-up step.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300364 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 19:23:50 +00:00
Craig Topper
0b4a709cf7 [InstCombine] Support folding a subtract with a constant LHS into a phi node
We currently only support folding a subtract into a select but not a PHI. This fixes that.

I had to fix an assumption in FoldOpIntoPhi that assumed the PHI node was always in operand 0. Now we pass it in like we do for FoldOpIntoSelect. But we still require some dancing to find the Constant when we create the BinOp or ConstantExpr. This is based code is similar to what we do for selects.

Since I touched all call sites, this also renames FoldOpIntoPhi to foldOpIntoPhi to match coding standards.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300363 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 19:20:12 +00:00
Stanislav Mekhanoshin
d8c6515dbf [AMDGPU] set read_only access qualifier for pointers
If a kernel's pointer argument is known to be readonly
set access qualifier accordingly. This allows RT not to
flush caches before dispatches.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300362 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 19:11:40 +00:00
Sam Clegg
aa717883e8 [Test commit] Cleanup some whitespace in a test file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300361 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 18:43:57 +00:00
Craig Topper
6142660ca8 [InstCombine] Regenerate test checks using script. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300360 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 18:42:55 +00:00
Sanjay Patel
41a76abbb9 [InstCombine] add/move tests for and/or-of-icmps equality folds; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300357 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 18:19:27 +00:00
Craig Topper
b4e05013d0 [ValueTracking] Avoid undefined behavior in unittest by not making a named ArrayRef from a std::initializer_list
One of the ValueTracking unittests creates a named ArrayRef initialized by a std::initializer_list. The underlying array for an std::initializer_list is only guaranteed to have a lifetime as long as the initializer_list object itself. So this can leave the ArrayRef pointing at an array that no long exists.

This fixes this to just create an explicit array instead of an ArrayRef.

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




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300354 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 17:59:19 +00:00
Craig Topper
c1656ad227 [InstCombine] Refactor SimplifyUsingDistributiveLaws to more explicitly skip code when LHS/RHS aren't BinaryOperators
Currently this code always makes 2 or 3 calls to tryFactorization regardless of whether the LHS/RHS are BinaryOperators. We make 3 calls when both operands are BinaryOperators with the same opcode. Or surprisingly, when neither are BinaryOperators. This is because getBinOpsForFactorization returns Instruction::BinaryOpsEnd when the operand is not a BinaryOperator. If both LHS and RHS are not BinaryOperators then they both have an Opcode of Instruction::BinaryOpsEnd. When this happens we rely on tryFactorization to early out due to A/B/C/D being null. Similar behavior occurs for the other calls, we rely on getBinOpsForFactorization having made A/B or C/D null to get tryFactorization to early out.

We also rely on these null checks to check the result of getIdentityValue and early out for it.

This patches refactors this to pull these checks up to SimplifyUsingDistributiveLaws so we don't rely on BinaryOpsEnd as a sentinel or this A/B/C/D null behavior. I think this makes this code easier to reason about. Should also give a tiny performance improvement for cases where the LHS or RHS isn't a BinaryOperator.

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





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300353 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 17:55:41 +00:00
Xinliang David Li
e8752f4f05 [Profile] Make host tool aware of object format when quering prof section names
Differential Revision: https://reviews.llvm.org/D32073


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300352 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 17:48:40 +00:00
Alexey Bataev
aaf7ddc474 Update tests for the patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300351 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 17:47:07 +00:00
Sanjoy Das
8806d7a68a Use range-for in a few places
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300350 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 17:42:12 +00:00
Sanjoy Das
4c23f32e1e Rewrite SCEV Normalization using SCEVRewriteVisitor; NFC
Removes all of the boilerplate, cache management etc. from
ScalarEvolutionNormalization, and keeps only the interesting bits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300349 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 17:42:10 +00:00
Sanjoy Das
e4f44dfa73 Make SCEVRewriteVisitor smarter about when it trys to create SCEVs
This change really saves just one foldingset lookup, but makes
SCEVRewriteVisitor "feature compatible" with the handwritten logic in
ScalarEvolutionNormalization, so that I can change
ScalarEvolutionNormalization to use SCEVRewriteVisitor in a next step.

This is a non-functional change, but _may_ improve performance in some
pathological cases, but that's unlikely.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300348 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 17:42:08 +00:00
Sanjoy Das
2eb84fd76a Add missing #include
Again, caught by the modules build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300346 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 17:25:23 +00:00
Krzysztof Parzyszek
0e9e7d51d9 [RDF] Switch RegisterAggr to a bit vector of register units
This avoids many complications related to the complex register
aliasing schemes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300345 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 17:25:13 +00:00
Davide Italiano
ec87df5c2d [FunctionImport] assert(false) -> llvm_unreachable(). NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300344 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 17:22:02 +00:00
Sanjoy Das
4a9d2df17b Remove "#if 0"ed out assert
It won't compile after the recent changes I've made, and I think
keeping it in provides very little value.

Instead I've added (in an earlier commit) a C++ unit test to check the
Denormalize(Normalized(X)) == X property for specific instances of X,
which is what the assert was trying to do anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300339 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 16:47:15 +00:00
Sanjoy Das
69a0438a05 Delete some unnecessary boilerplate
The PostIncTransform class was not pulling its weight, so delete it
and use free functions instead.

This also makes the use of `function_ref` more idiomatic.  We were
storing an instance of function_ref in the PostIncTransform class
before, which was fine in that specific case, but the usage after this
change is more obviously okay.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300338 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 16:47:12 +00:00
Krzysztof Parzyszek
58bea371b9 [RDF] Refine propagation of reached uses in liveness computation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300337 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 16:33:54 +00:00
Sanjoy Das
6e68f3381d Add missing #include for STLExtras
Looks like earlier I was relying on #include ordering in files that
used ScalarEvolutionNormalization.h.

Found thanks to the selfhost modules buildbot!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300336 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 16:28:12 +00:00
Krzysztof Parzyszek
3a98382e18 [Hexagon] Fix a latent problem with interpreting live-in lane masks
A non-zero lane mask on a register with no subregister means that the
whole register is live-in. It is equivalent to a full mask.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300335 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 16:21:55 +00:00
Sanjoy Das
edfd87d481 Use range for
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300334 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 15:50:19 +00:00
Sanjoy Das
7fd520400d Simplify PostIncTransform further; NFC
Instead of having two ways to check if an add recurrence needs to be
normalized, just pass in one predicate to decide that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300333 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 15:50:07 +00:00
Sanjoy Das
b50ba92cd8 Add a unit test for SCEV Normalization
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300332 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 15:50:04 +00:00