[PATCH] D158291: [PoC][WIP] Add an AArch64 specific pass for loop idiom recognition
Kerry McLaughlin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 18 09:31:50 PDT 2023
kmclaughlin created this revision.
Herald added subscribers: ctetreau, arphaman, hiraditya, kristof.beyls.
Herald added a project: All.
kmclaughlin requested review of this revision.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.
This pass looks for loops such as the following:
while (i != max_len)
if (a[i] != b[i])
break;
Although similar to a memcmp, this is slightly difference because instead of returning
the difference between the values of the first non-matching pair of bytes, it returns
the index of the first mismatch. As such, we are not able to lower this to a memcmp call.
Replacing this pattern with a specialised predicated SVE loop gives a significant
performance improvement for AArch64.
This patch introduces a new pass which identifies this pattern and replaces it with the
SVE loop. It is intended as a short-term solution until this is handled in the vectoriser.
A new intrinsic is created in this patch for counting the trailing zero elements in a
vector which has generic lowering in SelectionDAGBuilder. For AArch64 where SVE is
enabled, this is replaced with brkb & cntp instructions.
Note: This is a work in progress, see discussion on Discourse:
https://discourse.llvm.org/t/aarch64-target-specific-loop-idiom-recognition/72383
https://reviews.llvm.org/D158291
Files:
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/lib/Target/AArch64/AArch64.h
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h
llvm/lib/Target/AArch64/AArch64LoopIdiomRecognize.cpp
llvm/lib/Target/AArch64/AArch64LoopIdiomRecognize.h
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.h
llvm/lib/Target/AArch64/CMakeLists.txt
llvm/lib/Target/AArch64/SVEInstrFormats.td
llvm/test/CodeGen/AArch64/intrinsic-cttz-elts.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Transforms/LoopIdiom/AArch64/byte-compare-index.ll
llvm/utils/gn/secondary/llvm/lib/Target/AArch64/BUILD.gn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158291.551549.patch
Type: text/x-patch
Size: 105834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230818/0023f973/attachment-0001.bin>
More information about the llvm-commits
mailing list