53289 Commits

Author SHA1 Message Date
Luke Lau
ff313ee70a
[RISCV] Remove hasSideEffects=1 for vsetvli pseudos (#91319)
In a similar vein to #90049, we currently model all of the effects of a
vsetvli pseudo:

* VL and VTYPE are marked as defs
* VL preserving x0,x0 vsetvlis doesn't get emitted until
RISCVInsertVSETVLI, and when they are they have implicit uses on VL
* Regular vector pseudos are fully modelled too: Before
RISCVInsertVSETVLI they can be moved between vsetvli pseudos because we
will eventually insert vsetvlis to correct VL and VTYPE. Afterwards,
they will have implicit uses on VL and VTYPE.

Since we model everything we can remove hasSideEffects=1. This gives us
some improvements like sinking in vsetvli-insert-crossbb.ll.

We need to update RISCVDeadRegisterDefinitions to keep handling vsetvli
pseudos since it only operates on instructions with unmodelled side
effects.
2024-05-15 23:37:31 +08:00
Phoebe Wang
b576a6b045
[X86][AMX] Fix a bug after #83628 (#91207)
We need to check if `GR64Cand` a valid register before using it.

Test is not needed since it's covered in llvm-test-suite.

Fixes #90954
2024-05-15 23:15:48 +08:00
Jay Foad
466d266945
[AMDGPU] Fix GFX90x check prefixes in tests (#92254) 2024-05-15 15:13:53 +01:00
Simon Pilgrim
f8395f8420 [X86] Cleanup check prefixes identified in #92248
Avoid using leading numbers in check prefixes - replace with actual triple config names.
2024-05-15 14:25:29 +01:00
Simon Pilgrim
3f07430c38 [X86] avoid-sfb-g-no-change.mir - cleanup check prefixes identified in #92248
Don't include "-LABEL" (or any other FileCheck modifier) in the core check prefix name
2024-05-15 14:23:46 +01:00
Simon Pilgrim
e26eacf771 [X86] prefetch.ll - cleanup check prefixes identified in #92248
Avoid using leading numbers in check prefixes - replace with actual triple config names (and makes it easier to add X64 test coverage in a future commit).
2024-05-15 14:11:24 +01:00
Simon Pilgrim
96ac2e3af7 [X86] cmpxchg-clobber-flags.ll - cleanup check prefixes identified in #92248
Avoid using numbers as check prefix - replace with actual triple config names
2024-05-15 14:11:24 +01:00
Simon Pilgrim
97418bb519 [X86] patchable functions - cleanup check prefixes identified in #92248
Avoid using numbers as check prefix - replace with actual triple config names
2024-05-15 14:11:23 +01:00
Simon Pilgrim
8987369465 [X86] sibcall - cleanup check prefixes identified in #92248
Avoid using numbers as check prefix - replace with actual triple config names
2024-05-15 13:49:39 +01:00
Jay Foad
1650f1b3d7
Fix typo "indicies" (#92232) 2024-05-15 13:10:16 +01:00
Paul Walker
7621a0d364
[LLVM][CodeGen][SVE] Improve custom lowering for EXTRACT_SUBVECTOR. (#90963)
We can extract any legal fixed length vector from a scalable vector by
using VECTOR_SPLICE.
2024-05-15 11:27:06 +01:00
Jonas Paulsson
d6ee7e8481
[SystemZ] Handle address clobbering in splitMove(). (#92105)
When expanding an L128 (which is used to reload i128) it is
possible that the quadword destination register clobbers an
address register. This patch adds an assertion against the case
where both of the expanded parts clobber the address, and in the
case where one of the expanded parts do so puts it last.

Fixes #91437
2024-05-15 08:36:26 +02:00
Luke Lau
77047e3cd2
[RISCV] Make vsetvli in test not loop invariant. NFC (#92094)
The middle end will remove the inner vsetvli otherwise, and it's more
typical to set the AVL to the remaining VL.

This also prevents the test from showing up as a regression in #91319
2024-05-15 12:32:26 +08:00
Luke Lau
1a58e88690
[RISCV] Move RISCVInsertVSETVLI to after phi elimination (#91440)
Split off from #70549, this patch moves RISCVInsertVSETVLI to after phi
elimination where we exit SSA and need to move to LiveVariables.

The motivation for splitting this off is to avoid the large scheduling
diffs from moving completely to after regalloc, and instead focus on
converting the pass to work on LiveIntervals.

The two main changes required are updating VSETVLIInfo to store VNInfos
instead of MachineInstrs, which allows us to still check for PHI defs in
needVSETVLIPHI, and fixing up the live intervals of any AVL operands
after inserting new instructions.

On O3 the pass is inserted after the register coalescer, otherwise we
end up with a bunch of COPYs around eliminated PHIs that trip up
needVSETVLIPHI.

Co-authored-by: Piyou Chen <piyou.chen@sifive.com>
2024-05-15 11:44:32 +08:00
Craig Topper
e417e61532 [RISCV][LegalizeTypes] Add additional test coverage for type promotion of VP_FSHL/FSHR. NFC
There's a special path when the promoted type has an element size
more than twice the size of the original type.
2024-05-14 16:25:07 -07:00
Amara Emerson
d4c86e7f3e
[AArch64][SME] Fix frame lowering not using a base pointer for SME functions. (#91643)
The existing code is checking for the presence of the +sve subtarget
feature
when deciding to use a base pointer for the function, but this check
doesn't
work when only +sme is used.

rdar://126878490
2024-05-14 13:00:19 -07:00
PiJoules
19008d3218
[llvm] Support fixed point multiplication on AArch64 (#84237)
Prior to this, fixed point multiplication would lead to this assertion
error on AArhc64, armv8, and armv7.

```
 _Accum f(_Accum x, _Accum y) { return x * y; }

// ./bin/clang++ -ffixed-point /tmp/test2.cc -c -S -o - -target aarch64 -O3
clang++: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:10245: void llvm::TargetLowering::forceExpandWideMUL(SelectionDAG &, const SDLoc &, bool, EVT, const SDValue, const SDValue, const SDValue, const SDValue, SDValue &, SDValue &) const: Assertion `Ret.getOpcode() == ISD::MERGE_VALUES && "Ret value is a collection of constituent nodes holding result."' failed.
```

This path into forceExpandWideMUL should only be taken if we don't
support [US]MUL_LOHI or MULH[US] for the operand size (32 in this case).
But we should also check if we can just leverage regular wide
multiplication. That is, extend the operands from 32 to 64, do a regular
64-bit mul, then trunc and shift. These ops are certainly available on
aarch64 but for wider types.
2024-05-14 11:23:45 -07:00
Alex Bradbury
90109d4448
[RISCV] Improve constant materialisation for stores of i8 negative constants (#92131)
This follows the same pattern as 20e62658735a1b03ecadc. Although we
can't reduce the number of instructions used, if we are able to use a
sign-extended 6-bit immediate then the 16-bit c.li instruction can be
selected (thus saving code size). Although this _could_ be gated so it
only happens if C is enabled, I've opted not to because at worst it's
neutral and it doesn't seem helpful to add unnecessary divergence
between the RVC and non-RVC paths.
2024-05-14 19:08:04 +01:00
Alex Bradbury
de14b749fe [RISCV][test] Precommit tests for byte store of -1
Although we can't reduce the number of instructions, if we selected `li
rd, -1` instead then this could be encoded in a 16-bit instruction.
2024-05-14 19:03:46 +01:00
Simon Pilgrim
b2c5e9b9bf [ARM] iabs.ll - regenerate test checks 2024-05-14 16:36:39 +01:00
Sander de Smalen
3d6f18db7b
[AArch64] Remove redundant FDIV Combine. (#91924)
The target combine is no longer required because InstCombine will
transform the DIV by a power of 2 into a multiply, so in practice
this case will never trigger.

Additionally, the generated code would have been incorrect for
streaming(-compatible) functions, because it assumed NEON was available.
2024-05-14 16:28:28 +01:00
WANG Rui
82434c70b7 [LoongArch] Add test cases for div/mod to cover various extended combinations of 32-bit integers. NFC 2024-05-14 23:18:56 +08:00
Craig Topper
736ffdc383
[RISCV] Add X27 to SavedRegs when X26 is in SavedRegs for cm.push/pop (#92067)
cm.push can't save X26 without also saving X27. This removes two other
checks for this case.

This causes CFI to be emitted since X27 is now explicitly a callee saved
register.

The affected tests use inline assembly to clobber X26 rather than the
whole range of s0-s10.
2024-05-14 08:06:10 -07:00
Jake Egan
d9db266499
[PowerPC][test] Catch any exception when retrieving git revision (#92004)
This makes the `vc-rev-enabled` feature unsupported if we fail to
retrieve the git revision for any reason, such as if git is not
installed.
2024-05-14 10:32:30 -04:00
Graham Hunter
2b15c4a62b
[AArch64] Postcommit fixes for histogram intrinsic (#92095)
A buildbot with expensive checks enabled flagged some problems with my patch. There was also a post-commit nit on the langref changes.
2024-05-14 15:16:42 +01:00
Thorsten Schütt
d422e90fcb
[GlobalIsel][AArch64] fix out of range access in regbankselect (#92072)
Fixes https://github.com/llvm/llvm-project/issues/92062
2024-05-14 15:54:05 +02:00
wanglei
9d4f7f44b6 [test][LoongArch] Add -mattr=+d option. NFC
Because most of tests assume target-abi=`lp64d`, adding the
corresponding feature is reasonable.

rg -l loongarch -g '!*.s' | xargs sed -i '/mtriple=loongarch/ {/-mattr=/!{/target-abi/! s/mtriple=loongarch.. /&-mattr=+d /}}'
2024-05-14 20:23:04 +08:00
Simon Pilgrim
31fb0ae23d [PowerPC] Regenerate and_sext.ll with test checks
I've kept the grep checks for extsh/extsb instructions, but we can now see the actual codegen as well
2024-05-14 11:58:48 +01:00
Yingwei Zheng
3aae916ff7
Reland "[ValueTracking] Compute knownbits from known fp classes" (#92084)
This patch relands https://github.com/llvm/llvm-project/pull/86409.

I mistakenly thought that `Known.makeNegative()` clears the sign bit of
`Known.Zero`. This patch fixes the assertion failure by explicitly
clearing the sign bit.
2024-05-14 18:10:28 +08:00
Simon Pilgrim
9f80f437c0 [Hexagon] Regenerate asr-rnd.ll + asr-rnd64.ll to show all test checks
These are affected by upcoming support for AVG legalization
2024-05-14 10:49:35 +01:00
Vyacheslav Levytskyy
be9b4dab40
[SPIR-V] Introduce support for 'spirv.Decorations' metadata node in SPIR-V Backend (#91736)
This PR is to introduce support for 'spirv.Decorations' metadata node in
SPIR-V Backend.
See also
https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/main/docs/SPIRVRepresentationInLLVM.rst
that describes `spirv.Decorations` as an important part of
SPIRV-friendly LLVM IR.
2024-05-14 11:35:11 +02:00
chuongg3
0bc23f1032
[AArch64][GlobalISel] Select G_ICMP Zero Instruction (#90054) 2024-05-14 10:04:21 +01:00
Hari Limaye
d9be51ce68
[AArch64] Improve code generation for experimental.cttz.elts (#91505)
This patch extends support for lowering the experimental.cttz.elts
intrinsic to BRKB + CNTP instruction sequences, using this lowering for
all legal predicate types. An unused parameter is also removed from some
of the related regression tests.
2024-05-14 09:49:53 +01:00
Martin Storsjö
2e165a2c4b Revert "[ValueTracking] Compute knownbits from known fp classes (#86409)"
This reverts commit d03a1a6e5838c7c2c0836d71507dfdf7840ade49.

This change caused failed assertions, see
https://github.com/llvm/llvm-project/pull/86409#issuecomment-2109469845
for details.
2024-05-14 10:37:23 +03:00
Vyacheslav Levytskyy
cf9a5a162b
[SPIR-V] Support saturation arithmetic intrinsics in SPIR-V Backend (#91722)
This PR is to support saturation arithmetic intrinsics in SPIR-V
Backend.
2024-05-14 09:22:37 +02:00
Vyacheslav Levytskyy
3ae63430aa
[SPIR-V] Set non-kernel function linkage type via OpDecorate for all linkage types except for static functions (#91598)
This PR fixes the issue
https://github.com/llvm/llvm-project/issues/91595 by setting non-kernel
function linkage type via OpDecorate for all linkage types except for
static functions. A new test case is added.
2024-05-14 09:22:24 +02:00
Yeting Kuo
d488a54b40
[RISCV] Use software guarded branch for indirect jump table branch. (#66762)
When Zicfilp enabled, indirect jump table branch should be a software
guarded branch.
2024-05-14 14:44:25 +08:00
Phoebe Wang
881d45cd7d
[X86][BF16] Do not combine FP_TRUNC + FP_EXTEND if they come from user (#91420)
As discussed in
3cf8535dbf
We are not allowed to combine explicit fptrunc/fpext from user.
2024-05-14 10:18:10 +08:00
Xiang Li
531a0b67ea
[DirectX] Reapply Fix DXIL part header version encoding (#91956)
This reapplies
195d8ac26d
[DirectX] Fix DXIL part header version encoding. The endian issue was
fixed by
f42117c851.

Move MinorVersion be the lower 8 bit.
Set DXIL version in DXContainerObjectWriter::writeObject.

Fixes #89952
2024-05-13 18:50:16 -04:00
Stanislav Mekhanoshin
efc7bbb917
[AMDGPU] Make v2bf16 BUILD_VECTOR legal (#92022)
There is nothing specific here and it is not different from i16 or f16.
2024-05-13 14:53:26 -07:00
Fangrui Song
ef9090fcb5 [test] Fix check prefixes 2024-05-13 14:01:00 -07:00
David Green
34de2151e2
[AArch64][GlobalISel] Improve legalization of G_PTR_ADD (#91763)
The testing we have for vector ptradd was a bit lacking. In adding tests
this patch found a couple of issues mostly with the way v3 vectors of
ptrs were sometimes legalized via i64, and with non-i64 additions. It
does not attempt to fix the issue with mergevalues from returning vector
ptrs.
2024-05-13 21:58:41 +01:00
Craig Topper
55e59083cb [RISCV] Exclude vector callee saved registers from RISCVRegisterInfo::needsFrameBaseReg
The vector callee saved registers shouldn't affect the frame pointer
offset so we don't want to consider them.

I've listed the GPR, FPR32, and FPR64 register classes explicitly
because getMinimalPhysRegClass is slow and this function is called
frequently. So explicitly listing the interesting classs should be
a compile time improvement.
2024-05-13 13:38:41 -07:00
Craig Topper
c3028a2305 [RISCV] Don't exlude the frame pointer from the callee saved registers in RISCVRegisterInfo::needsFrameBaseReg.
Instead of using getReservedRegs, just check the subtarget reserved
list. getReservedRegs considers the frame pointer to be reserved when
it is being used, but we do need to save/restore it so it should be
counted as a callee saved register. AArch64 hardcodes their callee
saved size, but the comment mentions the Frame Pointer being counted.
2024-05-13 12:58:30 -07:00
Leon Clark
bd679865c0
[AMDGPU] Add tests for vector rebroadcast. (#91322)
Co-authored-by: Leon Clark <leoclark@amd.com>
2024-05-13 19:39:26 +01:00
Fangrui Song
4a67f80982 [test] Fix check prefixes 2024-05-13 11:25:12 -07:00
Craig Topper
026686bac6 [RISCV] Don't add getFrameIndexInstrOffset in RISCVRegisterInfo::needsFrameBaseReg.
It's already added in isFrameOffsetLegal so adding it in needsFrameBaseReg
causes it to be double counted.
2024-05-13 11:02:13 -07:00
Craig Topper
0817754126 [RISCV] Improve testing of loads with offset in local-stack-slot-allocation.ll. NFC
The test we had didn't match it's description.

Now we have one test with a large offset that requires a virtual base register
and a test with a smaller offset that should not.

There is currently a bug that causes the offset to double counted
leading to the small case also using a virtual base register.
2024-05-13 11:02:13 -07:00
Yingwei Zheng
d03a1a6e58
[ValueTracking] Compute knownbits from known fp classes (#86409)
This patch calculates knownbits from fp instructions/dominating fcmp
conditions. It will enable more optimizations with signbit idioms.
2024-05-14 01:58:45 +08:00
Philip Reames
6140b5bae4
[RISCV] Use RISCVISD::SHL_ADD in transformAddShlImm (#89832)
Doing so avoids negative interactions with other combines which don't
know the shl_add is a single instruction. From the commit log, we've had
several combine loops already.

This was originally posted as part of #88791, where a bug was pointed
out. That bug was fixed by #89789 which hits the same issue from another
angle. To confirm the fix, I included the reduced test case here.
2024-05-13 09:48:46 -07:00