7218 Commits

Author SHA1 Message Date
David Green
2238363a5f
[AArch64] Prevent v1f16 vselect/setcc type expansion. (#72048)
PR #71614 identified an issue in the lowering of v1f16 vector compares,
where the `v1i1 setcc` is expanded to `v1i16 setcc`, and the `v1i16
setcc` tries to be expanded to a `v2i16 setcc` which fails. For floating
point types we can let them scalarize instead though, generating a
`setcc f16` that can be lowered using normal fp16 lowering.

07a8ff4892b2a54f0bd5843f863bcffa7a258f1f added a special case combine
for v1 vselect to expand the predicate type to the same size as the fcmp
operands. This turns that off for float types, allowing them to
scalarize naturally, which hopefully fixes the issue by preventing the
v1i16 setcc, meaning it wont try to widen to larger vectors.

The codegen might not be optimal, but as far as I can tell everything
generated successfully, providing that no `v1i16 setcc v1f16`
instructions get generated.
2023-11-13 14:42:52 +00:00
Craig Topper
44e8bea400
[GISel][AArch64] Notify the Observer when CTTZ lowering changes the opcode to CTPOP. (#72008) 2023-11-12 19:36:24 -08:00
David Green
a31538d29c [AArch64] Add a test showing inefficient register allocation around loop IVs. NFC 2023-11-12 13:11:03 +00:00
Momchil Velikov
e8209b2486
[MachineSink] Drop debug info for instructions deleted by sink-and-fold (#71443)
After performing sink-and-fold over a COPY, the original instruction is
replaced with one that produces its output in the destination of the
copy. Its value is still available (in a hard register), so if there are
debug instructions which refer to the (now deleted) virtual register
they could be updated to refer to the hard register, in principle.
However, it's not clear how to do that, moreover in some cases the debug
instructions may need to be replicated proportionally to the number of
the COPY instructions replaced and in some extreme cases we can end up
with quadratic increase in the number of debug instructions, e.g:

        int f(int);
    
        void g(int x) {
          int y = x + 1;
    
          int t0 = y;
          f(t0);
    
          int t1 = y;
          f(t1);
        }
2023-11-11 19:43:14 +00:00
David Green
0bd67566f7 [AArch64] Remove AArch64/aarch64-neon-v1i1-setcc.ll test. NFC
These are replicated in llvm/test/CodeGen/AArch64/arm64-neon-v1i1-setcc.ll with
more tests and updated check lines. Remove the duplicate test.
2023-11-11 18:22:41 +00:00
Shoaib Meenai
c5dd1bbcc3 Revert "Revert "[IR] Mark lshr and ashr constant expressions as undesirable""
This reverts commit 8ee07a4be7f7d8654ecf25e7ce0a680975649544.

The revert is breaking AMDGPU backend tests (which I didn't have
enabled), and I don't want to risk breakages over the weekend, so just
revert for now.
2023-11-10 17:26:14 -08:00
Shoaib Meenai
8ee07a4be7 Revert "[IR] Mark lshr and ashr constant expressions as undesirable"
This reverts commit 82f68a992b9f89036042d57a5f6345cb2925b2c1.

cd7ba9f3d090afb5d3b15b0dcf379d15d1e11e33 needs to be reverted to fix
test failures on builds without assertions, and this one needs to be
reverted first for that.
2023-11-10 17:08:35 -08:00
Nikita Popov
82f68a992b [IR] Mark lshr and ashr constant expressions as undesirable
These will no longer be created by default during constant folding.
2023-11-10 16:29:13 +01:00
David Green
10ce319320
[AArch64][GlobalISel] Expand handling for sitofp and uitofp (#71282)
Similar to #70635, this expands the handling of integer to fp
conversions. The code is very similar to the float->integer conversions
with types handled oppositely. There are some extra unhandled cases
which require more handling for ASR operations.
2023-11-10 13:41:13 +00:00
Juergen Ributzka
6d1d7be133
Obsolete WebKit Calling Convention (#71567)
The WebKit Calling Convention was created specifically for the WebKit
FTL. FTL
doesn't use LLVM anymore and therefore this calling convention is
obsolete.

This commit removes the WebKit CC, its associated tests, and
documentation.
2023-11-09 09:08:41 -08:00
chuongg3
451bc3ec1d
[AArch64][GlobalISel] Legalize G_VECREDUCE_{MIN/MAX} (#69461)
Legalizes G_VECREDUCE_{MIN/MAX} and selects instructions for
vecreduce_{min/max}
2023-11-09 16:29:14 +00:00
Igor Kirillov
59a063d5c6
[ExpandMemCmp] Improve memcmp optimisation for boolean results (#71221)
This patch enhances the optimization of memcmp calls when only two
outcomes
are needed and comparison fits into one block, for example:

	bool result = memcmp(a, b, 6) > 0;

Previously, LLVM would generate unnecessary operations even when the
user of
memcmp was only interested in a binary outcome.
2023-11-09 11:52:04 +00:00
Dinar Temirbulatov
3f9d385e58
[AArch64][SME] Shuffle lowering, assume that the minimal SVE register is 128-bit, when NOEN is not available. (#71647)
We can assume that the minimal SVE register is 128-bit, when NEON is not
available. And we can lower the shuffle shuffle operation with one
operand to TBL1 SVE instruction.
2023-11-08 14:37:49 +00:00
Zhaoxuan Jiang
76b53a0216
[AArch64] (NFC) Fix test after loosening requirements for register renaming (#71634)
The landing of https://reviews.llvm.org/D88663 renders the existing
stp-opt-with-renaming-undef-assert test useless because the picked
register for renaming becomes q0 instead of q16.
2023-11-08 09:12:57 +00:00
Mitch Phillips
9e50c6e6b5 Revert "Reapply "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG""
This reverts commit ba385ae210b3659bc9dfb78ef1d280d03c2c3b5a.

Reason: Broke the MSan buildbot. See comments on
ba385ae210
for more information.
2023-11-07 15:08:45 +01:00
Graham Hunter
a850dbcc5c
[AArch64] Sink vscale calls into loops for better isel (#70304)
For more recent sve capable CPUs it is beneficial to use the inc*
instruction
to increment a value by vscale (potentially shifted or multiplied) even
in
short loops.

This patch tells codegenprepare to sink appropriate vscale calls into
blocks where they are used so that isel can match them.
2023-11-07 10:29:42 +00:00
Amara Emerson
e09184ffe0 [AArch64][GlobalISel] Remove -O0 from a legalizer test, which causes legalization failures to be silent.
This was masking legalization failures in some functions in the test. Remove
those for now since they don't actually work.
2023-11-07 00:36:15 -08:00
Matt Arsenault
ba385ae210 Reapply "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG"
This reverts commit e0f86ca2004b2d87ffe3c1e8242650a29fa98a82.

This was hitting some assertions which have since been relaxed.
2023-11-07 16:57:02 +09:00
Florian Hahn
8fb2113eb4
[AArch64] Preserve undef on registers when expanding CALL_RVMARKER. (#71177)
Preserve the undef flag on register operands when expanding
CALL_RVMARKER. This fixes a crash when the x0 operand is undef, e.g.
because it was poison in the input IR.

Fixes https://github.com/llvm/llvm-project/issues/68005.
2023-11-06 10:37:39 +00:00
David Green
3d870434b8 [AArch64] Add fopcysign testing. NFC 2023-11-04 13:50:42 +00:00
David Green
54574d3272
[AArch64][GlobalISel] Expand handling for fptosi and fptoui (#70635)
Now that we have more types handled for zext/sext and trunc, it is
possible to get more types working for the vector float to integer
conversions. This patch adds fp16, widening and narrowing vector support
to handle more types. The smaller types wil be expanded to the size of
the larger element type. A couple of case require more awkward truncates
to get working as they go from illegal to illegal types.
2023-11-04 11:47:05 +00:00
Paul Walker
de88371d9d
[LLVM][AArch64] Add ASM constraints for reduced GPR register ranges. (#70970)
[LLVM][AArch64] Add ASM constraints for reduced GPR register ranges.
    
The patch adds the follow ASM constraints:
  Uci => w8-w11/x8-x11
  Ucj => w12-w15/x12-x15
    
These constraints are required for SME load/store instructions
where a reduced set of GPRs are used to specify ZA array vectors.
    
NOTE: GCC has agreed to use the same constraint syntax.
2023-11-03 15:34:45 +00:00
Paul Walker
17970df6dc
[LLVM][SVE] Move ADDVL isel patterns under UseScalarIncVL feature flag. (#71173)
Also removes a duplicate pattern.
2023-11-03 13:23:02 +00:00
Nikita Popov
e4a4122eb6
[IR] Remove zext and sext constant expressions (#71040)
Remove support for zext and sext constant expressions. All places
creating them have been removed beforehand, so this just removes the
APIs and uses of these constant expressions in tests.

There is some additional cleanup that can be done on top of this, e.g.
we can remove the ZExtInst vs ZExtOperator footgun.

This is part of
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
2023-11-03 10:46:07 +01:00
Zhaoxuan Jiang
1f54ef78d5
[AArch64] Only clear kill flags if necessary when merging str (#69680)
Previously the kill flags of the source register were unconditionally
cleared when a `str` pair was merged, which results in suboptimal
register allocation and inhibits some renaming opportunities which may
allow further merging `str`.
2023-11-02 17:03:21 -07:00
Paul Walker
c95253b1ba [LLVM][SVE] Clean VLS tests to not use wide vectors as function return types. 2023-11-02 12:41:37 +00:00
Tobias Stadler
373c343a77 Reland: [GlobalISel] LegalizationArtifactCombiner: Elide redundant G_AND
Reland 3686a0b after fixing an exposed miscompile in #68840

Differential Revision: https://reviews.llvm.org/D159140
2023-11-02 00:18:19 +01:00
Fangrui Song
a62b86a3e6
[AArch64,ELF] Restrict MOVZ/MOVK to non-PIC large code model (#70178)
There is no PIC support for -mcmodel=large

(https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst)
and Clang recently rejects -mcmodel= with PIC (#70262).

The current backend code assumes that the large code model is non-PIC.
This patch adds `!getTargetMachine().isPositionIndependent()` conditions
to clarify that the support is non-PIC only. In addition, add some tests
as change detectors in case PIC large code model is supported in the
future.

If other front-ends/JITs use the large code model with PIC, they will
get small code model code sequence, instead of potentially-incorrect
MOVZ/MOVK sequence, which is only suitable for non-PIC. The sequence
will cause text relocations using ELF linkers.

(The small code model code sequence is usually sufficient as ADRP+ADD or
ADRP+LDR targets [-2**32,2**32), which has a doubled range of x86-64
R_X86_64_REX_GOTPCRELX/R_X86_64_PC32 [-2**32,2**32).)
2023-11-01 12:10:44 -07:00
Sander de Smalen
7dc20abed0 [AArch64] Fix spillfill-sve.mir with expensive checks.
This fixes an issue introduced by PR #70679.

Using constrainRegClass() is not strong enough to actually force
the use of a register to be a PPR register class. It will need an
actual COPY to do the conversion.

The downside is that this introduces an extra register, which is an
issue we may want to fix at a later point using a custom copy operation
where the register allocator uses the same register when it can.
2023-11-01 16:29:44 +00:00
Nikita Popov
57384aeb37 [ConstantFold] Avoid creating undesirable cast expressions
Similar to what we do for binops, for undesirable casts we should
call the constant folding API instead of the constant expr API,
to avoid indirect creation of undesirable cast ops.
2023-11-01 16:50:52 +01:00
Sander de Smalen
2efea512c2
[AArch64] Fix spilling/filling of virtual registers in PNR regclass. (#70679)
We made the assumption that the registers were always physical
registers, which doesn't have to be true.
2023-11-01 10:57:12 +00:00
Sander de Smalen
73498d2608
[AArch64] Also implement PNR -> PNR copies. (#70682)
Previously we only implemented PNR -> PPR and PPR -> PNR copies.
2023-10-31 16:52:42 +00:00
Kerry McLaughlin
3b786f2c76 [AArch64] Add intrinsic to count trailing zero elements
This patch introduces an experimental intrinsic for counting the
trailing zero elements in a vector. The intrinsic has generic expansion
in SelectionDAGBuilder, and for AArch64 there is a pattern which matches
to brkb & cntp instructions where SVE is enabled.

The intrinsic has a second operand, is_zero_poison, similar to the
existing cttz intrinsic.

These changes have been split out from D158291.
2023-10-31 10:48:08 +00:00
Igor Kirillov
849f963e31
[CodeGen] Improve ExpandMemCmp for more efficient non-register aligned sizes handling (#70469)
* Enhanced the logic of ExpandMemCmp pass to merge contiguous
subsequences
  in LoadSequence, based on sizes allowed in `AllowedTailExpansions`.
* This enhancement seeks to minimize the number of basic blocks and
produce
  optimized code when using memcmp with non-register aligned sizes.
* Enable this feature for AArch64 with memcmp sizes modulo 8 equal to
  3, 5, and 6.

Reapplication of #69942 after fixing a bug
2023-10-30 18:40:48 +00:00
Antonio Frighetto
9fe5700611 [AArch64] Add support for v8.4a ldapur/stlur
AArch64 backend now features v8.4a atomic Load-Acquire
RCpc and Store-Release register unscaled support.
2023-10-30 19:27:48 +01:00
Antonio Frighetto
a8799719f7 [AArch64] Introduce tests for PR67879 (NFC) 2023-10-30 19:27:48 +01:00
Craig Topper
9a7c26a399
[GISel] Restrict G_BSWAP to multiples of 16 bits. (#70245)
This is consistent with the IR verifier and SelectionDAG's getNode.

Update tests accordingly. I tried to keep some coverage of non-pow2 when
possible. X86 didn't like a G_UNMERGE_VALUES from s48 to 3 s16 that got
created when I tried s48.
2023-10-30 10:27:57 -07:00
Nikita Popov
292f34b0d3
[AArch64][GlobalISel] Fix incorrect ABI when tail call not supported (#70215)
The check for whether a tail call is supported calls
determineAssignments(), which may modify argument flags. As such, even
though the check fails and a non-tail call will be emitted, it will not
have a different (incorrect) ABI.

Fix this by operating on a separate copy of the arguments.

Fixes https://github.com/llvm/llvm-project/issues/70207.
2023-10-30 15:01:01 +01:00
Cullen Rhodes
54732a3e0b [AArch64] Use TargetRegisterClass::hasSubClassEq in tryToFindRegisterToRename
When renaming store operands for pairing in the load/store optimizer it
tries to find an available register from the minimal physical register
class of the original register. For each register it compares the
equality of minimal physical register class of all sub/super registers
with the minimal physical register class of the original register.

Simply checking for register class equality can break once additional
register classes are added, as was the case when adding:

    def foo : RegisterClass<"AArch64", [i32], 32, (sequence "W%u", 12, 15)>

which broke:

    CodeGen/AArch64/stp-opt-with-renaming-reserved-regs.mir
    CodeGen/AArch64/stp-opt-with-renaming.mir

Since the introduction of the register class above, the rename register
in test1 of the reserved regs test changed from x12 to x18. The reason
for this is the minimal physical register class of x12 (as well as
x13-x15) and its sub/super registers no longer matches that of x9
(GPR64noip_and_tcGPR64).

Rather than selecting a matching register based on a comparison of the minimal
physical register classes of the original and rename registers, this patch
selects based on `MachineInstr::getRegClassConstraint` for the original
register.

It's worth mentioning the parameter passing registers (r0-r7) could be now be
used as rename registers since the GPR32arg and GPR64arg register classes are
subclasses of the minimal physical register class for x8 for example. I'm not
entirely sure if we want to exclude those registers, if so maybe we could
explicitly exclude those register classes.

Reviewed By: efriedma, paulwalker-arm

Differential Revision: https://reviews.llvm.org/D88663
2023-10-30 08:47:39 +00:00
David Green
072a7edec3 [AArch64] Add additional concat trunc -> UZP1 patterns
These extra patterns come from the lowering of fptoi, where an extra assertzext
is present between some of the vectors.
2023-10-29 22:58:57 +00:00
Paul Walker
7c90be2857
[SVE] Fix incorrect offset calculation when rewriting an instruction's frame index. (#70315)
When partially packing an offset into an SVE load/store instruction we
are incorrectly calculating the remainder.
2023-10-27 16:53:30 +01:00
Igor Kirillov
deb429e5b0 Revert "[CodeGen] Improve ExpandMemCmp for more efficient non-register aligned sizes handling (#69942)"
This reverts commit 9bcb30d31813bbdea6b65789f64aed3f0e58d507.
2023-10-27 14:12:45 +00:00
Igor Kirillov
9bcb30d318
[CodeGen] Improve ExpandMemCmp for more efficient non-register aligned sizes handling (#69942)
* Enhanced the logic of ExpandMemCmp pass to merge contiguous
subsequences
  in LoadSequence, based on sizes allowed in `AllowedTailExpansions`.
* This enhancement seeks to minimize the number of basic blocks and
produce optimized code when using memcmp with non-register aligned sizes.
* Enable this feature for AArch64 with memcmp sizes modulo 8 equal to
  3, 5, and 6.
2023-10-27 12:41:08 +01:00
Amara Emerson
c9e8b73694
[AArch64][GlobalISel] Add support for extending indexed loads. (#70373) 2023-10-26 13:38:09 -07:00
David Green
3fe8fd712b [AArch64] Fix st2 check for nearby store with debug info.
It needs to be skipping over debug instructions, whilst not counting them in
the MaxLookupDist.
2023-10-26 21:37:04 +01:00
Alex Richardson
e39f6c1844 [opt] Infer DataLayout from triple if not specified
There are many tests that specify a target triple/CPU flags but no
DataLayout which can lead to IR being generated that has unusual
behaviour. This commit attempts to use the default DataLayout based
on the relevant flags if there is no explicit override on the command
line or in the IR file.

One thing that is not currently possible to differentiate from a missing
datalayout `target datalayout = ""` in the IR file since the current
APIs don't allow detecting this case. If it is considered useful to
support this case (instead of passing "-data-layout=" on the command
line), I can change IR parsers to track whether they have seen such a
directive and change the callback type.

Differential Revision: https://reviews.llvm.org/D141060
2023-10-26 12:07:37 -07:00
Amara Emerson
93659947d2
[AArch64][GlobalISel] Add support for pre-indexed loads/stores. (#70185)
The pre-index matcher just needs some small heuristics to make sure it
doesn't cause regressions. Apart from that it's a simple change, since
the only difference is an immediate operand of '1' vs '0' in the
instruction.
2023-10-26 10:29:12 -07:00
Simon Pilgrim
13a349425b [AArch64] Regenerate addr-of-ret-addr.ll 2023-10-26 15:35:17 +01:00
Simon Pilgrim
aaabf50d52 [AArch64] Regenerate tests to show missing constant comments 2023-10-26 15:35:17 +01:00
Oliver Stannard
339faffd05 Revert "[AArch64] Move SLS later in pass pipeline"
The (MF.size() == 0) assertis is triggering when building at -O0.
Reverting this while I work out what is going wrong.

This reverts commit 7e8eccd990d37d2771ca5ad7a84f54c3cfc4a5e1.
2023-10-26 09:50:13 +01:00