1058 Commits

Author SHA1 Message Date
Nikita Popov
60442f0d44 [CodeGen] Convert some tests to opaque pointers (NFC)
These are mostly MIR tests, which I did not handle during previous
conversions.
2023-01-05 13:21:20 +01:00
Fangrui Song
27751bed60 [XRay] Fix Hexagon sled version
D113638 emitted version 0 for XRaySledEntry, which will lead to an incorrect
address computation in the runtime.

While here, improve the test.
2022-12-28 12:03:09 -08:00
Nikita Popov
a96f691985 [Hexagon] Convert some tests to opaque pointers (NFC) 2022-12-19 12:53:32 +01:00
Krzysztof Parzyszek
1c7c7377cb [Hexagon] Handle rounding beyond low 32 bits 2022-12-14 10:25:34 -08:00
jacquesguan
c2f199fa48 [DAGCombiner] Scalarize extend/truncate for splat vector.
This revision scalarizes extend/truncate for splat vector.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D122875
2022-12-12 14:53:10 +08:00
Haojian Wu
3abdd9b91b Fix a typo ll->llc in test 2022-12-07 13:24:06 +01:00
Haojian Wu
a2215149ae Add implementation isTargetCanonicalConstantNode for hexagon.
This fixes an infinite compiling loop caused by https://reviews.llvm.org/D137140

Differential Revision: https://reviews.llvm.org/D139525
2022-12-07 13:21:29 +01:00
Krzysztof Parzyszek
87a3f1ab3b [Hexagon] Better detection of impossible completions to perfect shuffles
If there is an entry P that has C bits set, it could become one of C
different possibilities. If P occurs more than C times, then there are
no valid completions.
2022-12-05 12:40:08 -08:00
Bjorn Pettersson
a11faeed44 [test] Switch to use -passes syntax in various test cases 2022-12-01 21:25:59 +01:00
Krzysztof Parzyszek
2191137dff [Hexagon] Check if vector is empty before calling back() 2022-12-01 11:41:47 -08:00
Krzysztof Parzyszek
9b83935672 [Hexagon] Punt on GEPs with different base types in vector alignment 2022-12-01 10:33:48 -08:00
Krzysztof Parzyszek
073d5e5945 [Hexagon] Further improve code generation for shuffles
* Concatenate partial shuffles into longer ones whenever possible:
In selection DAG, shuffle's operands and return type must all agree. This
is not the case in LLVM IR, and non-conforming IR-level shuffles will be
rewritten to match DAG's requirements. This can also make a shuffle that
can be matched to a single HVX instruction become shuffles that require
more complex handling. Example: anything that takes two single vectors
and returns a pair (e.g. V6_vshuffvdd).
This is avoided by concatenating such shuffles into ones that take a vector
pair, and an undef pair, and produce a vector pair.

* Recognize perfect shuffles when masks contain `undef` values.

* Use funnel shifts for contracting shuffles.

* Recognize rotations as a separate step.

These changes go into a single commit, because each one on their own
introduced some regressions.
2022-11-29 14:19:29 -08:00
Krzysztof Parzyszek
d9ed93da86 [Hexagon] Don't lower legal EXTRACT_SUBVECTOR to EXTRACT_SUBREG
EXTRACT_SUBREG is a machine opcode and cannot be a part of an input
selection pattern.
2022-11-24 18:10:42 -08:00
Krzysztof Parzyszek
f8cb97a0f1 [Hexagon] Fix deinterleaving after vmpyh 2022-11-23 13:31:54 -08:00
Krzysztof Parzyszek
ae9356e8c4 [Hexagon] Fix order of operands in V6_vmpyhus
The unsigned operand is second: Vdd32.w = vmpy(Vu32.h,Vv32.uh)
2022-11-23 13:31:54 -08:00
Ikhlas Ajbar
4bb6e220a0 [Hexagon] Add missing patterns for select
Fixes https://github.com/llvm/llvm-project/issues/59077.
2022-11-22 12:20:38 -08:00
Krzysztof Parzyszek
e27e8e0541 [Hexagon] Use V6_vmpyuhvs for 16-bit mulhu on HVX v69+ 2022-11-22 11:31:22 -08:00
Krzysztof Parzyszek
ea6693d4c8 [Hexagon] Add missing patterns for mulhs/mulhu 2022-11-18 08:13:57 -08:00
Krzysztof Parzyszek
534b26aa07 [Hexagon] Improve inserting/extracting to/from scalar predicates
Fixes https://github.com/llvm/llvm-project/issues/59042.
2022-11-17 13:03:45 -08:00
Krzysztof Parzyszek
a2a89eb019 [Hexagon] Fix lowering loads/stores of scalar vNi1
Don't treat them as i1, all predicate bits need to be loaded or stored.
2022-11-17 12:48:01 -08:00
Krzysztof Parzyszek
a75bab6e60 [Hexagon] Fix even/odd word shuffling
Used the wrong shuffle instruction... -_-
2022-11-15 10:06:19 -08:00
Nikita Popov
884b919f2e Reapply [Hexagon] Use default attributes for intrinsics
The issue that caused the revert has been fixed in:
44bd80751274a81c870882968ecd478b03af292a

-----

This switches Hexagon intrinsics to use the default attributes
(nosync, nofree, nocallback and willreturn). Especially willreturn
is needed to prevent optimization regressions in the future.

The only intrinsics I've excluded here are the load/store locked
intrinsics, which presumably aren't nosync.

Differential Revision: https://reviews.llvm.org/D137623
2022-11-15 16:01:14 +01:00
Krzysztof Parzyszek
44bd807512 [Hexagon] Adjust handling of stack with variable-size and extra alignment
Make the stack alignment register (AP) reserved in the given function. This
will make it available everywhere in the function, and allow aligned access
to vector register spill slots.
2022-11-15 06:48:53 -08:00
Krzysztof Parzyszek
475d22895a [Hexagon] Reduce the spill alignment for double/quad vector classes
The spill alignment for HVX vectors is always the single vector size,
regardless of whether the class describes vector tuples or not.
2022-11-13 14:02:36 -06:00
Krzysztof Parzyszek
a03e16a16e [Hexagon] Improve idioms for fixed-point vector multiplication
Make the code more general, restore the ability to generate V6_vmpyhvsrs.
2022-11-12 08:46:27 -08:00
Alina Sbirlea
57dbca20ea Revert "[Hexagon] Use default attributes for intrinsics"
This reverts commit 8a8983b279dd5e4dceabe1fadbb8980b6adb88f9.

Uncovers existing regalloc issue in Hexagon backend - blocking for Halide
Hexagon users. Reverting to unblock, to be recommitted when underlying issue is resolved.
Reproducer available shortly.
2022-11-11 15:10:05 -08:00
Krzysztof Parzyszek
017186294d [Hexagon] Place aligned loads closer to users
Vector alignment code was grouping all aligned loads together. In some
cases the groups could become quite large causing a lot of spill to be
generated. This will place the loads closer to where they are used,
reducing the register pressure.
2022-11-11 12:04:33 -08:00
Nikita Popov
8a8983b279 [Hexagon] Use default attributes for intrinsics
This switches Hexagon intrinsics to use the default attributes
(nosync, nofree, nocallback and willreturn). Especially willreturn
is needed to prevent optimization regressions in the future.

The only intrinsics I've excluded here are the load/store locked
intrinsics, which presumably aren't nosync.

Differential Revision: https://reviews.llvm.org/D137623
2022-11-11 10:59:00 +01:00
Thomas Preud'homme
c8be35293c [SWP] Recognize mem carried dep with different base
The loop-carried dependency detection logic in isLoopCarriedDep relies
on the load and store using the same definition for the base register.
This misses the case of post-increment loads and stores whose base
register are different PHI initialized from the same initial value.

This commit extends the logic to accept the load and store having
different PHI base address provided that they had the same initial value
when entering the loop and are incremented by the same amount in each
loop.

Reviewed By: bcahoon

Differential Revision: https://reviews.llvm.org/D136463
2022-11-07 09:53:41 +00:00
Paul Robinson
4f0a1201a4 [lit][REQUIRES] Fix some tests with incorrect REQUIRES clauses
These weren't running anywhere because of bad specifications.
One test has bit-rotted and had to be XFAILed, the rest are okay.

Differential Revision: https://reviews.llvm.org/D136612
2022-11-01 13:49:23 -07:00
Krzysztof Parzyszek
b7449e7045 [Hexagon] Use HVX predicates when mapping HVX intrinsics in isel
In llvm/lib/Target/Hexagon/HexagonDepMapAsm2Intrin.td we use "HasV66" for
HVX v66 intrinsics. We should be using "UseHVXV66" instead, since HVX has
its own versioning.
2022-11-01 08:40:20 -07:00
Krzysztof Parzyszek
e3ad2ca85f [Hexagon] Add LLVM codegen testcases for V6_[add|sub]carryo intrinsics 2022-10-31 14:25:24 -07:00
Daniel Thornburgh
75cdab6dc2 [llvm-objdump] Add --no-print-imm-hex to tests depending on it.
This prepares for an upcoming change to make --print-imm-hex the default
behavior of llvm-objdump. These tests were updated in a semi-automatic
fashion.

See D136972 for details.
2022-10-29 15:40:26 -07:00
Krzysztof Parzyszek
9422a8d94c [Hexagon] Break up vectors into HVX-sized chunks in HvxIdioms
This will allow recognizing Q.31 multiplications on vectors that are
multiplies of HVX vectors. At the moment this comes at the expense of
Q.15 multiplications, which now are handled as 32-bit multiplications
with shifts.
In the longer term this will likely be replaced by a different scheme
of "legalizing" vectors, which is necessary for idiom recognition, at
least where using direct HVX instrinsics is desired.
2022-10-29 11:13:28 -07:00
Krzysztof Parzyszek
2ec380b23f [Hexagon] Improve handling of 32-bit mulh/mul_lohi on HVX
Handle MULH[US] by normalizing them into newly invented nodes
HexagonISD::(S|U|US)MUL_LOHI. On HVX v60, if only the high part of
SMUL_LOHI is used, use the original MULHS expansion. In all other
cases, expand the full product.
On HVX v62, always expand the full product.

Introduce Hexagon-specific LLVM IR intrinsics for 32x32 multiplication
returning low/high parts.
2022-10-22 15:08:27 -07:00
Krzysztof Parzyszek
e5d9ab08c3 [Hexagon] Fix insertion point for pointer difference calculation
HVC::calculatePointerDifference inserts temporary instructions for
simplification, and calulation of known bits. These instructions were
inserted at the end of a basic block (after the terminator), which
caused BB->getTerminator() to return nullptr. This, in turn, caused
a crash when a PHI instruction was examined in computeKnownBits.
2022-10-19 14:23:39 -07:00
Krzysztof Parzyszek
6a8cfe9a72 [Hexagon] Use shifts by scalar for funnel shifts by scalar
HVX has vector shifts by a scalar register. Use those in the expansions
of funnel shifts where profitable.
2022-10-18 09:49:17 -07:00
Krzysztof Parzyszek
9fde8e907b [Hexagon] Fix MULHS lowering for HVX v60
The carry bit from an intermediate addition was not properly propagated.
For example mulhs(7fffffff, 7fffffff) was evaluated as 3ffeffff, while
the correct result is 3fffffff.
2022-10-18 07:54:38 -07:00
Krzysztof Parzyszek
361a27c155 [Hexagon] Recognize idioms for fixed-point vector multiplication
Recognize Q.15*Q.15 and Q.31*Q.31, with and without rounding.
2022-10-14 15:22:25 -07:00
Krzysztof Parzyszek
705e77abed [Hexagon] Lower funnel shifts for HVX
HVX v62+ has bidirectional shifts, which do not mask the shift amount to
the bit width. Instead, the shift amount is sign-extended from the log(BW)
bit value, and a negative value causes a shift in the other direction.
For the shift amount being -log(BW), this reversed shift will shift all
bits out, inserting 0s or sign bits depending on the type and direction.
2022-10-14 14:13:18 -07:00
Krzysztof Parzyszek
7f4ce3f1eb [Hexagon] Introduce PS_vsplat[ir][bhw] pseudo instructions
HVX v60 only has splats that take a 32-bit word as input, while v62+
has splats that take 8- or 16-bit value. This makes writing output
patterns that need to use a splat annoying, because the entire output
pattern needs to be replicated for various versions of HVX.
To avoid this, the patterns will always use the pseudos, and then the
pseudos will be handled using a post-ISel hook.
2022-10-14 12:03:13 -07:00
Krzysztof Parzyszek
79632163db [Hexagon] Switch vunpackub->op->vpackeb pattern to vzb/vshuffeb
V6_vzb and V6_vshuffeb can use any 2 resources in a packet, while
V6_vunpackub/V6_vpackeb both need a shift resource.

Also, add patterns for shifting vectors of i8.
2022-10-12 15:31:28 -07:00
Krzysztof Parzyszek
dca7e451ee [Hexagon] Handle packing of even/odd 32-bit words
This is a workaround until perfect shuffle generation is improved.
2022-10-12 13:00:14 -07:00
Arthur Eubanks
f3a928e233 [opt] Don't translate legacy -analysis flag to require<analysis>
Tests relying on this should explicitly use -passes='require<analysis>,foo'.
2022-10-07 14:54:34 -07:00
Krzysztof Parzyszek
dfaf7a2846 [Hexagon] Avoid some unnecessary sign-extend instructions
Simplify (sext_inreg (extractu ...)) -> (extract ...) where appropriate.
2022-09-26 12:30:18 -07:00
Krzysztof Parzyszek
d6c0a5be7f [Hexagon] Make sure we can still shift scalar vectors by non-splats 2022-09-26 11:25:06 -07:00
Krzysztof Parzyszek
f6e7ad5604 [Hexagon] Revamp type legalization of ext/trunc/sat in HVX
Resizing operations (e.g. sign extension) in DAG can go from any width
to any other width, e.g. i8 -> i32. If the input and the result differ
by a factor larger than 2, the operation cannot be legal in HVX, since
the only two legal vector sizes in HVX are a single vector and a pair
of vectors.
To simplify the legalization, such operations are expanded into steps
that only double/halve the type size, so that each such step can be fully
legalized on its own. The complication is that DAG will automatically
fold these steps back into one, e.g. sext(sext) -> sext. To prevent that
new HexagonISD nodes are introduced: TL_EXTEND and TL_TRUNCATE. Once
legalized, these nodes are replaced with the original opcodes.

The type legalization is now common to aext/sext/zext/trunc and Hexagon-
specific ssat/usat nodes.
2022-09-21 11:25:27 -07:00
Krzysztof Parzyszek
94a71361d6 [Hexagon] Implement [SU]INT_TO_FP and FP_TO_[SU]INT for HVX 2022-09-19 11:11:20 -07:00
Krzysztof Parzyszek
ec51e38062 [Hexagon] Add HVX patterns for ISD::ABS 2022-09-19 10:12:15 -07:00
Krzysztof Parzyszek
3c817574c2 [Hexagon] Handle shifts of short vectors of i8 2022-09-08 07:52:16 -07:00