55755 Commits

Author SHA1 Message Date
Oliver Stannard
e1f8f84ace
[ARM] Fix frame chains with M-profile PACBTI (#110285)
When using AAPCS-compliant frame chains with PACBTI return address
signing, there ware a number of bugs in the generation of the frame
pointer and function prologues. The most obvious was that we sometimes
would modify r11 before pushing it to the stack, so it wasn't preserved
as required by the PCS. We also sometimes did not push R11 and LR
adjacent to one another on the stack, or used R11 as a frame pointer
without pointing it at the saved value of R11, both of which are
required to have an AAPCS compliant frame chain.

The original work of this patch was done by James Westwood, reviewed as
 #82801 and #81249, with some tidy-ups done by Mark Murray and myself.
2024-10-17 09:32:44 +01:00
Jinsong Ji
0bbdc76c86
[NVPTX] Allow MemTransferInst in adjustByValArgAlignment (#112462)
Before b7b28e770c46, AreSupportedUsers will skip
MemTransferInst, it may cause unexpected assertion.
https://godbolt.org/z/z5d691fj1
In b7b28e770c46, we start to allow MemTransferInst,
we should allow it in adjustByValArgAlignment too.
2024-10-16 20:02:44 -04:00
Luke Lau
e88bcc1204
[RISCV] Lower vector_splice on zvfhmin/zvfbfmin (#112579)
Similar to other permutation ops, we can just reuse the existing
lowering.
2024-10-16 21:40:18 +01:00
Michael Maitland
ae68d532f8
[RISCV][VLOPT] Allow propagation even when VL isn't VLMAX (#112228)
The original goal of this pass was to focus on vector operations with
VLMAX. However, users often utilize only part of the result, and such
usage may come from the vectorizer.

We found that relaxing this constraint can capture more optimization
opportunities, such as non-power-of-2 code generation and vector
operation sequences with different VLs.

---------

Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
2024-10-16 14:58:00 -04:00
Tex Riddell
875afa939d
[X86][CodeGen] Add base atan2 intrinsic lowering (p4) (#110760)
This change is part of this proposal:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294

Based on example PR #96222 and fix PR #101268, with some differences due
to 2-arg intrinsic and intermediate refactor (RuntimeLibCalls.cpp).

- Add llvm.experimental.constrained.atan2 - Intrinsics.td,
ConstrainedOps.def, LangRef.rst
- Add to ISDOpcodes.h and TargetSelectionDAG.td, connect to intrinsic in
BasicTTIImpl.h, and LibFunc_ in SelectionDAGBuilder.cpp
- Update LegalizeDAG.cpp, LegalizeFloatTypes.cpp, LegalizeVectorOps.cpp,
and LegalizeVectorTypes.cpp
- Update isKnownNeverNaN in SelectionDAG.cpp
- Update SelectionDAGDumper.cpp
- Update libcalls - RuntimeLibcalls.def, RuntimeLibcalls.cpp
- TargetLoweringBase.cpp - Expand for vectors, promote f16
- X86ISelLowering.cpp - Expand f80, promote f32 to f64 for MSVC

Part 4 for Implement the atan2 HLSL Function #70096.
2024-10-16 11:43:17 -07:00
Finn Plummer
835feaaf35
[DXIL] Add scalarization support for WaveReadLaneAt (#112570)
- Implement trivial scalarization for the `WaveReadLaneAt` DXIL
intrinsic
- Add test case to demonstrate the lowering path

Resolves #70104
2024-10-16 11:31:28 -07:00
David Green
569ad7cf34 [AArch64][GlobalISel] Move UseOutlineAtomics to a bool check. NFC
Similar to #111287, this moves the UseOutlineAtomics legalization rules to a
boolean predicate as opposed to needing the be nested functions.

There appeared to be a pair of redundant customIfs for s128 sizes (assuming
only scalars are supported).
2024-10-16 19:26:57 +01:00
Simon Pilgrim
b238c2b199 [X86] Regenerate test checks with vpternlog comments 2024-10-16 19:05:02 +01:00
Brox Chen
35e937b4de
[AMDGPU][True16][CodeGen] fp conversion in true/fake16 format (#101678)
fp conversion V_CVT_F_F/V_CVT_F_U instructions true16 format were
previously implemented using fake16 profile.

With the MC support inplace, correct and support these instructions in
true16/fake16 format in CodeGen
2024-10-16 12:26:01 -04:00
Brox Chen
7b4c8b35d4
[AMDGPU][True16][MC] VOP3 profile in True16 format (#109031)
Modify VOP3 profile and pesudo, and add encoding info for VOP3 True16
including DPP and DPP8 in true16 and fake16 format.

This patch applies true16/fake16 changes and asm/dasm changes to
V_ADD_NC_U16
V_ADD_NC_I16
V_SUB_NC_U16
V_SUB_NC_I16
2024-10-16 10:27:44 -04:00
Stefan Pintilie
dcc5ba4a4d
[PowerPC] Add missing patterns for lround when i32 is returned. (#111863)
The patch adds support for lround when the output type of the rounding
is i32.
The support for a rounding result of type i64 existed before this patch.
2024-10-16 10:25:09 -04:00
David Green
a3010c7791
[GlobalISel] Add boolean predicated legalization action methods. (#111287)
Under AArch64 it is common and will become more common to have operation
legalization rules dependant on a feature of the architecture. For
example HasFP16 or the newer CSSC integer min/max instructions, among
many others. With the current legalization rules this either means
adding a custom predicate based on the feature as in
`legalIf([=](const LegalityQuery &Query) { return HasFP16 && ...; }` or
splitting the legalization rules into pieces that place rules optionally
into them base on the features available.

This patch proposes an alternative where the existing routines like
legalFor(..) are provided a boolean predicate, which if false skips
adding the rule. It makes the rules cleaner and will hopefully allow
them to scale better as we add more features.

The SVE predicates for loads/stores I have changed to just be always
available. Scalable vectors without SVE have never been supported, but
it could also add a condition.
2024-10-16 14:43:28 +01:00
Michael Maitland
658ff0b84c
[RISCV][VLOPT] Add support for integer widening multiply instructions (#112204)
This adds support for these instructions and also tests getOperandInfo
for these instructions as well.
2024-10-16 09:37:27 -04:00
Simon Pilgrim
e839d2a60a [X86] andnot-patterns.ll - tweak #112425 test patterns to use separate source values for ANDNOT operands 2024-10-16 14:32:51 +01:00
VladiKrapp-Arm
df05512988
[ARM] Add test for thumb2-reduce-size NFC (#112333)
Check that t2MUL is reduced to tMUL
2024-10-16 13:50:19 +01:00
Sander de Smalen
11ed7f2d3c [AArch64] NFC: Regenerate aarch64-sve-asm.ll
It should use update_mir_test_checks.py instead of
update_llc_test_checks.py.
2024-10-16 12:38:55 +00:00
Simon Pilgrim
3e31e30a84 [X86] Add some basic test coverage for #112425 2024-10-16 13:27:04 +01:00
Lewis Crawford
f5f00764ab
[DAGCombiner] Fix check for extending loads (#112182)
Fix a check for extending loads in DAGCombiner,
where if the result type has more bits than the
loaded type it should count as an extending load.

All backends apart from AArch64 ignore this
ExtTy argument to shouldReduceLoadWidth, so this
change currently only impacts AArch64.
2024-10-16 13:23:46 +01:00
Simon Pilgrim
9ee9e0e3b2 [X86] Extend ANDNOT fold tests to cover all legal scalars and 256-bit vectors
Add tests to check what happens on i8/i16/i32 scalars (ANDN only has i32/i64 variants)
2024-10-16 11:15:36 +01:00
Benjamin Maxwell
4c28d21f6a
[AArch64] Avoid single-element vector fp converts in streaming[-compatible] functions (#112213)
The single-element vector variants of FCVTZS, FCVTZU, UCVTF, and SCVTF
are only supported in streaming[-compatible] functions with `+sme2p2`.

Reference:
-
https://developer.arm.com/documentation/ddi0602/2024-09/SIMD-FP-Instructions/FCVTZS--vector--integer---Floating-point-convert-to-signed-integer--rounding-toward-zero--vector--
-
https://developer.arm.com/documentation/ddi0602/2024-09/SIMD-FP-Instructions/UCVTF--vector--integer---Unsigned-integer-convert-to-floating-point--vector--
-
https://developer.arm.com/documentation/ddi0602/2024-09/SIMD-FP-Instructions/SCVTF--vector--integer---Signed-integer-convert-to-floating-point--vector--

Codegen will be improved in follow up patches.
2024-10-16 10:00:49 +01:00
Antonio Frighetto
d3a8363bec [X86] Do not elect to tail call if caller must preserve all registers
A miscompilation issue has been addressed with improved checking.

Fixes: https://github.com/llvm/llvm-project/issues/97758.
2024-10-16 09:54:08 +02:00
Antonio Frighetto
c137b3ee35 [X86] Introduce test for PR112098 (NFC) 2024-10-16 09:54:08 +02:00
Christudasan Devadasan
488d3924dd
[CodeGen][NewPM] Port EarlyIfConversion pass to NPM. (#108508) 2024-10-16 13:22:57 +05:30
Petar Avramovic
14d006c53c
AMDGPU/GlobalISel: Run redundant_and combine in RegBankCombiner (#112353)
Combine is needed to clear redundant ANDs with 1 that will be
created by reg-bank-select to clean-up high bits in register.
Fix replaceRegWith from CombinerHelper:
If copy had to be inserted, first create copy then delete MI.
If MI is deleted first insert point is not valid.
2024-10-16 09:43:16 +02:00
wanglei
4c2c177567
[LoongArch] Add options for annotate tablejump
This aligns with GCC. LoongArch kernel developers requested that this
option generate some corresponding relations in a section, including the
addresses of the jump instruction(jr) and the `MachineJumpTableEntry`.

Reviewed By: heiher

Pull Request: https://github.com/llvm/llvm-project/pull/102411
2024-10-16 11:58:00 +08:00
Finn Plummer
6d13cc9411
[HLSL] Implement WaveReadLaneAt intrinsic (#111010)
- create a clang built-in in Builtins.td
    - add semantic checking in SemaHLSL.cpp
    - link the WaveReadLaneAt api in hlsl_intrinsics.h
    - add lowering to spirv backend op GroupNonUniformShuffle
      with Scope = 2 (Group) in SPIRVInstructionSelector.cpp
    - add WaveReadLaneAt intrinsic to IntrinsicsDirectX.td and mapping
      to DXIL.td

    - add tests for HLSL intrinsic lowering to spirv intrinsic in
      WaveReadLaneAt.hlsl
    - add tests for sema checks in WaveReadLaneAt-errors.hlsl
    - add spir-v backend tests in WaveReadLaneAt.ll
    - add test to show scalar dxil lowering functionality

    - note that this doesn't include support for the scalarizer to
      handle WaveReadLaneAt will be added in a future pr

This is the first part #70104
2024-10-15 18:49:40 -07:00
Luke Lau
f6c23222a4
[RISCV] Promote fixed-length bf16 arith vector ops with zvfbfmin (#112393)
The aim is to have the same set of promotions on fixed-length bf16
vectors as on fixed-length f16 vectors, and then deduplicate them
similarly to what was done for scalable vectors.

It looks like fneg/fabs/fcopysign end up getting expanded because fsub
is now legal, and the default operation action must be expand.
2024-10-15 22:49:05 +01:00
Peter Collingbourne
3cab8827fd Revert "[AMDGPU] Serialize WWM_REG vreg flag (#110229)"
This reverts commit bec839d8eed9dd13fa7eaffd50b28f8f913de2e2.

Caused buildbot failures, e.g.
https://lab.llvm.org/buildbot/#/builders/52/builds/2928
2024-10-15 13:18:43 -07:00
Matt Arsenault
b0a25468fa
AMDGPU: Add baseline tests for flat-may-alias private atomic expansions (#109406) 2024-10-15 22:29:24 +04:00
Artem Belevich
7d7fb7ce5f
[NVPTX] restrict cvta.param use to kernels only. (#112278)
If `cvta.param` is used in regular functions, it may produce an
invalid pointer. It's unclear if it's a bug in ptxas or we're not using `cvta.param` correctly, but,
regardless of the underlying reason, the instruction has to be disabled for non-kernels, at least for now.
2024-10-15 10:45:12 -07:00
Vyacheslav Levytskyy
bfe84f7085
[SPIR-V] Implement support of the SPV_INTEL_split_barrier SPIRV extension (#112359)
This PR implements support of the SPV_EXT_arithmetic_fence SPIRV
extension
(https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/INTEL/SPV_INTEL_split_barrier.asciidoc)
and adds builtins from
https://registry.khronos.org/OpenCL/extensions/intel/cl_intel_split_work_group_barrier.html
2024-10-15 18:43:09 +02:00
Vyacheslav Levytskyy
8d8996dd1e
[SPIRV] Implement type deduction and reference to function declarations for indirect calls using SPV_INTEL_function_pointers (#111159)
This PR improves implementation of SPV_INTEL_function_pointers and type
inference for phi-nodes and indirect calls.
2024-10-15 18:42:51 +02:00
Vyacheslav Levytskyy
62d6fa830d
[SPIR-V] Support optimization of branching with analyzeBranch/removeBranch/insertBranch functions (#110653)
This PR fixes implementation of `SPIRVInstrInfo::analyzeBranch()` and
adds implementations of `SPIRVInstrInfo::removeBranch()` and
`SPIRVInstrInfo::insertBranch()` to support Branch Folding and If
Conversion optimization.

The attached test case failed before this PR due to report_fatal_error()
firing on missing implementation of `SPIRVInstrInfo::removeBranch()`.

The new test case is not able to pass spirv-val check at the moment due
to the issue described in
https://github.com/llvm/llvm-project/issues/110652 , this is not related
to this PR.

This PR also updates instructions definition in tablegen to set
isBranch=1 for relevant instructions.
2024-10-15 18:42:33 +02:00
Simon Pilgrim
ec78f0da0e [X86] combineAndNotOrIntoAndNotAnd - don't attempt with constant operands
Don't fold AND(X,OR(NOT(Z),C)) -> AND(X,NOT(AND(Z,C'))) as DAGCombiner will invert it back again.

Fixes #112347
2024-10-15 16:54:08 +01:00
Simon Pilgrim
a3a9ba8033 [X86] lowerShuffleAsVTRUNC - ensure we peek through bitcasts when looking for freely-concatable subvectors
Fixes #111611
2024-10-15 15:40:52 +01:00
Simon Pilgrim
64421eced2 [X86] shuffle-vs-trunc-512.ll - add missing AVX512BW FAST PERLANE/CROSSLANE check prefixes 2024-10-15 15:40:52 +01:00
Simon Pilgrim
e100e4afc9 [X86] Add test coverage for #111611 2024-10-15 15:23:03 +01:00
Simon Pilgrim
94eb97550a [X86] shuffle-vs-trunc-256.ll - regenerate test checks with vpternlog comments 2024-10-15 15:23:02 +01:00
Luke Lau
043f066a64
[RISCV][VLOPT] Fix operand check in isVectorOpUsedAsScalarOp (#112253)
A reduction instruction always has a passthru operand, so the scalar
operand should always be vs1 which is at index 3.

Even though the destination operand is also scalar, I think the passthru
will need to preserve all elements so I haven't included it.
2024-10-15 15:10:26 +01:00
Simon Pilgrim
b75f9f7b3a [X86[] fp128-libcalls-strict.ll - add missing fp80 libm declarations for completeness
Noticed while reviewing #110760
2024-10-15 14:53:40 +01:00
Simon Pilgrim
6e86496d2f [X86[] fp80-strict-libcalls.ll - add missing fp80 libm declarations for completeness
Noticed while reviewing #110760
2024-10-15 14:22:01 +01:00
c8ef
854ded9b24
Reapply "[DAG] Enhance SDPatternMatch to match integer minimum and maximum patterns in addition to the existing ISD nodes." (#112203)
This patch adds icmp+select patterns for integer min/max matchers in
SDPatternMatch, similar to those in IR PatternMatch.

Reapply #111774.

Closes #108218.
2024-10-15 21:07:06 +08:00
Sander de Smalen
f314e12494
[AArch64][SME] Fix iterator to fixupCalleeSaveRestoreStackOffset (#110855)
The iterator passed to `fixupCalleeSaveRestoreStackOffset` may be
incorrect when it tries to skip over the instructions that get the
current value of 'vg', when there is a 'rdsvl' instruction straight
after the prologue. That's because it doesn't check that the instruction
is still a 'frame-setup' instruction.
2024-10-15 11:56:40 +01:00
Paul Walker
d27394abf0
[LLVM][SelectionDAG] Ensure Constant[FP]SDnode only store references to scalar Constant{Int,FP}. (#111005)
This fixes a failure path when the use-constant-##-for-###-splat IR
options are enabled.
2024-10-15 10:56:41 +01:00
David Stenberg
97861981cc [LiveDebugVariables] Fix a DBG_VALUE reordering issue (#111124)
LDV could reorder reinserted fragment and non-fragment debug values for
the same variable (compared to the input order), potentially resulting
in stale values being presented.

For example, before:

  DBG_VALUE 1001, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 0, 16)
  DBG_VALUE 1002, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 16, 16)
  DBG_VALUE %0, $noreg, !13, !DIExpression()

After (without this patch):

  DBG_VALUE %stack.0, 0, !13, !DIExpression()
  DBG_VALUE 1002, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 16, 16)
  DBG_VALUE 1001, $noreg, !13, !DIExpression(DW_OP_LLVM_fragment, 0, 16)

It would also reorder DBG_VALUEs for different variables. Although that
does not matter for the debug information output, it resulted in some
noise in before/after pass diffs.

This should hopefully align so that instruction referencing and
DBG_VALUE emit debug instructions in the same order (see the
sdag-salvage-add.ll change).
2024-10-15 11:36:24 +02:00
Yingwei Zheng
8d8bb4032b
[Verifier] Verify attribute denormal-fp-math[-f32] (#112310)
Some typos are also fixed. Address
https://github.com/llvm/llvm-project/pull/112067#pullrequestreview-2363722447.
2024-10-15 17:32:16 +08:00
David Green
708b15413b [AArch64][GlobalISel] Add gisel run lines for more MULL tests. NFC 2024-10-15 08:32:17 +01:00
David Green
04546a0dd6
[GlobalISel] Support vector G_UNMERGE_VALUES in computeKnownBits. (#112172)
This adds computeKnownBits support for vector->vector G_UNMERGE_VALUES,
grabbing the known bits with an adjusted DemandedElts mask.
2024-10-15 08:23:05 +01:00
Phoebe Wang
08ddbab866
[X86][AMX] Fix missing stride register for tileloadd (#110226)
Fixes: #110190
2024-10-15 13:02:00 +08:00
Brandon Wu
ae7751f405
[RISCV][VCIX] Add a tied constraint between rd and rs3 in sf.v.xvv and sf.v.xvw instructions (#111630)
The instruction has the constraint, but the pseudo instruction is
missing.
2024-10-14 21:10:55 -07:00