77363 Commits

Author SHA1 Message Date
Simon Pilgrim
5a896c66e3 [X86] Merge repeated getTargetLoweringInfo() calls. NFC. 2024-03-06 15:47:35 +00:00
Simon Pilgrim
f53c2f66a7 [X86] combineSetCC - use getZExtOrTrunc() to perform the constant folding. NFCI 2024-03-06 15:47:34 +00:00
Mirko Brkušanin
1fd1f4c0e1
[AMDGPU] Handle amdgpu.last.use metadata (#83816)
Convert !amdgpu.last.use metadata into MachineMemOperand for last use
and handle it in SIMemoryLegalizer similar to nontemporal and volatile.
2024-03-06 16:33:52 +01:00
Emma Pilkington
4490003a22
[AMDGPU] Rename COV module flag to amdhsa_code_object_version (#79905)
The previous name 'amdgpu_code_object_version', was misleading since
this is really a property of the HSA OS. The new spelling also matches
the asm directive I added in bc82cfb.
2024-03-06 09:51:48 -05:00
yandalur
f7d354af57
[Hexagon] Fix shift value when folding shl DAG node (#83853)
When folding (or (shl xx, s), (zext y)) to (COMBINE (shl xx, s-32), y),
fix resulting shift value in HexagonISD::COMBINE node to not generate
negative values.

---------

Co-authored-by: Yashas Andaluri <yandalur@qti.qualcomm.com>
2024-03-06 08:17:02 -06:00
Joseph Huber
1fc5e50ceb
[AMDGPU] Implement 'llvm.get.fpenv' and 'llvm.set.fpenv' (#83906)
Summary:
This patch implements the LLVM floating point environment control
intrinsics and also exposes it through clang. We encode the floating
point environment as a 64-bit value that simply concatenates the values
of the mode registers and the current trap status. We only fetch the
bits relevant for floating point instructions. That is, rounding mode,
denormalization mode, ieee, dx10 clamp, debug, enabled traps, f16
overflow, and active exceptions.
2024-03-06 08:11:54 -06:00
Shilei Tian
e9c1dbb408 Revert "[AMDGPU] Replace isInlinableLiteral16 with specific version (#81345)"
This reverts commit 530f0e64ec11327879c44f2fd55c7c28efdbaa2d because it breaks
downstream.
2024-03-06 08:42:54 -05:00
Yingchi Long
cf922e51b8
[BPF] lowering target address leaf nodes tconstpool (#73667)
Adds custom lowering for tconstpool.

Please ref: https://github.com/llvm/llvm-project/pull/73668 for test
coverage
2024-03-06 19:47:44 +08:00
Yuta Mukai
ea23761429
[AArch64] Verify ldp/stp alignment stricter (#84124)
When ldp-aligned-only/stp-aligned-only is specified, modified to cancel
ldp/stp transformation if MachineMemOperand is not present or the access
size is unknown.
In the previous implementation, the test passed when there was no
MachineMemOperand. Also, if the size was unknown, an incorrect value was
used or an assertion failed. (But actually, if there is no
MachineMemOperand, it will be excluded from the target by
isCandidateToMergeOrPair() before reaching the part.)

A statistic NumFailedAlignmentCheck is added. NumPairCreated is modified
so that it only counts if it is not canceled.
2024-03-06 20:19:56 +09:00
Pierre van Houtryve
52d5b8e02d
[AMDGPU] Don't form sext/abs/neg fp8 cvt (#83843)
gfx940 does not allow abs/sext/neg on v_cvt_fp8/bf8 & pk variants.

Fixes SWDEV-447468
2024-03-06 10:38:20 +01:00
Sameer Sahasrabuddhe
60822637bf Restore "Implement convergence control in MIR using SelectionDAG (#71785)"
This restores commit c7fdd8c11e54585dc9d15d63de9742067e0506b9.
Previously reverted in f010b1bef4dda2c7082cbb41dbabf1f149cce306.

LLVM function calls carry convergence control tokens as operand bundles, where
the tokens themselves are produced by convergence control intrinsics. This patch
implements convergence control tokens in MIR as follows:

1. Introduce target-independent ISD opcodes and MIR opcodes for convergence
   control intrinsics.
2. Model token values as untyped virtual registers in MIR.

The change also introduces an additional ISD opcode CONVERGENCECTRL_GLUE and a
corresponding machine opcode with the same spelling. This glues the convergence
control token to SDNodes that represent calls to intrinsics. The glued token is
later translated to an implicit argument in the MIR.

The lowering of calls to user-defined functions is target-specific. On AMDGPU,
the convergence control operand bundle at a non-intrinsic call is translated to
an explicit argument to the SI_CALL_ISEL instruction. Post-selection adjustment
converts this explicit argument to an implicit argument on the SI_CALL
instruction.
2024-03-06 12:19:32 +05:30
Visoiu Mistrih Francis
eceb24c439
[RISCV] Hoist immediate addresses from loads/stores (#83644)
In case of loads/stores from an immediate address, avoid rematerializing
the constant for every block and allow consthoist to hoist it to the
entry block.
2024-03-05 22:41:56 -08:00
David Majnemer
9e759f3523 [AArch64] Fix fptoi/itofp for bf16
There were a number of issues that needed to be addressed:
- i64 to bf16 did not correctly round
- strict rounding needed to yield a chain
- fastisel did not have logic to bail on bf16
2024-03-06 06:17:39 +00:00
AtariDreams
2a13422b8b
Convert many LivePhysRegs uses to LiveRegUnits (#83905) 2024-03-06 10:38:14 +05:30
Craig Topper
5fb331106d
[RISCV] Use uint32_t for NumOfVReg in getVLENFactoredAmount. (#84110)
The rest of the code pretty much assumed this anyway.
2024-03-05 20:59:07 -08:00
Matt Arsenault
0f3628a937
AMDGPU: Correct cycle counts for f64 mfma on gfx940 (#83782) 2024-03-06 09:36:01 +05:30
Heejin Ahn
403b9cf1bb
[WebAssembly] Use RefTypeMem2Local instead of Mem2Reg (#83196)
When reference-types feature is enabled, forcing mem2reg unconditionally
even in `-O0` has some problems described in #81575. This uses
RefTypeMem2Local pass added in #81965 instead. This also removes
`IsForced` parameter added in

890146b192
given that we don't need it anymore.

This may still hurt debug info related to reference type variables a
little during the backend transformation given that they are not stored
in memory anymore, but reference type variables are presumably rare and
it would be still a lot less damage than forcing mem2reg on the whole
program. Also this fixes the EH problem described in #81575.

Fixes #81575.
2024-03-05 19:54:41 -08:00
Wang Pengcheng
ae709c1929
[RISCV] Add TargetParser to MCA (#84109)
This fixes buildbot failures:
https://lab.llvm.org/buildbot/#/builders/57/builds/33206
2024-03-06 11:49:28 +08:00
Wang Pengcheng
85388a06b6
[RISCV] Move RISCVVType namespace to TargetParser (#83222)
Clang and some middle-end optimizations may need these helper
functions.

This can reduce some duplications.
2024-03-06 10:56:19 +08:00
Changpeng Fang
49ec8b747c
AMDGPU: Define and Use HasInterpInsts for interp inst definitions (#84102) 2024-03-05 18:26:37 -08:00
Kolya Panchenko
889d99a50f
[TTI] Add alignment argument to TTI for compress/expand support (#83516)
Since `llvm.compressstore` and `llvm.expandload` do require memory
access, it's essential for some target to check if alignment is good to
be able to lower them to target-specific instructions
2024-03-05 20:33:56 -05:00
Luke Lau
0207270494
[RISCV] Don't remove extends for i1 indices in mgather/mscatter (#83951) 2024-03-06 08:52:27 +08:00
Benjamin Kramer
55c466da2f [X86][AVX512BF16] Add a few missing insert/extract patterns
These are really the same as the f16 (and i16) instructions, but we need
them for any type that can occur.
2024-03-06 00:52:29 +01:00
Florian Mayer
6f11c95d06
Revert "[AArch64] Verify ldp/stp alignment stricter" (#84096)
Reverts llvm/llvm-project#83948

This broke the ASan buildbot:
https://lab.llvm.org/buildbot/#/builders/168/builds/19054/steps/10/logs/stdio
2024-03-05 15:52:09 -08:00
Changpeng Fang
d6c52c1e2d
AMDGPU: Define HasExpOrExportInsts for export instruction definitions. (#84083) 2024-03-05 15:32:32 -08:00
Craig Topper
58d8805ff9
[RISCV] Always use signed APSInt in getExactInteger. (#84070)
We were setting based on whether the FP value is positive/negative, but
we really want to know whether the resulting integer will be treated as
a signed or unsigned value. Since we use SINT_TO_FP to convert the
integer to FP, we should always used signed here.

Without this we convert +2147483648.0 to an integer 0x80000000 and
convert it using sint_to_fp which produces -2147483648.0.
2024-03-05 14:36:37 -08:00
Fangrui Song
201572e34b
[AArch64] Implement -fno-plt for SelectionDAG/GlobalISel
Clang sets the nonlazybind attribute for certain ObjC features. The
AArch64 SelectionDAG implementation for non-intrinsic calls
(46e36f0953aabb5e5cd00ed8d296d60f9f71b424) is behind a cl option.

GCC implements -fno-plt for a few ELF targets. In Clang, -fno-plt also
sets the nonlazybind attribute. For SelectionDAG, make the cl option not
affect ELF so that non-intrinsic calls to a dso_preemptable function use
GOT. Adjust AArch64TargetLowering::LowerCall to handle intrinsic calls.

For FastISel, change `fastLowerCall` to bail out when a call is due to
-fno-plt.

For GlobalISel, handle non-intrinsic calls in CallLowering::lowerCall
and intrinsic calls in AArch64CallLowering::lowerCall (where the
target-independent CallLowering::lowerCall is not called).
The GlobalISel test in `call-rv-marker.ll` is therefore updated.

Note: the current -fno-plt -fpic implementation does not use GOT for a
preemptable function.

Link: #78275

Pull Request: https://github.com/llvm/llvm-project/pull/78890
2024-03-05 13:55:29 -08:00
Changpeng Fang
bf631c63d0
AMDGPU: Copy SubtargetPredicate from pseudo for DSDIR_Real (#84057) 2024-03-05 13:49:34 -08:00
bwlodarcz
7de6f61a9d
[SPIR-V] Memory leak fix in SPIRVEmitIntrinsics (#83015)
The architecture of SPIRVEmitIntrinsics is build in such way that every
private method is called by one main function runOnFunction which then
calls private methods. Private member IRB is allocated in runOnFunction
method but it's not freed. Due to that every time when IR function
contains intrinsics to emit, runOnFunction is entered and memory is
leaked on exit. It's especially true when there are two or more IR
functions to emit. IRB is set to nullptr during construction of object
and it's left without pointing resource until runOnFunction is entered.
This also create possibility of simple mistake when private method is
called but there is no resource pointed. Change requires passing
IRBuilder by reference to private methods. The visit* functions create
it's own IRBuilder thus IRB is eliminated from class scope. In addition
there is a small performance improvement because IRBuilder is not
allocated by heap.
2024-03-05 12:57:11 -08:00
Neumann Hon
eccc71783c
[SystemZ] [z/OS] Emit offset to PPA2 in separate MCSection (#84043)
The ppa2list section isn't really part of the ppa2 section. The ppa2list
section contains the offset to the ppa2, and must be created with a
special section name (specifically, C_@@QPPA2). The binder searches for
a section with this name, then uses this value to locate the ppa2.

In GOFF terms, these are entirely separate sections; the PPA2 section
isn't even really a section but rather belongs to the code section. On
the other hand, the ppa2list section is a section in its own right and
resides in a separate TXT record.
2024-03-05 15:29:07 -05:00
Martin Wehking
d35f2c439a
Remove constant local variable (#83850)
Remove isThisReturn, which always has the value false.
Replace its uses with false directly.
2024-03-06 00:53:09 +05:30
Noah Goldstein
61c06775c9 [KnownBits] Add API for nuw flag in computeForAddSub; NFC 2024-03-05 12:59:58 -06:00
Farzon Lotfi
b2ca23aed8
[HLSL] implement exp intrinsic (#83832)
This change implements: #70072

- `hlsl_intrinsics.h` - add the `exp` api
- `DXIL.td` - add the llvm intrinsic to DXIL opcode lowering mapping.
- This change reuses llvm's existing intrinsic
`__builtin_elementwise_exp` \ `int_exp` & `__builtin_elementwise_exp2` \
`int_exp2`
- This PR is part 1 of 2.
- Part 2 requires an intrinsic to instructions lowering.
Part2 will expand `int_exp` to 
```
A = Builder.CreateFMul(log2eConst, val);
int_exp2(A)
```
just like we do in
[TranslateExp](https://github.com/microsoft/DirectXShaderCompiler/blob/main/lib/HLSL/HLOperationLower.cpp#L2220C1-L2236C2)
2024-03-05 12:42:33 -05:00
Farzon Lotfi
643b31dbe8
[HLSL] implement mad intrinsic (#83826)
This change implements #83736
The dot product lowering needs a tertiary multipy add operation. DXIL
has three mad opcodes for `fmad`(46), `imad`(48), and `umad`(49). Dot
product in DXIL only uses `imad`\ `umad`, but for completeness and
because the hlsl `mad` intrinsic requires it `fmad` was also included.
Two new intrinsics were needed to be created to complete this change.
the `fmad` case already supported by llvm via `fmuladd` intrinsic.

- `hlsl_intrinsics.h` - exposed mad api call.
- `Builtins.td` - exposed a `mad` builtin.
- `Sema.h` - make `tertiary` calls check for float types optional. 
- `CGBuiltin.cpp` - pick the intrinsic for singed\unsigned & float also
reuse `int_fmuladd`.
- `SemaChecking.cpp` - type checks for `__builtin_hlsl_mad`. 
- `IntrinsicsDirectX.td` create the two new intrinsics for
`imad`\`umad`/
- `DXIL.td` - create the llvm intrinsic to  `DXIL` opcode mapping.

---------

Co-authored-by: Farzon Lotfi <farzon@farzon.com>
2024-03-05 12:23:26 -05:00
Changpeng Fang
1b1aea7919
AMDGPU: Make s_wait_samplecnt(_bvhcnt) dependent on hasImageInsts, NFC (#83932) 2024-03-05 09:16:42 -08:00
Jeremy Morse
f33f66be7d [NFC][RemoveDIs] Always use iterators for inserting PHIs
It's becoming potentially unsafe to insert a PHI instruction using a plain
Instruction pointer. Switch all the remaining sites that create and insert
PHIs to use iterators instead. For example, the code in
ComplexDeinterleavingPass.cpp is definitely at-risk of mixing PHIs and
debug-info.
2024-03-05 17:00:12 +00:00
Ulrich Weigand
a8cb9db5f5
[SystemZ] Use proper relocation for TLS variable debug info (#83975)
Debug info refering to a TLS variable via DW_OP_GNU_push_tls_address
needs to use a R_390_TLS_LDO64 relocation instead of R_390_64.

Fixed by adding a SystemZELFTargetObjectFile override class and proving
a getDebugThreadLocalSymbol implementation.
2024-03-05 17:48:06 +01:00
Yuta Mukai
6b5888c27f
[AArch64] Verify ldp/stp alignment stricter (#83948)
When ldp-aligned-only/stp-aligned-only is specified, modified to cancel
ldp/stp transformation if MachineMemOperand is not present or the access
size is unknown.
In the previous implementation, the test passed when there was no
MachineMemOperand. Also, if the size was unknown, an incorrect value was
used or an assertion failed. (But actually, if there is no
MachineMemOperand, it will be excluded from the target by
isCandidateToMergeOrPair() before reaching the part.)

A statistic NumFailedAlignmentCheck is added. NumPairCreated is modified
so that it only counts if it is not cancelled.
2024-03-06 01:47:28 +09:00
Jay Foad
e49479b881
[AMDGPU] Remove unneeded BUF _impl multiclasses. NFC. (#84034)
Remove MUBUF_Real_gfx11_impl and others. By converting the underlying
class MUBUF_Real_gfx11 into a multiclass, the _impl wrapper is no longer
needed.
2024-03-05 16:35:29 +00:00
James Westwood
b2c16e7ff4
Revert "[ARM] R11 not pushed adjacent to link register with PAC-M and… (#84019)
… AAPCS frame chain fix (#82801)"

This reverts commit 00e4a4197137410129d4725ffb82bae9ce44bdde. This patch
was found to cause miscompilations and compilation failures.
2024-03-05 14:34:43 +00:00
bcahoon
4cf8b298cf
[AMDGPU][PromoteAlloca] Correctly handle a variable vector index (#83597)
The promote alloca to vector transformation assumes that the
vector index is a constant value. If it is not a constant, then
either an assert occurs or the tranformation generates an
incorrect index.
2024-03-05 08:18:17 -06:00
Jay Foad
894f52fc0d
[AMDGPU] Use BUF multiclasses to reduce repetition. NFC. (#84003)
Define BUF Real instructions with this general pattern for all
architectures (not just GFX11):

  multiclass Something_Real_gfx11<...> {
    defvar ps = !cast<Pseudo>(NAME);
    def _gfx11 : ...;
  }

This allows removing a huge amount of repetition in the definitions of
individual Real instructions, where they would have to !cast their own
name to a Pseudo and pass that in as a class argument.
2024-03-05 13:27:51 +00:00
Nikita Popov
e84182af91
[X86][Inline] Skip inline asm in inlining target feature check (#83820)
When inlining across functions with different target features, we
perform roughly two checks:
 1. The caller features must be a superset of the callee features.
2. Calls in the callee cannot use types where the target features would
change the call ABI (e.g. by changing whether something is passed in a
zmm or two ymm registers). The latter check is very crude right now.

The latter check currently also catches inline asm "calls". I believe
that inline asm should be excluded from this check, as it is independent
from the usual call ABI, and instead governed by the inline asm
constraint string.

Fixes https://github.com/llvm/llvm-project/issues/67054.
2024-03-05 14:21:33 +01:00
Paul Walker
341d674b6f
[LLVM][AArch64][CodeGen] Mark FFR as a reserved register. (#83437)
This allows the removal of FFR related psuedo nodes that only existed to
work round machine verifier failures.
2024-03-05 12:34:15 +00:00
Jay Foad
67a7a5e89d [AMDGPU] Only use the BUF Base_ prefix for multiple architectures. NFC.
The Base_ prefix seems redundant on a class that is only used for GFX11.
2024-03-05 12:01:45 +00:00
Jay Foad
4693efe19c
[AMDGPU] Remove Base_MUBUF_Real_Atomic_gfx11. NFC. (#83994)
This class only existed to set the dlc bit for GFX11 atomics. It is
simpler to set dlc for all loads/stores/atomics in the base class.
2024-03-05 11:58:17 +00:00
Benjamin Kramer
20895965b2 [NVPTX] Remove sub.s16x2 instruction
According to the PTX ISA this doesn't exist (and ptxas rejects it)

See https://github.com/pytorch/pytorch/issues/118589
2024-03-05 12:43:02 +01:00
Jay Foad
762f762504
[AMDGPU] Rename get_MUBUF_ps and use it for MTBUF too. NFC. (#83991)
This allows removing a couple of MTBUF helper (multi)classes.
2024-03-05 11:21:38 +00:00
Graham Hunter
56abb8d535 [AArch64] Be stricter about insert/extract index
Post-commit fixup patch for a request on
https://github.com/llvm/llvm-project/pull/81135
2024-03-05 09:50:32 +00:00
Wang Pengcheng
3cb999c413
[RISCV] Remove note of Sscofpmf and add a newline after FeatureStdExtSscofpmf (#83958)
To address comments after committing #83831.
2024-03-05 14:26:54 +08:00