Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f9e5a7c
[Intrinsics][AArch64] Add intrinsic to mask off aliasing vector lanes
SamTebbs33 Nov 15, 2024
071728f
Rework lowering location
SamTebbs33 Jan 10, 2025
80a72ca
Fix ISD node name string and remove shouldExpand function
SamTebbs33 Jan 15, 2025
daa2ac4
Format
SamTebbs33 Jan 16, 2025
3fcb9e8
Move promote case
SamTebbs33 Jan 27, 2025
6628a98
Fix tablegen comment
SamTebbs33 Jan 27, 2025
0644542
Remove DAGTypeLegalizer::
SamTebbs33 Jan 27, 2025
75af361
Use getConstantOperandVal
SamTebbs33 Jan 27, 2025
5f563d9
Remove isPredicateCCSettingOp case
SamTebbs33 Jan 29, 2025
24df6bf
Remove overloads for pointer and element size parameters
SamTebbs33 Jan 30, 2025
ec37dfa
Clarify elementSize and writeAfterRead = 0
SamTebbs33 Jan 30, 2025
8d81955
Add i=0 to VF-1
SamTebbs33 Jan 30, 2025
8a09412
Rename to get.nonalias.lane.mask
SamTebbs33 Jan 30, 2025
45cbaff
Fix pointer types in example
SamTebbs33 Jan 30, 2025
1b7b0da
Remove shouldExpandGetAliasLaneMask
SamTebbs33 Jan 30, 2025
0a0de88
Lower to ISD node rather than intrinsic
SamTebbs33 Jan 30, 2025
54d32ad
Rename to noalias
SamTebbs33 Jan 31, 2025
2066929
Rename to loop.dependence.raw/war.mask
SamTebbs33 Feb 26, 2025
9b3a71a
Rename in langref
SamTebbs33 Mar 10, 2025
215d2e7
Reword argument description
SamTebbs33 Mar 21, 2025
ec2bfed
Fixup langref
SamTebbs33 May 20, 2025
9f5f91a
IsWriteAfterRead -> IsReadAfterWrite and avoid using ops vector
SamTebbs33 May 20, 2025
eb8d5af
Extend vXi1 setcc to account for intrinsic VT promotion
SamTebbs33 May 20, 2025
c3d6fc8
Remove experimental from intrinsic name
SamTebbs33 May 21, 2025
9c5631d
Clean up vector type creation
SamTebbs33 May 21, 2025
52fca12
Address review
SamTebbs33 Aug 5, 2025
9a985ab
Remove experimental from comment
SamTebbs33 Aug 7, 2025
b09d354
Add splitting
SamTebbs33 Aug 7, 2025
56f9a6b
Add widening
SamTebbs33 Aug 7, 2025
26bf362
Remove assertions and expand invalid immediates
SamTebbs33 Aug 11, 2025
a84e5e2
Remove comment about mismatched type and immediate
SamTebbs33 Aug 11, 2025
054f859
Improve lowering and splitting code a bit
SamTebbs33 Aug 12, 2025
970e7f9
Remove splitting from lowering
SamTebbs33 Aug 12, 2025
fddda14
Improve wording in lang ref
SamTebbs33 Aug 12, 2025
36be558
Rebase
SamTebbs33 Aug 12, 2025
c3d2acf
Remove backend promotion
SamTebbs33 Aug 13, 2025
8af5019
Don't create StoreVT
SamTebbs33 Aug 13, 2025
558bc3e
Use ternary for Addend
SamTebbs33 Aug 13, 2025
32e0192
Stop adding to PtrB
SamTebbs33 Aug 13, 2025
3d7c2da
Move nosve/nosve2 tests to separate files
SamTebbs33 Aug 13, 2025
5402e27
Rebase
SamTebbs33 Aug 15, 2025
5075b5f
Remove unneeded lowering cases
SamTebbs33 Aug 18, 2025
d85d375
Simplify lang ref again
SamTebbs33 Aug 19, 2025
4dedf42
More langref re-wording
SamTebbs33 Aug 27, 2025
33be150
Define a store-to-load forwarding hazard
SamTebbs33 Aug 28, 2025
587a25c
Scalarize <1 x Y> intrinsic calls
SamTebbs33 Aug 31, 2025
3abc7ba
Address review
SamTebbs33 Sep 1, 2025
8eb12a0
Address review
SamTebbs33 Sep 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24126,8 +24126,9 @@ Overview:
"""""""""

Given a vector load from %ptrA, followed by a vector store to %ptrB, this
intrinsic generates a mask where a true lane indicates that the accesses don't
overlap for that lane.
intrinsic generates a mask where an active lane indicates that the accesses can
be made safely without a lane being stored to before being read from. This can
occur when the pointers alias within a vectorised loop iteration.

A write-after-read hazard occurs when a write-after-read sequence for a given
lane in a vector ends up being executed as a read-after-write sequence due to
Expand All @@ -24146,13 +24147,12 @@ Semantics:
The intrinsic returns ``poison`` if the distance between ``%prtA`` and ``%ptrB``
is smaller than ``VF * %elementsize`` and either ``%ptrA + VF * %elementSize``
or ``%ptrB + VF * %elementSize`` wrap.
The element of the result mask is active when no write-after-read hazard occurs,
meaning that:
The element of the result mask is active when loading from %ptrA then storing to
%ptrB is safe and doesn't result in aliasing, meaning that:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
%ptrB is safe and doesn't result in a write-after-read hazard:
%ptrB is safe and doesn't result in a write-after-read hazard, meaning that:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thank you.


* (ptrB - ptrA) <= 0 (guarantees that all lanes are loaded before any stores are
committed), or
* (ptrB - ptrA) <= 0 (guarantees that all lanes are loaded before any stores), or
* (ptrB - ptrA) >= elementSize * lane (guarantees that this lane is loaded
before the store to the same address is committed)
before the store to the same address)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think committed is a term that is defined/used in LangRef. Would be goot to reframe this as well in general terms.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


Examples:
"""""""""
Expand Down Expand Up @@ -24184,18 +24184,10 @@ This is an overloaded intrinsic.
Overview:
"""""""""

Given a scalar store to %ptrA, followed by a scalar load from %ptrB, this
instruction generates a mask where an active lane indicates that there is no
read-after-write hazard for this lane and that this lane does not introduce any
new store-to-load forwarding hazard.

A read-after-write hazard occurs when a read-after-write sequence for a given
lane in a vector ends up being executed as a write-after-read sequence due to
the aliasing of pointers.

Note that the case where (ptrB - ptrA) < 0 does not result in any
read-after-write hazards, but may introduce new store-to-load-forwarding stalls
where both the store and load partially access the same addresses.
Given a vector store to %ptrA, followed by a vector load from %ptrB, this
instruction generates a mask where an active lane indicates that the accesses
can be made safely without a lane being read from before being stored to.
This can occur when the pointers alias within a vectorised loop iteration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

store-to-load forwarding hazard is not defined. Do we need this wording here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording for the store-to-load forwarding (hazard) behaviour cannot be removed, because it is the only distinction between this intrinsic and the .war intrinsic. i.e. The "safe" requirement is not the only behaviour that this intrinsic implements.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've re-added the hazard wording, thanks.


Arguments:
""""""""""
Expand All @@ -24210,11 +24202,11 @@ Semantics:
The intrinsic returns ``poison`` if the distance between ``%prtA`` and ``%ptrB``
is smaller than ``VF * %elementsize`` and either ``%ptrA + VF * %elementSize``
or ``%ptrB + VF * %elementSize`` wrap.
The element of the result mask is active when no read-after-write hazard occurs,
meaning that:
The element of the result mask is active when storing to %ptrA then loading from
%ptrB is safe and doesn't result in aliasing, meaning that:

abs(ptrB - ptrA) >= elementSize * lane (guarantees that the store of this lane
is committed before loading from this address)
occurs before loading from this address)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case for ptrA == ptrB needs to be explicitly called out as 'safe' here, because it doesn't introduce any new hazards.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


Examples:
"""""""""
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28331,9 +28331,7 @@ void AArch64TargetLowering::ReplaceNodeResults(
DAG.getNode(ISD::TRUNCATE, DL, MVT::i1, RuntimePStateSM));
return;
}
case Intrinsic::experimental_vector_match:
case Intrinsic::loop_dependence_raw_mask:
case Intrinsic::loop_dependence_war_mask: {
case Intrinsic::experimental_vector_match: {
if (!VT.isFixedLengthVector() || VT.getVectorElementType() != MVT::i1)
return;

Expand Down
Loading