3765 Commits

Author SHA1 Message Date
liqinweng
1f8746cc80 [RISCV][CostModel] Add half type support for the cost model of sqrt/fabs
1. Refactor for costs of sqrt/fabs
2. Add half type support for the cost model of sqrt/fabs

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D132908
2023-01-09 12:57:03 +08:00
liqinweng
f3408739da [RISCV][CostModel] Add cost model for integer abs
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D132999
2023-01-09 11:38:24 +08:00
Alexey Bataev
9b5f62685a [SLP]Fix cost of the broadcast buildvector/gather.
Need to include the cost of the initial insertelement to the cost of the
broadcasts. Also, need to adjust the cost of the gather/buildvector if
the element is inserted into poison/undef vector.

Differential Revision: https://reviews.llvm.org/D140498
2023-01-06 09:25:05 -08:00
Matt Arsenault
53075f8f4e Verifier: Move test from test/Analysis to test/Verifier
This test was purely checking the verifier error, and had no reason
to be running instcombine.
2023-01-05 10:26:02 -05:00
Yeting Kuo
1e9e1b9cf8 [VP][RISCV] Add vp.ctlz/cttz and RISC-V support.
The patch also adds expandVPCTLZ and expandVPCTTZ to expand vp.ctlz/cttz nodes
and the cost model of vp.ctlz/cttz.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D140370
2023-01-04 15:15:01 +08:00
Florian Hahn
a564048899
[SCEV] Properly clean up duplicated FoldCacheUser ID entries.
The current code did not properly handled duplicated FoldCacheUser ID
entries when overwriting an existing entry in the FoldCache.

This triggered verification failures reported by @uabelho and #59721.

The patch fixes that by removing stale IDs when overwriting an existing
entry in the cache.

Fixes #59721.
2022-12-28 00:09:52 +00:00
Florian Hahn
71ed89041f
[IVUsers] Precommit test for zext SCEV invalidation issue.
Test case for issue reported by @uabelho and #59721
2022-12-27 23:24:21 +00:00
Sameer Sahasrabuddhe
e4377cdde6 [UniformityAnalysis][NFC] Make checks independent of order using CHECK-DAG.
This fixes the buildbot failure on reverse iteration:
https://lab.llvm.org/buildbot/#/builders/54/builds/3034
2022-12-20 11:35:45 +05:30
Sameer Sahasrabuddhe
475ce4c200 RFC: Uniformity Analysis for Irreducible Control Flow
Uniformity analysis is a generalization of divergence analysis to
include irreducible control flow:

  1. The proposed spec presents a notion of "maximal convergence" that
     captures the existing convention of converging threads at the
     headers of natual loops.

  2. Maximal convergence is then extended to irreducible cycles. The
     identity of irreducible cycles is determined by the choices made
     in a depth-first traversal of the control flow graph. Uniformity
     analysis uses criteria that depend only on closed paths and not
     cycles, to determine maximal convergence. This makes it a
     conservative analysis that is independent of the effect of DFS on
     CycleInfo.

  3. The analysis is implemented as a template that can be
     instantiated for both LLVM IR and Machine IR.

Validation:
  - passes existing tests for divergence analysis
  - passes new tests with irreducible control flow
  - passes equivalent tests in MIR and GMIR

Based on concepts originally outlined by
Nicolai Haehnle <nicolai.haehnle@amd.com>

With contributions from Ruiling Song <ruiling.song@amd.com> and
Jay Foad <jay.foad@amd.com>.

Support for GMIR and lit tests for GMIR/MIR added by
Yashwant Singh <yashwant.singh@amd.com>.

Differential Revision: https://reviews.llvm.org/D130746
2022-12-20 07:22:24 +05:30
Nikita Popov
12aef5df0c [LAA] Convert test to opaque pointers (NFC)
When converting this test to opaque pointers (and dropping bitcast),
we get improved memory checks. Per fhahn:

> It looks like the difference is due to the logic that determines
> pointer strides in LAA not handling bitcasts. Without the
> bitcasts, the logic now triggers successfully.

Differential Revision: https://reviews.llvm.org/D140204
2022-12-19 16:58:33 +01:00
Florian Hahn
8a3efcd40b
[ValueTracking] Consider single poison operands in propgatesPoison.
This patch updates propgatesPoison to take a Use as argument and
propagatesPoison now returns true if the passed in operand causes the
user to yield poison if the operand is poison

This allows propagating poison if the condition of a select is poison.
This helps improve results for programUndefinedIfUndefOrPoison.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D111643
2022-12-19 11:47:51 +00:00
Matt Arsenault
bf67186bd2 Function: Respect IgnoreLLVMUsed with addrspacecasted functions
Try to respect IgnoreLLVMUsed if the function was addrspacecasted to
match llvm.used's type.
2022-12-16 14:24:03 -05:00
David Goldblatt
61042d2806 [AA][Intrinsics] Add separate_storage assumptions.
This operand bundle on an assume informs alias analysis that the
arguments point to regions of memory that were allocated separately
(i.e. different heap allocations, different allocas, or different
globals).

As a safety measure, we leave the analysis flag-disabled by default.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D136514
2022-12-16 11:05:00 -08:00
Sjoerd Meijer
5c94faba0b [TTI] [AArch64] getMemoryOpCost for ptr types
Opaque ptr types have a size in bits of 0. The legalised type is an i64 or
vector of i64s, which do have a size. Because of this difference in size, target
hook getMemoryOpCost modelled stores of ptr types as extending/truncating
load/stores. Now we just check for opaque ptr types and return the legalised
cost. This makes stores of pointers cheaper, and as a result we now SLP
vectorise the changed test case.

Differential Revision: https://reviews.llvm.org/D140193
2022-12-16 15:38:17 +00:00
Sjoerd Meijer
e909c3d31f [CostModel][AArch64] Precommit opaque ptr store tests. NFC. 2022-12-16 15:34:12 +00:00
Nikita Popov
e6676a1382 [SCEV] Convert tests to opaque pointers (NFC) 2022-12-16 14:32:36 +01:00
Nikita Popov
8b3323c365 [SCEV] Name instructions in test (NFC) 2022-12-16 14:30:52 +01:00
Nikita Popov
cc19628ed7 [SCEV] Convert some tests to opaque pointers (NFC) 2022-12-16 13:12:27 +01:00
Nikita Popov
05dc149c87 [LAA] Convert tests to opaque pointers (NFC) 2022-12-16 12:45:59 +01:00
Nikita Popov
07e1c9978d [LAA] Name instructions in test (NFC)
And regenerate test checks.
2022-12-16 12:32:58 +01:00
Nikita Popov
47f0b6630c [GlobalAA] Convert tests to opaque pointers (NFC) 2022-12-16 12:21:31 +01:00
Nikita Popov
aff69e1ec2 [LazyCallGraph] Convert tests to opaque pointers (NFC) 2022-12-16 12:20:01 +01:00
Nikita Popov
7fbbbfd638 [ValueTracking] Convert tests to opaque pointers (NFC) 2022-12-16 12:19:03 +01:00
Nikita Popov
6402fc22e1 [TBAA] Convert tests to opaque pointers (NFC) 2022-12-16 12:17:29 +01:00
Nikita Popov
4e49c9da14 [MemDep] Convert tests to opaque pointers (NFC) 2022-12-16 12:11:31 +01:00
Nikita Popov
5a37a774af [MemDep] Run test through instnamer (NFC) 2022-12-16 12:11:01 +01:00
Nikita Popov
ead84636a3 [Lint] Convert tests to opaque pointers (NFC) 2022-12-16 12:08:39 +01:00
Nikita Popov
da839fffe3 [IRSimilarity] Convert tests to opaque pointers (NFC) 2022-12-16 12:07:56 +01:00
Nikita Popov
2564096655 [DependenceAnalysis] Convert tests to opaque pointers (NFC) 2022-12-16 12:06:53 +01:00
Nikita Popov
303c308e45 [BasicAA] Convert tests to opaque pointers (NFC) 2022-12-16 11:57:17 +01:00
Nikita Popov
3caf301a8b [BasicAA] Convert some tests to opaque pointers (NFC) 2022-12-16 10:54:23 +01:00
Nikita Popov
2410b1cb83 [Delinearization] Convert tests to opaque pointers (NFC) 2022-12-16 10:37:10 +01:00
Nikita Popov
92619956eb [SCEV] Convert some tests to opaque pointers (NFC) 2022-12-15 10:00:45 +01:00
Nikita Popov
36ec97a575 [CostModel] Convert some tests to opaque pointers (NFC)
These required some manual fixup.
2022-12-15 09:57:59 +01:00
Nikita Popov
9c1dca3c2f [CostModel] Convert test to opaque pointers (NFC)
Replace GEP index from 0 to 1 so it is not a trivial GEP.
2022-12-15 09:52:29 +01:00
Nikita Popov
68c50b111d [CostModel] Convert some tests to opaque pointers (NFC) 2022-12-15 09:50:34 +01:00
Nikita Popov
ac92430579 [AliasSet] Convert tests to opaque pointers (NFC) 2022-12-15 09:48:12 +01:00
Yeting Kuo
ad68586a37 [VP][RISCV] Add vp.ctpop and RISC-V support.
The patch also adds expandVPCTPOP in TargetLowering to expand VP_CTPOP nodes.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D139920
2022-12-14 09:47:44 +08:00
Roman Lebedev
64d46e141c
[NFC][Costmodel][X86] Replication shuffle: AVX512F can promote i1 to i32.
As the added codegen test coverage shows,
there isn't that much difference between AVX512DQI and
baseline AVX512F codegen, DQI added `vpmovm2d`/`vpmovd2m`,
but with just the Foundation we can use `vpternlogd`/`vptestmd`
to do the same.
2022-12-13 21:21:07 +03:00
Roman Lebedev
ff5fcda430
[x86][Costmodel] AVX512VL: add missing costs for v8 i1<->i32 casts
This would come up as a regression in the follow-up Replication-of-i1 patch.

https://godbolt.org/z/fxr9Mzssr
2022-12-13 21:21:07 +03:00
Roman Lebedev
a64b2e9e3e
[NFC][SCEV][LoopUnroll] Add tests where treating or as add raises expansion cost
From https://reviews.llvm.org/rG46db90cc71d1#1154128
2022-12-12 20:41:56 +03:00
Nikita Popov
243acd5dcb [BasicAA] Remove support for PhiValues analysis
BasicAA currently has an optional dependency on the PhiValues
analysis. However, at least with our current pipeline setup, we
never actually make use of it. It's possible that this used to work
with the legacy pass manager, but I'm not sure of that either.

Given that this analysis has not actually been in use for a long
time, and nobody noticed or complained, I think we should drop
support for it and focus on one code path. It is worth noting that
analysis quality for the non-PhiValues case has significantly
improved in the meantime.

If we really wanted to make use of PhiValues, the right way would
probably be to pass it in via AAQI in places we want to use it,
rather than using an optional pass manager dependency (which are
an unpredictable PITA and should really only ever be used for
analyses that are only preserved and not used).

Differential Revision: https://reviews.llvm.org/D139719
2022-12-12 09:47:30 +01:00
Nikita Popov
8005332835 [AA] Remove CFL AA passes
The CFL Steens/Anders alias analysis passes are not enabled by
default, and to the best of my knowledge have no pathway towards
ever being enabled by default. The last significant interest in
these passes seems to date back to 2016. Given the little
maintenance these have seen in recent times, I also have very
little confidence in the correctness of these passes. I don't
think we should keep these in-tree.

Differential Revision: https://reviews.llvm.org/D139703
2022-12-12 09:34:20 +01:00
Florian Hahn
afe3558a0b
[SCEV] Cache ZExt SCEV expressions.
When creating SCEV expressions for ZExt, there's quite a bit of
reasoning done and in many places the reasoning in turn will try to
create new SCEVs for other ZExts.

This can have a huge compile-time impact. The attached test from #58402
takes an excessive amount of compile time; without the patch, the test
doesn't complete in 1500+ seconds, but with the patch it completes in 1
second.

To speed up this case, cache created ZExt expressions for given (SCEV, Ty) pairs.
Caching just ZExts is relatively straight-forward, but it might make
sense to extend it to other expressions in the future.

This has a slight positive impact on CTMark:
* O3: -0.03%
* ReleaseThinLTO: -0.03%
* ReleaseLTO-g: 0.00%

https://llvm-compile-time-tracker.com/compare.php?from=bf9de7464946c65f488fe86ea61bfdecb8c654c1&to=5ac0108553992fb3d58bc27b1518e8cf06658a32&stat=instructions:u

The patch also improves compile-time for some internal real-world workloads
where time spent in SCEV goes from ~300 seconds to ~3 seconds.

There are a few cases where computing & caching the result earlier may
return more pessimistic results, but the compile-time savings seem to
outweigh that.

Fixes #58402.

Reviewed By: mkazantsev

Differential Revision: https://reviews.llvm.org/D137505
2022-12-09 22:14:04 +00:00
Nikita Popov
cc1e2bb4d4 [BasicAA] Handle phi with itself as incoming value
We can skip such incoming values. This was already done by
PhiValues if present, but we can also do this without the
additional analysis.
2022-12-09 16:17:45 +01:00
Nikita Popov
fe9e442c57 [BasicAA] Add test for phi that contains itself (NFC)
This currently produces a better result with PhiValues.
2022-12-09 16:14:37 +01:00
Nikita Popov
258e551615 [BasicAA] Convert test to opaque pointers (NFC) 2022-12-09 16:05:46 +01:00
Nikita Popov
05ff7606c9 [BasicAA] Convert some tests to opaque pointers (NFC) 2022-12-09 15:49:46 +01:00
liqinweng
6efb45f5ab [AARCH64][CostModel] Modified the cost of mask vector load/store
Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D134413
2022-12-09 14:11:21 +08:00
Roman Lebedev
edeab4db65
[NFC] Port all Analysis/ScalarEvolution tests to -passes= syntax 2022-12-09 01:04:45 +03:00