This is an archive of the discontinued LLVM Phabricator instance.

[SPIR-V] Remove switch G_ICMP+G_BRCOND+G_BR before ISel
ClosedPublic

Authored by mpaszkowski on Mar 26 2023, 11:26 AM.

Details

Summary

IRTranslator lowers switches to [G_SUB] + G_ICMP + G_BRCOND + G_BR sequences. Since values and destination MBBs are included in the spv_switch intrinsics, the sequences are not needed for ISel.

Before this patch, the information decoded by these sequences were added to spv_switch intrinsics in SPIRVPreLegalizer and the sequences were kept until SPIRVModuleAnalysis where they were marked skipped for emission.

After this patch, the [G_SUB] + G_ICMP + G_BRCOND + G_BR sequences and MBBs containing only these MIs are erased in SPIRVPreLegalizer.

Diff Detail

Event Timeline

mpaszkowski created this revision.Mar 26 2023, 11:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 26 2023, 11:26 AM
mpaszkowski requested review of this revision.Mar 26 2023, 11:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 26 2023, 11:26 AM

Updated the commit with a fix to the failing OpenCL CTS test and added one new LIT test.

Added assert(!MBB.empty() && "MBB is empty!"). This should make it easier to spot similar issues in the future.

andreytr accepted this revision.Mar 30 2023, 1:35 PM
andreytr added a subscriber: andreytr.

Approve for lit tests.

This revision is now accepted and ready to land.Mar 30 2023, 1:35 PM
iliya-diyachkov accepted this revision.Apr 2 2023, 4:32 PM

The patch looks good to me, thanks Michal.