47683 Commits

Author SHA1 Message Date
Changpeng Fang
3bc1e084ee AMDGPU: Created a subclass for the return address operand in the tail call return instruction
Summary:
  This is to avoid using the callee saved registers for the return address
of the tail call return instruction.

Reviewers:
  arsenm, cdevadas

Differential Revision:
  https://reviews.llvm.org/D147096
2023-04-10 10:53:33 -07:00
skc7
635c725b30 [AMDGPU][NFC] Regenerate test checks for merge-tbuffer.mir 2023-04-10 18:47:52 +05:30
mmarjano
f6e70ed1c7 [AMDGPU] Extend tbuffer_load_format merge
Add support for merging _IDXEN and _BOTHEN variants of
TBUFFER_LOAD_FORMAT instruction.
2023-04-10 12:24:21 +02:00
skc7
b434051dc8 [AMDGPU] Introduce SIInstrWorklist to process instructions in moveToVALU
Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D147168
2023-04-10 11:34:14 +05:30
Noah Goldstein
d65720652d [X86] Add inst fixup for unpckps -> unpckdq.
`unpckps` has the same performance as `unpckpd` (only port5) wereas
`unpckdq` can run on p15 on some newer architectures.

`unpckdq` is in the integer domain, so only do the transform if the
target has no bypass delay on shuffles (SKL+).

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D147729
2023-04-10 00:17:00 -05:00
Noah Goldstein
c3f01f13b1 [X86] Add inst fixup for unpckpd -> unpckqdq.
`unpckqdq` seems to be treated as a shuffle from bypass delay
perspective (which makes sense it appears to have shared shuffle units
for all micro-arch).

`unpckqdq` is slightly preferable to `shufpd` as it saves 1-byte of
code size and can be used to replace the micro-fused `rm` version. So,
if the target has no bypass delay, we should do `unpckpd` ->
`unpckqdq` instead of `shufpd.

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D147728
2023-04-10 00:16:57 -05:00
Noah Goldstein
2ce1698a34 [X86] Fix perf bug in permilps -> shufd in X86FixupInstTuning.
We shouldn't do the transformation if we either have bypass delay OR
the new opcode has worse performance. Previous code was incorrectly
using AND.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D147727
2023-04-10 00:16:54 -05:00
Noah Goldstein
e2f6527690 [X86] Improve inst tuning tests for X86FixupInstTuning Pass; NFC
1) Add tests for `unpckps`.
2) Add explicit test for fast shuffles (ICX+) but WITH bypass delay.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D147726
2023-04-10 00:16:48 -05:00
Ben Shi
aa18091124 [AVR][NFC] Fix errors in commit 6e57f68e41c92936b9ef3a4e6fb286e8805a9fbc 2023-04-10 11:17:06 +08:00
wangpc
267708f9d5 [MachineOutliner] Add IsOutlined to MachineFunction
We add a field `IsOutlined` to indicate whether a MachineFunction
is outlined and set it true for outlined functions in MachineOutliner.

Reviewed By: paquette

Differential Revision: https://reviews.llvm.org/D146191
2023-04-10 10:57:29 +08:00
Ben Shi
6e57f68e41 [AVR] Reject invalid LDD instruction with explicit error
We should reject "ldd Rn, X" with explicit error message
rather than "llvm_unreachable" in llvm's release build.

Fixes https://github.com/llvm/llvm-project/issues/62012

Reviewed By: Miss_Grape

Differential Revision: https://reviews.llvm.org/D147877
2023-04-10 10:34:45 +08:00
Sergei Barannikov
790252dfb3 [AMDGPU] Update mcp-overlap-after-propagation.mir test
The test was added in D69953, but since D67794 landed a bit later it no
longer catches the bug. Update the test to be representative again.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D146934
2023-04-09 01:09:00 +03:00
Matt Arsenault
7a1044c6af AMDGPU: Add baseline test for issue 61083 2023-04-08 07:09:44 -04:00
Matt Arsenault
2a9f1dad2c AMDGPU: Fix LiveVariables verifier error for values defined before SI_END_CF
GlobalISel happens to insert some constant materializes before SI_END_CF
in one test. These need to be excluded from AliveBlocks since they
are defined in the original block and used in the split block,
so they aren't fully alive through either block.

The case where the value defined in the first block which was originally used
in a later block is still broken.

Avoids a verifier error in a future patch.
2023-04-08 07:05:35 -04:00
Matt Arsenault
7ac3ab34cb AMDGPU: Fix missing MIR serialization for PSInputAddr/PSInputEnable
Resuming any mir test for a pixel shader would assert in the AsmPrinter.
2023-04-08 07:05:35 -04:00
Nathan Lanza
87c0f67739 [Outliner] Add an option to only enable outlining of patterns above a certain threshold
Outlining isn't always a win when the saved instruction count is >= 1.
The overhead of representing a new function in the binary depends on
exception metadata and alignment. So parameterize this for local tuning.

Reviewed By: paquette

Differential Revision: https://reviews.llvm.org/D136774
2023-04-08 02:12:40 -04:00
Amaury Séchet
5aa7ad369e [NFC] Add a new test case in add-and-not.ll 2023-04-07 22:38:54 +00:00
Ruiling Song
2ab6835f28 AMDGPU: mark SET_INACTIVE_* as convergent operation
set_inactive is actually a kind of operation that is passing certain
value from active threads to inactive threads. In later WWM operation,
the activated threads which were disabled before would read such
values passed to them by set_inactive operation. So I think the
set_inactive is a convergent operation.

Differential Revision: https://reviews.llvm.org/D147683
2023-04-07 09:10:43 +08:00
Ruiling Song
fc06a429aa AMDGPU: Add a test to show bad compilation to set_inactive
The set_inactive was originally inside a if branch, but was incorrectly
hoisted out of the loop. So the lanes that were disabled later after the
if() branch inside the loop were not set correctly. It should stay in
the if branch.

Differential Revision: https://reviews.llvm.org/D147682
2023-04-07 09:10:43 +08:00
LiaoChunyu
b6ea46fe72 [RISCV] Add DAG combine to fold (sub 0, (setcc x, 0, setlt)) -> (sra x , xlen - 1)
The result of sub + setcc is 0 or 1 for all bits.
The sra instruction get the same result.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D147538
2023-04-07 08:59:28 +08:00
Ben Shi
c8a2301555 [LoongArch] Optimize multiplication with immediates
Optimize "(mul r, c)" to "(SLLI (ALSL r, r, i0), i1)", in which
"c = (1 + (1 << i0)) << i1".

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D147428
2023-04-07 08:46:49 +08:00
Ben Shi
d9e884fe74 [LoongArch][NFC] Add tests of multiplication with immediates (for D147428)
Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D147427
2023-04-07 08:46:49 +08:00
Min-Yih Hsu
aee4399f58 [M68k] Add subtarget features for M68881/2 FPU
Note that technically both M68000/010 can use M68881, despite the fact
that usually only M68020 and newer ISAs are equipped with M68881/2.
M68040 and newer processors have builtin M68882.

Differential Revision: https://reviews.llvm.org/D147479
2023-04-06 11:09:23 -07:00
Luke Lau
ce397e500d [RISCV] Lower scalar_to_vector
Loads of fixed length vectors with irregular element counts are
sometimes emitted as a scalar load + scalar_to_vector.
Previously the scalar_to_vector wasn't legal and so was scalarized
further. This patch handles it by lowering it to a vmv.s.x.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D147608
2023-04-06 17:39:19 +01:00
Luke Lau
491573d144 [RISCV] Add tests for loads and stores of illegal fixed length vectors
I was investigating why getMemoryOpCost was so expensive for these fixed length vector types, so I've added these tests to see what was going on.
It looks like there's some room for codegen improvement before we adjust the cost model.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D147607
2023-04-06 17:39:15 +01:00
Nico Weber
72e01ef1f1 Revert "[AMDGPU] Add Lower Bound to PipelineSolver"
This reverts commit 3c42a58c4f20ae3b621733bf5ee6d57c912994a9.
Breaks tests on mac, see https://reviews.llvm.org/rG3c42a58c4f20ae3b621733bf5ee6d57c912994a9#1191724
2023-04-06 12:35:44 -04:00
Joe Nash
5c0c2bc1c8 [AMDGPU] NFC. Make preserve-hi16.ll test auto-generated 2023-04-06 11:50:27 -04:00
Simon Pilgrim
846712b0cb [DAG] combineSelect - select(i1,vXi1,vXi1) - only cast <X x i1> constants to iX pre-legalization or if its a legal type
Fixes #61524
2023-04-06 13:35:45 +01:00
Simon Pilgrim
93fb1bac67 [X86] LowerVectorAllEqual - don't attempt to match comparisons of float data
FCMP may use ISD::SETNE when nnan, we don't want to end up with cases where we mismatch signed zeros etc.

Thanks to @pengfei for the test case from D147688
2023-04-06 11:31:59 +01:00
Dmitry Makogon
3d7242f05e Reapply "[LSR] Preserve LCSSA when rewriting instruction with PHI user"
This reverts commit efd34ba60f3839b0a68b2e32ff9011b6823bc16f.

Reapplies 8ff4832679e1. Missed a failing test. Needed to just
update test checks.
2023-04-06 17:31:27 +07:00
Luke Lau
5f2145adf9 [RISCV] Use non-strided load if VL=1 for optimized zero stride loads
When optimizing vmv.s.x/vmv.v.x's of scalar loads, if VL is known to be
1 then we don't need to perform a stride of x0, and can just do a
regular load.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D147609
2023-04-06 11:22:14 +01:00
Simon Pilgrim
b29ec28fd6 [X86] MatchVectorAllZeroTest - fix bug when splitting vectors of large elements
DAG::SplitVector only works with vectors with even numbers of elements, when splitting vectors with large (illegal) element widths, we are likely to split down to <1 x iXXX>.

In such cases, pre-bitcast to a <X x i64> type to ensure splitting will always succeed.

Thanks to @alexfh for identifying this.
2023-04-06 10:55:38 +01:00
Luke Lau
2b24e7b5f7 [RISCV] Use tail agnostic policy more often when lowering insert_subvector
If we're inserting a fixed length subvector into a fixed length vector,
then we can use a tail agnostic policy as long as we're inserting up to
or past the end of the main vector.
I.e., because we're overwriting all of the main vector's tail elements,
and we don't care what the elements after that are.
As noted by Philip in https://reviews.llvm.org/D146711#4220341

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D147347
2023-04-06 10:31:45 +01:00
Luke Lau
889a99ee58 [RISCV] Move some vector tests to rvv directory. NFC
I personally find it handy to be able to run the check-llvm-codegen-riscv-rvv target to test anything that involves vector codegen, so this patch moves some more vector-based test cases into that directory to increase its coverage.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D147644
2023-04-06 10:28:41 +01:00
Ben Shi
acb4d143bd [AVR] Fix incorrect expansion of pseudo instructions LPMWRdZ/ELPMWRdZ
The 'ELPM' instruction has three forms:

--------------------------
| form        | feature  |
| ----------- | -------- |
| ELPM        | hasELPM  |
| ELPM Rd, Z  | hasELPMX |
| ELPM Rd, Z+ | hasELPMX |
--------------------------

The second form is always used in the expansion of pseudo instructions
LPMWRdZ/ELPMWRdZ. But for devices without ELPMX and with only ELPM,
only the first form can be used.

Reviewed By: aykevl, Miss_Grape

Differential Revision: https://reviews.llvm.org/D141264
2023-04-06 15:27:04 +08:00
Noah Goldstein
fd347ceac4 [X86] Add InstFixup for masked unpck{l|h}pd -> masked shufpd
This is a follow up D147507 which removed the prior transformation to
`shufps` which was incorrect as the mask was for 64-bit double
elements, not 32-bit float elements. Using `shufpd` for the
replacement, however, preserves the mask semantics and has the same
benefits as `shufps`.

Reviewed By: pengfei, RKSimon

Differential Revision: https://reviews.llvm.org/D147541
2023-04-06 01:36:42 -05:00
Piyou Chen
8d7c865c2e [RISCV] Support __builtin_nontemporal_load/store by MachineMemOperand
Differential Revision: https://reviews.llvm.org/D143361
2023-04-05 22:57:49 -07:00
Jessica Del
04317d4da7 [AMDGPU][GISel] Add inverse ballot intrinsic
The inverse ballot intrinsic takes in a boolean mask for all lanes and
returns the boolean for the current lane. See SPIR-V's
`subgroupInverseBallot()` in the [[ https://github.com/KhronosGroup/GLSL/blob/master/extensions/khr/GL_KHR_shader_subgroup.txt | GL_KHR_shader_subgroup extension ]].
This allows decision making via branch and select instructions with a manually
manipulated mask.

Implemented in GlobalISel and SelectionDAG, since currently both are supported.
The SelectionDAG required pseudo instructions to use the custom inserter.

The boolean mask needs to be uniform for all lanes.
Therefore we expect SGPR input. In case the source is in a
VGPR, we insert one or more `v_readfirstlane` instructions.

Reviewed By: nhaehnle

Differential Revision: https://reviews.llvm.org/D146287
2023-04-06 07:46:50 +02:00
Craig Topper
2c57868e2e [RISCV] Add vector load/store intrinsics to getTgtMemIntrinsic.
This constructs a proper memory operand for these intrinsics.

Segment load/store will be added in a separate patch.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D147119
2023-04-05 19:28:05 -07:00
Maryam Moghadas
6dbb2a717a [PowerPC] Update pr61315.ll to address D146632 failure
This patch is to update pr61315.ll what was needed as part of
D146632 and caused build failures.

Reviewed By: stefanp

Differential Revision: https://reviews.llvm.org/D147675
2023-04-05 21:24:59 -05:00
Yeting Kuo
6858a920b8 [RISCV] Support vector type strict_[su]int_to_fp and strict_fp_to_[su]int.
Also the patch loose the fixed vector contraint in llvm/lib/IR/Verifier.cpp.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D147380
2023-04-06 10:09:44 +08:00
Maryam Moghadas
cf0395f816 [PowerPC] Fix the xxperm swap requirements
This patch is to fix the xxperm vector operand swap condition so that the
single-use operand is in V2 to prevent copying, it also fixes the subtarget
condition to exploit the xpperm.

Reviewed By: stefanp

Differential Revision: https://reviews.llvm.org/D146632
2023-04-05 20:13:40 -05:00
Ilia Kuklin
9a9c6b8e75 [MSP430] Add CFI instructions for MSP430.
Implement emission of DWARF CFI instructions for MSP430. This includes descriptions of stack frame layout and location of callee-saved registers that could be used for backtracing.

Differential Revision: https://reviews.llvm.org/D146966
2023-04-05 15:53:01 -07:00
Matt Arsenault
7907fd4961 RegAllocFast: Fix dropping subreg indexes on unassigned subreg defs
This was assuming all register operands were assigned to physical registers.
This should ignore the operands which weren't assigned in this run.

Fixes #61134
2023-04-05 18:25:51 -04:00
Han Zhu
7ccd21ce4f [isel] Pre-commit test for pr61964 fix 2023-04-05 15:01:26 -07:00
Jeff Byrnes
3c42a58c4f [AMDGPU] Add Lower Bound to PipelineSolver 2023-04-05 14:54:59 -07:00
Jon Chesterfield
3c76e5f0c8 [amdgpu][nfc] Remove dead code associated with LDS lowering
Pass disabled since approximately D104962 for miscompiling openmp

The functions under ReplaceConstant miscompile phis as noted in D112717 and
have no users in tree other than the disabled pass. It seems likely it has no
users out of tree.

Deletes the test cases associated with the disabled pass as well.

Reviewed By: rampitec

Differential Revision: https://reviews.llvm.org/D147586
2023-04-05 22:24:22 +01:00
David Sherwood
4f66ca3fb7 [AArch64][SME] Disable ZA LDR/STR addressing optimisations
Since the same encoded offset is used for both the vector
select offset and the address offset we have to spot two
patterns simulatenously in the ldr/str intrinsic inputs, i.e.

vector select = base + off
address = base + (off * VL)

whereas currently we only look for the address pattern. I
don't think this is possible in tablegen, so I suspect we'll
have to do this manually as part of lowering or as a target
DAG combine. For now, I've removed these tablegen patterns
so that we at least do the correct thing even if the code
quality isn't great.

I've also changed some of the ldr/str tests to pass in the
same vector select pattern (base + off) as the address
pattern.

Differential Revision: https://reviews.llvm.org/D147433
2023-04-05 14:46:41 +00:00
Krzysztof Parzyszek
bd310a5cca [Hexagon] Remove -opaque-pointers=0 from tests
Two tests still had opaque-pointers=0:
(1) llvm/test/CodeGen/Hexagon/addrmode.ll
(2) llvm/test/CodeGen/Hexagon/swp-epilog-phi7.ll

Deleted (1) since it no longer exercised the original scenario, modified
(2) to reflect codegen changes.

This fixes https://github.com/llvm/llvm-project/issues/61928
2023-04-05 07:28:33 -07:00
Simon Pilgrim
d73d62c439 [X86] combinePredicateReduction - reuse LowerVectorAllEqual for all_of/any_of(vXi1 eq/ne) reductions 2023-04-05 13:42:02 +01:00