274428 Commits

Author SHA1 Message Date
yonghong-song
7852ebc088
[BPF] Make -mcpu=v3 as the default (#107008)
Before llvm20, (void)__sync_fetch_and_add(...) always generates locked
xadd insns. In linux kernel upstream discussion [1], it is found that
for arm64 architecture, the original semantics of
(void)__sync_fetch_and_add(...), i.e., __atomic_fetch_add(...), is
preferred in order for jit to emit proper native barrier insns.

In llvm commits [2] and [3], (void)__sync_fetch_and_add(...) will
generate the following insns:
  - for cpu v1/v2: locked xadd insns to keep backward compatibility
  - for cpu v3/v4: __atomic_fetch_add() insns

To ensure proper barrier semantics for (void)__sync_fetch_and_add(...),
cpu v3/v4 is recommended.

This patch enables cpu=v3 as the default cpu version. For users wanting
to use cpu v1, -mcpu=v1 needs to be explicitly added to clang/llc
command line.

  [1]
https://lore.kernel.org/bpf/ZqqiQQWRnz7H93Hc@google.com/T/#mb68d67bc8f39e35a0c3db52468b9de59b79f021f
  [2] https://github.com/llvm/llvm-project/pull/101428
  [3] https://github.com/llvm/llvm-project/pull/106494
2024-09-03 07:15:18 -07:00
Han-Kuan Chen
d7c44eff42 [SLP][REVEC] Update test. NFC. 2024-09-03 06:58:15 -07:00
Jie Fu
20fa37bbfa [Vectorize] Fix -Wunused-variable in SLPVectorizer.cpp (NFC)
/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:10310:26:
error: unused variable 'isExtractSubvectorMask' [-Werror,-Wunused-variable]
                    bool isExtractSubvectorMask =
                         ^
1 error generated.
2024-09-03 21:46:42 +08:00
Han-Kuan Chen
ce8ec31298
[SLP][REVEC] Support more mask pattern usage in shufflevector. (#106212) 2024-09-03 21:30:40 +08:00
Alexey Bataev
b74e09cb20 [SLP]Check for the whole vector vectorization in unique scalars analysis
Need to check that thr whole number of register is attempted to
vectorize before actually trying to build the node to avoid compiler
crash.
2024-09-03 06:19:21 -07:00
Florian Hahn
dd94537b40
[LV] Update call widening decision when scalarzing calls.
collectInstsToScalarize may decide to scalarize a call. If so, we have
to update the widening decision for the call, otherwise the call won't
be scalarized as expected during VPlan construction.

This issue was uncovered by f82543d509.
2024-09-03 14:12:41 +01:00
Nikita Popov
0797c184c6 [SCCP] Explicitly mark gep as overdefined if ct eval fails
Don't just leave the result as unknown. I think this currently
works out thanks to undef resolution, but the correct thing to
do is set it to overdefined explicitly.
2024-09-03 14:39:31 +02:00
Alexey Bataev
f381cd0699 [SLP]Fix PR107036: Check if the type of the user is sizable before requesting its size.
Only some instructions should be considered as potentially reducing the
size of the operands types, not all instructions should be considered.

Fixes https://github.com/llvm/llvm-project/issues/107036
2024-09-03 05:29:59 -07:00
Nikita Popov
c80cabfcbe [SCCP] Avoid use of undef value in test (NFC)
Avoid optimization away most of the code if we resolve this to
a specific value.
2024-09-03 14:25:07 +02:00
Jay Foad
f77f60400f [CodeGen] Remove checks that implicit operands are implicit 2024-09-03 13:09:17 +01:00
Him188
0748f4227c
[AArch64][GlobalISel] Legalize 128-bit types for FABS (#104753)
This patch adds a common lower action for `G_FABS`, which generates `and
x8, x8, #0x7fffffffffffffff` to reset the sign bit. The action does not
support vectors since `G_AND` does not support fp128.


This approach is different than what SDAG is doing. SDAG stores the
value onto stack, clears the sign bit in the most significant byte, and
loads the value back into register. This involves multiple memory ops
and sounds slower.
2024-09-03 12:47:26 +01:00
Nathan Gauër
8861328303
Revert "[Utils][SPIR-V] Adding spirv-sim to LLVM" (#107084)
Reverts llvm/llvm-project#104020

Looks like it caused build failures.
2024-09-03 13:05:25 +02:00
Nikita Popov
52b879594f [LoopUnroll] Avoid undef values in test (NFC)
Avoid most of the code being optimized away as a result of
optimization improvements.
2024-09-03 12:10:29 +02:00
Aditi Medhane
d24a2fd38e
[AMDGPU] Create dir for amdgpu specific machineverifier tests (#106960)
Move the AMDGPU target specific testcases in MachineVerifier separately
into new directory.
Reference :
https://github.com/llvm/llvm-project/pull/105494#discussion_r1735055750
2024-09-03 15:19:04 +05:30
Nathan Gauër
c3d8124617
[Utils][SPIR-V] Adding spirv-sim to LLVM (#104020)
Currently, the testing infrastructure for SPIR-V is based on FileCheck.
Those tests are great to check some level of codegen, but when the test
needs check both the CFG layout and the content of each basic-block,
things becomes messy.

- Because the CHECK/CHECK-DAG/CHECK-NEXT state is limited, it is
sometimes hard to catch the good block: if 2 basic blocks have similar
instructions, FileCheck can match the wrong one.

- Cross-lane interaction can be a bit difficult to understand, and
writting a FileCheck test that is strong enough to catch bad CFG
transforms while not being broken everytime some unrelated codegen part
changes is hard.

And lastly, the spirv-val tooling we have checks that the generated
SPIR-V respects the spec, not that it is correct in regards to the
source IR.

For those reasons, I believe the best way to test the structurizer is
to:
 - run spirv-val to make sure the CFG respects the spec.
- simulate the function to validate result for each lane, making sure
the generated code is correct.

This simulator has no other dependencies than core python. It also only
supports a very limited set of instructions as we can test most features
through control-flow and some basic cross-lane interactions.

As-is, the added tests are just a harness for the simulator itself. If
this gets merged, the structurizer PR will benefit from this as I'll be
able to add extensive testing using this.

---------

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-09-03 11:46:30 +02:00
Nikita Popov
fe1a1eee2f [Tests] Regenerate test checks (NFC) 2024-09-03 11:42:47 +02:00
Simon Pilgrim
377045ece6 [X86] canCreateUndefOrPoisonForTargetNode - X86ISD::CMPP (CMPPS/D) nodes do not generate poison 2024-09-03 10:33:04 +01:00
Simon Pilgrim
851bacb7ce [IR] DebugProgramInstruction.cpp - fix GCC Wparentheses warning. NFC. 2024-09-03 10:18:34 +01:00
Simon Pilgrim
6c59dfb018 [X86] Add test showing failure to remove freeze from all_of pattern 2024-09-03 10:15:51 +01:00
Simon Pilgrim
6c8746b6e3
[Analysis] getIntrinsicForCallSite - add vectorization support for acos/asin/atan and cosh/sinh/tanh libcalls (#106844)
Followup to #106584 - ensure acos/asin/atan and cosh/sinh/tanh libcalls correctly map to the llvm intrinsic equivalents
2024-09-03 10:05:56 +01:00
Brandon Wu
7e6bad112c
[RISCV] Rename vcix_state register to sf_vcix_state. NFC (#106995)
Since it's SiFive VCIX specific register, it's better to have a prefix
so that it's more understandable.
2024-09-03 15:55:39 +08:00
Michael Marjieh
00c198b2ca
[MachinePipeliner] Make Recurrence MII More Accurate (#105475)
Current RecMII calculation is bigger than it needs to be. The
calculation was refined in this patch.
2024-09-03 16:15:17 +09:00
Akshat Oke
8e5b43c8ef
[AMDGPU][NewPM] Have consistent property changes in GCNDPPCombine (#106520) 2024-09-03 11:02:51 +05:30
Christudasan Devadasan
042104985c
[AMDGPU][NewPM] Port SIShrinkInstructions to new pass manager. (#106967) 2024-09-03 10:52:50 +05:30
Craig Topper
9a1eded9b9
[RISCV] Custom legalize f16/bf16 FCOPYSIGN with Zfhmin/Zbfmin. (#107039)
The LegalizeDAG expansion will go through memory since i16 isn't a legal
type. Avoid this by using FMV nodes.

Similar to what we did for #106886 for FNEG and FABS. Special care is
needed to handle the Sign operand being a different type.
2024-09-02 22:04:09 -07:00
Craig Topper
dc19b59ea2 [RISCV] Rename test cases in bfloat-arith.ll and half-arith.ll. NFC
Use _bf16 or _h instead of _s. The _s was copied from float-arith.ll
2024-09-02 19:00:38 -07:00
Kazu Hirata
9a1d14a8d2
[LTO] Don't make unnecessary copies of ImportIDTable (#106998)
Without this patch, {ImportMapTy,SortedImportList}::{begin,end} make
unnecessary copies of ImportIDTable via:

  map_iterator(Imports.begin(), IDs);

The second parameter, IDs, is passed by value, so we make a copy of
MapVector inside ImportIDTable every time we call begin and end.
These begin and end show up as time-consuming functions in the
performance profile.

This patch fixes the problem by passing IDs by reference with
std::cref.

While we are at it, this patch deletes the copy constructor and
assignment operator.  I cannot think of any legitimate need reason to
make a copy of the deduplication table.
2024-09-02 18:40:47 -07:00
Craig Topper
ba3c1edcc8
[RISCV] Correct the scheduler class for FCVT_S_BF16. (#107028)
Use FCvtF16ToF32 instead of FCvtF32ToF16.
2024-09-02 18:36:01 -07:00
Nico Weber
b6597f521d [gn] port 1e65b765879fb39
Apparently DragonFly BSD and Solaris/illumos call these APIs
`pthread_get_name_np` / `pthread_set_name_np` (with an extra
underscore) instead of `pthread_getname_np` / `pthread_setname_np`.
2024-09-02 20:00:27 -04:00
Craig Topper
366ac8c090
[LegalizeVectorOps] Defer UnrollVectorOp in ExpandFNEG to caller. (#106783)
Make ExpandFNEG return SDValue() when it doesn't expand. The caller
already knows how to Unroll when Results is empty.
2024-09-02 16:16:12 -07:00
Jesse D
0ba006daf5
[MIPS] Fix error messages when rejecting certain assembly not supported by ISA (#94695)
… instructions.

This is a fix I stumbled upon while working on something else. I decided
to break it out since it seems like a good "first issue" to submit. I
updated the comments in the "wrong error" test files to indicate that
the messages are no longer incorrect, but I left the names of the test
files alone. I was not sure what to do with those, so I would appreciate
thoughts or guidance.
2024-09-03 06:08:51 +08:00
Florian Hahn
954ed05c10
[VPlan] Simplify MUL operands at recipe construction.
This moves the logic to create simplified operands using SCEV to MUL
recipe creation. This is needed to match the behavior of the legacy's cost
model. TODOs are to extend to other opcodes and move to a transform.

Note that this also restricts the number of SCEV simplifications we
apply to more precisely match the cases handled by the legacy cost
model.

Fixes https://github.com/llvm/llvm-project/issues/107015.
2024-09-02 21:25:31 +01:00
Florian Hahn
50a02e7c68
[VPlan] Pass intrinsic inst to TTI in VPWidenCallRecipe::computeCost.
Follow-up to 9ccf825, adjust computeCost to also pass IntrinsicInst to
TTI if available, as there are multiple places in TTI which use the
IntrinsicInst.

Fixes https://github.com/llvm/llvm-project/issues/107016.
2024-09-02 20:47:37 +01:00
Alexandros Lamprineas
a586b5a49d
Reland [AArch64][AsmParser] Directives should clear transitively implied features (#106625) (#106850)
Relands 24977395592f addressing the buffer overflow caused when
dereferencing an iterator past the end of ExtensionMap.
2024-09-02 20:23:07 +01:00
Craig Topper
55eb93b268
[RISCV] Remove RISCVISD::FP_EXTEND_BF16. (#106939)
I don't think we need this node. We can isel fp_extend directly.
fp_extend to f64 requires two instructions, but we can emit them with an
isel pattern.

I have not removed RISCVISD::FP_ROUND_BF16 because f64->bf16 needs more
work to fix the double rounding.
2024-09-02 10:14:04 -07:00
Shilei Tian
cb949b74e8 [NFC][FIX] Work around update_test_checks bug 2024-09-02 12:33:24 -04:00
Shilei Tian
f32f0289fd [NFC] Update check lines of the test case llvm/test/CodeGen/AMDGPU/remove-no-kernel-id-attribute.ll 2024-09-02 12:23:26 -04:00
Orlando Cazalet-Hyams
b6a4ab5a12
[NFC] Fix #106873 - update assignment tracking docs (#106959) 2024-09-02 14:57:59 +01:00
Rahul Joshi
e5c7cde5c8
[NFC][TableGen] Refactor getIntrinsicFnAttributeSet (#106587)
Fix intrinsic function attributes to not generate attribute sets that
are empty in `getIntrinsicFnAttributeSet`. Refactor the code to use
helper functions to get effective memory effects for an intrinsic and to
check if it has non-default attributes.

This eliminates one case statement in `getIntrinsicFnAttributeSet` that
we generate today for the case when intrinsic attributes are default
ones.

Also rename `Intrinsic` to `Int` to follow the naming convention used in
this file and adjust emission code to not emit unnecessary empty line
between cases generated.
2024-09-02 06:28:43 -07:00
Rahul Joshi
ad30a050ca
[NFC][Support] Add FormatVariadic sub-test for validation (#106578)
- Add validation subtest that tests assert failures in assert enabled
  builds, and that validation is disabled in assert disabled builds.
2024-09-02 06:27:12 -07:00
Sam Tebbs
44cfbef1b3
[AArch64] Lower partial add reduction to udot or svdot (#101010)
This patch introduces lowering of the partial add reduction intrinsic to
a udot or svdot for AArch64. This also involves adding a
`shouldExpandPartialReductionIntrinsic` target hook, which AArch64 will
return false from in the cases that it can be lowered.
2024-09-02 14:06:14 +01:00
David Sherwood
df3d70b5a7
[Analysis] Add getPredicatedExitCount to ScalarEvolution (#105649)
Due to a reviewer request on PR #88385 I have created this patch
to add a getPredicatedExitCount function, which is similar to
getExitCount except that it uses the predicated backedge taken
information. With PR #88385 we will start to care about more
loops with multiple exits, and want the ability to query exit
counts for a particular exiting block. Such loops may require
predicates in order to be vectorised.

New tests added here:

Analysis/ScalarEvolution/predicated-exit-count.ll
2024-09-02 14:05:26 +01:00
Hans
ef26afcb88
Win release packaging: Don't try to use rpmalloc for 32-bit x86 (#106969)
because that doesn't work (results in `LINK : error LNK2001: unresolved
external symbol malloc`).
Based on the title of #91862 it was only intended for use in 64-bit
builds.
2024-09-02 15:04:13 +02:00
Florian Hahn
b0de7fa466
[VPlan] Use op from underlying call in computeCost if needed.
This fixes a divergence between legacy and VPlan-based cost model, e.g.
if one of the operands has an first-order recurrence phi as operand.
2024-09-02 14:00:10 +01:00
Nikita Popov
0c0bac94c0 [InstCombine] Add additional tests for arm intrinsic alignment (NFC) 2024-09-02 14:43:49 +02:00
David Sherwood
dc6c3ba4c4
[NFC][IR] Add CreateCountTrailingZeroElems helper (#106711)
The LoopIdiomVectorize pass already creates calls to the intrinsic
experimental_cttz_elts, but PR #88385 will start calling this more
too so I've created a helper for it.
2024-09-02 13:40:14 +01:00
Nikita Popov
224112f833 [ARM] Regenerate test checks (NFC) 2024-09-02 14:15:03 +02:00
Alastair Houghton
bdfd780490
[RuntimeDyld][Windows] Allocate space for dllimport things. (#106958)
We weren't taking account of the space we require in the stubs for
things that are dllimported, and as a result we could hit the assertion
failure for running out of stub space. Fix that.

Also add a couple of `override` specifiers that were missing last time
(#102586).

rdar://133473673
2024-09-02 12:34:12 +01:00
Simon Pilgrim
f19dff1b80 [X86] scmp/ucmp - add SSE42/AVX2/AVX512 test coverage to show current state of vector legalization/lowering 2024-09-02 12:17:21 +01:00
Jeremy Morse
25f87f2d70
[DebugInfo][RemoveDIs] Find types hidden in DbgRecords (#106547)
When serialising to textual IR, there can be constant Values referred to
by DbgRecords that don't appear anywhere else, and have types hidden
even deeper in side them. Enumerate these when enumerating all types.

Test by Mikael Holmén.
2024-09-02 11:56:40 +01:00