53542 Commits

Author SHA1 Message Date
Simon Pilgrim
2b1dfd2b35
[DAG] Replace getValid*ShiftAmountConstant helpers with getValid*ShiftAmount helpers to support KnownBits analysis (#93182)
The getValidShiftAmountConstant/getValidMinimumShiftAmountConstant/getValidMaximumShiftAmountConstant helpers only worked with constant shift amounts, which could be problematic after type legalization (e.g. v2i64 might be partially scalarized or split into v4i32 on some targets such as 32-bit x86, Thumb2 MVE).

This patch proposes we generalize these helpers to work with ConstantRange+KnownBits if a scalar/buildvector constant isn't available.

Most restrictions are the same - the helper fails if any shift amount is out of bounds, getValidShiftConstant must be a specific constant uniform etc.

However, getValidMinimumShiftAmount/getValidMaximumShiftAmount now can return bounds values that aren't values in the actual data, as they are based off the common KnownBits of every vector element.

This addresses feedback on #92096
2024-06-01 16:48:26 +01:00
Matt Arsenault
b263033c2b
AMDGPU: Remove arbitrary SCC liveness scan threshold (#94097) 2024-06-01 14:19:38 +02:00
Yingwei Zheng
47fd32f81c
[DAGCombine] Fix type mismatch in (shl X, cttz(Y)) -> (mul (Y & -Y), X) (#94008)
Proof: https://alive2.llvm.org/ce/z/J7GBMU

Same as https://github.com/llvm/llvm-project/pull/92753, the types of
LHS and RHS in shift nodes may differ.
+ When VT is smaller than ShiftVT, it is safe to use trunc.
+ When VT is larger than ShiftVT, it is safe to use zext iff
`is_zero_poison` is true (i.e., `opcode == ISD::CTTZ_ZERO_UNDEF`). See
also the counterexample `src_shl_cttz2 -> tgt_shl_cttz2` in the alive2
proofs.

Fixes issue
https://github.com/llvm/llvm-project/pull/85066#issuecomment-2142553617.
2024-06-01 19:04:55 +08:00
Yingwei Zheng
0864501b97
[GISel] Convert zext nneg to sext if it is cheaper (#93856)
This patch converts `zext nneg` to `sext` on RISCV to use free sext.

---------

Co-authored-by: Thorsten Schütt <schuett@gmail.com>
2024-06-01 15:02:43 +08:00
Kai Luo
59116e0941 [PowerPC] Update test so that target flags are exposed. NFC. 2024-06-01 13:00:18 +08:00
Craig Topper
1af0778f9c [RISCV] Use vadd.vi for tail undisturbe vsub intrinsic with small immediate.
Our pattern previously checked for the merge operand being undef.
2024-05-31 20:55:37 -07:00
Michael Liao
f5bab9678e [M68k] Fix compilation pipeline check
- Fix check after cab81dd03813ac6333ad7fc031d72b84341fe2b9
2024-05-31 20:06:54 -04:00
Ahmed Bougacha
cc548ec47c
[AArch64][PAC] Lower authenticated calls with ptrauth bundles. (#85736)
This adds codegen support for the "ptrauth" operand bundles, which can
be used to augment indirect calls with the equivalent of an
`@llvm.ptrauth.auth` intrinsic call on the call target (possibly
preceded by an `@llvm.ptrauth.blend` on the auth discriminator if
applicable.)

This allows the generation of combined authenticating calls
on AArch64 (in the BLRA* PAuth instructions), while avoiding
the raw just-authenticated function pointer from being
exposed to attackers.

This is done by threading a PtrAuthInfo descriptor through
the call lowering infrastructure, eventually selecting a BLRA
pseudo.  The pseudo encapsulates the safe discriminator
computation, which together with the real BLRA* call get emitted
in late pseudo expansion in AsmPrinter.

Note that this also applies to the other forms of indirect calls,
notably invokes, rvmarker, and tail calls.  Tail-calls in particular
bring some additional complexity, with the intersecting register
constraints of BTI and PAC discriminator computation.
However this doesn't currently support PAuth_LR tail-call variants.

This also adopts an x8+ allocation order for GPR64noip, matching
GPR64.
2024-05-31 14:08:10 -07:00
Egor Pasko
cab81dd038
[EntryExitInstrumenter] Move passes out of clang into LLVM default pipelines (#92171)
Move EntryExitInstrumenter(PostInlining=true) to as late as possible and
EntryExitInstrumenter(PostInlining=false) to an early pre-inlining stage
(but skip for ThinLTO post-link).

This should fix the issues reported in
https://github.com/rust-lang/rust/issues/92109 and
https://github.com/llvm/llvm-project/issues/52853. These are caused
by https://reviews.llvm.org/D97608.
2024-05-31 12:48:45 -07:00
Stanislav Mekhanoshin
fc21387b65
[AMDGPU] Enable constant offset promotion to immediate FLAT (#93884)
Currently it is only supported for FLAT Global.
2024-05-31 12:23:27 -07:00
Craig Topper
99a0cd6f7e
[RISCV] Use TU policy for C reduction intrinsics. (#93970)
The C intrinsics should allow a value to be specified for the upper
elements.

This used to work before https://reviews.llvm.org/D146752 which should
have only changed the behavior for the autovectorizer. It clearly
changed all reductions.
2024-05-31 14:03:02 -05:00
Luke Lau
458a31562a [RISCV] Add more tests for strided gathers with scalar offsets. NFC 2024-05-31 18:58:34 +01:00
Konstantin Zhuravlyov
775f1cd34d
AMDGPU: Add gfx12-generic target (#93875) 2024-05-31 12:46:44 -04:00
Luke Lau
fb87e11e72 [RISCV] Add test case for strided scatter with scalar offset. NFC 2024-05-31 15:49:16 +01:00
Craig Topper
edf4e02906
[RISCV] Support multiple levels of truncates in combineTruncToVnclip. (#93752)
We can use multiple vnclips to saturate an i32 value into an i8 value.
2024-05-31 09:09:12 -05:00
Simon Pilgrim
b52962d1b8 [X86] LowerVSELECT - split v16i16/v32i8 pre-AVX2 VSELECT ops if enough of the operands are free to split.
Often on AVX1 we're better off consistently using 128-bit instructions, so recognise when the operands are loads that can be freely/cheaply split - ideally this functionality needs to be moved to isFreeToSplitVector but we're using it in a few places where we don't want to split loads yet.

Based off a regression reported after #92794
2024-05-31 14:43:10 +01:00
Simon Pilgrim
f0e8d003e5 [X86] widen_load-3.ll - add missing nounwind attributes 2024-05-31 13:59:49 +01:00
Simon Pilgrim
189efb0fbb [X86] vselect-pcmp.ll - add tests showing poor codegen on AVX1 targets where we have to split/concat 128-bit subvectors
We'd be better off consistently using 128-bit instructions

Based off a regression reported after #92794
2024-05-31 12:29:01 +01:00
Sander de Smalen
f484c79e7a
[AArch64] Avoid NEON ctpop in Streaming-SVE mode (#93826)
The NEON ctpop instruction is also used for scalars.
2024-05-31 09:01:17 +01:00
Nikita Popov
63dc31b68b Reapply [IR] Avoid creating icmp/fcmp constant expressions (#92885)
Reapply after https://github.com/llvm/llvm-project/pull/93548,
which should address the lldb failure on macos.

-----

Do not create icmp/fcmp constant expressions in IRBuilder etc anymore,
i.e. treat them as "undesirable". This is in preparation for removing
them entirely.

Part of:
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179
2024-05-31 08:55:59 +02:00
Jianjian Guan
db6de1a20f
[DAGCombiner][VP] Add DAGCombine for VP_MUL (#80105)
Use visitMUL to combine VP_MUL, share most logic of MUL with VP_MUL.

Migrate from https://reviews.llvm.org/D121187
2024-05-31 10:17:11 +08:00
Matt Arsenault
419d363385
AMDGPU: Add kernarg input attributes to preloaded kernarg test (#93669)
Explicitly mark the unused implicit arguments in the test, since this
should be sensitive to the number of free user SGPRs.

This is in preparation for #83131.
2024-05-30 23:50:24 +02:00
Sterling Augustine
fc2b15987b Send output to a temp file, even in the error case
Prior to this, the test tries to write to the source directory,
which prevents it from working when the source is on a read-only
file systems.
2024-05-30 21:44:06 +00:00
Stanislav Mekhanoshin
215f92b979
[AMDGPU] Fix crash in the SILoadStoreOptimizer (#93862)
It does not properly handle situation when address calculation uses
V_ADDC_U32 0, 0, carry-in (i.e. with both src0 and src1 immediates).
2024-05-30 14:27:33 -07:00
Craig Topper
8247068b70
[RISCV] Support (truncate (smin (smax X, C1), C2)) for vnclipu in combineTruncToVnclip. (#93756)
If the smax removed all negative numbers, then we can treat the smin
like a umin.

If the smin and smax are in the other order we can swap them and use a
vnclipu as long as the smax constant is smaller than the smin constant.

This is based on similar code from X86's detectUSatPattern.
2024-05-30 15:41:07 -05:00
Brendan Dahl
8aa8019975
[WebAssembly] Implement all f16x8 relation instructions. (#93751)
All of these instructions can be generated using regular LL
instructions.

Specified at:

29a9b9462c/proposals/half-precision/Overview.md
2024-05-30 09:02:17 -07:00
Christudasan Devadasan
e8de977716
[AMDGPU] Fixed subtarget name in the lit test check-prefix string (NFC). (#93780) 2024-05-30 20:27:24 +05:30
Jay Foad
ed25d1a82e [AMDGPU] Regenerate checks in inst-select-load-global.s96.mir 2024-05-30 14:02:15 +01:00
Jay Foad
4d65887aac
[LLVM] Remove executable permission from some non-executable files (#93803) 2024-05-30 12:35:10 +01:00
Shengchen Kan
22c572eae0 [X86][CodeGen] Support memory folding for NDD -> RMW 2024-05-30 19:06:22 +08:00
Andrzej Warzyński
fecf5c7492
[llvm][nfc] Rename tests (#93794)
Renames asm-constraint-jR.ll and asm-constraint-jR.ll - on
case-insensitive files systems those are treated as one file. Originally
introduced in #92338.
2024-05-30 11:07:45 +01:00
Sergei Barannikov
3fee8b3469
[GISel] LegalizationArtifactCombiner: Elide redundant G_SEXT_INREG (#93687)
This is similar to 373c343a, but for targets with zero-or-negative-one
booleans.
The difference in tests is mostly due to G_SEXT_INREG being illegal for
some targets, in which case it gets expanded into G_SHL/G_ASHR pair,
which is not currently optimized by the combiner.
2024-05-30 12:40:42 +03:00
Him188
8bce40b1eb
[AArch64][GISel] Support SVE with 128-bit min-size for G_LOAD and G_STORE (#92130)
This patch adds basic support for scalable vector types in load & store
instructions for AArch64 with GISel.

Only scalable vector types with a 128-bit base size are supported, e.g.
`<vscale x 4 x i32>`, `<vscale x 16 x i8>`.

This patch adapted some ideas from a similar abandoned patch
[https://github.com/llvm/llvm-project/pull/72976](https://github.com/llvm/llvm-project/pull/72976).
2024-05-30 09:10:43 +01:00
Freddy Ye
73f4c2547d
[X86] Support EGPR for inline assembly. (#92338)
"jR": explicitly enables EGPR
"r", "l", "q": enables/disables EGPR w/wo -mapx-inline-asm-use-gpr32
"jr": explicitly enables GPR with -mapx-inline-asm-use-gpr32
-mapx-inline-asm-use-gpr32 will also define a new macro:
`__APX_INLINE_ASM_USE_GPR32__`

GCC patches:
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631183.html
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631186.html
[[PATCH v2] x86: Define _APX_INLINE_ASM_USE_GPR32_
(gnu.org)](https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649003.html)

Reference: https://gcc.godbolt.org/z/nPPvbY6r4
2024-05-30 14:47:47 +08:00
Nikita Popov
d10b76552f
[ConstantFold] Remove notional over-indexing fold (#93697)
The data-layout independent constant folding currently has some rather
gnarly code for canonicalizing GEP indices to reduce "notional
overindexing", and then infers inbounds based on that canonicalization.

Now that we canonicalize to i8 GEPs, this canonicalization is
essentially useless, as we'll discard it as soon as the GEP hits the
data-layout aware constant folder anyway. As such, I'd like to remove
this code entirely.

This shouldn't have any impact on optimization capabilities.
2024-05-30 08:36:44 +02:00
Alex MacLean
f32ebabc27
[NVPTX] Improve folding to mad with immediate 1 (#93628)
Extend NVPTX DAG combining logic to distribute a mul instruction across
an add of 1 into a mad where possible. In addition, add support for
transposing a mul through a select with an option of 1, if that would
allow further mul folding.
2024-05-29 18:09:21 -07:00
Craig Topper
c0873fa20e [RISCV] Add trunc-sat-clip tests for i32->i8, i64->i8, and i64->i16. NFC
These can be implemented with multiple vnclips.
2024-05-29 16:50:21 -07:00
Florian Mayer
fb607c9019
[MTE] add tests for stack tagging debug info (#93743)
These are equivalent to the tests in HWASan of the same name.
2024-05-29 16:16:04 -07:00
Craig Topper
e06e680a97
[RISCV] Replace duplicate trunc-sat-clip tests with more interesting tests. NFC (#93737)
For each pair of types, we had 3 identical tests using umin with the
unsigned max value.

This patch replaces two of them with smin+smax cases that can be
implemented with a signed vmax followed by a vnclipu.
2024-05-29 16:06:14 -07:00
Evgenii Kudriashov
11d7203c1d
[X86][GlobalISel] Enable G_BUILD_VECTOR and G_CONSTANT_POOL (#92844)
* Add support for G_LOAD from G_CONSTANT_POOL on X86 and X64
* Add X86GlobalBaseRegPass to handle base register initialization for
X86.
* Fix vector type legalization for G_STORE and G_LOAD as well as enable
scalarization for them.
* Custom lower G_BUILD_VECTOR into G_LOAD from G_CONSTANT_POOL.
2024-05-30 00:53:43 +02:00
Florian Mayer
66b9785670 [NFC] [MTE] make test more robust by not hardcoding %1 2024-05-29 15:29:30 -07:00
Florian Mayer
c3e6bd0b09 [NFC] [MTE] remove unused functions from test 2024-05-29 15:26:38 -07:00
Florian Mayer
4e67f45168 Reapply "[MTE] add stack frame history buffer"
In the reverted change, the order of the IR was dependent on the host
compiler, because we inserted instructions in arguments to functions.
Fix that, and also fix another problem with the test.

This reverts commit 3313f28897a87ec313ec0b52ef71c14d3b9ff652.
2024-05-29 13:02:58 -07:00
Luke Lau
1cff74130f
[RISCV] Merge RISCVCoalesceVSETVLI back into RISCVInsertVSETVLI (#92869)
We no longer need to separate the passes now that #70549 is landed and
this will unblock #89089.

It's not strictly NFC because it will move coalescing before register
allocation when -riscv-vsetvl-after-rvv-regalloc is disabled. But this
makes it closer to the original behaviour.
2024-05-29 20:59:34 +01:00
Craig Topper
b3bbb2de6f
[RISCV] Verify the VL and Mask on the outer TRUNCATE_VECTOR_VL in combineTruncOfSraSext. (#93578)
We checked the VL and mask of any additional TRUNCATE_VECTOR_VL
nodes we peek through, but not the outermost.
    
This moves the check to the outer node and then verifies all the
additional nodes have the same VL and Mask.

Stacked on #93574
2024-05-29 11:53:01 -07:00
Florian Mayer
3313f28897 Revert "[MTE] add stack frame history buffer"
This reverts commit 1f67f34a5cf993f03eca8936bfb7203778c2997a.
2024-05-29 11:21:29 -07:00
Florian Mayer
1f67f34a5c [MTE] add stack frame history buffer
this will allow us to find offending objects in a symbolization step,
like we can do with hwasan.

needs matching changes in AOSP:
https://android-review.git.corp.google.com/q/topic:%22stackhistorybuffer%22

Pull Request: https://github.com/llvm/llvm-project/pull/86356
2024-05-29 10:57:11 -07:00
Thorsten Schütt
6d90ac1e06
[GlobalIsel] Combine freeze (#93239) 2024-05-29 18:05:33 +02:00
zhijian lin
6127f15e5b
[PowerPC] option -msoft-float should not block the PC-relative address instruction (#92543)
The Prefix instruction is introduced on PowerPC ISA3_1.

In the PR,  
1. The `FeaturePrefixInstrs` do not imply the `FeatureP8Vector`
,`FeatureP9Vector` .
2. `FeaturePrefixInstrs`  implies only the FeatureISA3_1.
3. For the prefix instructions `paddi` and `pli` , they have `Predicates
= [PrefixInstrs] `
4. For the prefix instructions `plfs` and `plfd`, they have `Predicates
= [PrefixInstrs, HasFPU] `
5. For the prefix instructions "plxv` , "plxssp` and `plxsd` , they have
`Predicates = [PrefixInstrs, HasP10Vector]`

Fixes #62372
2024-05-29 10:53:00 -04:00
chuongg3
14dc97df5e
[AArch64][GlobalISel] Push ADD/SUB through Extend Instructions (#90964)
The regression in one test is due to a SUB instruction being pushed
through the extend, leaving behind the abs instruction, which prevents
it from selecting uabdl instructions shown below:

`i32 abs(i32 sub(i32 ext i8, i32 ext i8))` => 
`i32 abs(i32 ext(i16 sub(i16 ext i8, i16 ext i8)))`

This is intended to be fixed in a follow up patch
2024-05-29 15:15:53 +01:00