Commit Graph

3634 Commits

Author SHA1 Message Date
Jolanta Jensen 66e3589cd7 [NFC][CostModel] Added floating point frem test for SVE
Differential Revision: https://reviews.llvm.org/D136241
2022-10-19 19:34:14 +00:00
Florian Hahn 1625224fbb
[SCEV] Replace assert with returning CouldNotComp in computeMaxBECountForLT.
This patch removes the bail out for signed predicates and non-positive
strides in howManyLessThans and updates computeMaxBECountForLT to return
SCEVCouldNotCompute for signed predicates with negative strides.

AFAICT bail-out was only added because computeMaxBECountForLT may not
handle negative signed strides correctly. Instead of not calling
computeMaxBECountForLT at all because we bail out earlier, we can
instead return SCEVCouldNotCompute in computeMaxBECountForLT.

The max backedge taken count will be computed as the max value of the
symbolic backedge taken count.

This improves precision in cases where we can compute symbolic backedge
taken counts and also fixes a crash.

Fixes #57818.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D135667
2022-10-19 11:24:10 +01:00
Nikita Popov e9b8d704d3 [BasicAA] Add test for phi of geps of alloca (NFC)
Make sure we continue determining NoAlias in this case, where we
have a phi of constant index GEPs based on an alloca.
2022-10-17 16:47:35 +02:00
Nikita Popov 436fb27186 [BasicAA] Support loop phis in pointsToConstantMemory()
When looking for underlying objects, if we encounter one that we
have already seen, then we should skip it (as it has already been
checked) rather than bail out. In particular, this adds support
for the case where we have a loop use of a phi recurrence.
2022-10-17 12:34:55 +02:00
Nikita Popov aa89f08afa [BasicAA] Add tests for constant memory with loop phi (NFC) 2022-10-17 12:32:15 +02:00
David Green de6dfbbb30 [ARM] Fix for MVE i128 vector icmp costs.
We were hitting an assert as the legalied type needn't be a vector.

Fixes #58364
2022-10-14 18:49:25 +01:00
Nikita Popov 99dcee6f50 [MemorySSA] Add test for select with cross-iteration dependency (NFC)
This is currently miscompiled.
2022-10-14 11:03:02 +02:00
Nikita Popov 237b962031 [BasicAA] Account for cycles when checking for same select condition
If we have translated across a cycle backedge, the same SSA value
for the condition might be referring to two different loop iterations.
Use the isValueEqualInPotentialCycles() helper to avoid assuming
equality in that case.
2022-10-14 10:37:40 +02:00
Nikita Popov 7c5c77878b [BasicAA] Add test for select with loop carried dependency (NFC) 2022-10-14 10:32:33 +02:00
Nikita Popov 03f9d0ff22 [TBAA] Model call accessing immutable type as readnone
Accesses to constant memory are not observable and should be
reported as readnone, not readonly. This is consistent with what
we do for normal (non-call) instructions: For those, the TBAA
metadata will result in pointsToConstantMemory() returning true,
which will then result in a NoModRef result, not a Ref result.

Differential Revision: https://reviews.llvm.org/D135864
2022-10-14 10:08:37 +02:00
Arthur Eubanks 60e4af7ab8 [CallGraph] Port -print-callgraph-sccs to new pass manager
And remove the legacy opt-specific pass.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D135487
2022-10-11 14:43:16 -07:00
Simon Pilgrim a640aa5bfd [CostModel][X86] Add insertelement costs into a known base vector value
We were only testing inserting into undef/poison base vectors

Test coverage for Issue #58261
2022-10-11 12:07:25 +01:00
Nikita Popov 884bb97dca [MustExec][LICM] Handle latch being part of an inner cycle (PR57780)
The algorithm in allLoopPathsLeadToBlock() does not handle the case
where the loop latch is part of the predecessor set correctly: In
this case, we may take the backedge (escaping to a different loop
iteration) and not execute other latch successors. This can happen
if the latch is part of an inner cycle.

Fixes https://github.com/llvm/llvm-project/issues/57780.

Differential Revision: https://reviews.llvm.org/D134279
2022-10-11 09:30:13 +02:00
Arthur Eubanks f3a928e233 [opt] Don't translate legacy -analysis flag to require<analysis>
Tests relying on this should explicitly use -passes='require<analysis>,foo'.
2022-10-07 14:54:34 -07:00
Arthur Eubanks d3d8465446 [opt] Stop treating alias analysis specially when translating legacy opt syntax
I've attempted to keep AA tests as close to their original intent as possible.
2022-10-07 11:50:43 -07:00
Arthur Eubanks c384b20b55 [opt] Remove temporary legacy pass name translations
And update corresponding tests.
2022-10-07 11:09:46 -07:00
Nikita Popov 9c0314f54e [ValueTracking] Switch isKnownNonZero() to switch over opcodes (NFCI)
The change in the assume-queries-counter.ll test is because we skip
and unnecessary known bits query for arguments.
2022-10-04 10:54:28 +02:00
Craig Topper de0de294eb [RISCV] Update cost of vector roundeven to match round which uses the same sequence but a different FRM value.
Reviewed By: reames, eopXD

Differential Revision: https://reviews.llvm.org/D134978
2022-09-30 20:01:35 -07:00
Arthur Eubanks e23aee7175 [test] Update some legacy PM tests 2022-09-30 11:31:02 -07:00
Philip Reames 02bfe2de7c [RISCV] Adjust vector immediate store materialization cost
This change updates the costs to make constant pool loads match their actual cost, and adds the broadcast special case to avoid too many regressions. We really need more information about the constants being rematerialized, but this is an incremental improvement.

Differential Revision: https://reviews.llvm.org/D134746
2022-09-29 07:37:13 -07:00
eopXD 02a982829c [RISCV] Add lowering for llvm.roundeven
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D134785
2022-09-29 06:08:14 -07:00
Vitaly Buka 01f3e2d619 [StackLifetime] More efficient loop for LivenessType::Must
CFG with cycles may requires additional passes of "while (Changed)"
iteration if to propagate data back from latter blocks to earlier blocks,
ordered according to depth_fist.

OR logic, used for ::May, converge to stable state faster then AND logic
use for ::Must.

Though the better solution is to switch to some some form of queue, but
having that this one is good enough, I will consider to do that later.

We can switch ::Must to OR logic if we calculate "may be dead" instead
of direct "must be alive" and then convert values to match existing
interface.

Additionally it fixes correctness in "@cycle" test.

Reviewed By: kstoimenov, fmayer

Differential Revision: https://reviews.llvm.org/D134796
2022-09-28 16:28:45 -07:00
Florian Hahn eba84971ae
Revert "[AARCH64][CostModel] Modified the cost of mask vector load/store"
This reverts commit 1c62af3e23.

The commit causes the test below to fail. Revert for now to get the bots
back to green.

Failing test:
lvm/test/Transforms/LoopVectorize/AArch64/masked-op-cost.ll
2022-09-28 15:35:13 +01:00
liqinweng 1c62af3e23 [AARCH64][CostModel] Modified the cost of mask vector load/store
Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D134413
2022-09-28 19:40:29 +08:00
Vitaly Buka 8410823835 [test][StackLifetime] Add simple cycle test 2022-09-28 00:11:06 -07:00
Vitaly Buka fee1a4aa59 [test][StackLifetime] Add new test created debugging an issue
The issue is not confirmened, but tests can stay.
2022-09-27 23:13:43 -07:00
Nikita Popov ab3779a667 [MustExecute] Add additional test for PR57780 (NFC) 2022-09-26 15:03:15 +02:00
Simon Pilgrim 196f27bb56 [CostModel][X86] Add missing cost kinds for v2i64 icmp on SLM 2022-09-25 15:12:21 +01:00
Simon Pilgrim faff990e9b [X86] Fix Icelake VPMULLQ zmm pipes and adjust AVX512DQ v8i64 mul costs to match worse case
Icelake PMULLQ throughput regressed cf SkylakeServer as its Pipe0 only

Confirmed with Intel SOM, Agner and instlatx64
2022-09-25 14:18:08 +01:00
Simon Pilgrim a6e9141505 [TTI] Add OperandValueProperties::OP_NegatedPowerOf2 enum (PR51436)
The mul by constant costmodels handle power-of-2 constants, but not negated-power-of-2, despite the backends handling both.

This patch adds the OperandValueProperties::OP_NegatedPowerOf2 enum and wires it for use for basic mul cost analysis and SLP handling.

Fixes #50778

Differential Revision: https://reviews.llvm.org/D111968
2022-09-23 14:03:18 +01:00
Hassnaa Hamdi 181f200a1c [NFC]: AArch64-SVE
modify some comments
2022-09-23 12:07:31 +00:00
Nikita Popov 8e44f13c6d [MemorySSA] Convert tests to use opaque pointers (NFC) 2022-09-23 10:34:09 +02:00
Arthur Eubanks a8f1da128d [LazyCallGraph] Handle spurious ref edges when deleting a dead function
Spurious ref edges are ref edges that still exist in the call graph even
though the corresponding IR reference no longer exists. This can cause
issues when deleting a dead function which has a spurious ref edge
pointed at it because currently we expect the dead function's RefSCC to
be trivial.

In the case that the dead function's RefSCC is not trivial, remove all
ref edges from other nodes in the RefSCC to it.

Removing a ref edge can result in splitting RefSCCs. There's actually no
reason to revisit those RefSCCs because currently we only run passes on
SCCs, and we've already added all SCCs in the RefSCC to the worklist.
(as opposed to removing the ref edge in
updateCGAndAnalysisManagerForPass() which can modify the call graph of
SCCs we have not visited yet). We also don't expect that RefSCC
refinement will allow us to glean any more information for optimization
use. Also, doing so would drastically increase the complexity of
LazyCallGraph::removeDeadFunction(), requiring us to return a list of
invalidated RefSCCs and new RefSCCs to add to the worklist.

Fixes #56503

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D133907
2022-09-22 15:01:15 -07:00
Hassnaa Hamdi f2072e0ae0 [AArh64-SVE]: Improve cost model for div/udiv/mul 128-bit vector operations
Differential Revision: https://reviews.llvm.org/D132477
2022-09-22 16:50:55 +00:00
Simon Pilgrim e56b507447 [CostModel][X86] Add CostKinds test coverage for mul-by-constant patterns
Help check to see the costs predicted for mul->shift conversions
2022-09-22 16:40:57 +01:00
Simon Pilgrim e31482fb73 [CostModel][X86] Add gep.ll CostKind test coverage 2022-09-22 15:07:25 +01:00
Simon Pilgrim 867cd843fe [CostModel][X86] Regenerate gep.ll test checks 2022-09-22 15:07:25 +01:00
luxufan 2e9118f1e4 [MemorySSA] Reset location size if IsGuaranteedLoopInvariant after phi tranlation
We set the Location size to beforeOrAfter if the Location value is not
guaranteed loop invariant. But in some cases, we need to reset the
location size if the location size is precise after phi tranlation of
location value. This will improve MemorySSA analysis results.

Differential Revision: https://reviews.llvm.org/D134161
2022-09-22 05:08:09 +00:00
Simon Pilgrim e030be64d8 [CostModel][X86] Add partial CostKinds handling for funnelshifts/rotates
This mainly just adds costs for the targets where we have actual funnelshift/rotate instructions (VBMI2/XOP etc.) - the cases where we expand still need addressing, although for many the default shift+or expansion, especially for uniform cases, isn't that bad.

This was achieved with the 'cost-tables vs llvm-mca' script D103695
2022-09-22 11:24:11 +01:00
Simon Pilgrim b2cd8118d0 [CostModel][X86] Add CostKinds handling for smax/smin/umax/umin instructions
This was achieved with the 'cost-tables vs llvm-mca' script D103695
2022-09-22 10:19:23 +01:00
Christudasan Devadasan 32a8260ccc -dot-machine-cfg for printing MachineFunction to a dot file
This pass allows a user to dump a MIR function to a dot file
and view it as a graph. It is targeted to provide a similar
functionality as -dot-cfg pass on LLVM-IR. As of now the pass
also support below flags:
-dot-mcfg-only [optional][won't print instructions in the
graph just block name]
-mcfg-dot-filename-prefix [optional][prefix to add to output dot file]
-mcfg-func-name [optional] [specify function name or it's
substring, handy if mir file contains multiple functions and
you need to see graph of just one]

More flags and details can be introduced as per the requirements
in future. This pass is inspired from -dot-cfg IR pass and APIs
are written in almost identical format.

Patch by Yashwant Singh <Yashwant.Singh@amd.com> (yassingh)

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D133709
2022-09-22 12:48:33 +05:30
Simon Pilgrim 839ba13c3e [CostModel][X86] Add vbmi2 costs for funnelshift/rotate intrinsics
Add costs for the funnel shift instructions - fixes some discrepancies I was hitting with costs numbers from the 'cost-tables vs llvm-mca' script D103695
2022-09-21 13:48:22 +01:00
Simon Pilgrim 2a80a8623c [CostModel][X86] Add vbmi2 test coverage for funnelshift/rotate intrinsics
vbmi2 has vector funnel shift support that we should be costing correctly
2022-09-21 13:34:32 +01:00
Simon Pilgrim 46e036b5c2 [CostModel][X86] Remove out of date TODO
ROTR constant and uniform-constant tests were added some time ago by 2fe1076a08
2022-09-21 13:25:38 +01:00
Simon Pilgrim 7241b194de [CostModel][X86] Add CostKinds test coverage for funnelshift/rotate intrinsics 2022-09-21 12:00:20 +01:00
Graham Hunter 3c74ed9ee3 [LAA] Fix ICE with scAddExpr in forked pointers
The IR from https://github.com/llvm/llvm-project/issues/57368 results
in an assert firing when trying to create a runtime check for the
forked pointer. One of the forks is fine since it's loop invariant,
but the other is a scAddExpr (containing a scAddRecExpr, so not
invariant) when RtCheck::insert expects a scAddRecExpr.

This is a simple fix to just avoid forks which aren't AddRec or
loop invariant. We can allow it as a forked pointer later with
more work.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D133020
2022-09-21 10:27:06 +01:00
Nikita Popov 17994ed919 [MemorySSA] Remove PerformedPhiTranslation flag
I believe this is no longer necessary, as the underlying problem
has been fixed in a different way: Nowadays, we will adjust the
location size to beforeOrAfterPointer() if the pointer is not loop
invariant. This makes merging results translated across loop
backedges safe.

The two tests in phi-translation.ll show an improvement while still
being correct: The loads in the loop no longer alias with noalias
pointers, but still alias with the store in the entry block (which
they originally did not -- this is the bug that
PerformedPhiTranslation originally fixed).

Differential Revision: https://reviews.llvm.org/D133404
2022-09-21 10:32:09 +02:00
luxufan 67c482e0b4 [MemorySSA] Add test that all incoming values of phi node could be translated
Differential Revision: https://reviews.llvm.org/D134160
2022-09-20 02:46:43 +00:00
Simon Pilgrim 7e5db16850 [CostModel][X86] Add CostKinds test coverage for min/max intrinsics 2022-09-19 20:50:25 +01:00
Simon Pilgrim 6b4d409f69 [CostModel][X86] Add CostKinds handling for CTLZ_ZERO_UNDEF/CTTZ_ZERO_UNDEF instructions
This was achieved with the 'cost-tables vs llvm-mca' script D103695
2022-09-19 17:37:58 +01:00