Commit Graph

13879 Commits

Author SHA1 Message Date
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
Rong Xu 8f580be75c [PGO] Handle cases of failing to split critical edges
Fix PR41279 where critical edges to EHPad are not split.
The fix is to not instrument those critical edges. We used to be able to know
the size of counters right after MST is computed. With this, we have to
pre-collect the instrument BBs to know the size, and then instrument them.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361882 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-28 21:45:56 +00:00
Nikita Popov 03c816bd0e Revert "[CorrelatedValuePropagation] Fix prof branch_weights metadata handling for SwitchInst"
This reverts commit 53f2f3286572cb879b3861d7c15480e4d830dd3b.

As reported on D62126, this causes assertion failures if the switch
has incorrect branch_weights metadata, which may happen as a result
of other transforms not handling it correctly yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361881 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-28 21:28:24 +00:00
Nikita Popov 52fbca6990 [InstCombine] Add tests for signed saturating always overflow; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361864 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-28 18:59:28 +00:00
Simon Tatham 2edda5220d [ARM] Replace fp-only-sp and d16 with fp64 and d32.
Those two subtarget features were awkward because their semantics are
reversed: each one indicates the _lack_ of support for something in
the architecture, rather than the presence. As a consequence, you
don't get the behavior you want if you combine two sets of feature
bits.

Each SubtargetFeature for an FP architecture version now comes in four
versions, one for each combination of those options. So you can still
say (for example) '+vfp2' in a feature string and it will mean what
it's always meant, but there's a new string '+vfp2d16sp' meaning the
version without those extra options.

A lot of this change is just mechanically replacing positive checks
for the old features with negative checks for the new ones. But one
more interesting change is that I've rearranged getFPUFeatures() so
that the main FPU feature is appended to the output list *before*
rather than after the features derived from the Restriction field, so
that -fp64 and -d32 can override defaults added by the main feature.

Reviewers: dmgreen, samparker, SjoerdMeijer

Subscribers: srhines, javed.absar, eraman, kristof.beyls, hiraditya, zzheng, Petar.Avramovic, cfe-commits, llvm-commits

Tags: #clang, #llvm

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361845 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-28 16:13:20 +00:00
Hans Wennborg afeb42acc3 Re-commit r357452 (take 2): "SimplifyCFG SinkCommonCodeFromPredecessors: Also sink function calls without used results (PR41259)"
This was reverted in r360086 as it was supected of causing mysterious test
failures internally. However, it was never concluded that this patch was the
root cause.

> The code was previously checking that candidates for sinking had exactly
> one use or were a store instruction (which can't have uses). This meant
> we could sink call instructions only if they had a use.
>
> That limitation seemed a bit arbitrary, so this patch changes it to
> "instruction has zero or one use" which seems more natural and removes
> the need to special-case stores.
>
> Differential revision: https://reviews.llvm.org/D59936

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361811 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-28 12:19:38 +00:00
Yevgeny Rouban 689d9dc302 [CorrelatedValuePropagation] Fix prof branch_weights metadata handling for SwitchInst
This patch fixes the CorrelatedValuePropagation pass to keep
prof branch_weights metadata of SwitchInst consistent.
It makes use of SwitchInstProfUpdateWrapper.
New tests are added.

Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D62126

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361808 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-28 11:33:50 +00:00
Simon Pilgrim 8bdaa8fafd [SLPVectorizer][X86] Add broadcast test case from D62427
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361805 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-28 11:10:56 +00:00
Florian Hahn a023a86ed9 [LoopInterchange] Fix handling of LCSSA nodes defined in headers and latches.
The code to preserve LCSSA PHIs currently only properly supports
reduction PHIs and PHIs for values defined outside the latches.

This patch improves the LCSSA PHI handling to cover PHIs for values
defined in the latches.

Fixes PR41725.

Reviewers: efriedma, mcrosier, davide, jdoerfert

Reviewed By: jdoerfert

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361743 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-26 23:38:25 +00:00
Shawn Landden adebd9af50 [SimplifyCFG] back out all SwitchInst commits
They caused the sanitizer builds to fail.

My suspicion is the change the countLeadingZeros().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361736 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-26 18:15:51 +00:00