6522 Commits

Author SHA1 Message Date
Paul Walker
62e46f2621 [LLVM] Remove support for constant scalable vector GEPs.
This work has fallen out from D134648 as a requirement to loosen
the "constness" of vscale.

Differential Revision: https://reviews.llvm.org/D145404
2023-03-14 16:48:33 +00:00
Simon Pilgrim
da570ef1b4 [DAG] Match select(icmp(x,y),sub(x,y),sub(y,x)) -> abd(x,y) patterns
Pulled out of PowerPC, and added ABDS support as well (hence the additional v4i32 PPC matches)

Differential Revision: https://reviews.llvm.org/D144789
2023-03-14 15:10:30 +00:00
Nicholas Guy
96615c856d [Codegen][ARM][AArch64] Support symmetric operations on complex numbers
Differential Revision: https://reviews.llvm.org/D142482
2023-03-14 12:11:10 +00:00
Felipe de Azevedo Piovezan
dde08c9c48 [AArchExpandPseudo] Preserve instruction debug number in expansions
This is an initial attempt at preserving debug information in the pseudo
instruction expansion of the AArch backend. In particular, we preserve
the instruction number required by the InstrRef implementation of live
debug values.

There are many other expansions that need to be considered, but the ones
addressed in this commit should be extremely common, as they handle most
arithmetic and logical instructions.

Differential Revision: https://reviews.llvm.org/D145943
2023-03-13 15:29:15 -04:00
Hassnaa Hamdi
40a51e1afc [AArch64][SVE]: custom lower AVGFloor/AVGCeil.
-Lower AVGFloor(A, B) to:
 SRL(A) + SRL(B) + (A&B)&1.
-Lower AVGCeil(A, B) to:
 SRL(A) + SRL(B) + (A|B)&1.

Differential Revision: https://reviews.llvm.org/D143283
2023-03-13 19:00:57 +00:00
Paul Walker
3870857226 [SVE] Restrict cmp+and->pred_cmp isel to instances where the and is the sole user of the compare.
Without the single use restriction we may replace the and with a
more costly duplicated compare.

Differential Revision: https://reviews.llvm.org/D145755
2023-03-13 12:42:00 +00:00
Tim Northover
5c18444289 MachO: support custom section names on global variables
These attributes have been accepted in ELF for a while, and are generated by
Clang in some places, so it makes sense to support them on MachO too.

https://reviews.llvm.org/D143173
2023-03-10 18:23:25 +00:00
David Green
fb8839110c [AArch64] Remove fixed FIXMEs from D120706. NFC
These comments were not adjusted when the fix went in.
2023-03-10 14:28:15 +00:00
sgokhale
7b338a691e [CodeGen][AArch64] Generate Pseudo instructions for integer MLA/MAD/MLS/MSB
Differential Revision: https://reviews.llvm.org/D145488
2023-03-10 10:58:18 +05:30
Paul Walker
990b11c507 [SVE] Precommit multiuse predicated compare tests. 2023-03-10 00:55:11 +00:00
Juneyoung Lee
a66bc1c4a3 [DAGCombiner] Avoid converting (x or/xor const) + y to (x + y) + const if benefit is unclear
This patch resolves suboptimal code generation reported by https://github.com/llvm/llvm-project/issues/60571 .

DAGCombiner currently converts `(x or/xor const) + y` to `(x + y) + const` if this is valid.
However, if `.. + const` is broken down into a sequences of adds with carries, the benefit is not clear, introducing two more add(-with-carry) ops (total 6) in the case of the reported issue whereas the optimal sequence must only have 4 add(-with-carry)s.

This patch resolves this issue by allowing this conversion only when (1) `.. + const` is legal or promotable, or (2) `const` is a sign bit because it does not introduce more adds.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D144116
2023-03-08 18:13:57 +00:00
David Green
1c6ea96193 [AArch64] Fix load-insert-zero patterns with i8 and negative offsets.
These should have been using the LDURBi instructions where the offset is
negative, as reported from the reproducer in D144086.
2023-03-08 12:48:21 +00:00
Chen Zheng
fc26ab36a2 [DAGCombiner] don't use the pointer info for widen store
The merged store touches memory for other underlying objects, so mapping
the merged store to the first underlying object is not correct. For example
in https://github.com/llvm/llvm-project/issues/60744, the merged store is
not correctly analyzed as dependent with memory operations which are also
part of the merged store.

Fixes #60744

Reviewed By: foad

Differential Revision: https://reviews.llvm.org/D144711
2023-03-07 20:31:09 -05:00
David Green
9aa39481d9 [AArch64] Prefer to fold dup into fmul/fma as opposed to ld1r
There is a fold to create LD1DUPpost from dup(load) that can be postinc. If the
dup is used by a "by element" operation such as fmul or fma then it can be
slightly better to fold the dup into the fmul instead, which produces slightly
fast code.

  ld1r { v1.4s }, [x0], #4
  fmul v0.4s, v1.4s, v0.4s
vs
  ldr s1, [x0], #4
  fmul v0.4s, v0.4s, v1.s[0]

This could also be done with integer operations such as smull/umull too, so
long as the load/dup gets correctly combined into the mul operation. Currently
this just operates on foating point types.

Differential Revision: https://reviews.llvm.org/D145184
2023-03-07 21:24:16 +00:00
David Green
5a45d21a08 [AArch64] Tests for dup in load vs mul. NFC
See D145184.
2023-03-07 13:21:18 +00:00
Graham Hunter
92e0ab937f [AArch64] Don't map llvm sqrt intrinsics to veclib functions
Since AArch64 has sqrt instructions, we want to use those instead of
calls to vector math routines for llvm sqrt intrinsics (since those
don't imply some of the constraints that libm calls might have) so
we just remove the mappings.

Code originally written by mgabka

Reviewed By: danielkiss, paulwalker-arm

Differential Revision: https://reviews.llvm.org/D145392
2023-03-07 11:43:41 +00:00
sgokhale
ee1299c692 [CodeGen][AArch64] Precommit additional tests for integer MLA/MAD/MLS/MSB (NFC)
This forms the base for upcoming patch to generate pseudo instructions for MLA/MAD/MLS/MSB.

Differential Revision: https://reviews.llvm.org/D142998
2023-03-07 13:58:34 +05:30
David Green
a10ac6554d [AArch64] Extend load insert into zero patterns to SVE.
This extends the patterns for loading into the zeroth lane of a zero vector
from D144086 to SVE, which work in the same way as the existing patterns. Only
full length vectors are added here, not the narrower floating point vector
types.
2023-03-06 23:26:08 +00:00
Hsiangkai Wang
0847cc06a6 [NFC][AArch64] Use 'i' to encode the offset form of load/store.
STG, STZG, ST2G, STZ2G are the exceptions to append 'Offset' to name the
offset format of load/store instructions. All other load/store
instructions use 'i' as the appendix. If there is no special reason to
do so, we should make the naming consistent.

Differential Revision: https://reviews.llvm.org/D141819
2023-03-06 12:34:19 +00:00
David Green
ad002398c9 [AArch64] Add missing bf16 SVE extract vector patterns
Similar to the inserts, these are the same fp16 inserts but were missing
patterns.
2023-03-05 16:52:24 +00:00
David Green
2c958a5aa9 [AArch64] Add missing bf16 SVE insert vector patterns.
These should be identical to the fp16 SVE inserts but were missing from the
tests and tablegen patterns. They are always legal (not requiring +bf16),
although there are some other issues around bf16 legalization currently.
2023-03-05 16:24:43 +00:00
David Green
ae12e57a77 [AArch64] Add missing bf16 load insert pattern
We have LDRHui load patterns but would fail to select from unscaled offsets.
This adds the missing pattern.
2023-03-03 22:00:41 +00:00
Caroline Concatto
204800ad0a [IR][Legalization] Promote illegal deinterleave and interleave vectors
To make legalization easier, the operands and outputs have the same size for
these ISD Nodes. When legalizing the results in PromoteIntegerResult the operands
are legalized to the same size as the outputs.
The ISD Node has two output/results, therefore the legalizing functions update
both results/outputs.

Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D144846
2023-03-03 10:54:52 +00:00
Amara Emerson
1e1f1195a8 [AArch64] Fix crash in LowerBUILD_VECTOR trying to create invalid EXTRACT_SUBVECTOR.
rdar://106096671

Differential Revision: https://reviews.llvm.org/D145185
2023-03-02 14:10:29 -08:00
Craig Topper
06c6b787b2 [SelectionDAG][AArch64] Constant fold in SelectionDAG::getVScale if VScaleMin==VScaleMax.
Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D145113
2023-03-02 12:02:38 -08:00
Craig Topper
c546f13f1f [DAGCombiner] Replace LegalOperations check in visitSIGN_EXTEND with LegalTypes.
This is guarding a check for isTypeLegal so it should check is
LegalTypes.

Fixes PR61111.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D145139
2023-03-02 07:52:53 -08:00
Sander de Smalen
948ed21f12 [AArch64] NFC: Add missing CHECK lines for sme-aarch64-svcount.ll test 2023-03-02 12:42:09 +00:00
Sander de Smalen
170e7a0ec2 [AArch64][SME2] Add CodeGen support for target("aarch64.svcount").
This patch adds AArch64 CodeGen support such that the type can be passed
and returned to/from functions, and also adds support to use this type in
load/store operations and PHI nodes.

Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D136862
2023-03-02 12:07:41 +00:00
David Green
337215ddf9 [DAG] ABD is not reassociative
I'm not sure how I missed this in the testing, but as far as I understand
whilst ABDS and ABDU are commutive they are not associative. This patch
disables reassociateOps from visitABD, fixing the problems found in #61069.
ABDU: https://alive2.llvm.org/ce/z/eiT5QG
ABDS: https://alive2.llvm.org/ce/z/HzE29l

Differential Revision: https://reviews.llvm.org/D145064
2023-03-01 16:22:13 +00:00
David Green
83bbd3fdbd [AArch64] Load into zero vector patterns
A LDR will implicitly zero the rest of the vector, so vector_insert(zeros,
load, 0) can use a single load. This adds tablegen patterns for both scaled and
unscaled loads, detecting where we are inserting a load into the lower element
of a zero vector.

Differential Revision: https://reviews.llvm.org/D144086
2023-03-01 13:54:03 +00:00
Sjoerd Meijer
2b462eb98d [AArch64] More patterns to generate LD1R vector splats
We are missing patterns to generate vector splats using LD1R. A shuffle vector
with all 0s is a vector splat if the operands are a load and undef for which
we can generate a LD1R.

Differential Revision: https://reviews.llvm.org/D145004
2023-03-01 10:48:13 +00:00
Sjoerd Meijer
a4c828a9e2 [AArch64] Precommit tests to check more ld1r vector splat patterns in D145004. 2023-03-01 10:48:13 +00:00
David Green
18af853022 [AArch64] Remove 64bit->128bit vector insert lowering
The AArch64 backend, during lowering, will convert an 64bit vector insert to a
128bit vector:

vector_insert %dreg, %v, %idx
=>
%qreg = insert_subvector undef, %dreg, 0
%ins = vector_insert %qreg, %v, %idx
EXTRACT_SUBREG %ins, dsub

This creates a bit of mess in the DAG, and the EXTRACT_SUBREG being a machine
nodes makes it difficult to simplify. This patch removes that, treating the
64bit vector insert as legal and handling them with extra tablegen patterns.

The end result is a simpler DAG that is easier to write tablegen patterns for.

Differential Revision: https://reviews.llvm.org/D144550
2023-03-01 09:39:51 +00:00
Caroline Concatto
cb96eba27c [IR][Legalization] Split illegal deinterleave and interleave vectors
To make legalization easier, the operands and outputs have the same size for
these ISD Nodes. When legalizing the results in SplitVectorResult the operands
are legalized to the same size as the outputs.
The ISD Node has two output/results, therefore the legalizing functions update
both results/outputs.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D144744
2023-03-01 08:30:16 +00:00
David Sherwood
6333779ac0 [AArch64][SME2] Add multi-vector uunpk and sunpk intrinsics
This patch adds the LLVM IR intrinsics for the following:

* uunpk (2 and 4 vectors)
* sunpk (2 and 4 vectors)

I have named the tests sve2p1-intrinsics-* because although
the instructions are added as part of the SME2 feature they
only operate on SVE vectors.

NOTE: These intrinsics are still in development and are subject to future changes.

Differential Revision: https://reviews.llvm.org/D142964
2023-02-28 14:01:38 +00:00
Vladislav Dzhidzhoev
3a51eed948 [AArch64][GlobalISel] Legalize G_SHUFFLE_VECTOR with smaller dest size
Legalize G_SHUFFLE_VECTOR having destination vector length smaller than
source vector length by reshaping destination vector.

Differential Revision: https://reviews.llvm.org/D144670
2023-02-27 23:46:44 +01:00
Nilanjana Basu
72105d10d5 [AArch64] Avoid using intermediate integer registers for copying between source and destination floating point registers
In post-isel code, there are cases where there were redundant copies from a source FPR to an intermediate GPR in order to copy to a destination FPR. In this patch, we identify these patterns in post-isel peephole optimization and replace them with a direct FPR-to-FPR copy.
One example for this will be the insertion of the scalar result of 'uaddlv' neon intrinsic function into a destination vector. During instruction selection phase, 'uaddlv' result is copied to a GPR, & a vector insert instruction is matched separately to copy the previous result to a destination SIMD&FP register.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D142594
2023-02-27 12:20:10 -08:00
Amara Emerson
31d6a57257 [AArch64][GlobalISel] Reorder stack up-adjustment and register copies
This change reorders the stack up-adjustment and return value copying phases of
machine-ir generation on Aarch64. Doing so prevents a bug observed for fastcc
calls with >8 arguments, where the up-adjustment required from making that call
is placed in the wrong place relative to spill and reloading code.

See: https://github.com/llvm/llvm-project/issues/60972 for full issue
reproduction and context.

Patch contributed by Bruce Collie

Differential Revision: https://reviews.llvm.org/D144791
2023-02-27 11:24:24 -08:00
David Green
06daa515b2 [AArch64] Don't remove free sext_inreg(vector_extract(x)) if it leads to multiple extracts
If we have sext_inreg(vector_extract(x)) but the top bits are not used, DAG
will try to remove the sext_inreg, using vector_extract(x) directly. This can
lead to multiple uses of both sext_inreg(vector_extract(x)) and
vector_extract(x), leading to the generation of both umov and smov extracts.
This adds a target hook to prevent that under AArch64 where the sext_inreg can
be considered free if there are multiple uses of the sext and no uses of the
vector_extract. This helps fix a small regression from D144550.

Differential Revision: https://reviews.llvm.org/D144850
2023-02-27 19:20:10 +00:00
David Green
9e5bfa1ae3 [AArch64] Add some tests for multiple uses of extended vector extracts. NFC 2023-02-27 14:34:52 +00:00
Pavel Kosov
c417b7a695 [OHOS] Add support for OpenHarmony
Add support for OpenHarmony OS

General OpenHarmony OS discussion on discourse thread "[RFC] Add support for OpenHarmony OS"
https://discourse.llvm.org/t/rfc-add-support-for-openharmony-os/66656

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D138202
2023-02-27 17:15:45 +03:00
Kerry McLaughlin
a9df627050 [SME2][AArch64] Add multi-indexed multiply-add long long intrinsics
Adds intrinsics for the following SME2 instructions (1, 2 & 4 vector):
 - smlall
 - umlall
 - smlsll
 - umlsll
 - sumlall
 - usmlall

NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D143278
2023-02-27 13:58:35 +00:00
chendewen
ec67d703cf [SVE] Add intrinsics for uniform dsp operations that explicitly undefine the result for inactive lanes.
This patch adds new intrinsics for uniform dsp operations and changes the lowering for the following builtins to emit calls to the new aarch64.sve.###.u intrinsics.
  svsqsub_x
  svsqsub_n_x
  svuqsub_x
  svuqsub_n_x
  svsqsubr_x
  svsqsubr_n_x
  svuqsubr_x
  svuqsubr_n_x

Reviewed By: Paul Walker
Differential Revision: https://reviews.llvm.org/D144704
2023-02-27 18:44:55 +08:00
Nilanjana Basu
f3b8aef242 [AArch64] Added tests for inserting scalar result of uaddlv neon instrinsic function into a vector
Inserting scalar result of 'uaddlv' neon intrinsic function to a destination vector currently makes use of the integer unit. Subsequent patches will eliminate the redundant use of the integer registers in a more generic way that will include this special case. This is an initial set of tests for this functionality.

Differential Revision: https://reviews.llvm.org/D143038
2023-02-26 22:54:09 -08:00
Amara Emerson
4bc6434624 [GlobalISel] Fix an assertion failure in matchHoistLogicOpWithSameOpcodeHands().
We use this combine in the AArch64 postlegalizer combiner, which causes this
function to query the legalizer rules for the action for an invalid opcode/type
combination (G_AND and p0). Moving the legalizer query until after the validity
check in matchHoistLogicOpWithSameOpcodeHands() fixes this.
2023-02-26 15:42:57 -08:00
Simon Pilgrim
7ebf9b0ca3 [AArch64] Add coverage for select(icmp(x,y),sub(x,y),sub(y,x)) -> abd(x,y) patterns 2023-02-25 21:12:32 +00:00
Samuel Parker
f48d3b6f46 Revert "[DAGCombine] Fold redundant select"
This reverts commit c7f9344d0f8f6a00adab138037e2e7b406ef2b69.
2023-02-23 17:59:41 +00:00
Kerry McLaughlin
6c82d16d60 [SME2][AArch64] Add multi-vector rounding shift left intrinsics
Adds intrinsics for the following SME2 instructions:
 - srshl (single, 2 & 4 vector)
 - srshl (multi, 2 & 4 vector)
 - urshl (single, 2 & 4 vector)
 - urshl (multi, 2 & 4 vector)

NOTE: These intrinsics are still in development and are subject to future changes.

Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D144118
2023-02-23 14:33:33 +00:00
David Green
c33fd3b47f [AArch64] Lower all fp zero buildvectors through BUILD_VECTOR.
Just like with integers, we can treat zero fp buildvector as legal so that they
can be recognized in tablegen patterns using immAllZerosV.
2023-02-22 11:26:41 +00:00
Ricardo Jesus
272bd573dc [AArch64] Fix abs(sub nsw) -> absd
This partially reverts a regression introduced in 8f25e382c5b1 for
AArch64 targets. In particular, we restore the logic of `(abs (sub nsw
x, y)) -> abds(x, y)` for all targets except X86, which keeps the logic
introduced in 8f25e382c5b1. See also https://reviews.llvm.org/D142288.

Differential Revision: https://reviews.llvm.org/D144379
2023-02-22 09:17:25 +00:00