This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] Fix bug in MatchBSwapHWordLow.
ClosedPublic

Authored by craig.topper on May 15 2022, 12:47 PM.

Details

Summary

This function tries to match (a >> 8) | (a << 8) as (bswap a) >> 16.

If the SRL isn't masked and the high bits aren't demanded, we still
need to ensure that bits 23:16 are zero. After the right shift they
will be in bits 15:8 which is where the important bits from the SHL
end up. It's only a bswap if the OR on bits 15:8 only takes the bits
from the SHL.

Fixes PR55484.

Diff Detail

Event Timeline

craig.topper created this revision.May 15 2022, 12:47 PM
craig.topper requested review of this revision.May 15 2022, 12:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2022, 12:47 PM
Allen added a subscriber: Allen.May 15 2022, 7:49 PM
RKSimon added inline comments.May 16 2022, 3:01 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
6507

Isn't APInt::getBitsSet hiBit exclusive?

craig.topper added inline comments.May 17 2022, 5:17 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
6507

It is. I'll fix

Correct high bit for getsBitSet.

RKSimon accepted this revision.May 18 2022, 9:04 AM

LGTM - cheers

This revision is now accepted and ready to land.May 18 2022, 9:04 AM
This revision was landed with ongoing or failed builds.May 18 2022, 9:28 AM
This revision was automatically updated to reflect the committed changes.