This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE]: Optimize using ptest with whilelo
AbandonedPublic

Authored by hassnaa-arm on Jan 10 2023, 9:07 AM.

Details

Summary

Pointless AND, PTEST instructions are generated to force zeroing additional lanes after doing REINTERPRET_CAST operation.
For sve_whilelo operation, no need for that, because its inactive lanes are zeroed by construction.

Diff Detail

Event Timeline

hassnaa-arm created this revision.Jan 10 2023, 9:07 AM
Herald added a project: Restricted Project. · View Herald Transcript
hassnaa-arm requested review of this revision.Jan 10 2023, 9:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 10 2023, 9:07 AM
sdesmalen added inline comments.Jan 10 2023, 9:13 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
266

There are also other while intrinsics, which would benefit in a similar way?

llvm/test/CodeGen/AArch64/sve2-ptest_whilelt.ll
6

lt or lo?

32

Do you need the loop to test this? Or can you just use:

%0 = tail call <vscale x 4 x i1> @llvm.aarch64.sve.ptrue.nxv4i1(i32 31)
%1 = tail call <vscale x 4 x i1> @llvm.aarch64.sve.whilelo.nxv4i1.i32(i32 0, i32 %width)
%2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv4i1(<vscale x 4 x i1> %0, <vscale x 4 x i1> %1)

?

hassnaa-arm edited the summary of this revision. (Show Details)Jan 10 2023, 9:15 AM
david-arm added inline comments.Jan 10 2023, 9:16 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
266

Hi @hassnaa-arm, I think we should probably add the other while variants too here, since the same thing applies for whilelt, etc.

llvm/test/CodeGen/AArch64/sve2-ptest_whilelt.ll
1

The test file suggests this is SVE2, but in fact whilelo was introduced in SVE. Also, the file name suggests you're testing whilelt, but actually it's testing whilelo. Is it worth just renaming the file to be something like

sve-ptest-removal-while.ll

similar to the other existing sve-ptest-removal-xyz.ll tests?

hassnaa-arm added inline comments.Jan 10 2023, 9:16 AM
llvm/test/CodeGen/AArch64/sve2-ptest_whilelt.ll
6

sorry, lo.

Matt added a subscriber: Matt.Jan 10 2023, 3:53 PM
hassnaa-arm abandoned this revision.Jan 31 2023, 1:19 AM