Commit Graph

47 Commits

Author SHA1 Message Date
Craig Topper
ee18eb90ff [AVX-512] Fix accidental uses of AH/BH/CH/DH after copies to/from mask registers
We've had several bugs(PR32256, PR32241) recently that resulted from usages of AH/BH/CH/DH either before or after a copy to/from a mask register.

This ultimately occurs because we create COPY_TO_REGCLASS with VK1 and GR8. Then in CopyToFromAsymmetricReg in X86InstrInfo we find a 32-bit super register for the GR8 to emit the KMOV with. But as these tests are demonstrating, its possible for the GR8 register to be a high register and we end up doing an accidental extra or insert from bits 15:8.

I think the best way forward is to stop making copies directly between mask registers and GR8/GR16. Instead I think we should restrict to only copies between mask registers and GR32/GR64 and use EXTRACT_SUBREG/INSERT_SUBREG to handle the conversion from GR32 to GR16/8 or vice versa.

Unfortunately, this complicates fastisel a bit more now to create the subreg extracts where we used to create GR8 copies. We can probably make a helper function to bring down the repitition.

This does result in KMOVD being used for copies when BWI is available because we don't know the original mask register size. This caused a lot of deltas on tests because we have to split the checks for KMOVD vs KMOVW based on BWI.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298928 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-28 16:35:29 +00:00
Simon Pilgrim
a71393791a [X86][SSE] Enable post-legalize vXi64 shuffle combining on 32-bit targets
Long ago (2010 according to svn blame), combineShuffle probably needed to prevent the accidental creation of illegal i64 types but there doesn't appear to be any combines that can cause this any more as they all have their own legality checks.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296966 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-04 12:50:47 +00:00
Simon Pilgrim
0e35fcb104 [X86][AVX512] Update VPBROADCASTQ test to combine from VPERMQ instead of VPERMI2Q.
VPERMI2Q doesn't have shuffle decoding from re-materializable constants.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295736 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-21 17:04:11 +00:00
Simon Pilgrim
d0be5ae522 [X86][AVX] Rename shuffle combine tests to show combined shuffle type. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295735 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-21 16:45:31 +00:00
Simon Pilgrim
a77fb3315a [X86][AVX] Add tests showing missed VPBROADCASTQ folding on 32-bit targets.
As i64 isn't a value type on 32-bit targets, we fail to fold the VZEXT_LOAD into VPBROADCASTQ.

Also shows that we're not decoding VPERMIV3 shuffles very well....

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295729 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-21 16:05:35 +00:00
Simon Pilgrim
f47a06ee95 [X86][SSE] Add support for combining target shuffles to SHUFPD.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289407 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-11 21:26:25 +00:00
Simon Pilgrim
73f20efb6b [X86][AVX512] Add target shuffle test showing missing PSHUFPD combine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289400 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-11 19:41:23 +00:00
Craig Topper
df9e980077 [X86] Remove masking from 512-bit PSHUFB intrinsics in preparation for being able to constant fold it in InstCombineCalls like we do for 128/256-bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289344 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-10 23:09:43 +00:00
Simon Pilgrim
26d70f7d77 [X86][SSE] Add support for combining target shuffles to UNPCKL/UNPCKH.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288663 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 11:25:13 +00:00
Simon Pilgrim
46dd0f7aed [X86][AVX512] Add target shuffle tests showing missing UNPCK combines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288627 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-04 22:54:21 +00:00
Craig Topper
aa9982b218 [AVX-512] Add support for commuting VPERMT2(B/W/D/Q/PS/PD) to/from VPERMI2(B/W/D/Q/PS/PD).
Summary:
The index and one of the table operands can be swapped by changing the opcode to the other version. Neither of these operands are the one that can load from memory so this can't be used to increase memory folding opportunities.

We need to handle the unmasked forms and the kz forms. Since the load operand isn't being commuted we can commute the load and broadcast instructions too.

Reviewers: igorb, delena, Ayal, Farhana, RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287621 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-22 04:57:34 +00:00
Simon Pilgrim
d14ddee539 [X86][AVX512] Combine unary + zero target shuffles to VPERMV3 with a zero vector where possible
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287497 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-20 16:11:36 +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
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
Simon Pilgrim
cad4756e00 [X86][AVX512] Add mask/maskz writemask support to constant pool shuffle decode commentx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284488 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-18 15:45:37 +00:00
Craig Topper
63ae3007f1 [X86] Fix DecodeVPERMVMask to handle cases where the constant pool entry has a different type than the shuffle itself.
This is especially important for 32-bit targets with 64-bit shuffle elements.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284453 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-18 04:48:33 +00:00
Craig Topper
a97a64ce70 [AVX-512] Fix DecodeVPERMV3Mask to handle cases where the constant pool entry has a different type than the shuffle itself.
Summary: This is especially important for 32-bit targets with 64-bit shuffle elements.This is similar to how PSHUFB and VPERMIL handle the same problem.

Reviewers: RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284451 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-18 04:00:32 +00:00
Craig Topper
d56fafdbd2 [AVX-512] Add shuffle combining support for vpermi2var shuffles derived from existing support for vpermt2var.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284357 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-17 04:26:47 +00:00
Craig Topper
11061fd0cb [AVX-512] Add vpermi2var test cases to shuffle combining test case. Combining will be added in a future commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284356 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-17 04:26:44 +00:00
Craig Topper
bc745ca586 [AVX-512] Correct execution domain for VPERMT2PS and VPERMI2PS.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284328 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-16 04:54:31 +00:00
Craig Topper
b54d49d9c9 [X86] Add EVEX encoded VBROADCASTSS/SD and VPBROADCASTD/Q to execution domain fixing table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282687 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-29 05:54:39 +00:00
Simon Pilgrim
83d088fe4b [X86][AVX] Test target shuffle combining on 32 and 64-bit targets
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281833 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-17 18:42:41 +00:00
Craig Topper
7a4565f0eb [AVX-512] Correct ExeDomain for many AVX-512 instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277416 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-02 05:11:15 +00:00
Craig Topper
f876acdcd8 [AVX512] Add initial support for the Execution Domain fixing pass to change some EVEX instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276393 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-22 05:00:52 +00:00
Simon Pilgrim
15e94506a9 [X86][AVX512] Add support for VPERMILPD/VPERMILPS variable shuffle mask comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275272 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 15:45:36 +00:00
Simon Pilgrim
c0ce5801a7 [X86][AVX] Add support for target shuffle combining to VPERMILPS variable shuffle mask
Added AVX512F VPERMILPS shuffle decoding support

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275270 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 15:10:43 +00:00
Craig Topper
b6d6904481 [AVX512] Use vpternlog with an immediate of 0xff to create 512-bit all one vectors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275045 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-11 05:36:48 +00:00
Simon Pilgrim
8f101a7589 [X86][SSE] Add support for target shuffle combining to PSHUFLW/PSHUFHW
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275022 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-10 21:02:47 +00:00
Simon Pilgrim
cc3ff76d51 [X86][SSE] Added tests for combining shuffles to PSHUFLW/PSHUFHW
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275019 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-10 20:19:56 +00:00
Simon Pilgrim
bc06f80641 [X86][AVX2] Add support for target shuffle combining to VPERMPD/VPERMQ
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274908 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08 19:23:29 +00:00
Simon Pilgrim
6d5efdd3dd [X86][SSE] Accept any shuffle mask that is all zeroes
Until we have a better way to extract constants through bitcasted build vectors (and how to handle undefs of partial lanes etc.) at least accept build vectors that are all zeroes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274833 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-08 10:39:12 +00:00
Simon Pilgrim
2b2f63aebe [X86][SSE] Added test cases for missed opportunities to combine pshufb to pslldq/psrldq
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274631 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 15:09:48 +00:00
Simon Pilgrim
88147b7c5c [X86][AVX2] Add support for target shuffle combining to BROADCAST
Only support broadcast from vector register so far - memory folding support will have to wait.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274572 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-05 20:11:29 +00:00
Simon Pilgrim
319708c881 [X86][AVX512] Fixed decoding of permd/permpd variable mask shuffles + enabled them for target shuffle combining
Corrected element mask masking to extract the bottom index bits (now matches the perm2 implementation but for unary inputs).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274571 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-05 18:31:17 +00:00
Simon Pilgrim
2f0ee9010f [X86][AVX512] Add support for VPERM/VSHUF masked shuffle comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274462 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-03 13:55:41 +00:00
Simon Pilgrim
50f3e3a607 [X86][AVX512] Add support for masked shuffle comments
This patch adds support for including the avx512 mask register information in the mask/maskz versions of shuffle instruction comments.

This initial version just adds support for MOVDDUP/MOVSHDUP/MOVSLDUP to reduce the mass of test regenerations, other shuffle instructions can be added in due course.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274459 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-03 13:08:29 +00:00
Simon Pilgrim
f5d0848f55 [X86][SSE] Added support for combining target shuffles to (V)PSHUFD/VPERMILPD/VPERMILPS immediate permutes
This patch allows target shuffles to be combined to single input immediate permute instructions - (V)PSHUFD/VPERMILPD/VPERMILPS - allowing more general pattern matching than what we current do and improves the likelihood of memory folding compared to existing patterns which tend to reuse the input in multiple arguments.

Further permute instructions (V)PSHUFLW/(V)PSHUFHW/(V)PERMQ/(V)PERMPD may be added in the future but its proven tricky to create tests cases for them so far. (V)PSHUFLW/(V)PSHUFHW is already handled quite well in combineTargetShuffle so it may be that removing some of that code may allow us to perform more of the combining in one place without duplication.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273999 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-28 08:08:15 +00:00
Simon Pilgrim
979f1bb4eb [X86][SSE] Allow target shuffle combining to match masks with SM_Sentinel values
We currently only allow exact matches of shuffle mask patterns during target shuffle combining.

This patch relaxes this to permit SM_SentinelUndef in the combined shuffle to always be accepted as well as allowing exact matching of the SM_SentinelZero value.

I've adjusted some tests that were requiring exact shuffle masks to now include undef values.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273119 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-19 18:03:52 +00:00
Simon Pilgrim
11c52a1f5a [X86][AVX] Generalized matching for target shuffle combines
This patch is a first step towards a more extendible method of matching combined target shuffle masks.

Initially this just pulls out the existing basic mask matches and adds support for some 256/512 bit equivalents. Future patterns will require a number of features to be added but I wanted to keep this patch simple.

I hope we can avoid duplication between shuffle lowering and combining and share more complex pattern match functions in future commits.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270230 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20 16:19:30 +00:00
Simon Pilgrim
d91145c2d6 [X86][AVX512] Added another masked shuffle combine from load test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269077 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-10 16:55:20 +00:00
Simon Pilgrim
86f93f6dff [X86][AVX] Added some shuffle combine from load tests
As discussed on D19198 - we need to check what happens when we shuffle with different value type to the load

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269068 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-10 16:08:24 +00:00
Simon Pilgrim
122b5fb8b8 [X86][AVX512] Added masked version of MOVDDUP test with 16f32
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269038 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-10 10:30:00 +00:00
Simon Pilgrim
a5df424f08 [X86][AVX512] Added masked version of combine tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268904 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-09 10:43:13 +00:00
Simon Pilgrim
30836943b4 [X86][AVX] Add shuffle combine tests for MOVDDUP/MOVSHDUP/MOVSLDUP
128, 256 and 512 bit implementations (some not yet supported by combineX86ShuffleChain)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266535 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-16 20:30:59 +00:00
Simon Pilgrim
0c5336e71f [X86][AVX512] Fixed VPERMT2* shuffle mask decoding and enabled target shuffle combining.
Patch to add support for target shuffle combining of X86ISD::VPERMV3 nodes, including support for detecting unary shuffles.

This uncovered several issues with the X86ISD::VPERMV3 shuffle mask decoding of non-64 bit shuffle mask elements - the bit masking wasn't being correctly computed.

Removed non-constant pool mask decode path as we have no way of testing it right now.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262809 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-06 21:54:52 +00:00
Simon Pilgrim
058a70fa91 [X86][AVX512] Added some basic X86ISD::VPERMV3 shuffle combining tests
None of these actually combine yet as we haven't enabled X86ISD::VPERMV3 for target shuffle combining

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262718 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-04 15:19:42 +00:00
Simon Pilgrim
7ac9a82d13 [X86][AVX512BW] Fixed 512-bit PSHUFB shuffle mask decode and added combine test.
PSHUFB decoder was assuming that input was 128 or 256-bit vector only.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262661 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-03 21:55:01 +00:00