This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Don't change switch table from desirable to illegal types
ClosedPublic

Authored by dmgreen on Oct 26 2022, 6:10 AM.

Details

Summary

In InstCombine we treat i8/i16 as desirable, even if they are not legal. The current logic in shouldChangeType will decide to convert from an illegal but desirable type (such as an i8) to an illegal and undesirable type (such as i3). This patch prevents changing the switch conditions to an odd type on like Arm/AArch64 where i8/i16 are not legal.

This is the same issue as https://reviews.llvm.org/D54115. In the case I was looking it is was converting an i32 switch to an i8 switch, which then became a i3 switch.

Diff Detail

Event Timeline

dmgreen created this revision.Oct 26 2022, 6:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2022, 6:10 AM
dmgreen requested review of this revision.Oct 26 2022, 6:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2022, 6:10 AM
spatel accepted this revision.Oct 26 2022, 6:29 AM

LGTM - but please update the code comments to match, so it's easier to know what we're doing without parsing all of the code logic. :)

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
225–226

Update comment:

/// We don't want to convert from a legal or desirable type (like i8)...

...or maybe we can reword the whole paragraph now?

241–242

Update comment:

// If this is a legal or desirable (for example, i8) type...
This revision is now accepted and ready to land.Oct 26 2022, 6:29 AM