Commit Graph

339 Commits

Author SHA1 Message Date
Simon Pilgrim
8859b11a89 [CostModel][AArch64] Add cost tests for ALTERNATE/SELECT style shuffle masks
Precursor to fixing a regression with SLP vectorizer for supporting SELECT shuffles (vs the current ALTERNATE)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334714 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 14:20:20 +00:00
Simon Pilgrim
d9dafe02fb [CostModel] Recognise REVERSE shuffle mask if the elements come from the second src
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334698 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 09:35:00 +00:00
Simon Pilgrim
b083fc6f49 [CostModel][X86] Test showing failure to recognise REVERSE shuffle mask if the elements come from the second src
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334623 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 17:12:11 +00:00
Simon Pilgrim
31dfcf10a6 [CostModel] Recognise BROADCAST shuffle mask if the elements come from the second src
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334620 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 16:52:02 +00:00
Simon Pilgrim
4252f6639c [CostModel][X86] Test showing failure to recognise BROADCAST shuffle mask if the elements come from the second src
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334616 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 16:33:42 +00:00
Simon Pilgrim
21582f2af6 [CostModel] Replace ShuffleKind::SK_Alternate with ShuffleKind::SK_Select (PR33744)
As discussed on PR33744, this patch relaxes ShuffleKind::SK_Alternate which requires shuffle masks to only match an alternating pattern from its 2 sources:

e.g. v4f32: <0,5,2,7> or <4,1,6,3>

This seems far too restrictive as most SIMD hardware which will implement it using a general blend/bit-select instruction, so replaces it with SK_Select, permitting elements from either source as long as they are inline:

e.g. v4f32: <0,5,2,7>, <4,1,6,3>, <0,1,6,7>, <4,1,2,3> etc.

This initial patch just updates the name and cost model shuffle mask analysis, later patch reviews will update SLP to better utilise this - it still limits itself to SK_Alternate style patterns.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334513 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 16:12:29 +00:00
Simon Pilgrim
861e3f325f [CostModel] Treat Identity shuffle masks as zero cost
As discussed on D47985, identity shuffle masks should probably be free.

I've limited this to the case where the input and output types all match - but we could probably accept all cases.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334506 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 14:47:13 +00:00
Simon Pilgrim
5700275056 [CostModel][X86] Add extra Identity shuffle mask cost tests (D47986)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334486 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 09:18:13 +00:00
Simon Pilgrim
0c500a83b4 [CostModel][X86] Add 'select' style shuffle costs tests (PR33744)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334351 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-09 16:08:25 +00:00
Simon Pilgrim
f68ced99b1 [X86][SSE] Use multiplication scale factors for v8i16 SHL on pre-AVX2 targets.
Similar to v4i32 SHL, convert v8i16 shift amounts to scale factors instead to improve performance and reduce instruction count. We were already doing this for constant shifts, this adds variable shift support.

Reduces the serial nature of the codegen, which relies on chains of plendvb/pand+pandn+por shifts.

This is a step towards adding support for vXi16 vector rotates.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334023 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-05 15:17:39 +00:00
Simon Pilgrim
91eac1017f [TTI] Add uniform/non-uniform constant Pow2 detection to TargetTransformInfo::getInstructionThroughput
This enables us to detect more fast path sdiv cases under cost analysis.

This patch also enables us to handle non-uniform-constant pow2 cases for X86 SDIV costs.

Found while working on D46276

Future patches can then extend the vectorizers to more fully support non-uniform pow2 cases.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332969 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-22 10:40:09 +00:00
Adhemerval Zanella
cae204293a [AArch64] Improve cost of vector division by constant
With custom lowering for vector MULLH{S,U}, it is now profitable to
vectorize a divide by constant loop for the custom types (v16i8, v8i16,
and v4i32).  The cost if based on TargetLowering::Build{S,U}DIV which
uses a multiply by constant plus adjustment to express a divide by
constant.

Both {u,s}mull{2} are expressed as Instruction::Mul and shifts by
Instruction::AShr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331873 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09 12:48:22 +00:00
Simon Pilgrim
d80aa1ad9d [CostModel][X86] Split off SLM checks
A future patch will require this and the diff is much better if we perform the split separately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331867 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09 11:42:34 +00:00
Matthew Simpson
daa39fa144 [TTI, AArch64] Add transpose shuffle kind
This patch adds a new shuffle kind useful for transposing a 2xn matrix. These
transpose shuffle masks read corresponding even- or odd-numbered vector
elements from two n-dimensional source vectors and write each result into
consecutive elements of an n-dimensional destination vector. The transpose
shuffle kind is meant to model the TRN1 and TRN2 AArch64 instructions. As such,
this patch also considers transpose shuffles in the AArch64 implementation of
getShuffleCost.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330941 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-26 13:48:33 +00:00
Simon Pilgrim
26c891e911 [CostModel][X86] Add div/rem tests for non-uniform constant divisors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330852 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-25 18:03:31 +00:00
Matthew Simpson
871b8fe06d [AArch64] Add cost model test case for transpose
This patch adds a cost model test case for vector shuffles having transpose
masks. The given costs are inaccurate and will be updated in a follow-on patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330625 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-23 18:21:29 +00:00
Simon Pilgrim
c01ee6eab4 [CostModel][X86] Add vector element insert/extract cost tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330439 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-20 15:26:59 +00:00
Simon Pilgrim
45252fa7dd [CostModel][X86] Add srem/urem constant cost tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330436 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-20 15:01:03 +00:00
Simon Pilgrim
b43e74c487 [CostModel][X86] Add SLM/GLM/BtVer2 compare + division/remainder cost tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330435 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-20 14:50:34 +00:00
Simon Pilgrim
a0c7210b95 [CostModel][X86] Split off BtVer2 cost checks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330433 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-20 13:50:33 +00:00
Simon Pilgrim
e1311cf67e [CostModel][X86] Add GoldmontPlus cost tests
Just reuses goldmont costs atm

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330432 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-20 13:42:53 +00:00
Simon Pilgrim
58f4dfd178 [CostModel][X86] Add some specific cpu targets to the cost models
We're mostly testing with generic isa attributes, but PR36550 will require testing of specific target's scheduler models as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330056 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-13 19:30:15 +00:00
Simon Pilgrim
4cba8e9e90 [CostModel][X86] Split fma arith costs tests from other fp tests
Was proving cumbersome to test with/without fma

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330054 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-13 19:12:32 +00:00
Simon Pilgrim
069de1ba37 [CostModel][X86] Regenerate latency/codesize cost tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330052 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-13 18:56:58 +00:00
Simon Pilgrim
7a7d602cc9 [CostModel][X86] Regenerate cast conversion cost tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330051 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-13 18:56:05 +00:00
Simon Pilgrim
8a10d1ef10 [CostModel][X86] Regenerate masked intrinsic cost tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330050 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-13 18:54:16 +00:00
Simon Pilgrim
9c4e19d127 [CostModel][X86] Regenerate vector reduction cost tests with update_analyze_test_checks.py
NOTE: We're only really interested in the extractelement cost (which represents the entire reduction).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329504 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-07 14:20:10 +00:00
Simon Pilgrim
cc6d45b972 [CostModel][X86] Regenerate vector select cost tests with update_analyze_test_checks.py
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329502 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-07 14:09:54 +00:00
Simon Pilgrim
43dba22c37 [CostModel][X86] Regenerate vector integer truncation cost tests with update_analyze_test_checks.py
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329500 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-07 14:05:35 +00:00
Simon Pilgrim
8ba0797e36 [CostModel][X86] Regenerate silvermont (and added goldmont) cost tests with update_analyze_test_checks.py
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329499 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-07 14:02:14 +00:00
Simon Pilgrim
5eeb34e4ee [CostModel][X86] Fix v32i16/v64i8 SETCC costs on AVX512BW targets
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329498 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-07 13:24:33 +00:00
Simon Pilgrim
d5e5cebeae [CostModel][X86] Regenerate vector comparison cost tests with update_analyze_test_checks.py
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329497 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-07 12:47:35 +00:00
Simon Pilgrim
b41985cc63 [CostModel][X86] Regenerate bit count cost tests with update_analyze_test_checks.py
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329413 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-06 16:14:27 +00:00
Simon Pilgrim
2f648b3d19 [CostModel][X86] Regenerate vector shuffle cost tests with update_analyze_test_checks.py
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329410 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-06 16:00:28 +00:00
Simon Pilgrim
5f3a882593 [CostModel][X86] Regenerate bswap/bitreverse cost tests with update_analyze_test_checks.py
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329407 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-06 15:46:26 +00:00
Simon Pilgrim
8e98b84255 [CostModel][X86] Regenerate integer extension/truncation cost tests with update_analyze_test_checks.py
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329402 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-06 15:28:26 +00:00
Simon Pilgrim
46037d2543 [CostModel][X86] Regenerate integer division/remainder tests with update_analyze_test_checks.py
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329401 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-06 15:23:26 +00:00
Simon Pilgrim
873c2f82eb [CostModel][X86] Regenerate vector shift cost tests with update_analyze_test_checks.py
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329400 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-06 15:14:34 +00:00
Simon Pilgrim
13f7056389 [CostModel][X86] Regenerate int<->fp cost tests with update_analyze_test_checks.py
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329398 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-06 15:12:36 +00:00
Simon Pilgrim
d79c539c3b [UpdateTestChecks] Add update_analyze_test_checks.py for cost model analysis generation
The script allows the auto-generation of checks for cost model tests to speed up their creation and help improve coverage, which will help a lot with PR36550.

If the need arises we can add support for other analyze passes as well, but the cost models was the one I needed to get done - at the moment it just warns that any other analysis mode is unsupported.

I've regenerated a couple of x86 test files to show the effect.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329390 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-06 12:36:27 +00:00
Simon Pilgrim
1fbc6fa39c [X86][CostModel] Use generic SSE levels instead of particular CPUs for shuffle costs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329168 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-04 11:14:12 +00:00
Craig Topper
e192eb0ee6 [X86] Update cost model for Goldmont. Add fsqrt costs for Silvermont
Add fdiv costs for Goldmont using table 16-17 of the Intel Optimization Manual. Also add overrides for FSQRT for Goldmont and Silvermont.

Reviewers: RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328451 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-25 15:58:12 +00:00
Matthew Simpson
a7fd2c3c2a [AArch64] Implement getArithmeticReductionCost
This patch provides an implementation of getArithmeticReductionCost for
AArch64. We can specialize the cost of add reductions since they are computed
using the 'addv' instruction.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327702 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-16 11:34:15 +00:00
Matthew Simpson
107433d6ad [TTI, AArch64] Allow the cost model analysis to test vector reduce intrinsics
This patch considers the experimental vector reduce intrinsics in the default
implementation of getIntrinsicInstrCost. The cost of these intrinsics is
computed with getArithmeticReductionCost and getMinMaxReductionCost. This patch
also adds a test case for AArch64 that indicates the costs we currently compute
for vector reduce intrinsics. These costs are inaccurate and will be updated in
a follow-on patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327698 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-16 10:00:30 +00:00
Evandro Menezes
6b4f6ae091 [AArch64] Adjust the cost of integer vector division
Since there is no instruction for integer vector division, factor in the
cost of singling out each element to be used with the scalar division
instruction.

Differential revision: https://reviews.llvm.org/D43974

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326955 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-07 22:35:32 +00:00
Simon Pilgrim
c637af82e0 [X86] Add silvermont fp arithmetic cost model tests
Add silvermont to existing high coverage tests instead of repeating in slm-arith-costs.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326747 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-05 22:13:22 +00:00
Simon Pilgrim
0eea35a6ef [X86][SSE] Reduce FADD/FSUB/FMUL costs on later targets (PR36280)
Agner's tables indicate that for SSE42+ targets (Core2 and later) we can reduce the FADD/FSUB/FMUL costs down to 1, which should fix the Himeno benchmark.

Note: the AVX512 FDIV costs look rather dodgy, but this isn't part of this patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326133 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-26 22:10:17 +00:00
Sanjay Patel
1c629279f1 revert r325515: [TTI CostModel] change default cost of FP ops to 1 (PR36280)
There are too many perf regressions resulting from this, so we need to 
investigate (and add tests for) targets like ARM and AArch64 before 
trying to reinstate.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325658 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-21 01:42:52 +00:00
Sanjay Patel
1fceaab028 [TTI CostModel] change default cost of FP ops to 1 (PR36280)
This change was mentioned at least as far back as:
https://bugs.llvm.org/show_bug.cgi?id=26837#c26
...and I found a real program that is harmed by this: 
Himeno running on AMD Jaguar gets 6% slower with SLP vectorization:
https://bugs.llvm.org/show_bug.cgi?id=36280
...but the change here appears to solve that bug only accidentally.

The div/rem costs for x86 look very wrong in some cases, but that's already true, 
so we can fix those in follow-up patches. There's also evidence that more cost model
changes are needed to solve SLP problems as shown in D42981, but that's an independent 
problem (though the solution may be adjusted after this change is made).

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325515 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-19 16:11:44 +00:00
Simon Pilgrim
15833560a5 [X86][SSE] Increase PMULLD costs to better match hardware
Until Skylake, most hardware could only issue a PMULLD op every other cycle

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324823 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-10 19:27:10 +00:00