This is an archive of the discontinued LLVM Phabricator instance.

[SPIR-V] Fix switch lowering with common compare register
ClosedPublic

Authored by mpaszkowski on Jan 7 2023, 11:11 AM.

Details

Summary

Often switches share a compare register. This is the case when the source code shares the same variable for multiple switches. For example, in CTS math_brute_force/pow test:

size_t parity = ...
...
switch( parity )
{
    case 1:
        ...
    case 0:
        ...
}
...
switch( parity )
{
    case 0:
        ...
    case 1:
        ...
}

The virtual register representing the parity variable cannot be used for differentiating between switches (as it was done before).
This change removes this mapping of case values + target machine basic blocks to concrete switch compare registers.

Diff Detail

Event Timeline

mpaszkowski created this revision.Jan 7 2023, 11:11 AM
mpaszkowski requested review of this revision.Jan 7 2023, 11:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 7 2023, 11:11 AM

looks good to me

This revision is now accepted and ready to land.Jan 13 2023, 7:17 AM
iliya-diyachkov accepted this revision.Jan 13 2023, 8:02 AM

It looks good to me too. Thanks, Michal.