60637 Commits

Author SHA1 Message Date
Craig Topper
56289647be
[DAGCombiner] Preserve nuw when converting mul to shl. Use nuw in srl+shl combine. (#155043)
If the srl+shl have the same shift amount and the shl has the nuw flag,
we can remove both.

In the affected test, the InterleavedAccess pass will emit a udiv after
the `mul nuw`. We expect them to combine away. The remaining shifts on
the RV64 tests are because we didn't add the zeroext attribute to the
incoming evl operand.
2025-08-25 20:44:06 -07:00
Kane Wang
81740e0c97
[RISCV][GlobalISel] Legalize and select G_ATOMICRMW_ADD instruction (#153791)
This patch adds legalization and instruction selection support for the
`G_ATOMICRMW_ADD` opcode in the RISCV GlobalISel backend. Support for
other opcodes will be added in subsequent PRs.

Co-authored-by: Kane Wang <kanewang95@foxmail.com>
2025-08-25 20:38:41 -07:00
Carl Ritson
1f6648ccaa
[AMDGPU] AMDGPUPromoteAlloca: increase default max-regs to 32 (#155076)
Increase promote-alloca-to-vector-max-regs to 32 from 16.
This restores default promotion of 16 x double which was disabled by
#127973.

Fixes SWDEV-525817.
2025-08-26 09:30:16 +09:00
Josh Stone
e6ae4e689c
[PowerPC] Indicate that PPC32PICGOT clobbers LR (#154654)
This pseudo-instruction emits a local `bl` writing LR, so that must be
saved and restored for the function to return to the right place. If
not, we'll return to the inline `.long` that the `bl` stepped over.

This fixes the `SIGILL` seen in rayon-rs/rayon#1268.
2025-08-25 15:31:27 -07:00
Stanislav Mekhanoshin
94e4ef5f65
[AMDGPU] gfx1250 waitcnt related codegen tests update. NFC (#155317) 2025-08-25 15:23:59 -07:00
Stanislav Mekhanoshin
f3ea46a31b
[AMDGPU] Add few missing gfx1250 codegen tests. NFC (#155314) 2025-08-25 15:22:33 -07:00
Stanislav Mekhanoshin
f13a35c447
[AMDGPU] gfx1250 intrinscs codegen tests update. NFC (#155312) 2025-08-25 15:18:27 -07:00
Stanislav Mekhanoshin
68107bb360
[AMDGPU] gfx1250 run line in the fp atomics test. NFC (#155306) 2025-08-25 15:15:22 -07:00
Justin Fargnoli
33de41988f
Partial revert "[NVPTX] Enhance mul.wide and mad.wide peepholes #150477" (#155024)
Fix
https://github.com/llvm/llvm-project/pull/150477#issuecomment-3191367837

Undo `add (mul.wide a, b), c` -> `mad.wide a, b, c` instruction
selection pattern, but preserve `mul.wide` DAG combine.
2025-08-25 22:11:18 +00:00
Stanislav Mekhanoshin
43a9b666b6
[AMDGPU] gfx1250 trans instructions bf16 codegen tests update. NFC (#155310)
Co-authored-by: Shilei Tian <Shilei.Tian@amd.com>
2025-08-25 15:10:12 -07:00
Stanislav Mekhanoshin
efd8143c24
[AMDGPU] gfx1250 codegen load tests update. NFC. (#155305) 2025-08-25 15:09:41 -07:00
Stanislav Mekhanoshin
e903a6c2b5
[AMDGPU] gfx1250 SADDR tests update. NFC (#155307) 2025-08-25 15:07:15 -07:00
Stanislav Mekhanoshin
c6c48b4585
[AMDGPU] gfx1250 s_buffer_load tests. NFC. (#155295) 2025-08-25 14:32:50 -07:00
Stanislav Mekhanoshin
c8b46f3c5d
[AMDGPU] gfx1250 sram-ecc feature codegen tests. NFC. (#155293)
sram-ecc is always on.
2025-08-25 14:32:29 -07:00
Stanislav Mekhanoshin
b412d7d111
[AMDGPU] gfx1250 min/max codegen tests. NFC. (#155292) 2025-08-25 14:32:08 -07:00
joaosaffran
c6dfbc5cc7
[DirectX] Refactor RootSignature Backend to remove to_underlying from Root Parameter Header (#154249)
This patch is refactoring Root Parameter Header in DX Container backend
to remove the usage of `to_underlying`. This requires some changes:
first, MC Root Signature should not depend on Object/DXContainer.h;
Second, we need to assume data to be valid in scenarios where it was
originally not expected, this made some tests be removed.
2025-08-25 16:28:07 -04:00
Victor Mustya
6a5cb5afdc
[GISel] Fix crash in GlobalISel utils method (#153334)
The `getDefSrcRegIgnoringCopies` method in GlobalISel Utils crashed when
the first operand of the input instruction was not a register, e.g.,
the `INLINEASM` instruction has a non-register first operand.

---------

Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-08-25 12:59:01 -07:00
AZero13
79dfe48865
[ARM] Set isCheapToSpeculateCtlz as true for hasV5TOps and no Thumb 1 (#154848)
This is so that we don't expand to include unneeded 0 checks.

Also fix the logic error in LegalizerInfo so it is NOT legal on Thumb1
in Fast-ISEL.

Finally, Remove the README entry regarding this issue.
2025-08-25 12:43:48 -07:00
Alex MacLean
8ab917a241
Reland "[NVPTX] Legalize aext-load to zext-load to expose more DAG combines" (#155063)
The original version of this change inadvertently dropped
b6e19b35cd87f3167a0f04a61a12016b935ab1ea. This version retains that fix
as well as adding tests for it and an explanation for why it is needed.
2025-08-25 09:15:44 -07:00
RolandF77
d1cbe6ed74
[PowerPC] Add DMF builtins for build and disassemble (#153097)
Add support for PPC Dense Math builtins mma_build_dmr and
mma_disassemble_dmr builtins.
2025-08-25 12:14:55 -04:00
Jim Lin
296163f85d [RISCV] Add missing check lines for vwmulu_v64i32 in fixed-vectors-vwmulu.ll. NFC 2025-08-25 16:52:18 +08:00
Matt Arsenault
db024764c1
AMDGPU: Fix not diagnosing unaligned VGPRs for vsrc operands (#155104)
This was not checking the alignment requirement for 64-bit
operands which accept inline immediates. Not all custom operand
types were handled in the switch, so round out with explicit
handling of all enum values, and change the default to use
the default checks for unhandled cases.

Fixes #155095
2025-08-25 17:42:58 +09:00
Dharuni R Acharya
0263c15f87
[MLIR][NVVM] Add globaltimer_lo support in NVVM Dialect and NVPTX backend (#154672)
This patch adds support for reading the global timer low register in the
NVVM dialect and NVPTX backend. This change includes adding the
`NVVM_GlobalTimerLoOp` operation to NVVM dialect and 
`int_nvvm_read_ptx_sreg_globaltimer_lo` intrinsic to the NVPTX backend.

All the lit tests have been added.
2025-08-25 13:12:16 +05:30
hev
0437f08142
[LoongArch] Support PreserveMost calling convention (#154898)
This introduces the simplest implementation of the `PreserveMost`
calling convention, under which registers `r4-r31` are preserved, with
the exception of `r12-r15` (used by the PLT) and `r20-r21` (`r20` used
by the tail calls).

Related rust-lang/rust#145692
2025-08-25 14:15:58 +08:00
Jim Lin
1c1ec480b6 [RISCV] Add more common check prefixes to reduce the lines in half-convert-strict.ll. NFC.
To make it easier to see that the codegen is the same across different options.
2025-08-25 13:57:11 +08:00
tangaac
95a4c9c4f0
[LoongArch] Custom lower vecreduce_add. (#154304) 2025-08-25 09:06:39 +08:00
David Green
294ae1e115 [AArch64][GlobalISel] Mark G_TRAP, G_DEBUGTRAP and G_UBSANTRAP as legal. NFC
Similar to #153545 these nodes are always legal for AArch64, this patch marks
them so to reduce the dependency on the legacy legalizer ruleset.
2025-08-23 08:11:19 +01:00
Nicolai Hähnle
46762421c3
AMDGPU/GFX12: Do not wait unnecessarily before barriers (#154970)
The barrier intrinsic itself should not have memory semantics. Frontends
should use appropriate fence instructions for memory effects, and some
frontends want to rely on that for performance (e.g. wait only for LDS
before a barrier).

See the code comment for more detail.
2025-08-23 00:07:59 -07:00
Matt Arsenault
52ed03db59
AMDGPU: Simplify foldImmediate with register class based checks (#154682)
Generalize the code over the properties of the mov instruction,
rather than maintaining parallel logic to figure out the type
of mov to use. I've maintained the behavior with 16-bit physical
SGPRs, though I think the behavior here is broken and corrupting
any value that happens to be live in the high bits. It just happens
there's no way to separately write to those with a real instruction
but I don't think we should be trying to make assumptions around
that property.

This is NFC-ish. It now does a better job with imm pseudos which
practically won't reach here. This also will make it easier
to support more folds in a future patch.

I added a couple of new tests with 16-bit extract of 64-bit sources.
2025-08-23 02:13:50 +00:00
Matt Arsenault
65d12622fa
RuntimeLibcalls: Add entries for stackprotector globals (#154930)
Add entries for_stack_chk_guard, __ssp_canary_word, __security_cookie,
and __guard_local. As far as I can tell these are all just different
names for the same shaped functionality on different systems.

These aren't really functions, but special global variable names. They
should probably be treated the same way; all the same contexts that
need to know about emittable function names also need to know about
this. This avoids a special case check in IRSymtab.

This isn't a complete change, there's a lot more cleanup which
should be done. The stack protector configuration system is a
complete mess. There are multiple overlapping controls, used in
3 different places. Some of the target control implementations overlap
with conditions used in the emission points, and some use correlated
but not identical conditions in different contexts.

i.e. useLoadStackGuardNode, getIRStackGuard, getSSPStackGuardCheck and
insertSSPDeclarations are all used in inconsistent ways so I don't know
if I've tracked the intention of the system correctly.

The PowerPC test change is a bug fix on linux. Previously the manual
conditions were based around !isOSOpenBSD, which is not the condition
where __stack_chk_guard are used. Now getSDagStackGuard returns the
proper global reference, resulting in LOAD_STACK_GUARD getting a
MachineMemOperand which allows scheduling.
2025-08-23 10:21:00 +09:00
XChy
fd330dedcb
[DAG] Constant fold ISD::FSHL/FSHR nodes (#154480)
Fixes #153612.
This patch handles trinary scalar integers for FSHL/R in
`FoldConstantArithmetic`.
Pending until #153790 is merged.
2025-08-23 10:08:21 +09:00
Aiden Grossman
c87a29f650 Revert "[RISCV] Add test coverage for upcoming change to zicond select lowering"
This reverts commit 0c28482d91dbc80fb26990d0b4fac2974a72322e.

This took out a ton of buildbots because the test fails in most
configurations. Ex:
1. https://lab.llvm.org/buildbot/#/builders/185/builds/23944
2. https://lab.llvm.org/staging/#/builders/192/builds/1542
2025-08-22 21:34:28 +00:00
Joseph Huber
d439c9ea4a Revert "[NVPTX] Legalize aext-load to zext-load to expose more DAG combines (#154251)"
Causes failures in the LLVM libc test suite
https://lab.llvm.org/buildbot/#/builders/69/builds/26327/steps/12/logs/stdio.

This reverts commit a3ed96b899baddd4865f1ef09f01a83da011db5c.
2025-08-22 16:13:58 -05:00
Philip Reames
0c28482d91 [RISCV] Add test coverage for upcoming change to zicond select lowering 2025-08-22 13:48:06 -07:00
Peter Collingbourne
97716d2e31 Revert "CodeGen: Respect function align attribute if less than preferred alignment."
This reverts commit 9878ef3abd2a48fcfb81357d581dac292b52ddb3.

Needs more discussion of the semantics of the align attribute. See:
https://discourse.llvm.org/t/rfc-enhancing-function-alignment-attributes/88019
2025-08-22 13:17:53 -07:00
Kirill Vedernikov
533cc9a6ac
[NVPTX] Limit a sparsity selector in sparse MMA intrinsics. (#154984)
This PR fixes NVPTX tests in LLVM testing by adding more limitations for a sparsity selector in sparse MMA intrinsics. The previous PR that is merged to llvm:main is [PR150950](https://github.com/llvm/llvm-project/pull/150950). The merge
to llvm:main is d9c6b7b
2025-08-23 00:57:31 +05:30
Sam Elliott
f06b7f258e
[RISCV] Mark More Fatal Errors as Usage/Internal (#154876)
We have lots of uses of `report_fatal_error` in the backend, which will
result in a crash and a backtrace. This API has been replaced with
`reportFatalUsageError` and `reportFatalInternalError`, for which only
the latter emits a stack trace.

This tries to move the errors in RISCVISelLowering and RISCVRegisterInfo
to the new APIs, to prevent some stack traces where we specificially do
not support certain situations.

Updates #124132
2025-08-22 11:57:17 -07:00
Jasmine Tang
7fcee5fe08
[WebAssembly] Add support for avgr_u in loops (#153252)
Fixes https://github.com/llvm/llvm-project/issues/150550.

With the test case 
```
void f(unsigned char *x, unsigned char *y, int n) {
  // should have been vectorized into avgr_u instead of seperated vectorized add and logical right shift
  for (int i = 0; i < n; i++)
    x[i] = (x[i] + y[i] + 1) / 2;
}
```

the backend failed to recognize that this can be reduced to avgr_u since
the loop vectorizer doesn't transform into the existing pattern in
tablegen.

This PR sets AVGCEIL_U as legal for v8i16 and v16i8 and selects it to
avgr_u in the tablegen file.
2025-08-22 09:52:49 -07:00
Kirill Vedernikov
ee7826b5f9
[NVPTX] Add sparse MMA intrinsics (#150950)
This change adds intrinsics for MMA sparse. The implementation is based on PTX ISA version 8.8.
2025-08-22 20:08:19 +05:30
Anshil Gandhi
7dfd5ba811
[AMDGPU] Update codegen tests for PR #154069 (#154862) 2025-08-22 07:58:21 -06:00
Simon Pilgrim
2a79ef66eb
[AMDGPU] canCreateUndefOrPoisonForTargetNode - BFE_I32/U32 can't create poison/undef (#154932)
Add AMDGPUTargetLowering::canCreateUndefOrPoisonForTargetNode handler
and tag BFE_I32/U32 nodes as they can only propagate poison, not create
poison/undef.

Fighting some of the remaining regressions in #152107
2025-08-22 12:14:45 +00:00
paperchalice
2014890c09
[SelectionDAG] Remove UnsafeFPMath in visitFP_ROUND (#154768)
Remove `UnsafeFPMath` in `visitFP_ROUND` part, it blocks some bugfixes
related to clang and the ultimate goal is to remove `resetTargetOptions`
method in `TargetMachine`, see FIXME in `resetTargetOptions`.
See also
https://discourse.llvm.org/t/rfc-honor-pragmas-with-ffp-contract-fast

https://discourse.llvm.org/t/allowfpopfusion-vs-sdnodeflags-hasallowcontract

Now all UnsafeFPMath uses are eliminated in LLVMCodeGen
2025-08-22 19:46:33 +08:00
Simon Pilgrim
d8769bb5b7 [AMDGPU] bf16-conversions.ll - regenerate checks
Reduce diffs in #152107
2025-08-22 12:20:50 +01:00
tangaac
8439777131
[LoongArch] Pre-commit tests for vecreduce_and/or/... (#154879) 2025-08-22 17:52:43 +08:00
Abhinav Garg
bfc16510c7
[AMDGPU] Regenerate test case to cover gfx10 check lines. (#154909)
Check lines for GFX10 is missing in this test case. Regenerate to fix
test case.
2025-08-22 15:00:28 +05:30
Pierre van Houtryve
4ab5efd48d
[AMDGPU][gfx1250] Add memory legalizer tests (NFC) (#154725) 2025-08-22 10:14:09 +02:00
Matt Arsenault
2b46f31ee3
AMDGPU: Sign extend immediates for 32-bit subregister extracts (#154870)
extractSubregFromImm previously would sign extend the 16-bit subregister
extracts, but not the 32-bit. We try to consistently store immediates
as sign extended, since not doing it can result in misreported
isInlineImmediate checks.
2025-08-22 16:50:36 +09:00
Stanislav Mekhanoshin
e0945dfa30
[AMDGPU] Add test to show failure with SRC_*_HI registers. NFC. (#154828)
Since src_{private|shared}_{base|limit} registers are added and
are not artifical compiler happily uses it when it can. In HW
these registers do not exist and the encoding belongs to their
64-bit super-register or 32-bit low register. Same instructions
will produce relocation if run through asm.
2025-08-22 00:50:25 -07:00
paperchalice
945a186089
[DAGCombiner] Remove most UnsafeFPMath references (#146295)
This pull request removes all references to `UnsafeFPMath` in dag
combiner except FP_ROUND.
- Set fast math flags in some tests.
2025-08-22 15:27:25 +08:00
Matt Arsenault
b1b5102624
AMDGPU: Start considering new atomicrmw metadata on integer operations (#122138)
Start considering !amdgpu.no.remote.memory.access and
!amdgpu.no.fine.grained.host.memory metadata when deciding to expand
integer atomic operations. This does not yet attempt to accurately
handle fadd/fmin/fmax, which are trickier and require migrating the
old "amdgpu-unsafe-fp-atomics" attribute.
2025-08-22 05:29:36 +00:00