53164 Commits

Author SHA1 Message Date
Matt Arsenault
f548c4d83c AMDGPU: Add mode register use to s_getreg_b32
This should fix reading the wrong mode after setting the mode.
Ideally we would have separate pseudos for the case that we know
does not read mode.
2024-05-07 16:06:51 +02:00
Chris Copeland
651bdb96b1
[ARM] Armv8-R does not require fp64 or neon. (#88287)
This was [addressed for AArch64
here](https://github.com/llvm/llvm-project/pull/79004), but the same
applies to ARM.

Move the enablement of neon+fp64 to `-mcpu=cortex-r52`, which optionally
supports these features.
2024-05-07 11:48:30 +01:00
Simon Pilgrim
abd314938d
[X86] Use GFNI for vXi8 shifts/rotates (#89115)
As detailed here: https://github.com/InstLatx64/InstLatX64_Demo/blob/master/GFNI_Demo.h

We can use the gf2p8affine instruction to lower byte shifts/rotates as well as the existing bitreverse case.

Based off the original patch here: https://reviews.llvm.org/D137026
2024-05-07 10:28:55 +01:00
Quentin Colombet
6ce04747cf
[SDISel] Teach the type legalizer about ADDRSPACECAST (#90969)
Vectorized ADDRSPACECASTs were not supported by the type legalizer.

This patch adds the support for:
- splitting the vector result: <2 x ptr> => 2 x <1 x ptr>
- scalarization: <1 x ptr> => ptr
- widening: <3 x ptr> => <4 x ptr>

This is all exercised by the added NVPTX tests.
2024-05-07 11:08:33 +02:00
Simon Pilgrim
d838e5b3e8
[X86] Add FastImm16 tuning flag to Intel Atom + AMD Bobcat/Ryzen Families (#90635)
This patch limits the icmp_i16(x,c) -> icmp_i32(ext(x),ext(c)) fold to CPUs that aren't known to have fast handling for length-changing prefixes for imm16 operands.

We are always assuming that 66/67h length-changing prefixes cause severe stalls and we should always extend imm16 operands and use a i32 icmp instead, the only exception being Intel Bonnell CPUs.

Agner makes this clear (see microarchitecture.pdf) that there are no stalls for any of the Intel Atom family (at least as far as Tremont - not sure about Gracemont or later). This is also true for AMD Bobcat/Jaguar and Ryzen families.

Recent performance Intel CPUs are trickier - Core2/Nehalem and earlier could have a 6-11cy stall, while SandyBridge onwards this is reduced to 3cy or less. I'm not sure if we should accept this as fast or not, we only use this flag for the icmp_i16 case, so that might be acceptable? If so, we should add this to x86-64-v3/v4 tuning as well.

Part of #90355 + #62952
2024-05-07 10:00:00 +01:00
Luke Lau
d9f2b93918 [RISCV] Change more undef passthrus to $noreg in vector tests. NFC 2024-05-07 16:02:18 +08:00
hev
ad59967336
[LoongArch] Optimize codegen for ISD::{ROTL,ROTR} (#91174) 2024-05-07 15:46:11 +08:00
Luke Lau
ebde770c3e [RISCV] Use IMPLICIT_DEF for undef GPR reg in vsetvli test. NFC
Only VRs should use $noreg, this GPR was accidentally changed in d392520c6
2024-05-07 15:42:16 +08:00
Thorsten Schütt
b42f553af5
[GlobalIsel] Combine extract vector element (#90339)
look through shuffle vectors
2024-05-07 07:12:58 +02:00
Jianjian Guan
37fcb323f6
[RISCV] Add codegen support for Zvfbfmin (#87911)
This patch adds basic codegen support for Zvfbfmin extension.
2024-05-07 10:25:06 +08:00
antangelo
2287f8d235
[NFC][X86] Fix check directive typo in preserve_none dynamic regmask test (#91048)
Fixes an inactive check line and updates the check to match output and
other cases.
2024-05-06 19:47:33 -04:00
Brandt Bucher
d3e77f5408
Try to use non-volatile registers for preserve_none parameters (#88333)
This uses non-volatile registers for the first four (six on Windows)
registers used for `preserve_none` argument passing. This allows these
registers to stay "pinned", even if the body of the `preserve_none`
function contains calls to other "normal" functions.

Example:

```c
void boring(void);

__attribute__((preserve_none)) void (continuation)(void *, void *, void *, void *);

__attribute__((preserve_none)) void entry(void *a, void *b, void *c, void *d)
{
    boring();
    __attribute__((musttail)) return continuation(a, b, c, d);
}
``` 

Before:

```asm
pushq   %rax
movq    %rcx, %rbx
movq    %rdx, %r14
movq    %rsi, %r15
movq    %rdi, %r12
callq   boring@PLT
movq    %r12, %rdi
movq    %r15, %rsi
movq    %r14, %rdx
movq    %rbx, %rcx
popq    %rax
jmp     continuation@PLT
```

After:

```asm
pushq   %rax
callq   boring@PLT
popq    %rax
jmp     continuation@PLT
```
2024-05-06 10:55:36 -07:00
David Green
363ec6f691 [AArch64][GlobalISel] Common some shuffle mask functions.
This removes the GISel versions of isREVMask, isTRNMask, isUZPMask and
isZipMask. They are combined with the existing versions from SDAG into
AArch64PerfectShuffle.h.
2024-05-06 18:37:04 +01:00
Simon Pilgrim
d0be944aa5
[X86] Add slow div64 tuning flag to Nehalem target (#91129)
This appears to have been missed because later cpus don't inherit from Nehalem tuning much.

Noticed while cleaning up for #90985
2024-05-06 18:31:36 +01:00
Luke Lau
52187b9f2e
[RISCV] Move RISCVDeadRegisterDefinitions to post vector regalloc (#90636)
Currently RISCVDeadRegisterDefinitions runs after vsetvli insertion, but
in #70549 vsetvli insertion runs after vector regalloc and as a result
we no longer convert some vsetvli a0, a0s to vsetvli x0, a0. This patch
moves it to after vector regalloc, but before scalar regalloc so we
still get the benefits of reducing register pressure.
2024-05-07 00:36:47 +08:00
David Green
e50060fc6f [AArch64][GlobalISel] Addition GISel test coverage for shuffles. NFC 2024-05-06 17:20:09 +01:00
Simon Pilgrim
8e7618aa21
[X86] Fold BLEND(PERMUTE(X),PERMUTE(Y)) -> PERMUTE(BLEND(X,Y)) (#90219)
If we don't demand the same element from both single source shuffles (permutes), then attempt to blend the sources together first and then perform a merged permute.

For vXi16 blends we have to be careful as these are much more likely to involve byte/word vector shuffles that will result in the creation of additional shuffle instructions.

This fold might be worth it for VSELECT with constant masks on AVX512 targets, but I haven't investigated this yet, but I've tried to write combineBlendOfPermutes so to be prepared for this.

The PR34592 -O0 regression is an unfortunate failure to cleanup with a later pass that calls SimplifyDemandedElts like the -O3 does - I'm not sure how worried we should be tbh.
2024-05-06 11:25:23 +01:00
Ulrich Weigand
0a0cac6dbd
[SystemZ] Simplify f128 atomic load/store (#90977)
Change definition of expandBitCastI128ToF128 and expandBitCastF128ToI128
to allow for simplified use in atomic load/store.

Update logic to split 128-bit loads and stores in DAGCombine to also
handle the f128 case where appropriate. This fixes the regressions
introduced by recent atomic load/store patches.
2024-05-06 12:17:19 +02:00
Simon Pilgrim
522b4bfe5b
[DAG] Fold bitreverse(shl/srl(bitreverse(x),y)) -> srl/shl(x,y) (#89897)
Noticed while investigating GFNI per-element vector shifts (we can form SHL but not SRL/SRA)

Alive2: https://alive2.llvm.org/ce/z/fSH-rf
2024-05-06 11:13:05 +01:00
WANG Rui
0933a7a125 [LoongArch] Rename some OptWInstrs functions. NFC 2024-05-06 18:07:30 +08:00
WANG Rui
d98a78590f [LoongArch] Mark data type i32 are sign-extended. NFC 2024-05-06 16:43:57 +08:00
hev
e9bcd2bf67
[LoongArch] Optimize *W Instructions at MI level (#90463)
Referring to RISC-V, adding an MI level pass to optimize *W instructions
for LoongArch.

First it removes unneeded sext(addi.w rd, rs, 0) instructions. Either
because the sign extended bits aren't consumed or because the input was
already sign extended by an earlier instruction.

Then:
1. Unless explicit disabled or the target prefers instructions with W
suffix, it removes the -w suffix from opw instructions whenever all
users are dependent only on the lower word of the result of the
instruction. The cases handled are:
* addi.w because it helps reduce test differences between LA32 and LA64
w/o being a pessimization.

2. Or if explicit enabled or the target prefers instructions with W
suffix, it adds the W suffix to the instruction whenever all users are
dependent only on the lower word of the result of the instruction. The
cases handled are:
   * add.d/addi.d/sub.d/mul.d.
   * slli.d with imm < 32.
   * ld.d/ld.wu.
2024-05-06 16:41:26 +08:00
Sameer Sahasrabuddhe
8a65ee8b2a
[AMDGPU] don't mark control-flow intrinsics as convergent (#90026)
This is really a workaround to allow control flow lowering in the
presence of convergence control tokens. Control-flow intrinsics in LLVM
IR are convergent because they indirectly represent the wave CFG, i.e.,
sets of threads that are "converged" or "execute in lock-step". But they
exist during a small window in the lowering process, inserted after the
structurizer and then translated to equivalent MIR pseudos. So rather
than create convergence tokens for these builtins, we simply mark them
as not convergent.

The corresponding MIR pseudos are marked as having side effects, which
is sufficient to prevent optimizations without having to mark them as
convergent.
2024-05-06 14:07:11 +05:30
Matt Arsenault
eb75af223f Reapply "SystemZ: Fold copy of vector immediate to gr128" (#91099)
This reverts commit a415b4dfcc02e3e82b8c8a7836f7c04b9d65dc9b.

Modify the instruction in place to transform it into a REG_SEQUENCE,
which is what other implementations of foldImmediate do. Also start
erasing the def instruction if there are no other uses.

Fixes #91110.
2024-05-06 10:00:20 +02:00
Matt Arsenault
4b61d04645 SystemZ: Remove unnecessary REQUIRES asserts from tests 2024-05-06 09:52:35 +02:00
Matt Arsenault
181e82143e SystemZ: Remove redundant REQUIRES systemz from test 2024-05-06 09:52:35 +02:00
Matt Arsenault
d654278bde
Reapply "AMDGPU: Implement llvm.set.rounding (#88587)" series (#91113)
Revert "Revert 4 last AMDGPU commits to unbreak Windows bots"

This reverts commit 0d493ed2c6e664849a979b357a606dcd8273b03f.

MSVC does not like constexpr on the definition after an extern
declaration of a global.
2024-05-06 09:09:19 +02:00
Luke Lau
1500dc0af9 [RISCV] Use virtual registers for AVL instrs in coalesce-vsetvli.mir. NFC
All GPR registers will still be virtual at this stage, so update the test
to reflect that.
2024-05-06 14:23:49 +08:00
Luke Lau
b944b543d6 [RISCV] Add RISCVCoalesceVSETVLI tests for removing dead AVLs. NFC 2024-05-06 13:31:11 +08:00
Phoebe Wang
f7bfb078cf
[X86][FP16] Do not create VBROADCAST_LOAD for f16 without AVX2 (#91125)
AVX doesn't provide 16-bit BROADCAST instruction.

Fixes #91005
2024-05-06 10:59:44 +08:00
Allen
e12364301e
[AArch64][SelectionDAG] Lower multiplication by a constant to shl+sub+shl+sub (#90199)
Change the costmodel to lower a = b * C where C = 1 - (1 - 2^m) * 2^n to
              sub  w8, w0, w0, lsl #m
              sub  w0, w0, w8, lsl #n
Fix https://github.com/llvm/llvm-project/issues/89430
2024-05-06 08:56:34 +08:00
Simon Pilgrim
77d8c3878a [X86] 2008-08-31-EH_RETURN32.ll - regenerate with update_llc_test_checks.py 2024-05-05 16:38:52 +01:00
Simon Pilgrim
176be3ee8c [X86] bypass-slow-division-64.ll - add udiv+urem test coverage 2024-05-05 16:03:17 +01:00
Simon Pilgrim
de9b386f84 [X86] bypass-slow-division-64.ll - add optsize/minsize tests
Make sure we're not expanding div32-div64 codegen when we're focussed on codesize
2024-05-05 13:24:10 +01:00
Simon Pilgrim
983333234b [X86] bypass-slow-division-64.ll - extend cpu test coverage
Ensure we test with/without the idivq-to-divl attribute, and test the x86-64-v* cpu levels and some common Intel/AMD cpus
2024-05-05 13:11:34 +01:00
Weihang Fan
72eaa0ed99
[AArch64][SelectionDAG] Mask for SUBS with multiple users cannot be elided (#90911)
In DAGCombiner, the `performCONDCombine` function attempts to remove AND
instructions in front of SUBS (cmp) instructions for which the AND is
transparent. The rules for that are correct, but it fails to take into
account the case where the SUBS instruction has multiple users with
different condition codes for comparison and simply removes the AND for
all of them. This causes a miscompilation in the attached test case.
2024-05-05 12:01:13 +01:00
Phoebe Wang
7963d9a2b3
[X86][EVEX512] Add HasEVEX512 when NoVLX used for 512-bit patterns (#91106)
With KNL/KNC being deprecated, we don't need to care about such no VLX
cases anymore. We may remove such patterns in the future.

Fixes #90844
2024-05-05 18:40:27 +08:00
Simon Pilgrim
78a28b3ef7
[X86] Support icmp_i64(i64 X, i64 Y) --> icmp_i32(trunc(X), trunc(Y)) for non-constant Y (#91085)
Relax the constraint on the fold to allow any value for X and Y iff all upper 32-bits are known zero

Minor code-size saving by moving to i32 bit instructions
2024-05-05 10:15:00 +01:00
Vitaly Buka
a415b4dfcc
Revert "SystemZ: Fold copy of vector immediate to gr128" (#91099)
Fails here:
https://lab.llvm.org/buildbot/#/builders/239/builds/6893
https://lab.llvm.org/buildbot/#/builders/5/builds/43113
https://lab.llvm.org/buildbot/#/builders/168/builds/20228

Reverts llvm/llvm-project#90706
2024-05-04 23:59:49 -07:00
Phoebe Wang
02dfbbff19
[SelectionDAG] Make ARITH_FENCE support half and bfloat type (#90836) 2024-05-05 13:08:34 +08:00
Mehdi Amini
0d493ed2c6 Revert 4 last AMDGPU commits to unbreak Windows bots
Revert "AMDGPU: Try to fix build error with old gcc"
This reverts commit c7ad12d0d7606b0b9fb531b0b273bdc5f1490ddb.

Revert "AMDGPU: Use umin in set.rounding expansion"
This reverts commit a56f0b51dd988ad2b533de759c98457c1ed42456.

Revert "AMDGPU: Optimize set_rounding if input is known to fit in 2 bits (#88588)"
This reverts commit b4e751e2ab0ff152ed18dea59ebf9691e963e1dd.

Revert "AMDGPU: Implement llvm.set.rounding (#88587)"
This reverts commit 9731b77e80261c627d79980f8c275700bdaf6591.
2024-05-04 19:57:33 +02:00
Simon Pilgrim
caacf8685a
[DAG] Fold freeze(shuffle(x,y,m)) -> shuffle(freeze(x),freeze(y),m) (#90952)
If the shuffle mask contains no undef elements, then we can move the freeze through a shuffle node.

This requires special case handling to create a new ShuffleVectorSDNode.

Includes VECTOR_SHUFFLE support for isGuaranteedNotToBeUndefOrPoison  / canCreateUndefOrPoison.
2024-05-04 12:03:10 +01:00
paperchalice
e7939d0df6
[Instrumentation] Support verifying machine function (#90931)
We need it to test isel related passes. Currently
`verifyMachineFunction` is incomplete (no LiveIntervals support), but is
enough for testing isel pass, will migrate to complete
`MachineVerifierPass` in future.
2024-05-04 09:00:59 +08:00
Craig Topper
0c7e706c08 [AArch64] Pre-commit another test case for #90936. NFC
Another similar problem was added to the ticket after the first fix.
2024-05-03 16:29:47 -07:00
Chris B
9299a136dc
[DirectX] Remove unneccary check lines (#90979)
These check lines break as of 91446e2aa687e due to changes in how LLVM
handles debug information. Since debug informaiton isn't important to
what this test is verifying we can remove the check lines.
2024-05-03 14:54:21 -05:00
Matt Arsenault
7ec698e6ed
AMDGPU: Add tests for minimum and maximum intrinsics (#90997)
Baseline tests for new expansion. I think we can do better and avoid the
classes.
2024-05-03 21:43:30 +02:00
Abhinav Garg
76508dce43
[AMDGPU] Fix mode register pass for constrained FP operations (#90085)
This PR will fix the si-mode-register pass which is inserting an extra
setreg instruction in case of constrained FP operations. This pass will
be ignored for strictfp functions.
2024-05-03 19:47:15 +02:00
Matt Arsenault
a56f0b51dd AMDGPU: Use umin in set.rounding expansion
Addresses comment from #88587
2024-05-03 19:22:19 +02:00
Fangrui Song
b9ae06ba15 [test] Convert text files from CRLF to LF
Skip *.pdb, *.rc, *crlf*, and FileCheck/dos-style-eol.txt
2024-05-03 10:09:52 -07:00
Fangrui Song
2265df9696 [test] Fix CodeGen/DirectX/strip-fn-attrs.ll 2024-05-03 10:07:37 -07:00