87419 Commits

Author SHA1 Message Date
David Green
e22985795c [AArch64] Clean up the formatting of some bitconvert patterns. NFC 2025-09-19 19:43:57 +01:00
AZero13
733c1aded1
[ARM] Replace ABS and tABS machine nodes with custom lowering (#156717)
Just do a custom lowering instead.

Also copy paste the cmov-neg fold to prevent regressions in nabs.
2025-09-19 19:43:36 +01:00
zhijian lin
2e34188513
[PowerPC] clean unused PPC target feature FeatureBPERMD (#159782)
clean unused PPC target feature FeatureBPERMD.
2025-09-19 13:38:26 -04:00
Sergei Barannikov
4cace1ff0f
[ARM] Verify that disassembled instruction is correct (#157360)
This change adds basic `MCInst` verification (checks the number of
operands) and fixes detected bugs.

* `RFE*` instructions have only one operand, but `DecodeRFEInstruction`
added two.
* `DecodeMVEModImmInstruction` and `DecodeMVEVCMP` added a `vpred`
operand, but this is what `AddThumbPredicate` normally does. This
resulted in an extra `vpred` operand.
* `DecodeMVEVADCInstruction` added an extra immediate operand.
* `getARMInstruction` added a `pred` operand to instructions that don't
have one (via `DecodePredicateOperand`).
* `AddThumb1SBit` appended an extra register operand to instructions
that don't modify CPSR (such as `tBL`).
* Instructions in `NEONDup` namespace have `pred` operand that the
generated code successfully decodes. The operand was added once again by
`getARMInstruction`/`getThumbInstruction` via `AddThumbPredicate`.

Functional changes extracted from #156540.
2025-09-19 17:37:52 +00:00
Craig Topper
90d03a0386
[RISCV] Use MutableArrayRef instead of SmallVectorImpl&. NFC (#159651)
We're only going to modify existing items, not add or remove any
elements to the vector.
2025-09-19 10:21:00 -07:00
Sergei Barannikov
bf835169a5
[AArch64] Remove post-decoding instruction mutations (#156364)
Add `bits<0>` fields to instructions using the ZTR/MPR/MPR8 register
classes. These register classes contain only one register, and it is
not encoded in the instruction. This way, the generated decoder can 
completely decode instructions without having to perform a post-decoding
pass to insert missing operands.

Some immediate operands are also not encoded and have only one possible
value "zero". Use this trick for them, too.

Finally, remove `-ignore-non-decodable-operands` option from
`llvm-tblgen` invocation to ensure that non-decodable operands do not
appear in the future.
2025-09-19 17:15:38 +00:00
Sam Clegg
cac54a8ad0
[WebAssembly] Require tags for Wasm EH and Wasm SJLJ to be defined externally (#159143)
Rather then defining these tags in each object file that requires them
we can can declare them as undefined and require that they defined
externally in, for example, compiler-rt or libcxxabi.
2025-09-19 10:11:15 -07:00
Akash Dutta
c256966fe2
[AMDGPU]: Unpack packed instructions overlapped by MFMAs post-RA scheduling (#157968)
This is a cleaned up version of PR #151704. These optimizations are now
performed post-RA scheduling.
2025-09-19 09:41:02 -07:00
Craig Topper
6119d1f115
[RISCV] Re-work how VWADD_W_VL and similar _W_VL nodes are handled in combineOp_VLToVWOp_VL. (#159205)
These instructions have one already narrow operand. Previously, we
pretended like this operand was a supported extension.

This could cause problems when we called getOrCreateExtendedOp on this
narrow operand when creating the the VWADD_VL. If the narrow operand
happened to be an extend of the opposite type, we would peek through it
and then rebuild it with the wrong extension type. So (vwadd_w_vl (i32
(sext X)), (i16 (zext Y))) would become (vwadd_vl (i16 (sext X)), (i16
(sext Y))).

To prevent this, we ignore the operand instead and pass std::nullopt for
SupportsExt to getOrCreateExtendedOp so it won't peek through any
extends on the narrow source.

Fixes #159152.
2025-09-19 09:19:57 -07:00
Michael Liao
ffb70b00f9 [RISCV] Fix build after e747223c03e16d02cd0dc6f8eedb5c825a7366c1 2025-09-19 12:11:16 -04:00
Brandon Wu
7f2dcaab39
[NFC][RISCV] Move Zvfbf* relative stuffs to RISCVInstrInfoZvfbf.td (#159619) 2025-09-19 23:57:59 +08:00
Matt Arsenault
acc156dc6f
PPC: Replace PointerLikeRegClass with RegClassByHwMode (#158777) 2025-09-19 14:46:54 +00:00
RolandF77
1eb575dcae
[PowerPC] Fix vector extend result types in BUILD_VECTOR lowering (#159398)
The result type of the vector extend intrinsics generated by the
BUILD_VECTOR lowering code should match how they are actually defined.
Currently the result type is defaulting to the operand type there. This
can conflict with calls to the same intrinsic from other paths.
2025-09-19 10:43:22 -04:00
zhijian lin
be6c4d933d
[PowerPC] using milicode call for strlen instead of lib call (#153600)
AIX has "millicode" routines, which are functions loaded at boot time
into fixed addresses in kernel memory. This allows them to be customized
for the processor. The __strlen routine is a millicode implementation;
we use millicode for the strlen function instead of a library call to
improve performance.
2025-09-19 10:02:21 -04:00
Matt Arsenault
084872a26d
Mips: Switch to RegClassByHwMode (#158273) 2025-09-19 13:50:07 +00:00
Matt Arsenault
2654b511fe
X86: Switch to RegClassByHwMode (#158274)
Replace the target uses of PointerLikeRegClass with RegClassByHwMode
2025-09-19 13:42:00 +00:00
Mikhail Gudim
562146499c
[CodeGen][NewPM] Port ReachingDefAnalysis to new pass manager. (#159572)
In this commit:
  (1) Added new pass manager support for `ReachingDefAnalysis`.
  (2) Added printer pass.
  (3) Make old pass manager use `ReachingDefInfoWrapperPass`
2025-09-19 09:38:34 -04:00
Matt Arsenault
cc680fc50c
X86: Avoid using isArch64Bit for 64-bit checks (#157412)
Just directly check x86_64. isArch64Bit just adds extra
steps around this.
2025-09-19 12:49:13 +00:00
Matt Arsenault
9113592312
SPARC: Use RegClassByHwMode instead of PointerLikeRegClass (#158271) 2025-09-19 12:37:14 +00:00
Paul Walker
b7e4edca3d
[LLVM][CodeGen] Update PPCFastISel::SelectRet for ConstantInt based vectors. (#159331)
The current implementation assumes ConstantInt return values are scalar,
which is not true when use-constant-int-for-fixed-length-splat is
enabled.
2025-09-19 13:15:57 +01:00
Hongyu Chen
fba55c89c3
[X86] Fold X * 1 + Z --> X + Z for VPMADD52L (#158516)
This patch implements the fold `lo(X * 1) + Z --> lo(X) + Z --> X iff X
== lo(X)`.
2025-09-19 19:35:05 +08:00
Matt Arsenault
6b54c92be0
CodeGen: Add RegisterClass by HwMode (#158269)
This is a generalization of the LookupPtrRegClass mechanism.
AMDGPU has several use cases for swapping the register class of
instruction operands based on the subtarget, but none of them
really fit into the box of being pointer-like.

The current system requires manual management of an arbitrary integer
ID. For the AMDGPU use case, this would end up being around 40 new
entries to manage.

This just introduces the base infrastructure. I have ports of all
the target specific usage of PointerLikeRegClass ready.
2025-09-19 20:08:51 +09:00
AZero13
a05e8d506b
[X86] Allow all legal integers to optimize smin with 0 (#151893)
It makes no sense why smin has to be limited to 32 and 64 bits.

hasAndNot only exists for 32 and 64 bits, so this does not affect smax.
2025-09-19 11:08:06 +00:00
UmeshKalappa
b59d410202
RISC-V: builtins support for MIPS RV64 P8700 execution control .
the following changes are made 

a)Typo Fix (with previous PRhttps://github.com/llvm/llvm-project/pull/155747)
b)builtins support  for MIPS P8700 execution control instructions .
c)Testcase
2025-09-19 15:10:28 +05:30
Fabian Ritter
771c94c8db
[SDAG][AMDGPU] Allow opting in to OOB-generating PTRADD transforms (#146074)
This PR adds a TargetLowering hook, canTransformPtrArithOutOfBounds,
that targets can use to allow transformations to introduce out-of-bounds
pointer arithmetic. It also moves two such transformations from the
AMDGPU-specific DAG combines to the generic DAGCombiner.

This is motivated by target features like AArch64's checked pointer
arithmetic, CPA, which does not tolerate the introduction of
out-of-bounds pointer arithmetic.
2025-09-19 11:07:59 +02:00
Fabian Ritter
a2dcc88f39
[AMDGPU][SDAG] Handle ISD::PTRADD in various special cases (#145330)
There are more places in SIISelLowering.cpp and AMDGPUISelDAGToDAG.cpp
that check for ISD::ADD in a pointer context, but as far as I can tell
those are only relevant for 32-bit pointer arithmetic (like frame
indices/scratch addresses and LDS), for which we don't enable PTRADD
generation yet.

For SWDEV-516125.
2025-09-19 10:19:38 +02:00
Jim Lin
e747223c03
[RISCV] Implement MC support for Zvfofp8min extension (#157014)
This patch adds MC support for Zvfofp8min
https://github.com/aswaterman/riscv-misc/blob/main/isa/zvfofp8min.adoc.
2025-09-19 07:49:31 +00:00
Jianjian Guan
332eb5f693
[RISCV][GISel] Support select vx, vf form rvv intrinsics (#157398)
For vx form, we legalize it with widen scalar. And for vf form, we select the right register bank.
2025-09-19 14:30:48 +08:00
ZhaoQi
680c657a4f
[LoongArch] Simplily fix extractelement on LA32 (#159564) 2025-09-19 14:14:55 +08:00
Craig Topper
446a490f93
[RISCV] Use Subtarget member variable instead of getting it from MachineFunction. NFC (#159664) 2025-09-18 21:28:13 -07:00
Luke Lau
7a77127c0f
[RISCV] Ignore debug instructions in RISCVVLOptimizer (#159616)
Don't put them onto the worklist, since they'll crash when we try to
check their opcode.

Fixes #159422
2025-09-19 12:22:44 +08:00
Florian Mayer
48f804d609
Revert "[TTI][ASan][RISCV] Move InterestingMemoryOperand to Analysis and embed in MemIntrinsicInfo" (#159700)
Reverts llvm/llvm-project#157863
2025-09-18 21:13:04 -07:00
Hank Chang
f8b7f64ad2
[TTI][ASan][RISCV] Move InterestingMemoryOperand to Analysis and embed in MemIntrinsicInfo (#157863)
Previously asan considers target intrinsics as black boxes, so asan
could not instrument accurate check. This patch make
SmallVector<InterestingMemoryOperand> a member of MemIntrinsicInfo so
that TTI can make targets describe their intrinsic informations to asan.

Note,
1. This patch move InterestingMemoryOperand from Transforms to Analysis.
2. Extend MemIntrinsicInfo by adding a
SmallVector<InterestingMemoryOperand> member.
3. This patch does not support RVV indexed/segment load/store.
2025-09-19 11:09:41 +08:00
Qihan Cai
dd92609fcc
[RISC-V] Add P-ext MC Support for Remaining Pair Operations (#159247)
This patch implements pages 21-24 from jhauser.us/RISCV/ext-P/RVP-instrEncodings-015.pdf

Documentation:
jhauser.us/RISCV/ext-P/RVP-baseInstrs-014.pdf
jhauser.us/RISCV/ext-P/RVP-instrEncodings-015.pdf

Co-authored-by: Craig Topper <craig.topper@sifive.com>
2025-09-19 13:08:23 +10:00
ZhaoQi
1ad5d63e5e
[LoongArch] Add generation support for [x]vnori.b (#158772) 2025-09-19 09:34:11 +08:00
Matt Arsenault
daed12d00d
AMDGPU: Remove unnecessary AGPR legalize logic (#159491)
The manual legalizeOperands code only need to consider cases that
require full instruction context to know if the operand is legal.
This does not need to handle basic operand register class constraints.
2025-09-19 09:51:46 +09:00
Craig Topper
0c1ab02e46
[RISCV] Use bseti 31 for (or X, -2147483648) when upper 32 bits aren't used. (#159678)
If the original type was i32, type legalization will sign extend
the constant. This prevents it from having a single bit set or clear
so other patterns can't match. If the upper bits aren't used, we
can ignore the sign extension.

Similar for bclri and binvi.
2025-09-18 17:33:08 -07:00
Sam Elliott
dda7ce6624
[RISCV] Move Xqci Select-likes to use riscv_selectcc (#153147)
The original patterns for the Xqci select-like instructions used
`select`, and marked that ISD node as legal. This is not the usual way
that `select` is dealt with in the RISC-V backend.

Usually on RISC-V, we expand `select` to `riscv_select_cc` which holds
references to the operands of the comparison and the possible values
depending on the comparison. In retrospect, this is a much better fit
for our instructions, as most of them correspond to specific condition
codes, rather than more generic `select` with a truthy/falsey value.

This PR moves the Xqci select-like patterns to use `riscv_select_cc`
nodes. This applies to the Xqcicm, Xqcics and Xqcicli instruction
patterns.

In order to match the existing codegen, minor additions had to be made
to `translateSetCCForBranch` to ensure that comparisons against specific
immediate values are left in a form that can be matched more closely by
the instructions. This prevents having to insert additional `li`
instructions and use the register forms.

There are a few slight regressions:
- There are sometimes more `mv` instructions than entirely necessary. I
believe these would not be seen with larger examples where the register
allocator has more leeway.
- In some tests where just one of the three extensions is enabled,
codegen falls back to using a branch over a move. With all three
extensions enabled (the configuration we most care about), these are not
seen.
- The generated patterns are very similar to each other - they have
similar complexity (7 or 8) and there are still overlaps. Sometimes the
choice between two instructions can be affected by the order of the
patterns in the tablegen file.

One other change is that Xqcicm instructions are prioritised over Xqcics
instructions where they have identical patterns. This is done because
one of the the Xqcicm instructions is compressible (`qc.mveqi`), while
none of the Xqcics instructions are.
2025-09-19 00:16:44 +00:00
Stanislav Mekhanoshin
6ac0abf8c4
[AMDGPU] gfx1251 VOP3 dpp support (#159654) 2025-09-18 16:18:09 -07:00
Stanislav Mekhanoshin
8cfbace7b2
[AMDGPU] gfx1251 VOP2 dpp support (#159641) 2025-09-18 15:38:29 -07:00
Craig Topper
cdd78989b8 [RISCV] Pass SDValue by value. NFC 2025-09-18 15:09:22 -07:00
Stanislav Mekhanoshin
e3c7b7f806
[AMDGPU] gfx1251 VOP1 dpp support (#159637) 2025-09-18 13:42:06 -07:00
Min-Yih Hsu
1cee4fa968
[RISCV] Update the vector integer division cycle in SiFive7 scheduling model (#159468)
Vector integer division in SiFive7 processes a single bit at a time up
to 4 elements. This patch updates to reflect this behavior.

Co-authored-by: Michael Maitland <michaeltmaitland@gmail.com>
2025-09-18 13:29:47 -07:00
Min-Yih Hsu
a3f901f70a
[RISCV] Update floating point load latency in SiFive7 scheduling model (#159462)
The latency of floating point loads in SiFive7 should be the same as
their integer counterparts.

Co-authored-by: Michael Maitland <michaeltmaitland@gmail.com>
2025-09-18 13:27:36 -07:00
AZero13
3ad40d1535
[AArch64] Use getNegative instead of manually sub with 0 (NFC) (#158511) 2025-09-18 12:07:44 -07:00
Shaoce SUN
c3383d74a7
[RISCV][GlobalIsel] Remove redundant sext.w for ADDIW (#159597)
This is the minimal case generated by clang at `-O0`; I'm not sure if
writing the test this way is appropriate.
2025-09-18 17:29:54 +00:00
Alexey Karyakin
bbcb5f421d
Shuffle patterns to vdeal + vpack (#159464)
Lowering shuffle patterns to vdeal + vpack caused an assertion because
the vdeal parameter value is negative but an unsigned one was expected.
2025-09-18 11:55:46 -05:00
Craig Topper
b405e3249b
[RISCV] Add MVendorID, MArchID, and MImpID for sifive-p550. (#159465) 2025-09-18 07:16:51 -07:00
Fabian Ritter
01b4b2a5b8
[AMDGPU][SDAG] Handle ISD::PTRADD in VOP3 patterns (#143881)
This patch mirrors similar patterns for ISD::ADD. The main difference is
that ISD::ADD is commutative, so that a pattern definition for, e.g.,
(add (mul x, y), z), automatically also handles (add z, (mul x, y)).
ISD::PTRADD is not commutative, so we would need to handle these cases
explicitly. This patch only implements (ptradd z, (op x, y)) patterns,
where the nested operation (shift or multiply) is the offset of the
ptradd (i.e., the right operand), since base pointers that are the
result of a shift or multiply seem less likely.

For SWDEV-516125.
2025-09-18 15:01:07 +02:00
Petar Avramovic
2ec7959b96
[AMDGPU][SIInsertWaitcnts] Track SCC. Insert KM_CNT waits for SCC writes. (#157843)
Add new event SCC_WRITE for s_barrier_signal_isfirst and s_barrier_leave,
instructions that write to SCC, counter is KM_CNT.
Also start tracking SCC for reads and writes.
s_barrier_wait on the same barrier guarantees that the SCC write from
s_barrier_signal_isfirst has landed, no need to insert s_wait_kmcnt.
2025-09-18 14:41:01 +02:00