Page MenuHomePhabricator

[GlobalISel] Fix computing known bits for loads with range metadata

Authored by paquette on Aug 5 2020, 4:57 PM.



In GlobalISel, if you have a load into a small type with a range, you'll hit an assert if you try to compute known bits on it starting at a larger type.


%x:_(s8) = G_LOAD %whatever(p0) :: (load 1 ... !range !n)
%y:_(s32) = G_SOMETHING %x

When we walk through G_SOMETHING and hit the load, the width of our known bits is 32. However, the width of the range is going to be 8. This will cause us to hit an assert.

To fix this, make computeKnownBitsFromRangeMetadata zero extend or truncate the range type to match the bitwidth of the known bits we're calculating.

Add a testcase in CodeGen/GlobalISel/KnownBitsTest.cpp to reflect that this works now.

Diff Detail

Event Timeline

paquette created this revision.Aug 5 2020, 4:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 5 2020, 4:57 PM
paquette requested review of this revision.Aug 5 2020, 4:57 PM
aemerson accepted this revision.Aug 6 2020, 4:28 PM


This revision is now accepted and ready to land.Aug 6 2020, 4:28 PM
paquette closed this revision.Aug 7 2020, 9:23 AM

Forgot to type "differential revision" in commit, closing.