60124 Commits

Author SHA1 Message Date
Pierre van Houtryve
2ad4e93ded
[AMDGPU][gfx1250] Use SCOPE_SE for stores that may hit scratch (#150586) 2025-07-28 11:40:56 +02:00
Florian Hahn
cad5328b00
[X86] Add late tail duplication tests with computed gotos.
Add a new test for post-regalloc tail duplication with computed gotos to
complement llvm/test/CodeGen/X86/tail-dup-computed-goto.mir.
2025-07-28 09:37:16 +01:00
Nikita Popov
525090e83c
Revert "[MIPS]Fix QNaNs in the MIPS legacy NaN encodings" (#150773)
Reverts llvm/llvm-project#139829.

We can't just randomly change the value of constants during lowering.

Fixes https://github.com/llvm/llvm-project/issues/149295.
2025-07-28 10:36:40 +02:00
Matt Arsenault
72b77c193f
AMDGPU: Avoid contraction in wwm allocation failure message (#150888) 2025-07-28 17:11:28 +09:00
Nikita Popov
fe0dbe0f29
[CodeGen] More consistently expand float ops by default (#150597)
These float operations were expanded for scalar f32/f64/f128, but not
for f16 and more problematically, not for vectors. A small subset of
them was separately set to expand for vectors.

Change these to always expand by default, and adjust targets to mark
these as legal where necessary instead.

This is a much safer default, and avoids unnecessary legalization
failures because a target failed to manually mark them as expand.

Fixes https://github.com/llvm/llvm-project/issues/110753.
Fixes https://github.com/llvm/llvm-project/issues/121390.
2025-07-28 09:46:00 +02:00
David Green
376326c660 [AArch64] Update some tests to use a more common check prefix. NFC
I'm just trying to more consistently use CHECK-SD and CHECK-GI.
2025-07-28 08:26:48 +01:00
Haohai Wen
07d396b6f5
[COFF] Set .llvmbc and .llvmcmd to metadata section (#150879)
Those are metadata sections for ELF but was not properly set for COFF.
2025-07-28 15:25:13 +08:00
Vikram Hegde
495774d6d5
Revert "[CodeGen][NPM] Stitch up loop passes in codegen pipeline" (#150883)
Reverts llvm/llvm-project#148114

will update with fixed PR.
2025-07-28 11:28:00 +05:30
Vikram Hegde
d35bf478a8
[CodeGen][NPM] Stitch up loop passes in codegen pipeline (#148114)
same as https://github.com/llvm/llvm-project/pull/133050

Co-authored-by : Oke, Akshat
<[Akshat.Oke@amd.com](mailto:Akshat.Oke@amd.com)>
2025-07-28 11:13:44 +05:30
ZhaoQi
80e0d41677
[LoongArch] Custom legalizing build_vector with same constant elements (#150584) 2025-07-28 09:50:35 +08:00
yingopq
778fb76e63
[Mips] Fix wrong ELF FP ABI info when inline asm was empty (#146457)
When Mips process emitStartOfAsmFile and updateABIInfo, it did not know
the real value of IsSoftFloat and STI.useSoftFloat(). And when inline
asm instruction was empty, Mips did not process asm parser, so it would
not do TS.updateABIInfo(STI) again and at this time the value of
IsSoftFloat is correct.

Fix #135283.
2025-07-28 09:07:51 +08:00
Mahesh-Attarde
bca80a00e7
[X86][GlobalISel] Add test for IS_FP_CLASS (#148816)
Test for PR https://github.com/llvm/llvm-project/pull/148801
2025-07-28 00:39:23 +02:00
Matt Arsenault
1c6e75cb98 AMDGPU: Fix test with broken checks
This was broken in 6118a254ff9acb4b54a6bdb952c088a792b679af

update_llc_test_checks behavior in the conflict case is dangerous
and terrible; it silently deletes all checks and inserts the unused
check prefixes at the bottom.
2025-07-27 10:31:54 +09:00
Philip Reames
f65b329d70 [IA] Fix a bug introduced by a recent refactoring
I had dropped the check for which intrinsics were supported.  This is
a quick fix to get tree back into an unbroken state, a cleaner change
may follow.
2025-07-26 11:46:15 -07:00
Fangrui Song
b22e22ebfa MC: Allocate initial fragment and define section symbol in changeSection
Reland #150574 with a MCStreamer::changeSection change:
In Mach-O, DWARF sections use Begin as a temporary label, requiring a label
definition, unlike section symbols in other file formats.
(Tested by dec978036ef1037753e7de5b78c978e71c49217b)

---

13a79bbfe583e1d8cc85d241b580907260065eb8 (2017) introduced fragment
creation in MCContext for createELFSectionImpl, which was inappropriate.
Fragments should only be created when using MCSteramer, not during
`MCContext::get*Section` calls.
`initMachOMCObjectFileInfo` defines multiple sections, some of which may
not be used by the code generator. This caused symbol names matching
these sections to be incorrectly marked as undefined (see
https://reviews.llvm.org/D55173).

The fragment code was later replicated in other file formats, such as
WebAssembly (see https://reviews.llvm.org/D46561), XCOFF, and GOFF.

This patch fixes the problem by moving initial fragment allocation from
MCContext::createSection to MCStreamer::changeSection.
While MCContext still creates a section symbol, the symbol is not
attached to the initial fragment. In addition,

* Move `emitLabel`/`setFragment` from `switchSection*` and
  overridden changeSection to `MCObjectStreamer::changeSection` for
  consistency.
* De-virtualize `switchSectionNoPrint`.
* test/CodeGen/XCore/section-name.ll now passes. XCore doesn't support
  MCObjectStreamer. I don't think the MCAsmStreamer output behavior
  change matters.

Pull Request: https://github.com/llvm/llvm-project/pull/150574
2025-07-26 00:05:10 -07:00
ZhaoQi
f2a4cc1dd0
[LoongArch] Avoid expanding build_vector containing insertion of undef elements (#150377) 2025-07-26 14:24:39 +08:00
Matt Arsenault
5f3eea7ef2
AMDGPU: Fix not folding splat immediate into VGPR MFMA src2 (#150628) 2025-07-26 13:54:49 +09:00
dyung
cb37916a25
Revert "MC: Allocate initial fragment and define section symbol in changeSection" (#150736)
Reverts llvm/llvm-project#150574

This is causing a test failure on AArch64 MacOS bots:
https://lab.llvm.org/buildbot/#/builders/190/builds/24187
2025-07-25 20:21:59 -07:00
Matt Arsenault
3f8a05893f
AMDGPU: Add a few mfma test with immediate splat src2 (#150627) 2025-07-26 11:58:54 +09:00
Matt Arsenault
110692b5cc
Mips: Add frexp intrinsic test (#148677) 2025-07-26 11:20:44 +09:00
Matt Arsenault
1461a1c3b8
DAG: Emit an error if trying to legalize read/write register with illegal types (#145197)
This is a starting point to have better legalization failure diagnostics
2025-07-26 10:54:59 +09:00
Matt Arsenault
a4bbfd532e
Mips: Add some llvm.sincos tests (#147465)
I guessed at some basic triples. Mips is also missing
tests for the basic sin and cos calls too.
2025-07-26 10:48:23 +09:00
Matt Arsenault
e4d5969d71
AMDGPU: Add tests with forced selection of mfmas to VGPR form (#150626)
Add some run lines to existing tests with VGPR selection enabled.
2025-07-26 09:45:59 +09:00
Hood Chatham
15b03687ff
[WebAssembly,clang] Add __builtin_wasm_test_function_pointer_signature (#150201)
Tests if the runtime type of the function pointer matches the static
type. If this returns false, calling the function pointer will trap.
Uses `@llvm.wasm.ref.test.func` added in #147486.

Also adds a "gc" wasm feature to gate the use of the ref.test
instruction.
2025-07-25 16:52:39 -07:00
Jeffrey Byrnes
6118a254ff
[AMDGPU] Allocate AVRegClass last (#146606)
This changes the RC priorities such that AVRegClass is the least
prioritized. These registers are less constrained than the VRegClass and
ARegClass as they can be either agpr or vgpr. Thus, assigning them last
removes unnecessary constraints from VRegClass and ARegClass
assignments, and allows the RA to make smarter decisions about whether
to use vgpr / agpr for AVRegClass.

We only have 5 bits for RC priorities, and we still want to prioritize
larger RCs over smaller ones. Since this new prioritization uses the 5th
bit for AVRegClass vs ARegClass / VRegClass, we only have 4 bits to
encode the size priorities. Previously, each RC with a distinct size,
had a distinct priority. However, this PR groups together multiple sizes
to the same priority. Currently, this will have no effect on
prioritization in practice because we only have one actually defined RC
per group per vector register type.

For example, a register class with 15 or 16 32bit registers will have
the same size priority (14). However, we only have VReg_512 (VReg_480
doesn't exist), so only one actual RC in VRegClass has this priority.
Similarly, we give register class with 17-32+ 32 bit registers a size
priority of 15, but we only have VReg_1024.

The effect of this PR is to prioritize first the vector register type
(VReg & Areg have top priority, then AVReg), with the size of the
register class having second priority.

Passes PSDB.

---------

Co-authored-by: Matt Arsenault <Matthew.Arsenault@amd.com>
2025-07-25 13:46:41 -07:00
Vigneshwar Jayakumar
56ae79a6ab
reland "[StructurizeCFG] Hoist and simplify zero-cost incoming else p… (#149744)
…hi values (#139605)"

This relands commit b11523b494b with the fix for llvm-buildbot failures
"clang-hip-vega20" and "openmp-offload-amdgpu-runtime-2". The reland
prevents hoisting the phi node which fixes the issue.

Original PR description:

The order of if and else blocks can introduce unnecessary VGPR copies.
Consider the case of an if-else block where the incoming phi from the
'Else block' only contains zero-cost instructions, and the 'Then' block
modifies some value. There would be no interference when coalescing
because only one value is live at any point before structurization.
However, in the structurized CFG, the Then value is live at 'Else' block
due to the path if→flow→else, leading to additional VGPR copies.

This patch addresses the issue by:
- Identifying PHI nodes with zero-cost incoming values from the Else
block and hoisting those values to the nearest common dominator of the
Then and Else blocks.
- Updating Flow PHI nodes by replacing poison entries (on the if→flow
edge) with the correct hoisted values.
2025-07-25 15:23:45 -05:00
Jasmine Tang
8e6a05d471
[WebAssembly] Added vectorized version of fexp10 to the supported list (#150564)
Fixes https://github.com/llvm/llvm-project/issues/117200.

The default behavior in TargetLoweringBase is only scalar floats on fexp
are supported by default, not the vectorized version. This PR adds
`ISD::FEXP10` to the supported list.
2025-07-25 12:30:59 -07:00
Changpeng Fang
400ce1a3d3
[AMDGPU] Support AMDGPUClamp for bf16 on gfx1250 (#150663)
Scalar version uses V_MAX_BF16_PSEUDO which is expanded to V_PK_MAX_BF16
with unused high bits. If V_PK_MAX_BF16 is produced directly instead
that creates problem with folding of the clamp into other scalar
instructions due to incompatible clamp bits.

FIXME-TRUE16: enable bf16 clamp with true16

---------

Co-authored-by: Stanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
2025-07-25 12:13:06 -07:00
Philip Reames
6564bf6a5e [RISCV] Rewrite tests to preserve test intent and simplify
Cleaning up tests in advance of pr #150049.
2025-07-25 12:01:32 -07:00
Helena Kotas
f169af3ba7
[HLSL] Fix detection of overlapping binding with unbounded array (#150547)
Fixes #150534
2025-07-25 09:41:20 -07:00
Matt Arsenault
74502168c4
AMDGPU: Convert some mfma tests to generated checks (#150607) 2025-07-25 23:42:53 +09:00
Jonathan Cohen
81bbe98abf
Revert "[AArch64][Machine-Combiner] Split gather patterns into neon regs to multiple vectors (#142941)" (#150505)
Reverting due to reported miscompiles, will reland once it is fixed.
2025-07-25 14:09:23 +01:00
Matt Arsenault
2b1ce25e21
AMDGPU: Fix -amdgpu-mfma-vgpr-form flag on gfx908 (#150599)
This should be ignored since there are no VGPR forms. This
makes it possible to flip the default for the flag to true.
2025-07-25 19:49:56 +09:00
Nikita Popov
129a35454c [WebAssemblyOptimizeReturned] Skip lifetime intrinsic uses
Replacing an alloca with a call result in a lifetime intrinsic
will cause a verifier error.

Fixes https://github.com/llvm/llvm-project/issues/150498.
2025-07-25 12:12:26 +02:00
Anatoly Trosinenko
6e04e1e164
[AArch64][PAC] Introduce AArch64::PAC pseudo instruction (#146488)
Introduce a pseudo instruction carrying address and immediate modifiers
as separate operands to be selected instead of a pair of `MOVKXi` and
`PAC[ID][AB]` . The new pseudo instruction is expanded in AsmPrinter, so
that `MOVKXi` is emitted immediately before `PAC[ID][AB]`. This way, an
attacker cannot control the immediate modifier used to sign
the value, even if address modifier can be substituted.

To simplify the instruction selection, select `AArch64::PAC` pseudo
using TableGen pattern and post-process its `$AddrDisc` operand by
custom inserter hook - this eliminates duplication of the logic for
DAGISel and GlobalISel. Furthermore, this improves cross-BB analysis in
case of DAGISel.
2025-07-25 13:10:37 +03:00
Qi Zhao
e3b5daf2db [LoongArch] Pre-commit tests for build_vector with same constant elements. NFC 2025-07-25 15:29:41 +08:00
Fangrui Song
1955a01d63
MC: Allocate initial fragment and define section symbol in changeSection
13a79bbfe583e1d8cc85d241b580907260065eb8 (2017) introduced fragment
creation in MCContext for createELFSectionImpl, which was inappropriate.
Fragments should only be created when using MCSteramer, not during
`MCContext::get*Section` calls.
`initMachOMCObjectFileInfo` defines multiple sections, some of which may
not be used by the code generator. This caused symbol names matching
these sections to be incorrectly marked as undefined (see
https://reviews.llvm.org/D55173).

The fragment code was later replicated in other file formats, such as
WebAssembly (see https://reviews.llvm.org/D46561), XCOFF, and GOFF.

This patch fixes the problem by moving initial fragment allocation from
MCContext::createSection to MCStreamer::changeSection.
While MCContext still creates a section symbol, the symbol is not
attached to the initial fragment.
In addition, move `emitLabel`/`setFragment` from `switchSection*` and
overridden changeSection to `MCObjectStreamer::changeSection` for
consistency.

* test/CodeGen/XCore/section-name.ll now passes. XCore doesn't support
  MCObjectStreamer. I don't think the MCAsmStreamer output behavior
  change matters.

Pull Request: https://github.com/llvm/llvm-project/pull/150574
2025-07-24 23:37:48 -07:00
Luke Lau
4b1ca9c072
[RISCV] Remove -riscv-enable-vl-optimizer flag (#149349)
The RISCVVLOptimizer has been enabled by default for a while now and I'm
not aware of any outstanding issues that might need it to be disabled.
This removes the -riscv-enable-vl-optimizer flag to reduce the number of
configurations we have to support.
2025-07-25 12:34:09 +08:00
Philip Reames
7c37722f19
[IA] Recognize repeated masks which come from shuffle vectors (#150285)
This extends the fixed vector lowering to support the case where the
mask is formed via shufflevector idiom.

---------

Co-authored-by: Luke Lau <luke_lau@icloud.com>
2025-07-24 21:11:38 -07:00
Jim Lin
4e3266fb6e
[RISCV] Implement load/store support for XAndesBFHCvt (#150350)
We use `lh` to load 2 bytes from memory into a gpr, then mask this gpr
with -65536 to emulate nan-boxing behavior, and then the value in gpr is
moved to fpr using `fmv.w.x`.
To move the value back from fpr to gpr, we use `fmv.x.w` and finally,
`sh` is used to store the lower 2 bytes back to memory.

If zfh is enabled at the same time, we can just use flh/fsw to
load/store bf16 directly.
2025-07-25 11:29:17 +08:00
Matt Arsenault
14e6390e84
AVR: Add llvm.sincos intrinsic test (#148601)
Mostly to test libcall behavior; f64 case is broken
2025-07-25 10:50:07 +09:00
Matt Arsenault
548ca9e976
AMDGPU: Fix asserting on non-register mfma src2 (#150552)
Also validate the subregister, although for the moment this
is redundant since we currently only process full copies.
2025-07-25 10:13:53 +09:00
Sudharsan Veeravalli
d3937e2d12
[RISCV] Pass sign-extended value to isInt check in expandMul (#150211)
In the `isInt` check that was added in #147661 we were passing the
zero-extended `uint64_t` value instead of the sign-extended one.
2025-07-25 05:47:09 +05:30
Deric C.
4ae2678372
[DirectX] Add support for vector type checking in DXIL Shader Flag Analysis (#150532)
Fixes #150482 by replacing all `Instruction.getType()` in
DXILShaderFlags.cpp with `Instruction.getType()->getScalarType()` to
account for vectors types as suggested by @bogner
2025-07-24 17:09:34 -07:00
Matt Arsenault
df5b483ccd
MSP430: Add test for llvm.exp10 intrinsic (#148605) 2025-07-25 09:01:17 +09:00
Changpeng Fang
d7a38a94cd
[AMDGPU] Support builtin/intrinsics for load monitors on gfx1250 (#150540) 2025-07-24 16:23:33 -07:00
Meredith Julian
be58069515
[LLVM][NVPTX] Upstream tanh intrinsic for libdevice (#149596)
Currently __nv_fast_tanhf() in libdevice maps to an nvvm intrinsic that
has not been upstreamed, which is causing issues when using the NVPTX
backend from upstream. Instead of upstreaming the intrinsic, we can
instead use the existing Intrinsic::tanh with the afn flag. This change
adds NVPTX backend support for ISD::TANH, adds auto-upgrade for the old
tanh_approx intrinsic to @llvm.tanh.f32 with afn flag so that libdevice
works properly upstream, and adds a basic codegen test and a case to the
auto-upgrade test.
2025-07-24 14:32:59 -07:00
Deric C.
e178e82c63
[DirectX] Do not flatten GEP chains for unsupported types (#150484)
Fixes #150463 by not processing GEPs for unsupported types such as
structs in the DXILFlattenArrays pass.
2025-07-24 13:36:36 -07:00
Stanislav Mekhanoshin
96e5eed92a
[AMDGPU] Select VMEM prefetch for llvm.prefetch on gfx1250 (#150493)
We have a choice to use a scalar or vector prefetch for an uniform
pointer. Since we do not have scalar stores our scalar cache is
practically readonly. The rw argument of the prefetch intrinsic is
used to force vector operation even for an uniform case. On GFX12
scalar prefetch will be used anyway, it is still useful but it will
only bring data to L2.
2025-07-24 13:22:50 -07:00
Stanislav Mekhanoshin
9deb7f6062
[AMDGPU] gfx1250 vmem prefetch target intrinsics and builtins (#150466) 2025-07-24 12:13:59 -07:00