[llvm-dev] [AA] Question on the full restrict patch
Kelvin Li via llvm-dev
llvm-dev at lists.llvm.org
Mon Nov 23 08:32:17 PST 2020
Hi Jeroen,
In working on a scheme to represent Fortran alias information precisely,
we encounter a situation in which two alias sets partially overlap. We
would
like to seek any idea of representing such alias sets, particular, in the
scheme of
the full restrict alias approach in D68484.
Consider the following Fortran code,
module m
implicit none
!set A: variables *with* the TARGET attribute
integer, allocatable, target :: tgtA01, tgtA02, tgtA03
integer, pointer :: p_1_SetA, p_2_SetA, p_3_SetA
!set B: variables *without* the TARGET attribute
integer :: tgtB01, tgtB02, tgtB03
contains
subroutine init_ptr()
p_1_SetA = 0 ; p_2_SetA = 0 ; p_3_SetA = 0
end subroutine init_ptr
subroutine compute(n)
integer :: idx, n
call init_var(tgtB01)
call init_var(tgtB02)
call init_var(tgtB03)
associate(assoc_tgtA01 => tgtA01, assoc_tgtA02 => tgtA02, assoc_tgtB02
=> tgtB02)
do idx = 1, n
assoc_tgtA01 = assoc_tgtA01 * tgtB03 + assoc_tgtA02 * tgtA03 +
tgtB01 * assoc_tgtB02
end do
end associate
end subroutine compute
end module
The alias analysis in frontend can generate the following alias sets for
"tgtA01" and "tgtA02".
-------------------------------
"tgtA01" is aliased to:
"__m_NMOD__&&_m" "__m_NMOD_init_ptr" "__m_NMOD_compute" "init_var"
"p_1_SetA" "p_2_SetA" "p_3_SetA"
"assoc_tgtA01" "tgtA01"
-------------------------------
"tgtA02" is aliased to:
"__m_NMOD__&&_m" "__m_NMOD_init_ptr" "__m_NMOD_compute" "init_var"
"p_1_SetA" "p_2_SetA" "p_3_SetA"
"assoc_tgtA02" "tgtA02"
-------------------------------
If we express this alias info with the scheme that we presented in the
last LLVM
Developers' Meeting (https://youtu.be/Vp4GklTXDys), the optimizer manages
to
move the loop invariant code out of the loop body. We think that the
optimizer
can make use of the alias information even though there is an overlap in
the two
alias sets. With the D69542 patch (https://reviews.llvm.org/D69542), we
would
like to know if there is any way to express that with the intrinsics
proposed in
the full restrict patch.
We attach the ll files for reference.
Note: The options --unroll-max-count=0 --interleave-loops=false
-passes=default<O3> -aa-pipeline=default are used in opt.
Attachments
0. alias-sets-from-fe.txt - full alias sets generated from Fortran
frontend
1. before-opt-without-alias-from-fe.ll - IR before opt (NO alias info is
emitted)
2. after-opt-without-alias-from-fe.ll - IR after opt (NO alias info is
emitted)
3. before-opt-with-alias-from-fe.ll - IR before opt (noalias/alias.scope
metadata is emitted)
4. after-opt-with-alias-from-fe.ll - IR after opt (noalias/alias.scope
metadata is emitted)
Thanks,
Kelvin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201123/ed203a17/attachment-0001.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: alias-sets-from-fe.txt
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201123/ed203a17/attachment-0001.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: after-opt-without-alias-from-fe.ll
Type: application/octet-stream
Size: 5735 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201123/ed203a17/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: before-opt-without-alias-from-fe.ll
Type: application/octet-stream
Size: 14132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201123/ed203a17/attachment-0005.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: after-opt-with-alias-from-fe.ll
Type: application/octet-stream
Size: 11868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201123/ed203a17/attachment-0006.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: before-opt-with-alias-from-fe.ll
Type: application/octet-stream
Size: 26042 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201123/ed203a17/attachment-0007.obj>
More information about the llvm-dev
mailing list