Commit Graph

13888 Commits

Author SHA1 Message Date
Shawn Landden 61ba9dc40d [SimplifyCFG] NFC; remove bogus test case
Even if one bit is defined, the code is not clear what it is suppose to do.

The test wants to assert that some bits are undef, but that's not what the IR does and I don't think it's even possible to do that in any meaningful way. It was added in D12497, so @reames might want to double check.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362499 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-04 14:17:46 +00:00
Cameron McInally 63813a4718 [SCCP] Add UnaryOperator visitor to SCCP for unary FNeg
Differential Revision: https://reviews.llvm.org/D62819

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362449 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-03 21:53:56 +00:00
Matt Arsenault a69b8271d5 TTI: Improve default costs for addrspacecast
For some reason multiple places need to do this, and the variant the
loop unroller and inliner use was not handling it.

Also, introduce a new wrapper to be slightly more precise, since on
AMDGPU some addrspacecasts are free, but not no-ops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362436 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-03 18:41:34 +00:00
Andrew Kaylor 4bc2f18957 Fix a crash when the default of a switch is removed
This patch fixes a problem that occurs in LowerSwitch when a switch statement has a PHI node as its condition, and the PHI node only has two incoming blocks, and one of those incoming blocks is through an unreachable default in the switch statement. When this condition occurs, LowerSwitch holds a pointer to the condition value, but removes the switch block as a predecessor of the PHI block, causing the PHI node to be replaced. LowerSwitch then tries to use its stale pointer to the original condition value, causing a crash.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362427 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-03 17:54:15 +00:00
Philip Reames b58d51e15c [Tests] Add LFTR tests for multiple exit loops (try 2)
(Recommit after fixing a keymash in the run line.  Sorry for breakage.)

This is preparation for D62625 <https://reviews.llvm.org/D62625>



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362426 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-03 17:41:12 +00:00
Dmitri Gribenko 4e8306274d Revert "[Tests] Add LFTR tests for multiple exit loops"
This reverts commit r362417.  There's a syntax error in the RUN line.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362418 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-03 16:58:11 +00:00
Philip Reames 66a14657fe [Tests] Add LFTR tests for multiple exit loops
This is preparation for D62625



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362417 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-03 16:46:03 +00:00
Simon Pilgrim 3748537115 [CostModel][X86] Improve masked load/store AVX1/AVX2 costs
A mixture of internal tests and review of the scheduler models indicates we're overestimating the cost of a masked load, which we're estimating at 4x regular memory ops - more realistic values indicates that its closer to 2x. Masked stores costs are a lot more diverse but 8x is roughly in the middle of the range.

e.g. SandyBridge
defm : X86WriteRes<WriteFMaskedLoad, [SBPort23,SBPort05], 8, [1,2], 3>;
defm : X86WriteRes<WriteFMaskedLoadY, [SBPort23,SBPort05], 9, [1,2], 3>;
defm : X86WriteRes<WriteFMaskedStore, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
defm : X86WriteRes<WriteFMaskedStoreY, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;

e.g. Btver2
defm : X86WriteRes<WriteFMaskedLoad, [JLAGU, JFPU01, JFPX], 6, [1, 2, 2], 1>;
defm : X86WriteRes<WriteFMaskedLoadY, [JLAGU, JFPU01, JFPX], 6, [2, 4, 4], 2>;
defm : X86WriteRes<WriteFMaskedStore, [JSAGU, JFPU01, JFPX], 6, [1, 1, 4], 1>;
defm : X86WriteRes<WriteFMaskedStoreY, [JSAGU, JFPU01, JFPX], 6, [2, 2, 4], 2>;

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362338 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-02 20:37:02 +00:00
Nikita Popov c813a34137 [IndVarSimplify] Add tests for saturating math on IV; NFC
These saturating math ops can be replaced with simple math.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362320 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-02 08:49:35 +00:00
Craig Topper 1f535d6428 [InlineCost] Don't add the soft float function call cost for the fneg idiom, fsub -0.0, %x
Summary: Fneg can be implemented with an xor rather than a function call so we don't need to add the function call overhead. This was pointed out in D62699

Reviewers: efriedma, cameron.mcinally

Reviewed By: efriedma

Subscribers: javed.absar, eraman, hiraditya, haicheng, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362304 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-01 19:40:07 +00:00
Simon Pilgrim 0ea813a1e5 [SLPVectorizer][X86] Add other tests described in PR28474
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362297 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-01 12:35:03 +00:00
Simon Pilgrim 51c8e674ad [SLPVectorizer][X86] This test was from PR28474
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362296 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-01 12:10:29 +00:00
Nikita Popov 7a3adb340c [IndVarSimplify] Fixup nowrap flags during LFTR (PR31181)
Fix for https://bugs.llvm.org/show_bug.cgi?id=31181 and partial fix
for LFTR poison handling issues in general.

When LFTR moves a condition from pre-inc to post-inc, it may now
depend on value that is poison due to nowrap flags. To avoid this,
we clear any nowrap flag that SCEV cannot prove for the post-inc
addrec.

Additionally, LFTR may switch to a different IV that is dynamically
dead and as such may be arbitrarily poison. This patch will correct
nowrap flags in some but not all cases where this happens. This is
related to the adoption of IR nowrap flags for the pre-inc addrec.
(See some of the switch_to_different_iv tests, where flags are not
dropped or insufficiently dropped.)

Finally, there are likely similar issues with the handling of GEP
inbounds, but we don't have a test case for this yet.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362292 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-01 09:40:18 +00:00
Nikita Popov a3372ba9d1 [IndVarSimplify] Add additional PR33181 tests; NFC
Two more tests with a switch to a dynamically dead IV, with poison
occuring on the first or second iteration.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362291 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-01 09:40:09 +00:00
Philip Reames f9207feee4 [LoopPred] Handle a subset of NE comparison based latches
At the moment, LoopPredication completely bails out if it sees a latch of the form:
%cmp = icmp ne %iv, %N
br i1 %cmp, label %loop, label %exit
OR
%cmp = icmp ne %iv.next, %NPlus1
br i1 %cmp, label %loop, label %exit

This is unfortunate since this is exactly the form that LFTR likes to produce. So, go ahead and recognize simple cases where we can.

For pre-increment loops, we leverage the fact that LFTR likes canonical counters (i.e. those starting at zero) and a (presumed) range fact on RHS to discharge the check trivially.

For post-increment forms, the key insight is in remembering that LFTR had to insert a (N+1) for the RHS. CVP can hopefully prove that add nsw/nuw (if there's appropriate range on N to start with). This leaves us both with the post-inc IV and the RHS involving an nsw/nuw add, and SCEV can discharge that with no problem.

This does still need to be extended to handle non-one steps, or other harder patterns of variable (but range restricted) starting values. That'll come later.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362282 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-01 00:31:58 +00:00
Erik Pilkington 8964612be0 [SimplifyLibCalls] Fold more fortified functions into non-fortified variants
When the object size argument is -1, no checking can be done, so calling the
_chk variant is unnecessary. We already did this for a bunch of these
functions.

rdar://50797197

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362272 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 22:41:36 +00:00
Philip Reames 6dfa1767ad [Tests] Better represent the postinc form produced by LFTR in LoopPred tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362270 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 22:22:29 +00:00
Nikita Popov 9361861fe5 Reapply [CVP] Simplify non-overflowing saturating add/sub
If we can determine that a saturating add/sub will not overflow based
on range analysis, convert it into a simple binary operation. This is
a sibling transform to the existing with.overflow handling.

Reapplying this with an additional check that the saturating intrinsic
has integer type, as LVI currently does not support vector types.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362263 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 20:48:26 +00:00
Nikita Popov 01f46451ca [CVP] Add vector saturating add test; NFC
Extra test for the assertion failure from D62703.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362262 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 20:42:13 +00:00
Nikita Popov f4c874ffcf [CVP] Fix assertion failure on vector with.overflow
Noticed on D62703. LVI only handles plain integers, not vectors of
integers. This was previously not an issue, because vector support
for with.overflow is only a relatively recent addition.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362261 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 20:42:07 +00:00
Philip Reames aa578f685a [Tests] Add ne icmp tests w/preinc forms for LoopPredication
Turns out this is substaintially easier to match then the post increment form, so let's start there.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362260 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 20:34:57 +00:00
Cameron McInally e8160b5532 [NFC][InstCombine] Add unary FNeg tests to AMDGPU/amdgcn-intrinsics.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362255 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 19:12:59 +00:00
Nikita Popov 89d074eed3 Revert "[CVP] Simplify non-overflowing saturating add/sub"
This reverts commit 1e692d1777ae34dcb93524b5798651a29defae09.

Causes assertion failure in builtins-wasm.c clang test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362254 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 19:04:47 +00:00
Cameron McInally e11ffd7416 [NFC][InstCombine] Add unary FNeg to cos-1.ll cos-2.ll cos-sin-intrinsic.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362253 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 18:54:44 +00:00
Philip Reames 2e66afabcf [Tests] Add tests for loop predication of loops w/ne latch conditions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362244 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 16:54:38 +00:00
Nikita Popov 57b4161e8f [CVP] Simplify non-overflowing saturating add/sub
If we can determine that a saturating add/sub will not overflow
based on range analysis, convert it into a simple binary operation.
This is a sibling transform to the existing with.overflow handling.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362242 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 16:46:05 +00:00
Stanislav Mekhanoshin 66f50791b8 [AMDGPU] Use InliningThresholdMultiplier for inline hint
AMDGPU uses multiplier 9 for the inline cost. It is taken into account
everywhere except for inline hint threshold. As a result we are penalizing
functions with the inline hint making them less probable to be inlined
than those without the hint. Defaults are 225 for a normal function and
325 for a function with an inline hint. Currently we have effective
threshold 225 * 9 = 2025 for normal functions and just 325 for those with
the hint. That is fixed by this patch.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362239 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 16:19:26 +00:00
Cameron McInally 89d0e435ac [NFC][InstCombine] Add unary FNeg tests to fabs.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362238 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 16:17:04 +00:00
Cameron McInally dbb88f14e2 [NFC][InstCombine] Add unary FNeg tests to fcmp.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362234 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 15:40:03 +00:00
Cameron McInally f97ce7c953 [NFC][InstCombine] Add unary FNeg tests to fdiv.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362231 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 15:10:34 +00:00
Cameron McInally 8f390d9399 [NFC][InstCombine] Add unary FNeg tests to fma.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362227 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 14:49:31 +00:00
Roman Lebedev 9c291f7450 [InstCombine] 'C-(C2-X) --> X+(C-C2)' constant-fold
It looks this fold was already partially happening, indirectly
via some other folds, but with one-use limitation.
No other fold here has that restriction.

https://rise4fun.com/Alive/ftR

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362217 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 09:47:16 +00:00
Roman Lebedev 08e5b97049 [InstCombine] 'add (sub C1, X), C2 --> sub (add C1, C2), X' constant-fold
https://rise4fun.com/Alive/qJQ

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362216 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 09:47:04 +00:00
Roman Lebedev 8f0fce179c [NFC][InstCombine] Copy add/sub constant-folding tests from codegen
Last three patterns are missed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362209 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-31 08:24:07 +00:00
Nikita Popov faba0ea778 [CVP] Add tests for non-overflowing saturating math; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362153 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-30 21:03:17 +00:00
Cameron McInally ab622e5a2e [NFC][InstCombine] Add unary FNeg tests to fmul.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362137 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-30 19:42:25 +00:00
Tim Northover a8aa168ce3 Reapply: IR: add optional type to 'byval' function parameters
When we switch to opaque pointer types we will need some way to describe
how many bytes a 'byval' parameter should occupy on the stack. This adds
a (for now) optional extra type parameter.

If present, the type must match the pointee type of the argument.

The original commit did not remap byval types when linking modules, which broke
LTO. This version fixes that.

Note to front-end maintainers: if this causes test failures, it's probably
because the "byval" attribute is printed after attributes without any parameter
after this change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362128 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-30 18:48:23 +00:00
Craig Topper 8c0b3da9d4 [LoopVectorize] Add FNeg instruction support
Differential Revision: https://reviews.llvm.org/D62510

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362124 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-30 18:19:35 +00:00
Roman Lebedev c1ef73e8d8 [LoopIdiom] Basic OptimizationRemarkEmitter handling
Summary:
I'm adding ORE to memset/memcpy formation, with tests,
but mainly this is split off from D61144.

Reviewers: reames, anemet, thegameg, craig.topper

Reviewed By: thegameg

Subscribers: llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362092 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-30 13:02:06 +00:00
Craig Topper 13480b8846 [LoopVectorize] Precommit tests for D62510. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362060 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-30 06:48:13 +00:00
Florian Hahn 7c4db390c2 [LV] Inform about exactly reason of loop illegality
Currently, only the following information is provided by LoopVectorizer
in the case when the CF of the loop is not legal for vectorization:

 LV: Can't vectorize the instructions or CFG
    LV: Not vectorizing: Cannot prove legality.

But this information is not enough for the root cause analysis; what is
exactly wrong with the loop should also be printed:

 LV: Not vectorizing: The exiting block is not the loop latch.

Patch by Pavel Samolysov.

Reviewers: mkuper, hsaito, rengolin, fhahn

Reviewed By: fhahn

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362056 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-30 05:03:12 +00:00
Matt Arsenault b37f1aa225 LoopVersioningLICM: Respect convergent and noduplicate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362031 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-29 20:47:59 +00:00
Tim Northover 3d26f10b85 Revert "IR: add optional type to 'byval' function parameters"
The IRLinker doesn't delve into the new byval attribute when mapping types, and
this breaks LTO.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362029 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-29 20:46:38 +00:00
Tim Northover aef2b1ac1a IR: add optional type to 'byval' function parameters
When we switch to opaque pointer types we will need some way to describe
how many bytes a 'byval' parameter should occupy on the stack. This adds
a (for now) optional extra type parameter.

If present, the type must match the pointee type of the argument.

Note to front-end maintainers: if this causes test failures, it's probably
because the "byval" attribute is printed after attributes without any parameter
after this change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362012 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-29 19:12:48 +00:00
Nikita Popov 2a507f1555 [InstCombine] Optimize always overflowing signed saturating add/sub
Based on the overflow direction information added in D62463, we can
now fold always overflowing signed saturating add/sub to signed min/max.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362006 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-29 18:37:13 +00:00
Matt Arsenault 6eb463fb73 CallSiteSplitting: Respect convergent and noduplicate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361990 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-29 16:59:48 +00:00
Cameron McInally 7dc0230252 [NFC][InstCombine] Add a unary FNeg test to fsub.ll.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361988 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-29 16:50:14 +00:00
Cameron McInally 49367f4ed8 [NFC][InstCombine] Add unary FNeg tests to fpcast.ll and fpextend.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361973 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-29 15:29:35 +00:00
Cameron McInally e145e44a7c [NFC][InstCombine] Add unary FNeg tests to fsub.ll known-never-nan.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361971 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-29 15:21:28 +00:00
Matt Arsenault f53b32d49e SpeculateAroundPHIs: Respect convergent
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361957 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-29 13:14:39 +00:00