528 Commits

Author SHA1 Message Date
Bjorn Pettersson
a20f7efbc5 Remove several no longer needed includes. NFCI
Mostly removing includes of InitializePasses.h and Pass.h in
passes that no longer has support for the legacy PM.
2023-04-17 13:54:19 +02:00
Florian Hahn
668045eb77
[VPlan] Unify Value2VPValue and VPExternalDefs maps (NFCI).
Before this patch, a VPlan contained 2 mappings for Values -> VPValue:
1) Value2VPValue and 2) VPExternalDefs.

This duplication is unnecessary and there are already cases where
external defs are added to Value2VPValue. This patch replaces all uses
of VPExternalDefs with Value2VPValue.

It clarifies the naming of getOrAddVPValue (to getOrAddExternalVPValue)
and addVPValue (to addExternalVPValue).

At the moment, this is NFC, but will enable additional simplifications
in D147783.

Depends on D147891.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D147892
2023-04-16 15:38:31 +01:00
Dmitry Makogon
797da79a92 [LoopUtils] Add isKnownPositiveInLoop and isKnownNonPositiveInLoop functions 2023-04-12 18:46:11 +07:00
Florian Hahn
11896357d4
[VPlan] Add VPInterleaveRecipe::NeedsMaskForGaps field (NFCI).
This patch adds a NeedsMaskForGaps field to VPInterleaveRecipe to record
whether a mask for gaps is needed. This removes a dependence on the cost
model in VPlan code-generation.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D147467
2023-04-07 13:11:03 +01:00
Noah Goldstein
92d854e2b8 Revert "[X86] Simplify some pternlog intrinsics"
This reverts commit cacc0033b12b2e6400eedd6e449644e87ec3099b.
2023-04-03 11:59:32 -05:00
Simon Pilgrim
7d2b447344 Fix MSVC "not all control paths return a value" warning. NFC. 2023-04-03 17:12:37 +01:00
Noah Goldstein
cacc0033b1 [X86] Simplify some pternlog intrinsics
Currently `pternlog` intrinsics stay as a function call and are unable
to merge with other bin-ops / constant-fold.

This commit adds support for reducing all `pternlog` intrinsics to
their base logic-ops so that they can be further reduced in other
passes.

Since the x86 backend doesn't do a great job creating `vpternlog`
instructions from stray logic ops, the current logic only simplifies
in the cases were we obviously will be able to do as good or
better. As the x86 backend improves, more cases can be simplified.

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D145220
2023-04-03 11:05:11 -05:00
Arthur Eubanks
3f23c7f5be [InstSimplify] Actually use NewOps for calls in simplifyInstructionWithOperands
Resolves a TODO.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D146599
2023-03-22 09:22:00 -07:00
Florian Hahn
54558fd8f3
[VPlan] Replace InvariantCond field from VPWidenSelectRecipe.
There is no need to store information about invariance in the recipe.
Replace the fields with checks of the operands using
isDefinedOutsideVectorRegions.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D144489
2023-03-10 15:28:43 +01:00
Florian Hahn
79272ec028
[VPlan] Add predicate to VPReplicateRecipe, expand region later.
This patch adds the predicate as additional operand to VPReplicateRecipe
during initial construction. The predicated recipes are later moved into
replicate regions. This simplifies constructions and some VPlan
transformations, like fixed-order recurrence handling.

It also improves codegen in some cases (e.g. for in-loop reductions),
because the recipes remain in the same block.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D143865
2023-03-08 20:11:28 +01:00
Carl Ritson
8e1038bd15 [ValueMapper] Preserve poison types during value mapping
Poison needs to be treated directly during type remap otherwise
it will be considered an instance of undef.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D145317
2023-03-06 14:21:09 +09:00
Florian Hahn
be968dbeee
[VPlan] VPWidenCallRecipe has side-effects if the call has.
Handle VPWidenCallRecipe in VPRecipeBase::mayHaveSideEffects by
delegating to the underlying call.
2023-03-05 12:08:56 +01:00
Florian Hahn
1df8de238b
[VPlan] Add test with intrinsic without side-effects (NFC).
Extra test coverage for mayHaveSideEffects for VPWidenCallRecipe.
2023-03-03 20:30:30 +01:00
J. Ryan Stinnett
0bbe6040be [DebugInfo] Remove dbg.addr from Transforms
Part of `dbg.addr` removal
Discussed in https://discourse.llvm.org/t/what-is-the-status-of-dbg-addr/62898

Differential Revision: https://reviews.llvm.org/D144797
2023-03-02 09:29:43 +00:00
David Stuttard
c4f7cc8672 [Coroutines] Modify CoroFrame materializable into a callback
This change makes it possible to optionally provide a different callback to
determine if an instruction is materializable.

By default the behaviour is unchanged.

Differential Revision: https://reviews.llvm.org/D142621
2023-02-13 11:02:25 +00:00
Florian Hahn
32efff591a
[VPlan] Mark load VPWidenMemoryInstruction as not having side-effects.
Also add an assert using the underlying instruction to catch any
potential violations.
2023-02-07 22:02:50 +00:00
Archibald Elliott
62c7f035b4 [NFC][TargetParser] Remove llvm/ADT/Triple.h
I also ran `git clang-format` to get the headers in the right order for
the new location, which has changed the order of other headers in two
files.
2023-02-07 12:39:46 +00:00
Florian Hahn
cf2d436b31
[VPlan] VPPredInstPHIRecipe does not read from memory.
VPPredInstPHIRecipe just merges the incoming values and does not write
to memory.
2023-01-31 21:51:03 +00:00
Florian Hahn
5368536cf1
[VPlan] VPPredInstPHIRecipes does not write to memory.
VPPredInstPHIRecipe just merges the incoming values and does not write
to memory.
2023-01-30 10:29:27 +00:00
Florian Hahn
dde3194876
[VPlan] Add sideffect/read or write test for VPPredInstPHIRecipe. (NFC) 2023-01-29 22:46:17 +00:00
Florian Hahn
b6b3d20d06
[VPlan] Use VPDominatorTree in VPlanVerifier .
Use VPDominatorTree to generalize def-use verification.

Depends on D140513.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D140514
2023-01-25 16:32:40 +00:00
Florian Hahn
ca8b0b4af4
[VPlan] Fix leak by manually cleaning up allocated Phi in test.
This should fix a LeakSanitizer failure reported here:
https://lab.llvm.org/buildbot/#/builders/5/builds/30952
2023-01-24 17:20:17 +00:00
Florian Hahn
dc8e2ea929
[VPlan] Add tests for VPlanVerifier (NFC).
Extra test coverage suggested for D140514.
2023-01-24 14:58:22 +00:00
Florian Hahn
bf9e0da1a5
[VPlan] Switch default graph traits to be recursive, update VPDomTree.
This updates the GraphTraits specialization for VPBlockBase to recurse
through VPRegionBlocks.

This in turn enables using VPDominatorTree to query dominance between
any block in a plan. This should enable additional use cases, including
improvements to def-use verification and porting IR-based transforms
that rely on the dominator tree.

Specifically, this change means that for regions, the entry and exit
blocks dominate the successors of the region.

Depends on D140512 and D142162.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D140513
2023-01-23 14:00:43 +00:00
Florian Hahn
0e13ccc69c
[VPlan] Add initial VPDT test. (NFC) 2023-01-20 09:51:07 +00:00
Florian Hahn
e2c43a547b
[VPlan] Add vp_depth_first_deep (NFC)
Similar to vp_depth_first_shallow (D140512) add vp_depth_first_deep to
make existing code clearer and more compact.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D142055
2023-01-19 20:34:23 +00:00
Florian Hahn
feee22db52
[VPlan] Disconnect VPRegionBlock from successors in graph iterator(NFCI)
This updates the VPAllSuccessorsIterator to not connect the
VPRegionBlock itself to its successors. The successors are connected to
the exit block of the region. At the moment, this doesn't change any
exisint functionality.

But the new schema ensures the following property when used for
VPDominatorTree:

1. Entry & exit blocks of regions dominate the successors of the region.

This allows for convenient checking of dominance between defs and uses
that are not defined in the same region. I will share a follow-up patch
to use it for the VPDominatorTree soon.

Depends on D140500.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D140511
2023-01-18 15:02:41 +00:00
Florian Hahn
3632bf8507
[VPlan] Add test for VPAllSuccessorIterator directly. (NFC)
Additional test coverage for D140511.
2023-01-17 12:12:11 +00:00
Johannes Doerfert
d987fe67ad [Attributor] Properly repair broken unittest
Reverts 2dc7c7095153822ecd1a8f43aa4c185f9e80cc00 and instead repairs the
unittest properly. The test was broken as that it used references to
dead functions, assumed dead functions could reach code, assumed code
would not be deleted, and did not pre-query all assertion queries.
Arguably, the querry AAs don't make it easy to use them outside the
attributor pipeline, maybe we just should not (or should fix them
pessimistically). For now, the unittest is fixed.
2023-01-12 02:23:59 -08:00
Johannes Doerfert
2dc7c70951 [Attributor] Temporarily disable unit test to unbreak buildbots
The root cause seems to have expressed in two separate errors and isn't
caught by any IR tests. Will be investigated.
2023-01-12 00:53:21 -08:00
Johannes Doerfert
31ad4dbcb9 Reapply "[Attributor] Introduce AA[Intra/Inter]Reachability"
This reverts commit e425a4c45618fcfa8ffb13be4ddfaa5d28aa38f1 after the
memory leak has been fixed.
2023-01-10 12:29:24 -08:00
OCHyams
042107494d [DebugInfo][NFC] Rename is/setUndef to is/setKilllocation
These names better reflect the semantics and also the implementation, since
it's not just "undef" operands that are sentinels used to signal that the debug
intrinsic terminates dominating locations definitions.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

Reviewed By: StephenTozer

Differential Revision: https://reviews.llvm.org/D140903
2023-01-06 09:15:02 +00:00
Roman Lebedev
5f2acfb635
[ScalarEvolutionExpanderTest] Avoid sign warning 2023-01-05 17:47:17 +03:00
Nikita Popov
1ff253236f [SCEVExpanderTest] Convert to opaque pointers (NFC) 2023-01-05 13:01:24 +01:00
Florian Hahn
cd16a3f04c
[VPlan] Move GraphTraits definitions to separate header (NFC).
This reduces the size of VPlan.h and avoids future growth of the file
when the graph traits are extended in future patches.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D140500
2022-12-31 15:14:57 +00:00
Florian Hahn
5df34e971d
[VPlan] Add support for tracking UFs applicable to VPlan (NFC).
Explicitly track the UFs supported in a VPlan. This is needed to
allow transformations to restrict the UFs which are supported.

Discussed as separate improvement in D135017.
2022-12-22 18:58:25 +00:00
Florian Hahn
bd2b4aeeaf
[VPlan] Add unittest for printing plans with VFs and UFs (NFC). 2022-12-22 18:29:39 +00:00
Archibald Elliott
f09cf34d00 [Support] Move TargetParsers to new component
This is a fairly large changeset, but it can be broken into a few
pieces:
- `llvm/Support/*TargetParser*` are all moved from the LLVM Support
  component into a new LLVM Component called "TargetParser". This
  potentially enables using tablegen to maintain this information, as
  is shown in https://reviews.llvm.org/D137517. This cannot currently
  be done, as llvm-tblgen relies on LLVM's Support component.
- This also moves two files from Support which use and depend on
  information in the TargetParser:
  - `llvm/Support/Host.{h,cpp}` which contains functions for inspecting
    the current Host machine for info about it, primarily to support
    getting the host triple, but also for `-mcpu=native` support in e.g.
    Clang. This is fairly tightly intertwined with the information in
    `X86TargetParser.h`, so keeping them in the same component makes
    sense.
  - `llvm/ADT/Triple.h` and `llvm/Support/Triple.cpp`, which contains
    the target triple parser and representation. This is very intertwined
    with the Arm target parser, because the arm architecture version
    appears in canonical triples on arm platforms.
- I moved the relevant unittests to their own directory.

And so, we end up with a single component that has all the information
about the following, which to me seems like a unified component:
- Triples that LLVM Knows about
- Architecture names and CPUs that LLVM knows about
- CPU detection logic for LLVM

Given this, I have also moved `RISCVISAInfo.h` into this component, as
it seems to me to be part of that same set of functionality.

If you get link errors in your components after this patch, you likely
need to add TargetParser into LLVM_LINK_COMPONENTS in CMake.

Differential Revision: https://reviews.llvm.org/D137838
2022-12-20 11:05:50 +00:00
Mitch Phillips
e425a4c456 Revert "[Attributor] Introduce AA[Intra/Inter]Reachability"
This reverts commit fc21f2d7bae2e0be630470cc7ca9323ed5859892.

This patch broke the ASan buildbot. See
https://reviews.llvm.org/rGfc21f2d7bae2e0be630470cc7ca9323ed5859892 for
more information.
2022-12-16 17:56:48 -08:00
Johannes Doerfert
fc21f2d7ba [Attributor] Introduce AA[Intra/Inter]Reachability
We had two AAs for reachability but it was very cumbersome to extend
them. We also had some fallback to use LLVM-core mechanisms and cache
the result. The new design shares the query code and interface nicely
between AAIntraFnReachability and AAInterFnReachability.

As part of the rewrite we also added the ExclusionSet to the queries.
2022-12-13 19:38:15 -08:00
Florian Hahn
3c5f07349f
[VPlan] Mark VPScalarIVStepsRecipe as not reading/writing memory.
The recipe only computes the inductions steps using its operands. It
does neither read nor write memory.

Split of from D133760.
2022-12-04 12:58:46 +00:00
Florian Hahn
cf28e6b2f1
[VPlan] Add sideeffect/memory unit test for VPScalarIVStepsRecipe. (NFC) 2022-12-04 12:50:09 +00:00
Kazu Hirata
b6a01caa64 [llvm/unittests] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-02 22:10:37 -08:00
Matt Arsenault
f0693277c7 CloneModule: Handling cloning ifuncs
This is tested in a future llvm-reduce patch.
2022-11-23 12:22:06 -05:00
Florian Hahn
b52d328ee8
[VPlan] Remove unnecessary casts from tests after 32f1c5531b.
After 32f1c5531b, getDefiningRecipe returns a VPRecipeBase* so there's
no need to cast to VPRecipeBase.

Suggested by @Ayal during review of D136068, thanks!
2022-11-16 22:17:08 +00:00
Florian Hahn
32f1c5531b
[VPlan] Update VPValue::getDef to return VPRecipeBase, adjust name(NFC)
The return value of getDef is guaranteed to be a VPRecipeBase and all
users can also accept a VPRecipeBase *. Most users actually case to
VPRecipeBase or a specific recipe before using it, so this change
removes a number of redundant casts.

Also rename it to getDefiningRecipe to make the name a bit clearer.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D136068
2022-11-16 22:12:08 +00:00
Craig Topper
ace05124f5 [IntegerDivision][AMDGPU] Use CreateLogicalOr to block poison propagation.
There are two ctlz intrinsics here with the zero_is_poison flag
set. There are also two comparisons that check if either of the
inputs the ctlzs are zero. We need to use a logical or to block
the poison from the ctlz if either of the inputs is zero.

Reviewed By: arsenm, aqjune

Differential Revision: https://reviews.llvm.org/D130680
2022-09-15 09:38:02 -07:00
Arthur Eubanks
7e3aa8f01a Revert "[LoopPassManager] Implement and use LoopNestAnalysis::run() instead of manually creating LoopNests"
This reverts commit 57fd8665516161c3d2dbe3f0ad8461552967692a.

Causes crashes, see comments in D132581.
2022-09-05 15:42:48 -07:00
Arthur Eubanks
57fd866551 [LoopPassManager] Implement and use LoopNestAnalysis::run() instead of manually creating LoopNests
The current code is basically just emulating what the analysis manager does.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D132581
2022-09-02 10:55:53 -07:00
Florian Hahn
fc444ddc77
[VPlan] Add field to track if intrinsic should be used for call. (NFC)
This patch moves the cost-based decision whether to use an intrinsic or
library call to the point where the recipe is created. This untangles
code-gen from the cost model and also avoids doing some extra work as
the information is already computed at construction.

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D132585
2022-09-01 13:14:40 +01:00