8672 Commits

Author SHA1 Message Date
Sanjay Patel
3dc20a0272 [x86] add tests for missed umin/umax
This is actually a deficiency in ValueTracking's matchSelectPattern(),
but a codegen test is the simplest way to expose the bug.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285429 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-28 19:08:20 +00:00
Arnold Schwaighofer
05af2b25b3 More swift calling convention tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285417 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-28 17:21:05 +00:00
Juergen Ributzka
67d80b9ced Revert "[DAGCombiner] Add vector demanded elements support to computeKnownBits"
This seems to have increased LTO compile time bejond 2x of previous builds.
See http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto/10676/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285381 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-28 04:01:12 +00:00
Simon Pilgrim
0de3e81c28 [X86][AVX512DQ] Improve lowering of MUL v2i64 and v4i64
With DQI but without VLX, lower v2i64 and v4i64 MUL operations with v8i64 MUL (vpmullq).

Updated cost table accordingly.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285304 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-27 15:27:00 +00:00
Simon Pilgrim
5579104d09 [DAGCombiner] Add vector demanded elements support to computeKnownBits
Currently computeKnownBits returns the common known zero/one bits for all elements of vector data, when we may only be interested in one/some of the elements.

This patch adds a DemandedElts argument that allows us to specify the elements we actually care about. The original computeKnownBits implementation calls with a DemandedElts demanding all elements to match current behaviour. Scalar types set this to 1.

The approach was found to be easier than trying to add a per-element known bits solution, for a similar usefulness given the combines where computeKnownBits is typically used.

I've only added support for a few opcodes so far (the ones that have proven straightforward to test), all others will default to demanding all elements but can be updated in due course.

DemandedElts support could similarly be added to computeKnownBitsForTargetNode in a future commit.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285296 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-27 14:29:28 +00:00
Zvi Rackover
a1f05a248d [X86] AVX512 fallback for floating-point scalar selects
Summary:
In the case where of 'select i1 , f32, f32' or select i1, f64, f64 prefer lowering to masked-moves over branches.

Fixes pr30561

Reviewers: igorb, aymanmus, delena

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285196 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-26 14:12:46 +00:00
Craig Topper
9fc96e5646 [AVX-512] Add scalar vfmsub/vfnmsub mask3 intrinsics
Summary: Clang's intrinsic header currently tries to negate the third operand of a vfmadd mask3 in order to create vfmsub, but this fails isel. This patch adds scalar vfmsub and vfnmsub mask3 that we can use instead to avoid the negate. This is consistent with the packed instructions.

Reviewers: igorb, delena

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285173 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-26 04:59:58 +00:00
Simon Pilgrim
d9bc309e9c [DAGCombiner] Enable (urem x, (shl pow2, y)) -> (and x, (add (shl pow2, y), -1)) combine for splatted vectors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285129 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 22:01:09 +00:00
Simon Pilgrim
908c768e1c [X86][SSE] Regenerated known-bits test with srem->urem fix
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285124 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 21:24:33 +00:00
Simon Pilgrim
b03ba30cbf [DAGCombiner] Enable srem(x.y) -> urem(x,y) combine for vectors
SelectionDAG::SignBitIsZero (via SelectionDAG::computeKnownBits) has supported vectors since rL280927

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285123 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 21:20:18 +00:00
Simon Pilgrim
4864d89aff [X86][SSE] Added vector srem combine tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285121 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 21:14:11 +00:00
Simon Pilgrim
b4f0b6e6d3 [X86][SSE] Added vector urem combine tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285119 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 21:10:12 +00:00
Simon Pilgrim
baad275225 [DAGCombiner] Enable sdiv(x.y) -> udiv(x,y) combine for vectors
SelectionDAG::SignBitIsZero (via SelectionDAG::computeKnownBits) has supported vectors since rL280927

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285118 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 20:56:42 +00:00
Simon Pilgrim
09845fdead [X86][SSE] Added vector sdiv combine tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285112 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 20:25:47 +00:00
Simon Pilgrim
16ce778275 [X86][SSE] Add support for (V)PMOVSX* constant folding
We already have (V)PMOVZX* combining support, this is the beginning of handling (V)PMOVSX* similarly - other combines in combineVSZext can be generalized in future patches.

This unearthed an interesting bug in that we were generating illegal build vectors on 32-bit targets - it was proving difficult to create a test for it from PMOVZX, but it fired immediately with PMOVSX. I've created a more general form of the existing getConstVector to handle these cases - ideally this should be handled in non-target-specific code but I couldn't find an equivalent.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285072 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 14:29:25 +00:00
Zvi Rackover
3ed32c90ce [DAGCombine] Preserve shuffles when one of the vector operands is constant
Summary:
Do *not* perform combines such as:

    vector_shuffle<4,1,2,3>(build_vector(Ud, C0, C1 C2), scalar_to_vector(X))
    ->
    build_vector(X, C0, C1, C2)

Keeping the shuffle allows lowering the constant build_vector to a materialized
constant vector (such as a vector-load from the constant-pool or some other idiom).

Reviewers: delena, igorb, spatel, mkuper, andreadb, RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285063 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 12:14:19 +00:00
Craig Topper
53bf46f680 [AVX-512] Add support for creating SIGN_EXTEND_VECTOR_INREG and ZERO_EXTEND_VECTOR_INREG for 512-bit vectors to support vpmovzxbq and vpmovsxbq.
Summary: The one tricky thing about this is that the sign/zero_extend_inreg uses v64i8 as an input type which isn't legal without BWI support. Though the vpmovsxbq and vpmovzxbq instructions themselves don't require BWI. To support this we need to add custom lowering for ZERO_EXTEND_VECTOR_INREG with v64i8 input. This can mostly reuse the existing sign extend code with a couple checks for sign extend vs zero extend added.

Reviewers: delena, RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285053 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 04:00:29 +00:00
Simon Pilgrim
8d980444a4 [SelectionDAG] Update ComputeNumSignBits SRA/SHL handlers to accept scalar or vector splats
Use isConstOrConstSplat helper.

Also use APInt instead of getZExtValue directly to avoid out of range issues.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285033 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-24 21:47:19 +00:00
Sanjay Patel
ddbec7c447 [x86] add tests for {-1,0,1} select of constants
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285005 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-24 19:13:29 +00:00
Mandeep Singh Grang
b831a5dabd [llvm] Remove redundant --check-prefix=CHECK from tests
Reviewers: MatzeB, mcrosier, rengolin

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285003 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-24 18:57:55 +00:00
Sanjay Patel
83768272ee [x86] regenerate checks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284982 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-24 15:43:40 +00:00
Craig Topper
bc9b41f1b1 [AVX-512] Remove masked pmin/pmax intrinsics and autoupgrade to native IR.
Clang patch to replace 512-bit vector and 64-bit element versions with native IR will follow.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284955 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-24 04:04:16 +00:00
Sanjay Patel
0800ef1513 [DAG] enhance computeKnownBits to handle SRL/SRA with vector splat constant
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284953 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-23 23:13:31 +00:00
Simon Pilgrim
ae8e401759 [X86][AVX512VL] Added support for combining target 256-bit shuffles to AVX512VL VPERMV3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284922 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-22 20:15:39 +00:00
Simon Pilgrim
d83c830dc4 [X86][AVX512] Added support for combining target shuffles to AVX512 VPERMV3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284921 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-22 19:53:59 +00:00
Zvi Rackover
6fa81ba24f [X86] Apply the Update LLC Test Checks tool on the mmx-bitcast test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284916 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-22 07:15:00 +00:00
Craig Topper
061426e6a1 [X86] Add support for printing shuffle comments for VALIGN instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284915 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-22 06:51:56 +00:00
Sanjay Patel
1b0519f03d [x86] add test for missing vector SRA combine via computeKnownBits
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284896 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 23:02:31 +00:00
Sanjay Patel
8751486522 [DAG] enhance computeKnownBits to handle SHL with vector splat constant
Also, use APInt to avoid crashing on types larger than vNi64.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284874 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 20:16:27 +00:00
Peter Collingbourne
7d77c5caa7 X86: Improve BT instruction selection for 64-bit values.
If a 64-bit value is tested against a bit which is known to be in the range
[0..31) (modulo 64), we can use the 32-bit BT instruction, which has a slightly
shorter encoding.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284864 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 19:57:55 +00:00
Simon Pilgrim
b859d6d852 [X86][AVX512BWVL] Added support for lowering v16i16 shuffles to AVX512BWVL vpermw
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284863 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 19:54:38 +00:00
Simon Pilgrim
714d9ba4ef [X86][AVX512BWVL] Added support for combining target v16i16 shuffles to AVX512BWVL vpermw
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284860 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 19:40:29 +00:00
Simon Pilgrim
fcb8cd9f1b [X86][AVX512] Added support for combining target shuffles to AVX512 vpermpd/vpermq/vpermps/vpermd/vpermw
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284858 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 19:18:09 +00:00
Sanjay Patel
be29b1044e [DAG] fold negation of sign-bit
0 - X --> 0, if the sub is NUW
0 - X --> 0, if X is 0 or the minimum signed value and the sub is NSW
0 - X --> X, if X is 0 or the minimum signed value

This is the DAG equivalent of:
https://reviews.llvm.org/rL284649

plus the fold for the NUW case which already existed in InstSimplify.

Note that we miss a vector fold because of a deficiency in the DAG version of
computeKnownBits().



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284844 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 17:24:26 +00:00
Sanjay Patel
7ff284e6ae [x86] add tests for potential negation folds
These are the backend equivalents for the tests added in r284627.
The patterns may emerge late, so we should have folds for these in the DAG too.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284842 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 16:56:29 +00:00
Simon Pilgrim
c2abd3ebe2 [X86][SSE] Regenerated sext/zext constant folding tests and added i686 tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284837 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 16:22:16 +00:00
Simon Pilgrim
51f1efc164 [X86][SSE] Regenerated chained pmovsx store tests and added i686 tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284833 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 15:51:24 +00:00
Sanjay Patel
f8de69b006 [DAG] use SDNode flags 'nsz' to enable fadd/fsub with zero folds
As discussed in D24815, let's start the process of killing off the broken fast-math global
state housed in TargetOptions and eliminate the need for function-level fast-math attributes.

Here we enable two similar folds that are possible when we don't care about signed-zero:
fadd nsz x, 0 --> x
fsub nsz 0, x --> -x

Note that although the test cases include a 'sin' function call, I'm side-stepping the 
FMF-on-calls question (and lack of support in the DAG) for now. It's not needed for these
tests - isNegatibleForFree/GetNegatedExpression just look through a ISD::FSIN node.

Also, when we create an FNEG node and propagate the Flags of the FSUB to it, this doesn't
actually do anything today because Flags are silently dropped for any node that is not a
binary operator.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284824 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 14:36:58 +00:00
Simon Pilgrim
01109e8b73 [X86][AVX512] Add mask/maskz writemask support to subvector broadcast shuffle decode comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284821 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 12:14:24 +00:00
Simon Pilgrim
4b5784c2cd [X86][AVX] Add 32-bit target tests for vector lzcnt/tzcnt to demonstrate missed folding opportunities
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284816 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 10:50:52 +00:00
Craig Topper
7413606415 [AVX-512] Add tests to show opportunities for commuting vpermi2/vpermt2 instructions.
Commuting will be added in a future commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284808 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-21 05:55:40 +00:00
Dehao Chen
0872bb248f Using branch probability to guide critical edge splitting.
Summary:
The original heuristic to break critical edge during machine sink is relatively conservertive: when there is only one instruction sinkable to the critical edge, it is likely that the machine sink pass will not break the critical edge. This leads to many speculative instructions executed at runtime. However, with profile info, we could model the splitting benefits: if the critical edge has 50% taken rate, it would always be beneficial to split the critical edge to avoid the speculated runtime instructions. This patch uses profile to guide critical edge splitting in machine sink pass.

The performance impact on speccpu2006 on Intel sandybridge machines:

spec/2006/fp/C++/444.namd                  25.3  +0.26%
spec/2006/fp/C++/447.dealII               45.96  -0.10%
spec/2006/fp/C++/450.soplex               41.97  +1.49%
spec/2006/fp/C++/453.povray               36.83  -0.96%
spec/2006/fp/C/433.milc                   23.81  +0.32%
spec/2006/fp/C/470.lbm                    41.17  +0.34%
spec/2006/fp/C/482.sphinx3                48.13  +0.69%
spec/2006/int/C++/471.omnetpp             22.45  +3.25%
spec/2006/int/C++/473.astar               21.35  -2.06%
spec/2006/int/C++/483.xalancbmk           36.02  -2.39%
spec/2006/int/C/400.perlbench              33.7  -0.17%
spec/2006/int/C/401.bzip2                  22.9  +0.52%
spec/2006/int/C/403.gcc                   32.42  -0.54%
spec/2006/int/C/429.mcf                   39.59  +0.19%
spec/2006/int/C/445.gobmk                 26.98  -0.00%
spec/2006/int/C/456.hmmer                 24.52  -0.18%
spec/2006/int/C/458.sjeng                 28.26  +0.02%
spec/2006/int/C/462.libquantum            55.44  +3.74%
spec/2006/int/C/464.h264ref               46.67  -0.39%

geometric mean                                   +0.20%

Manually checked 473 and 471 to verify the diff is in the noise range.

Reviewers: rengolin, davidxl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284757 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-20 18:06:52 +00:00
Pirama Arumuga Nainar
f2b19f9394 Fix *_EXTEND_VECTOR_INREG legalization
Summary:
While promoting *_EXTEND_VECTOR_INREG nodes whose inputs are already
promoted, perform the appropriate sign extension for the promoted node
before doing the *_EXTEND_VECTOR_INREG operation.  If not, the undefined
high-order bits of the promoted operand may (a) be garbage inc ase of
zext) or (b) contribute the wrong sign-bit (in case of sext)

Updated the promote-vec3.ll test after this change.  The diff shows
explicit zeroing in case of zext and intermediate sign extension in case
of sext.

Reviewers: RKSimon

Subscribers: llvm-commits, srhines

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284752 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-20 17:56:36 +00:00
Simon Pilgrim
b4c99dd5d2 [DAGCombiner] Add general constant vector support to (srl (shl x, c), c) -> (and x, cst2)
We already supported scalar constant / splatted constant vector - now accepts any (non opaque) constant scalar / vector

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284717 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-20 11:10:21 +00:00
Simon Pilgrim
9f2ab76dca [DAGCombiner] Add general constant vector support to (shl (add x, c1), c2) -> (add (shl x, c2), c1 << c2)
We already supported scalar constant / splatted constant vector - now accepts any (non opaque) constant scalar / vector

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284613 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 17:12:22 +00:00
Reid Kleckner
0c4885106a [WinEH] Allow catchpads to reuse the same catch object
This code used a regular when it should have used a multimap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284612 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 17:08:23 +00:00
Sanjay Patel
85745f9561 [DAG] optimize negation of bool
Use mask and negate for legalization of i1 source type with SIGN_EXTEND_INREG.
With the mask, this should be no worse than 2 shifts. The mask can be eliminated
in some cases, so that should be better than 2 shifts.

This change exposed some missing folds related to negation:
https://reviews.llvm.org/rL284239
https://reviews.llvm.org/rL284395

There may be others, so please let me know if you see any regressions.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284611 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 16:58:59 +00:00
Simon Pilgrim
057fdd87c1 [DAGCombiner] Add general constant vector support to (shl (sra x, c1), c1) -> (and x, (shl -1, c1))
We already supported scalar constant / splatted constant vector - now accepts any (non opaque) constant scalar / vector

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284608 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 16:15:30 +00:00
Simon Pilgrim
f02821bc98 [DAGCombiner] Add general constant vector support to (shl (mul x, c1), c2) -> (mul x, c1 << c2)
We already supported scalar constant / splatted constant vector - now accepts any (non opaque) constant scalar / vector

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284607 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 15:59:28 +00:00
Simon Pilgrim
1a8de66835 Fix line endings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284576 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 11:16:58 +00:00