Commit Graph

13785 Commits

Author SHA1 Message Date
Orlando Cazalet-Hyams 8d0ebfc10c [DebugInfo] Update loop metadata for inlined loops
Summary:
Currently, when a loop is cloned while inlining function (A) into function (B) the loop metadata is copied and then not modified at all. The loop metadata can encode the loop's start and end DILocations. Therefore, the new inlined loop in function (B) may have loop metadata which shows start and end locations residing in function (A).

This patch ensures loop metadata is updated while inlining so that the start and end DILocations are given the "inlinedAt" operand. I've also added a regression test for this.

This fix is required for D60831 because that patch uses loop metadata to determine the DILocation for the branches of new loop preheaders.

Reviewers: aprantl, dblaikie, anemet

Reviewed By: aprantl

Subscribers: eraman, hiraditya, llvm-commits

Tags: #debug-info, #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361132 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-20 09:40:44 +00:00
Sanjay Patel 8dbc761309 [InstSimplify] fold fcmp (maxnum, X, C1), C2
This is the sibling transform for rL360899 (D61691):

  maxnum(X, GreaterC) == C --> false
  maxnum(X, GreaterC) <= C --> false
  maxnum(X, GreaterC) <  C --> false
  maxnum(X, GreaterC) >= C --> true
  maxnum(X, GreaterC) >  C --> true
  maxnum(X, GreaterC) != C --> true

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361118 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-19 14:26:39 +00:00
Matt Arsenault 1b8894c87a GVN: Handle addrspacecast
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361103 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-18 14:36:06 +00:00
Cameron McInally e36567e474 [NFC][InstSimplify] Add more unary fneg tests to floating-point-arithmetic.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361076 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17 21:10:11 +00:00
Cameron McInally 4edb268ba5 [NFC][InstSimplify] Precommit new unary fneg test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361060 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17 18:34:35 +00:00
Sanjay Patel 81037cf3be [InstCombine] move bitcast after insertelement-with-bitcasted-operands
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361058 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17 18:06:12 +00:00
Cameron McInally b6fe331584 [NFC][InstSImplify] Fix flip-flopped comments and test names
In test/Transforms/InstSimplify/floating-point-arithmetic.ll

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361057 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17 17:59:17 +00:00
Sanjay Patel 7527749e86 [InstCombine] add tests for insertelement with bitcasted operands; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361051 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17 17:23:13 +00:00
Cameron McInally 9b20dc3577 [InstSimplify] Add unary fneg to fsub 0.0, (fneg X) ==> X transform
Differential Revision: https://reviews.llvm.org/D62013

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361047 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17 16:47:00 +00:00
Roman Lebedev f96e8b1ee5 [InstCombine] canShiftBinOpWithConstantRHS(): drop bogus signbit check
Summary:
In D61918 i was looking at dropping it in DAGCombiner `visitShiftByConstant()`,
but as @craig.topper pointed out, it was copied from here.

That check claims that the transform is illegal otherwise.
That isn't true:
1. For `ISD::ADD`, we only process `ISD::SHL` outer shift => sign bit does not matter
   https://rise4fun.com/Alive/K4A
2. For `ISD::AND`, there is no restriction on constants:
   https://rise4fun.com/Alive/Wy3
3. For `ISD::OR`, there is no restriction on constants:
   https://rise4fun.com/Alive/GOH
3. For `ISD::XOR`, there is no restriction on constants:
   https://rise4fun.com/Alive/ml6

So, why is it there then?
As far as i can tell, it dates all the way back to original check-in rL7793.
I think we should just drop it.

Reviewers: spatel, craig.topper, efriedma, majnemer

Reviewed By: spatel

Subscribers: llvm-commits, craig.topper

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361043 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17 15:52:49 +00:00
Clement Courbet 1160f948c2 Re-land r360859: "[MergeICmps] Simplify the code."
With a fix for PR41917: The predecessor list was changing under our feet.

-  for (BasicBlock *Pred : predecessors(EntryBlock_)) {
+  while (!pred_empty(EntryBlock_)) {
+    BasicBlock* const Pred = *pred_begin(EntryBlock_);

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361009 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17 09:43:45 +00:00
Clement Courbet 539b6a0c16 [MergeICmps] Add test from PR41917.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361001 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17 08:52:25 +00:00
Nico Weber db8503e5ea Revert r360859: "Reland r360771 "[MergeICmps] Simplify the code.""
It caused PR41917.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360963 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17 00:43:53 +00:00
Philip Reames 85725de61f [Tests] Consolidate more lftr tests
These are all of the ones involving the same data layout string.  Remainder take a bit more consideration, but at least everything can be auto-updated now.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360961 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17 00:19:28 +00:00
Philip Reames e3c69b2f50 [Tests] Expand basic lftr coverage
Newly written tests to cover the simple cases.  We don't appear to have broad coverage of this transform anywhere.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360957 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 23:41:28 +00:00
Philip Reames b0d16dea25 [Tests] More consolidation of lftr tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360936 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 20:42:00 +00:00
Philip Reames 4497208d41 [Test] Remove a bunch of cruft from a test
This test hadn't been fully reduced, so do so.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360935 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 20:37:20 +00:00
Philip Reames 66f0cce052 [Tests] Start consolidating lftr tests into a single file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360934 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 20:33:41 +00:00
Philip Reames c6a8d32225 [Tests] Autogen the last lftr test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360933 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 20:24:57 +00:00
Philip Reames 390a063d12 [Tests] Autogen a few more lftr tests for readability
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360932 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 20:19:02 +00:00
Philip Reames abb5c3714d [Tests] Autogen a few lftr test in preparation for merging
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360931 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 20:15:25 +00:00
Cameron McInally ef6ec86b0c [NFC][InstSimplify] Update fast-math.ll tests I botched in r360808.
These were new tests I added in r360808. I made a mistake while converting the exisiting binary FNeg test into the new unary FNeg tests. Correct that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360928 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 19:00:57 +00:00
Sanjay Patel bcb375a2bf [InstCombine] add tests for shuffle of insert subvectors; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360923 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 18:09:47 +00:00
Sanjay Patel ba81ceb9be [InstSimplify] add tests for fcmp of maxnum with constants; NFC
Sibling tests for rL360899 (D61691).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360905 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 15:00:11 +00:00
Matt Arsenault a3e4b69abb AMDGPU: Assume xnack is enabled by default
This is the conservatively correct default. It is always safe to
assume xnack is enabled, but not the converse.

Introduce a feature to blacklist targets where xnack can never be
meaningfully enabled. I'm not sure the targets this is applied to is
100% correct.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360903 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 14:48:34 +00:00
Stephen Tozer 4ca34ad3d2 Resubmit: [Salvage] Change salvage debug info implementation to use DW_OP_LLVM_convert where needed
Fixes issue: https://bugs.llvm.org/show_bug.cgi?id=40645

Previously, LLVM had no functional way of performing casts inside of a
DIExpression(), which made salvaging cast instructions other than Noop casts
impossible. With the recent addition of DW_OP_LLVM_convert this salvaging is
now possible, and so can be used to fix the attached bug as well as any cases
where SExt instruction results are lost in the debugging metadata. This patch
introduces this fix by expanding the salvage debug info method to cover these
cases using the new operator.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360902 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 14:41:01 +00:00
Sanjay Patel 90a7bd7e82 [InstSimplify] fold fcmp (minnum, X, C1), C2
minnum(X, LesserC) == C --> false
   minnum(X, LesserC) >= C --> false
   minnum(X, LesserC) >  C --> false
   minnum(X, LesserC) != C --> true
   minnum(X, LesserC) <= C --> true
   minnum(X, LesserC) <  C --> true

maxnum siblings will follow if there are no problems here.

We should be able to perform some other combines when the constants
are equal or greater-than too, but that would go in instcombine.

We might also generalize this by creating an FP ConstantRange
(similar to what we do for integers).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360899 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 14:03:10 +00:00
Clement Courbet ed46b2831a Reland r360771 "[MergeICmps] Simplify the code."
This revision does not seem to be the culprit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360859 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 06:18:02 +00:00
Yevgeny Rouban 0e5da9bc1e Fix prof branch_weights in entry_counts_missing_dbginfo.ll test
Removed extra parameter from !prof branch_weights metadata of
a call instruction according to the spec.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360843 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-16 03:39:09 +00:00
Roman Lebedev bca5cee306 [NFC][InstCombine] Add some more tests for pulling binops through shifts
The ashr variant may see relaxation in https://reviews.llvm.org/D61938

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360814 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 21:15:44 +00:00
Cameron McInally ab863397eb Revert llvm-svn: 360807
Somehow submitted this patch twice.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360812 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 20:48:50 +00:00
Cameron McInally 832b299ea5 Pre-commit unary fneg tests to InstSimplify
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360808 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 20:27:37 +00:00
Cameron McInally da36bb93c8 Add unary fneg to InstSimplify/fp-nan.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360807 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 20:27:35 +00:00
Cameron McInally fbfc565fb1 Add unary fneg to InstSimplify/fp-nan.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360797 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 19:37:03 +00:00
Taewook Oh 3e20d61b66 [PredicateInfo] Do not process unreachable operands.
Summary: We should excluded unreachable operands from processing as their DFS visitation order is undefined. When `renameUses` function sorts `OpsToRename` (https://fburl.com/d2wubn60), the comparator assumes that the parent block of the operand has a corresponding dominator tree node. This is not the case for unreachable operands and crashes the compiler.

Reviewers: dberlin, mgrang, davide

Subscribers: efriedma, hiraditya, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360796 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 19:35:38 +00:00
Hiroshi Yamauchi 1149c3500b [JumpThreading] A bug fix for stale loop info after unfold select
Summary:
The return value of a TryToUnfoldSelect call was not checked, which led to an
incorrectly preserved loop info and some crash.

The original crash was reported on https://reviews.llvm.org/D59514.

Reviewers: davidxl, amehsan

Reviewed By: davidxl

Subscribers: fhahn, brzycki, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360780 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 15:15:16 +00:00
Cameron McInally 917249a6e6 Teach InstSimplify -X + X --> 0.0 about unary FNeg
Differential Revision: https://reviews.llvm.org/D61916

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360777 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 14:31:33 +00:00
Clement Courbet 1e3d019b42 Revert r360771 "[MergeICmps] Simplify the code."
Breaks a bunch of builbdots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360776 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 14:21:59 +00:00
Stephen Tozer dabe45c6d5 Revert "[Salvage] Change salvage debug info implementation to use DW_OP_LLVM_convert where needed"
This reverts r360772 due to build issues.
Reverted commit: 17dd4d7403770bd683675e45f5517e0cdb8f9b2b.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360773 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 13:41:44 +00:00
Stephen Tozer 76562e6377 [Salvage] Change salvage debug info implementation to use DW_OP_LLVM_convert where needed
Fixes issue: https://bugs.llvm.org/show_bug.cgi?id=40645

Previously, LLVM had no functional way of performing casts inside of a
DIExpression(), which made salvaging cast instructions other than Noop
casts impossible. With the recent addition of DW_OP_LLVM_convert this
salvaging is now possible, and so can be used to fix the attached bug as
well as any cases where SExt instruction results are lost in the
debugging metadata. This patch introduces this fix by expanding the
salvage debug info method to cover these cases using the new operator.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360772 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 13:15:48 +00:00
Clement Courbet de3c2efffe [MergeICmps] Simplify the code.
Instead of patching the original blocks, we now generate new blocks and
delete the old blocks. This results in simpler code with a less twisted
control flow (see the change in `entry-block-shuffled.ll`).

This will make https://reviews.llvm.org/D60318 simpler by making it more
obvious where control flow created and deleted.

Reviewers: gchatelet

Subscribers: hiraditya, llvm-commits, spatel

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360771 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 13:04:24 +00:00
Roman Lebedev 4e5f939b02 [NFC][InstCombine] Regenerate trunc.ll test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360759 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 10:24:38 +00:00
Fangrui Song db3a9bcd37 Fix 2-field llvm.global_ctors REQUIRES: asserts tests after rL360742
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360743 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 03:08:21 +00:00
Fangrui Song d7a1a7be42 [IR] Disallow llvm.global_ctors and llvm.global_dtors of the 2-field form in textual format
The 3-field form was introduced by D3499 in 2014 and the legacy 2-field
form was planned to be removed in LLVM 4.0

For the textual format, this patch migrates the existing 2-field form to
use the 3-field form and deletes the compatibility code.
test/Verifier/global-ctors-2.ll checks we have a friendly error message.

For bitcode, lib/IR/AutoUpgrade UpgradeGlobalVariables will upgrade the
2-field form (add i8* null as the third field).

Reviewed By: rnk, dexonsmith

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360742 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15 02:35:32 +00:00
Florian Hahn 7956582324 [LICM] Allow AliasSetMap to contain top-level loops.
When an outer loop gets deleted by a different pass, before LICM visits
it, we cannot clean up its sub-loops in AliasSetMap, because at the
point we receive the deleteAnalysisLoop callback for the outer loop, the loop
object is already invalid and we cannot access its sub-loops any longer.

Reviewers: asbirlea, sanjoy, chandlerc

Reviewed By: asbirlea

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360704 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-14 19:41:36 +00:00
Nikita Popov 18a4e27c7d [LVI][CVP] Add support for abs/nabs select pattern flavor
Based on ConstantRange support added in D61084, we can now handle
abs and nabs select pattern flavors in LVI.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360700 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-14 18:53:47 +00:00
Philip Reames d2a49ce9fc [IndVars] Extend reasoning about loop invariant exits to non-header blocks
Noticed while glancing through the code for other reasons.  The extension is trivial enough, decided to just do it.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360694 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-14 17:20:10 +00:00
Cameron McInally ddde212471 Support FNeg in SpeculativeExecution pass
Differential Revision: https://reviews.llvm.org/D61910

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360692 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-14 16:51:18 +00:00
Philip Reames 705ed45080 [Test] Autogen a test for ease of later changing
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360690 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-14 16:37:29 +00:00
Tim Northover 0f7b4d7811 GlobalOpt: do not promote globals used atomically to constants.
Some atomic loads are implemented as cmpxchg (particularly if large or
floating), and that usually requires write access to the memory involved
or it will segfault.

We can still propagate the constant value to users we understand though.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360662 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-14 11:03:13 +00:00