This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SVE] Remove redundant PTEST following PNEXT/PFIRST
ClosedPublic

Authored by peterwaller-arm on Sep 21 2021, 7:36 AM.

Details

Summary

PNEXT and PFIRST set the NZCV flags, so the subsequent PTEST can be
optimized away in AArch64InstrInfo::optimizePTestInstr.

See-also: https://reviews.llvm.org/D93292

Diff Detail

Unit TestsFailed

Event Timeline

peterwaller-arm requested review of this revision.Sep 21 2021, 7:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2021, 7:36 AM
sdesmalen added inline comments.Sep 21 2021, 9:36 AM
llvm/test/CodeGen/AArch64/sve-ptest-removal-pfirst.mir
3 ↗(On Diff #373927)

Do these tests necessarily need to be MIR tests? The reason I ask is because I generally find them more difficult to read and would have thought some LLVM IR intrinsics would have been sufficient to prove an extra ptest is not added.

llvm/test/CodeGen/AArch64/sve-ptest-removal-pfirst.mir
3 ↗(On Diff #373927)

Good question. These tests reuse the same form as the other tests for this. But I agree an IR test would be seem straightforward. I'll wait for anyone else to chime in with reasoning and if I don't hear anything I'll switch it on Monday next week. I have an open question in my mind of whether the other tests (llvm/test/CodeGen/AArch64/sve-ptest-removal-*.mir) should be migrated to IR tests too, as a separate commit.

paulwalker-arm added inline comments.Sep 22 2021, 5:53 AM
llvm/test/CodeGen/AArch64/sve-ptest-removal-pfirst.mir
3 ↗(On Diff #373927)

My view is MIR tests are better at ensuring a specific piece of code within the code generator is exercised, which is a good fit for ensuring isPTestLike works as expected.

That said, this patch is only decorating more instructions with an existing property and so there isn't really any new functionality to exercise. For that reason I see no problem with using an LLVM IR test to validate the newly decorated instructions but please don't convert all the existing MIR tests.

Perhaps just one of the sve-ptest-removal-while##.mir tests is sufficient and the others can be converted to LLVM IR tests. Given the tests already exist I'm not sure what value there is in rewriting them, but that's your call.

Matt added a subscriber: Matt.Sep 27 2021, 1:20 PM
  • Switch mir tests to a single ll test file, per review comments.
peterwaller-arm marked 2 inline comments as done.Sep 30 2021, 7:11 AM
  • Remove bogus _neg tests, they were taken from the brk tests where they were applicable because there were non-flag-setting variants.
  • Rename test file to pfirst-pnext since the one file tests both.
paulwalker-arm accepted this revision.Oct 4 2021, 2:41 AM
This revision is now accepted and ready to land.Oct 4 2021, 2:41 AM