This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] fix a bug for folding RLWINM(LI) to LI due to wrap mask
ClosedPublic

Authored by shchenz on Jun 2 2020, 7:11 AM.

Details

Summary

This is found during code review for https://reviews.llvm.org/D80907

See comment https://reviews.llvm.org/D80907#2068594

Peephole pass will convert following pattern:

%1:gprc = LI 100
%2:gprc = RLWINM %1:gprc, 1, 3, 2

to

%2:gprc = LI 0

The wrap mask is not handled well in convertToImmediateForm

Diff Detail

Event Timeline

shchenz created this revision.Jun 2 2020, 7:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2020, 7:11 AM
shchenz updated this revision to Diff 268347.Jun 3 2020, 7:04 PM

update test case

steven.zhang added inline comments.Jun 5 2020, 5:45 PM
llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
3424

Can we fix this in the wrap?It does nothing now if lo == hi. But as it is [lo,hi), if lo == hi, we expect it to be all ones if it is with wrap.

shchenz marked an inline comment as done.Jun 5 2020, 7:06 PM
shchenz added inline comments.
llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
3424

Yeah, Good idea. We should differentiate getBitsSetWithWrap & getBitsSet when lo == hi. I will post a APInt patch soon to improve this.

steven.zhang accepted this revision.Jun 9 2020, 11:40 PM

LGTM. Thank you for addressing this.

This revision is now accepted and ready to land.Jun 9 2020, 11:40 PM
This revision was automatically updated to reflect the committed changes.