89974 Commits

Author SHA1 Message Date
David Green
8f484ff2a0
[AArch64] Add FeatureUseFixedOverScalableIfEqualCost to Neoverse-V3 and Neoverse-V3ae (#179903)
This was missing from neoverse-v3 and neoverse-v3ae, but should be
present like neoverse-v2.
2026-02-05 17:55:49 +00:00
Justin Fargnoli
ca93dd399e
Reland "[NVPTX] Validate user-specified PTX version against SM version" (#179304)
Previous commit message: 

> Original commit message:
>
>>When users explicitly specify a PTX version via -mattr=+ptxNN that's
insufficient for their target SM, we now emit a fatal error. Previously,
we silently upgraded the PTX version to the minimum required for the
target SM.
>>
>>When no SM or PTX version is specified, we now use PTX 3.2 (the
minimum for the default SM 3.0) instead of PTX 6.0.
>
>The following commits should fix the failures that arose when I
previously tried to land this commit:
>

>9fc5fd0ad6
should address the llvm-nvptx*-nvidia-* build failures:
https://github.com/llvm/llvm-project/pull/174834#issuecomment-3742242651
>

>600514a637
should address the MLIR failures

---

The previous commit was reverted with
d23cb79ba497281de050ef609cb91b91058bf323 because the
[mlir-nvidia](https://lab.llvm.org/buildbot/#/builders/138/builds/24797)
and
[mlir-nvidia-gcc7](https://lab.llvm.org/buildbot/#/builders/116/builds/23929)
Buildbots were failing.

Those tests failed because MLIR's default SM was 5.0, which caused NVPTX
to target PTX ISA v4.0, which did not support the intrinsics used in the
failing tests.

243f011577193c99358ccc4142b296d4fa80ea11 should address this by bumping
MLIR's default SM to 7.5. Now, using MLIR's new default SM, NVPTX
targets the PTX ISA v6.3, which supports the intrinsics used in the
failing tests.
2026-02-05 17:42:41 +00:00
Simon Pilgrim
c662f11c7d
[X86] mayFoldIntoVector - ensure we check for custom lowering to logic/add/sub ops (#179988)
As noted on #174761 - we need to ensure custom lowering to logic/add/sub
ops might actually occur before assuming the node will have been on the
vector unit
2026-02-05 17:42:26 +00:00
Alexander Weinrauch
3b16468814
[AMDGPU] Global and Buffer loads to LDS should not increase lgkmcnt (#179305)
`global_load_lds` and `buffer_load to lds` do only increment `vmcnt` and
not touch `lgkmcnt`. This causes invalid `waitcnts` for some Triton
kernels, similar to the added lit tests.

Note that the change for buffer ops is not necesssary, i.e. the lit test
passes even before this PR, because it seems like `SIInsertWaitcnts`
does not use `LGKM_CNT` for buffer ops. But this change might prevent a
bug in the future.
2026-02-05 09:36:00 -08:00
SiliconA-Z
37aba1b5d4
[ARM] Set operation action for UMULO and SMULO as Custom if not Thumb1 (#154253)
We should specify a custom lowering for SMULO and UMULO like we do for
AArch64, but only if not Thumb 1 obviously.
2026-02-05 08:47:56 -08:00
anjenner
903a5ab93d
[AMDGPU] [GlobalISel] Add register bank legalize rules for G_FEXP2 (#179954)
Also G_INTRINSIC_TRUNC, G_INTRINSIC_ROUNDEVEN, G_FFLOOR, G_FCEIL, and
G_FLOG2.
2026-02-05 16:35:31 +00:00
Nick Sarnie
3a08424124
[SPIRV] Do not emit @llvm.used (#179498)
Extending the work from https://github.com/llvm/llvm-project/pull/162678
which skips `llvm.compiler.used`, we also need to skip processing of
`llvm.used`.

The OpenMP frontend puts an `addrspace(2)` variable in `llvm_used`, but
the `llvm.used` array type uses the generic AS `addrspace(4)` so there's
a `addrspacecast` from `2` to `4` inside the initalizer for `llvm.used`
which is illegal and errors in the backend.

There is
[discussion](https://github.com/llvm/llvm-project/pull/162678#issuecomment-3396735124)
in the above linked PR that the handing should be the same for
`llvm.used` and `llvm.compiler.used`, but `llvm.used` was not added to
minimize the scope of the PR.

This is required to use the OpenMP Device RTL with SPIR-V.

Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
2026-02-05 16:28:23 +00:00
Vigneshwar Jayakumar
2dcd75eb44
[AMDGPU] Fix missing waitcnt after buffer_wbl2 (#178316)
On GFX9, BUFFER_WBL2 is used to write back dirty cache lines and
requires an s_waitcnt vmcnt(0) afterwards to ensure completion.

This patch fixes by incrementing vmcnt for buffer_wbl2 instruction

---------

Co-authored-by: Jay Foad <jay.foad@gmail.com>
2026-02-05 10:13:51 -06:00
Luke Lau
63918f51aa
[RISCV] Fold vmerge into op with undef passthru by using vmerge's vl (#179862)
Currently we only fold an op into vmerge if we know the smaller of the
two vls, because we can't increase the vl.

However if the op's passthru is undef, then we can just use vmerge's vl
because the lanes past op's vl were undef anyway. We need to make sure
that the op doesn't access memory though. Other instructions where the
result depends on the VL should already be handled by the
RISCVII::elementsDependOnVL check below.

This is probably always profitable because even though we increase vl,
we remove a vmerge which needs to process vl elements anyway.

This removes some regressions in #179622.
2026-02-06 00:13:14 +08:00
Luke Lau
9ed7ba87c4
[RISCV] Remove redundant vand.vi with fpto*i to i1 (#179876)
If the source of an fpto*i doesn't fit in the destination type, the
result is poison. For i1 destinations, this means the result needs to be
0 or 1/-1, so we can just compare the result to 0 directly instead of
truncating.

The VP lowering for fpto*i already does this.
2026-02-06 00:06:32 +08:00
Nikita Popov
d3fb3c5d36
[GISel][CallLowering] Keep IR types longer (#179946)
GISel CallLowering currently does a Type -> EVT -> Type roundtrip early
on when populating ArgInfo in splitToValueType(). This is a bit odd as
this structure operates at the IR Type level. Keep the original type
there and only convert to EVT when performing assignments.
2026-02-05 16:37:08 +01:00
vangthao95
e0c2cc7ed0
[AMDGPU][GlobalISel] Add buffer store byte/short RegBankLegalize rules (#179367) 2026-02-05 07:18:39 -08:00
Craig Topper
bfbbed1327
[RISCV] Call updateCZceFeatureImplications from RISCVAsmParser::setFeatureBits. (#179870) 2026-02-05 07:03:26 -08:00
Matt Arsenault
2502e3b7ba
IR: Promote "denormal-fp-math" to a first class attribute (#174293)
Convert "denormal-fp-math" and "denormal-fp-math-f32" into a first
class denormal_fpenv attribute. Previously the query for the effective
denormal mode involved two string attribute queries with parsing. I'm
introducing more uses of this, so it makes sense to convert this
to a more efficient encoding. The old representation was also awkward
since it was split across two separate attributes. The new encoding
just stores the default and float modes as bitfields, largely avoiding
the need to consider if the other mode is set.

The syntax in the common cases looks like this:
  `denormal_fpenv(preservesign,preservesign)`
  `denormal_fpenv(float: preservesign,preservesign)`
  `denormal_fpenv(dynamic,dynamic float: preservesign,preservesign)`

I wasn't sure about reusing the float type name instead of adding a
new keyword. It's parsed as a type but only accepts float. I'm also
debating switching the name to subnormal to match the current
preferred IEEE terminology (also used by nofpclass and other
contexts).

This has a behavior change when using the command flag debug
options to set the denormal mode. The behavior of the flag
ignored functions with an explicit attribute set, per
the default and f32 version. Now that these are one attribute,
the flag logic can't distinguish which of the two components
were explicitly set on the function. Only one test appeared to
rely on this behavior, so I just avoided using the flags in it.

This also does not perform all the code cleanups this enables.
In particular the attributor handling could be cleaned up.

I also guessed at how to support this in MLIR. I followed
MemoryEffects as a reference; it appears bitfields are expanded
into arguments to attributes, so the representation there is
a bit uglier with the 2 2-element fields flattened into 4 arguments.
2026-02-05 13:31:26 +00:00
Paul Walker
96d2cb4145
[LLVM][CodeGen][DirectX] Fix scalarisation when vector ConstantFP is used. (#172684)
When using -use-constant-fp-for-fixed-length-splat `splat (float C)`
becomes ConstantFP(C) rather than ConstantVector(C, C, C...).
2026-02-05 13:18:38 +00:00
Phoebe Wang
744827e22f
[X86] Fixed truncated masked stores (#179853)
Fixes: #179489
2026-02-05 21:06:17 +08:00
paperchalice
d1598c96e0
[ARM] Recognize abi tag module flags (#161306)
Recognize abi tag hints from frontend rather than from architecture and
options.
Frontend part: #161106.
2026-02-05 12:08:22 +00:00
Paul Walker
fc0c707358
[NFC][LLVM][CodeGen][SVE] Restructure urshr related PatFrags. (#170521) 2026-02-05 11:09:31 +00:00
Acim Maravic
b0827f3b36
[LLVM] Select fma_mix for v_cvt_f32_f16 and v_add_f32/v_mul_f32 (#160151) 2026-02-05 11:51:25 +01:00
Graham Hunter
ad86f7dda3
[AArch64] Use brk{a,b} for a lane mask from cttz.elts (#178674)
cttz.elts is usually lowered (for SVE) to a brkb followed by a cntp. If
we then want a mask based on that (say, for early exit masking) then we
would use a whilelo from 0 to the result of cntp. But that just gives us
the same mask as the initial brkb, so we can just remove the cntp and
the whilelo.

Brka matches the extra +1 in the pattern.
2026-02-05 10:19:22 +00:00
Simon Pilgrim
9e052debf0
[X86] lower1BitShuffle - recognise a blend shuffle that can lower to AND/MASKZ pattern (#179717)
Part of the missed-optimisation mentioned on #179630 - if the shuffle is
a blend with zero, then lower as a ISD::AND pattern
2026-02-05 09:42:31 +00:00
YunQiang Su
209ff8bf06
MIPS: Fix unsigned compare with zero in MipsSEInstrInfo::copyPhysReg (#179866)
SrcRegOff >= 0 is not needed at all for unsigned.

This fixes the warning:
```
llvm/lib/Target/Mips/MipsSEInstrInfo.cpp: In member function ‘virtual void llvm::MipsSEInstrInfo::copyPhysReg(llvm::MachineBasicBlock&, llvm::MachineBasicBlock::iterator, const llvm::DebugLoc&, llvm::Register, llvm::Register, bool, bool, bool) const’:
llvm/lib/Target/Mips/MipsSEInstrInfo.cpp:245:48: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
  245 |       if (SrcRegOff == DestRegOff && SrcRegOff >= 0 && SrcRegOff <= 31)
      |                                      ~~~~~~~~~~^~~~
llvm/lib/Target/Mips/MipsSEInstrInfo.cpp:256:48: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
  256 |       if (SrcRegOff == DestRegOff && SrcRegOff >= 0 && SrcRegOff <= 31)
```
2026-02-05 17:09:22 +08:00
Benjamin Maxwell
c7dd96e6f2
[AArch64][SME] Add missing ZT0 transition (#179193)
This transition was missed off the switch, but is already supported (see
the test for the expected behavior).
2026-02-05 08:57:23 +00:00
Matt Arsenault
8461579298
AMDGPU: Add nofpclass when expanding pow (#177933)
The codegen regression is tracked in #177913
2026-02-05 07:40:21 +01:00
Jim Lin
79a26b9d65
[RISCV] Update Andes45 vector integer arithmetic scheduling info (#174538)
This PR adds latency/throughput for all RVV integer arithmetic to the
andes45 series scheduling model.
2026-02-05 13:07:33 +08:00
Chinmay Deshpande
93d99e3e54
[NFC][AMDGPU] Reorganize gfx125x features (#179843) 2026-02-04 20:46:08 -08:00
Craig Topper
fc56916a5d
[RISCV] Correct lowering of ISD::SETGE/SETULE/SETLE/SETUGE in lowerVPSetCCMaskOp. (#179801)
XOR should be OR to match the comment.

Found while reviewing #179622 which deletes this function. I would like
to commit this first so we have a correct baseline for reviewing that
patch.
2026-02-04 20:25:13 -08:00
Anshul Nigham
34523c200b
[NewPM] Port x86-lvi-load (#179371) 2026-02-04 19:02:00 -08:00
Akshay Deodhar
fab5b1858d
Reland "[NVPTX][AtomicExpandPass] Complete support for AtomicRMW in NVPTX (#176015)" (#179553)
This PR adds full support for atomicrmw in NVPTX. This includes:

- Memory order and syncscope support (changes in AtomicExpandPass.cpp,
NVPTXIntrinsics.td)

- Script-generated tests for integer and atomic operations
(atomicrmw.py, atomicrmw-sm*.ll in tests/CodeGen/NVPTX). Existing
atomics tests which are subsumed by these have been removed
(atomics-sm*.ll, atomics.ll, atomicrmw-expand.ll).

- ~~Changes shouldExpandAtomicRMWInIR to take a constant argument: This
is to allow some other TargetLowering constant-argument functions to
call it. This change touches several backends. An alternative solution
exists, but to me, this seems the "right" way.~~ Has been split out into
https://github.com/llvm/llvm-project/pull/176073. Rebased.

- NOTE: The initial load issued for atomicrmw emulation loops (and
cmpxchg emulation loops) must be a strong load. Currently,
AtomicExpandPass issues a weak load. Fixing this breaks several
backends. I'm planning to follow up with a separate PR.

Initially failed due to error: ptxas fatal   : Value 'sm_60' is not
defined for option 'gpu-name'. Updated RUN lines in atomicrmw-sm*.py to
skip the ptxas-verify check if ptxas does not support that SM version.
2026-02-04 16:15:49 -08:00
Sam Elliott
0cac3e381d
[CodeGen][TII] Delete analyzeSelect hook (#175828)
The only caller of this function (`PeepholeOptimizer::optimizeSelect`)
did not use most of the parameters, was broadly equivalent to
`MI->isSelect()`, and the `optimizeSelect` hook can return `nullptr`
anyway.

Update `optimizeSelect` to return `nullptr` by default rather than
asserting when not implemented.
2026-02-04 14:14:45 -08:00
Craig Topper
861d2e2dd3
[RISCV] Deprecate RISCVSubtarget::hasStdExtCOrZcd() and hasStdExtCOrZcfOrZce(). (#179762)
Replace with hasStdExtZcd() and hastStdExtZcf().

Creation of RISCVSubtarget/MCSubtargetInfo handles implication of Zcf
and Zcd now. The exception is .option arch handling which will require
+zcf and +zcd to be listed explicitly. I'll try to fix this in a follow
up. #155035 had the same issue.

I've left the error messages mentioning both Zcf and C+F/D. We can
consider changing that in a follow up.
2026-02-04 13:00:21 -08:00
Nicolai Hähnle
3e1e86ef1f
[AMDGPU] Return two MMOs for load-to-lds and store-from-lds intrinsics (#175845)
Accurately represent both the load and the store part of those intrinsics.

The test changes seem to be mostly fairly insignificant changes caused
by subtly different scheduler behavior.
2026-02-04 12:29:49 -08:00
Brian Cain
65c46fee1d
[Hexagon] Fix use-after-poison in balanceSubTree (#179239)
The balanceSubTree() function in HexagonISelDAGToDAG was accessing node
operands after recursive calls that could invalidate those nodes through
RAUW.

Use pre-captured Op0/Op1 values instead of re-accessing N's operands
after BST calls, add bounds checking before accessing node operands in
several places, check if nodes were RAUW'd before calling getHeight() on
them.
2026-02-04 13:40:12 -06:00
vporpo
d9da5d7626
[AMDGPU][SIInsertWaitcnt][NFC] Move eventCounter() function (#178949)
The eventCounter() function searches through the array of events. This
array is owned by the WaitcntGenerator class.

This patch moves the function into the WaitcntGenerator class which
helps hide the event array from the user.
It also renames it to getCounterFromEvent().

This should be NFC.
2026-02-04 11:11:18 -08:00
Jun Wang
b9b7b31e23
[AMDGPU][MC] Allow nodone etc. in exp instructions (#172749)
This patch allows nodone, nocompr, novm, and norow_en to be used in exp
instructions to indicate the corresponding modifiers are not present.
2026-02-04 10:29:07 -08:00
weiguozhi
9a47c3bcba
[RegAlloc] Change the computation of CSRCost (#177226)
This patch fixes https://github.com/llvm/llvm-project/issues/150737.

The original computed CSRCost is too small, so the optimization of
spilling instead of using CSR is rarely triggered.
    
Also the original cost model is too difficult to be understood and too
hard to be tuned by backend developers and users.
    
So this patch changes the CSRCost to be

        CSRCost = TRI->getCSRFirstUseCost() * EntryFreq * Scale
    
TRI->getCSRFirstUseCost() is the raw cost of save/restore a CSR. Usually
we don't need to tune this number.
   EntryFreq is the BlockFrequency of the entry block.
Scale is used to scale down the CSRCost, because we usually prefer a CSR
register instead of spilling if we have similar CSRCost and spill cost,
so it should be less than 100%. We usually tune this number.
    
Another problem is the original function RAGreedy::calcSpillCost()
actually computes a cost for block split, so this patch also implements
a correct RAGreedy::calcSpillCost() function.

This new behavior is not enabled by default. This optimization is used
by 3 targets (AArch64 / AMDGPU / RISCV), I will change them one by one
in following patches.
2026-02-04 10:08:57 -08:00
Craig Topper
6d96ae6aa8
[RISCV] Add tied destination constraint to CustomSiFiveVMACC. (#179567)
As the name suggess, these are multiply-accumulate instructions and
thus they have 3 sources.
2026-02-04 17:58:07 +00:00
Craig Topper
7083354fd6
[RISCV] Remove deprecated RISCVSubtarget::hasStdExtCOrZca(). NFC (#179616) 2026-02-04 09:49:44 -08:00
vangthao95
273ee97738
[AMDGPU][GlobalISel] Add G_SADDE/SSUBE RegBankLegalize rule (#179603) 2026-02-04 09:41:27 -08:00
Jay Foad
7ea33e6848
[CodeGen] Remove unused first operand of SUBREG_TO_REG (#179690)
The first input operand of SUBREG_TO_REG was an immediate that most
targets set to 0. In practice it had no effect on codegen. Remove it.
2026-02-04 17:35:21 +00:00
Craig Topper
265a994f4d
[RISCV] Add C/Zcf/Zcd/Zce implication rules to subtarget construction. (#179615)
This ensures the feature bits and RISCVSubtarget flags match what
RISCVISAInfo would do.

I'm not excited about the code duplication, but I need to set the
RISCVSubtarget flags along with calling ToggleFeature. I'll think about
how to improve this.
2026-02-04 09:32:11 -08:00
vangthao95
b0aea0539f
[AMDGPU][GlobalISel] Add buffer load format D16 RegBankLegalize rules (#179566) 2026-02-04 09:20:41 -08:00
Matt Arsenault
8a83911c40
AMDGPU: Fix incorrect fold of undef for llvm.amdgcn.trig.preop (#179025)
We were folding undef inputs to qnan which is incorrect. The instruction
never returns nan. Out of bounds segment select will return 0, so fold
undef segment to 0.
2026-02-04 17:56:55 +01:00
sujianIBM
8b28f5229e
[SystemZ][z/OS] Reverse the order of instructions to save and restore CSRs (#179540)
Reverse the order of instructions to save and restore CSRs so
instruction on small numbered reg goes first.
2026-02-04 11:48:09 -05:00
Islam Imad
3c0e3268a5
[X86] Lower i512 ADD/SUB using Kogge-Stone on AVX512 (#174761)
Closes #173996
2026-02-04 16:07:59 +00:00
sujianIBM
bc80d1ac0c
[SystemZ][z/OS] Set R5 as not restored. (#179666)
R5 (environment register) should not be restored. This is missing in the
code.
Add it back and also add a test to verify it.
2026-02-04 10:57:24 -05:00
Brox Chen
2e58f6024a
[AMDGPU][True16] t16 pseudo for mubuffer d16 load/store (#178822)
create t16 pseudos for mubuffer d16 load/store with vgpr16 in vdst/vdata
and use these t16 pseudo for isel pattern. Lower them back to d16
machine inst in mc level.
2026-02-04 10:54:11 -05:00
Tony Tao
637a038c04
[SystemZ][GOFF] Implement lowerConstant (#179394)
Implement lowerConstants for SystemZ and handle special cases where
entries need to be created in the ADA for static functions or VCon for
externals.

---------

Co-authored-by: Tony Tao <tonytao@ca.ibm.com>
2026-02-04 10:03:34 -05:00
Dmitry Sidorov
c487e248b9
[SPIR-V] Fix environment resolution causing legalization crash (#179052)
When the triple is spirv-unknown-unknown, SPIRVSubtarget::Env starts as
Unknown and was set via const_cast in SPIRVCallLowering when the first
entry point was lowered. This is too late: SPIRVLegalizerInfo has
already been constructed with, for example, the wrong vector size
limits, causing a crash (at best) or invalid SPIR-V generation.

Resolve the environment early in SPIRVPrepareFunctions::runOnModule() by
scanning the module for "hlsl.shader" attributes. Reinitialize the
legalizer and extended instruction sets after resolution. Remove the
const_cast lazy setting from SPIRVCallLowering.

Fixes: https://github.com/llvm/llvm-project/issues/171898
2026-02-04 15:27:48 +01:00
Simon Pilgrim
cc2b48f1e4
SPIRVInstructionSelector::selectExtractVal - add missing brackets to assertion condition to fix gcc -Wparentheses warning (#179656) 2026-02-04 14:02:25 +00:00