52796 Commits

Author SHA1 Message Date
Pravin Jagtap
edb9fab390 [AMDGPU] Support FMin/FMax in AMDGPUAtomicOptimizer.
Reviewed By: arsenm, #amdgpu

Differential Revision: https://reviews.llvm.org/D157388
2023-08-30 12:11:11 -04:00
Pravin Jagtap
6ef6c954c6 [AMDGPU] Reorder atomic optimizer to avoid CAS loop.
Expand-Atomic pass emits the CAS loop for FP operations
which limits the optimizations offered by atomic optimizer.

Moving atomic optimizer before expand-atomics allows
better codegen.

Reviewed By: arsenm, #amdgpu

Differential Revision: https://reviews.llvm.org/D157265
2023-08-30 12:05:21 -04:00
Pravin Jagtap
f09360d20d [AMDGPU] Support FAdd/FSub global atomics in AMDGPUAtomicOptimizer.
Reduction and Scan are implemented using `Iterative`
and `DPP` strategy for `float` type.

Reviewed By: arsenm, #amdgpu

Differential Revision: https://reviews.llvm.org/D156301
2023-08-30 11:57:48 -04:00
Matt Arsenault
6012fed6f5 AMDGPU: Fix sqrt fast math flags spreading to fdiv fast math flags
This was working around the lack of operator| on FastMathFlags. We
have that now which revealed the bug.
2023-08-30 11:53:05 -04:00
Amara Emerson
c95ed6e492 [GlobalISel] Try to commute G_CONSTANT_FOLD_BARRIER LHS operands to RHS.
Differential Revision: https://reviews.llvm.org/D159097
2023-08-30 08:07:22 -07:00
Luke Lau
3a4ad45a2c [DAGCombiner] Combine trunc (splat_vector x) -> splat_vector (trunc x)
From the discussion in https://reviews.llvm.org/D158853, moving the truncate
into the splat helps more splatted scalar operands get selected on RISC-V, and
also avoids the need for splat_vector_parts on RV32.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D159147
2023-08-30 15:22:57 +01:00
Matt Arsenault
aa539b128f AMDGPU: Add baseline tests for libcall recognition of pow/powr/pown 2023-08-30 10:10:03 -04:00
OverMighty
38c92c1ee2 [AArch64] Add patterns for FMADD, FMSUB
FMADD, FMSUB instructions perform better or the same compared to indexed
FMLA, FMLS.

For example, the Arm Cortex-A55 Software Optimization Guide lists "FP
multiply accumulate" FMADD, FMSUB instructions with a throughput of 2
IPC, whereas it lists "ASIMD FP multiply accumulate, by element" FMLA,
FMLS with a throughput of 1 IPC.

The Arm Cortex-A77 Software Optimization Guide, however, does not
separately list "by element" variants of the "ASIMD FP multiply
accumulate" instructions, which are listed with the same throughput of 2
IPC as "FP multiply accumulate" instructions.

Reviewed By: samtebbs, dzhidzhoev

Differential Revision: https://reviews.llvm.org/D158008
2023-08-30 12:39:04 +02:00
Luke Lau
976244bb84 [RISCV] Canonicalize vrot{l,r} to vrev8 when lowering shuffle as rotate
A rotate of 8 bits of an e16 vector in either direction is equivalent to a
byteswap, i.e. vrev8. There is a generic combine on ISD::ROT{L,R} to
canonicalize these rotations to byteswaps, but on fixed vectors they are
legalized before they have the chance to be combined. This patch teaches the
rotate vector_shuffle lowering to emit these rotations as byteswaps to match
the scalable vector behaviour.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D158195
2023-08-30 11:01:49 +01:00
Luke Lau
a61c4a0ef6 [RISCV][SelectionDAG] Lower shuffles as bitrotates with vror.vi when possible
Given a shuffle mask like <3, 0, 1, 2, 7, 4, 5, 6> for v8i8, we can
reinterpret it as a shuffle of v2i32 where the two i32s are bit rotated, and
lower it as a vror.vi (if legal with zvbb enabled).
We also need to make sure that the larger element type is a valid SEW, hence
the tests for zve32x.

X86 already did this, so I've extracted the logic for it and put it inside
ShuffleVectorSDNode so it could be reused by RISC-V. I originally tried to add
this as a generic combine in DAGCombiner.cpp, but it ended up causing worse
codegen on X86 and PPC.

Reviewed By: reames, pengfei

Differential Revision: https://reviews.llvm.org/D157417
2023-08-30 11:01:47 +01:00
Dinar Temirbulatov
73e3866acb [AArch64][SME] Promote mask for masked load to a similar type size with load value.
The legalizer could keep an original mask type of masked load combined with
sign/zero extend, but we have to extend the mask to a type similar to our
combined load otherwise instruction selection could not lower the load.

Differential Revision: https://reviews.llvm.org/D158386
2023-08-30 08:54:46 +00:00
Qiu Chaofan
21bea1a208 [PowerPC] Support initial-exec TLS relocation on AIX
Add TLS_IE relocation type to XCOFF writer, and emit code sequence for
initial-exec TLS variables.

Reviewed By: lkail

Differential Revision: https://reviews.llvm.org/D156292
2023-08-30 16:22:16 +08:00
Yingwei Zheng
3521677994
[RISCV] Add pre-commit tests for D158759 2023-08-30 15:36:47 +08:00
Jingu Kang
82e851a407 [AArch64] Change bound for known zero bits of uaddlv intrinsic
As @efriedma's comment, the largest number of bits that can actually be set
for a v8i8 is 11 (the number of bits set in 8*255) so we can change the bound.
Additionally, v16i8 type is supported as v8i8.

Differential Revision: https://reviews.llvm.org/D158613
2023-08-30 08:21:13 +01:00
Garvit Gupta
fdef7952cb [RISCV] Fix assertion failure when zcmp extension is enabled.
Before accessing "getOpcode" thorugh machine instruction, check if the iterator
has reached the end of Machine basic block otherwise we will crash at the
assertion `!NodePtr->isKnownSentinel()`.

The above assertion is hit in "Prologue/Epilogue Insertion & Frame Finalization
pass".

Reviewed By: craig.topper, wangpc

Differential Revision: https://reviews.llvm.org/D158256
2023-08-29 22:06:30 -07:00
Chen Zheng
732f63d96d [PowerPC]set default min-jump-table-entries to 64 on PPC
Reviewed By: nemanjai

Differential Revision: https://reviews.llvm.org/D159050
2023-08-29 21:42:22 -04:00
Chen Zheng
833b1e307f [NFC] add testcase for MinimumJumpTableEntries change on PowerPC. 2023-08-29 21:13:50 -04:00
Daniel Hoekwater
0982d96186 [CodeGen][AArch64] Don't split inline asm goto blocks or their targets
Machine function splitting + branch relaxation currently don't properly
handle inline asm goto blocks that conditional branch to cold goto
labels. While such inline asm is technically invalid, machine
function splitting is the only thing that exposes it as such.

Since machine function splitting doesn't help too much in these
circumstances anyway, disable it for asm goto blocks and their targets.

Differential Revision: https://reviews.llvm.org/D158647
2023-08-29 20:24:38 +00:00
Craig Topper
7b5cf52f32 [RISCV] Improve splatPartsI64WithVL for fixed vector constants where Hi and Lo are the same and the VL is constant.
If doubling the VL will fit in a vsetivli, use it. It will be cheap
to change and cheap to change back.

This improves codegen from D158896.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D158896
2023-08-29 09:27:48 -07:00
Craig Topper
299b1b4071 [SelectionDAG][RISCV] Teach getConstant to use SPLAT_VECTOR_PARTS if vXi64 SPLAT_VECTOR is legal but i64 scalars are not.
That matches how such a SPLAT_VECTOR would have been type legalized
so assume it is ok to use for creating constants after type legalization.

Still need some improvements to SPLAT_VECTOR lowering.

This overlaps with some of what D158742 was trying to fix.

Reviewed By: luke

Differential Revision: https://reviews.llvm.org/D158870
2023-08-29 09:22:17 -07:00
Danila Malyutin
2fce8f74b3 [CodeGen][AArch64] Commit test for #65044 2023-08-29 19:06:24 +03:00
Simon Pilgrim
4b383107fa [X86] combineConcatVectorOps - support concatenation of 128->256-bit X86ISD::PCMPEQ/PCMPGT nodes on AVX2+ targets
Only bother if one of the ops is free to concat (most likely compare with constant).
2023-08-29 14:33:22 +01:00
Simon Pilgrim
2a82da8097 [X86] combineConcatVectorOps - handle splatting of a X86ISD::SUBV_BROADCAST_LOAD node
If we're splatting the original subvector width then just use the original X86ISD::SUBV_BROADCAST_LOAD node - similar to what we're already doing with X86ISD::VBROADCAST/VBROADCAST_LOAD
2023-08-29 14:21:13 +01:00
Simon Pilgrim
85cf2e8286 [X86] combineConcatVectorOps - concatenation of constant subvectors is free. 2023-08-29 14:15:24 +01:00
wangpc
8c6d8381ea [RISCV] Add isCommutable for pseudos without merge operand
`vmadc` and vector mask-register logical instructions are commutable
and there is no merge operand for their pseudos.

We add `isCommutable=1` for these pseudos to gain more optimization
opportunities.

This patch fixes part of https://github.com/llvm/llvm-project/issues/64422.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D158976
2023-08-29 15:51:17 +08:00
Phoebe Wang
b667e9c23d [X86][BF16] Lower FP_ROUND for vector types under AVX512BF16
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D158952
2023-08-29 13:48:13 +08:00
Serguei Katkov
a701b7e368 [CGP] Remove dead PHI nodes before elimination of mostly empty blocks
Before elimination of mostly empty block it makes sense to remove dead PHI nodes.
It open more opportunity for elimination plus eliminates dead code itself.

It appeared that change results in failing many unit tests and some of
them I've updated and for another one I disable this optimization.
The pattern I observed in the tests is that there is a infinite loop
without side effects. As a result after elimination of dead phi node all other
related instruction are also removed and tests stops to check what it is expected.

Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D158503
2023-08-29 04:35:06 +00:00
Phoebe Wang
30ec9473c6 [X86][BF16] Add test coverage for AVX-NE-CONVERT
Split from D158952.
2023-08-29 09:08:01 +08:00
Daniel Hoekwater
ef1c25eb50 [CodeGen][AArch64] Don't split jump table basic blocks
Jump tables on AArch64 are label-relative rather than table-relative, so
having jump table destinations that are in different sections causes
problems with relocation. Jump table lookups have a max range of 1MB, so
all destinations must be in the same section as the lookup code. Both of
these restrictions can be mitigated with some careful and complex logic,
but doing so doesn't gain a huge performance benefit.

Efficiently ensuring jump tables are correct and can be compressed on
AArch64 is a TODO item. In the meantime, don't split blocks that can
cause problems.

Differential Revision: https://reviews.llvm.org/D157124
2023-08-28 21:47:57 +00:00
Matt Arsenault
80e5b46e45 AMDGPU: Fix assertion on half typed pow with constant exponents
https://reviews.llvm.org/D158993
2023-08-28 13:54:49 -04:00
Daniel Hoekwater
3f00c7b2ab [CodeGen][AArch64] Precommit tests for D156767 (NFC)
Differential Revision: https://reviews.llvm.org/D158871
2023-08-28 17:25:18 +00:00
Craig Topper
747836c5dd Revert "[RISCV][GlobalISel] Select ALU GPR instructions"
This reverts commit 538b90cf4c63c7f7b55a9eb9812e951529abd66c.

Committed by mistake.
2023-08-28 10:14:26 -07:00
Craig Topper
ff6d33382f [RISCV] Prevent tryToFoldBNEOnCmpXchgResult from deleting AND if it has others users.
This disables the transform if the branch does not have the kill
flag set for the AND we want to delete.

Ideally we'd be able to share the AND with the AND we create in
the expansion, but that's a more complex transform. So this starts
with the simple approach to fix miscompile.

This should be backported to LLVM 17.

Fixes PR65025.ll

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D158962
2023-08-28 10:11:12 -07:00
Craig Topper
538b90cf4c [RISCV][GlobalISel] Select ALU GPR instructions
Some instruction selection patterns required for ALU GPR instructions have already been automatically imported from existing TableGen descriptions - this patch simply adds testing for them. Logic for selecting constants and copies has been added, along with the first of the GIComplexPatternEquiv definitions required to select the shiftMaskXLen ComplexPattern. New patterns have been added to directly select RV64 W instructions from gMIR rather than using custom gMIR operations earlier in the pipeline. In future this could also support the checks present in the DAGToDAGISel for finding ops whose users only require the lower 32 bits.

Differential Revision: https://reviews.llvm.org/D76445
2023-08-28 10:11:09 -07:00
Phoebe Wang
6688701497 [X86][BF16] Lower FP_EXTEND for vector types under AVX512BF16
Fixes #64460

Reviewed By: RKSimon, skan

Differential Revision: https://reviews.llvm.org/D158950
2023-08-28 21:27:10 +08:00
Phoebe Wang
23e2a82446 Revert "[X86][BF16] Lower FP_EXTEND for vector types under AVX512BF16"
This reverts commit 4ae7ed6e19bab0d62c0f936bd6f555103cc3b197.

Sorry, missing the test update.
2023-08-28 21:06:22 +08:00
Phoebe Wang
4ae7ed6e19 [X86][BF16] Lower FP_EXTEND for vector types under AVX512BF16
Fixes #64460

Reviewed By: RKSimon, skan

Differential Revision: https://reviews.llvm.org/D158950
2023-08-28 20:52:06 +08:00
Phoebe Wang
3753ea8311 Revert "[X86][BF16] Lower FP_EXTEND for vector types under AVX512BF16"
This reverts commit 915139fc73fd34223caaec0c3b3525ad79540ec0.

The constant value is 16 rather than 8. Revert it and then reland.
2023-08-28 20:48:16 +08:00
Jim Lin
b91b4ece34 [RISCV] Add missing mask operand for masked vclmul/vclmulh tests. NFC. 2023-08-28 17:36:38 +08:00
Luke Lau
8f1d1e2b61 [SDAG] Add computeKnownBits support for ISD::SPLAT_VECTOR_PARTS
We can work out the known bits for a given lane by concatenating the known bits of each scalar operand.

In the description of ISD::SPLAT_VECTOR_PARTS in ISDOpcodes.h it says that the
total size of the scalar operands must cover the output element size, but I've
added a stricter assertion here that the total width of the scalar operands
must be exactly equal to the element size. It doesn't seem to trigger, and I'm
not sure if there any targets that use SPLAT_VECTOR_PARTS for anything other
than v4i32 -> v2i64 splats.

We also need to include it in isTargetCanonicalConstantNode, otherwise
returning the known bits introduces an infinite combine loop.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D158852
2023-08-28 10:35:58 +01:00
Luke Lau
6e4860f5d0 [SDAG] Add SimplifyDemandedBits support for ISD::SPLAT_VECTOR
This improves some cases where a splat_vector uses a build_pair that can be
simplified, e.g:

(rotl x:i64, splat_vector (build_pair x1:i32, x2:i32))

rotl only demands the bottom 6 bits, so this patch allows it to simplify it to:

(rotl x:i64, splat_vector (build_pair x1:i32, undef:i32))

Which in turn improves some cases where a splat_vector_parts is lowered on
RV32.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D158839
2023-08-28 10:35:56 +01:00
Nikita Popov
98cf20f890 Revert "[Verifier] Sanity check alloca size against DILocalVariable fragment size"
This reverts commit 183f49c3e0f4a7facf237581f83ae07e7f4544ab.

The lang/cpp/trivial_abi/TestTrivialABI.py lldb test fails on
buildbots.
2023-08-28 09:44:51 +02:00
Nikita Popov
183f49c3e0 [Verifier] Sanity check alloca size against DILocalVariable fragment size
Add a check that the DILocalVariable fragment size in dbg.declare
does not exceed the size of the alloca.

This would have caught the invalid debuginfo regenerated by rustc
in https://github.com/llvm/llvm-project/issues/64149.

Differential Revision: https://reviews.llvm.org/D158743
2023-08-28 09:16:33 +02:00
esmeyi
8514d207ba [AIX] Handle ReadOnlyWithRel kind on AIX.
Summary: This patch handles the SectionKind of ReadOnlyWithRel on AIX. The failure was discovered during sanitizer enablement and occured with `-fsanitize-coverage` option.

Reviewed By: hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D157483
2023-08-28 00:21:09 -04:00
Jim Lin
57aee4ea69 [RISCV] Add check-prefixes ZVFH for zvfh and CHECK for zvfhmin. NFC.
It has more readability to show the difference or the same between Zvfh and Zvfhmin.
2023-08-28 11:14:00 +08:00
Phoebe Wang
915139fc73 [X86][BF16] Lower FP_EXTEND for vector types under AVX512BF16
Fixes #64460

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D158950
2023-08-28 09:47:12 +08:00
Weining Lu
26021577d1 [LoongArch] Optimize (and (a & ~((2^^X - 1) << Y)) to (bstrins a, zero, X+Y-1, Y)
Inspired by D158384.

Differential Revision: https://reviews.llvm.org/D158832
2023-08-28 08:36:54 +08:00
Weining Lu
73a2eecb21 [LoongArch] Pre-commit test for bstrins optimization
Differential Revision: https://reviews.llvm.org/D158831
2023-08-28 08:36:54 +08:00
Simon Pilgrim
54c20055da [X86] MergeConsecutiveStores.ll - add 32-bit i686 coverage 2023-08-27 11:35:16 +01:00
Arthur Eubanks
0a4fc4ac1c Revert "Emit the CodeView S_ARMSWITCHTABLE debug symbol for jump tables"
This reverts commit 8d0c3db388143f4e058b5f513a70fd5d089d51c3.

Causes crashes, see comments in https://reviews.llvm.org/D149367.

Some follow-up fixes are also reverted:

This reverts commit 636269f4fca44693bfd787b0a37bb0328ffcc085.
This reverts commit 5966079cf4d4de0285004eef051784d0d9f7a3a6.
This reverts commit e7294dbc85d24a08c716d9babbe7f68390cf219b.
2023-08-25 18:34:15 -07:00