This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Only try LUI+SH*ADD+ADDI for int materialization if LUI+ADDI+SH*ADD failed.
ClosedPublic

Authored by craig.topper on Apr 8 2022, 10:08 AM.

Details

Summary

There's an assert in LUI+SH*ADD+ADDI materialization that makes sure the
lower 12 bits aren't zero since that case should have been handled as
LUI+ADDI+SH*ADD. But nothing prevented the LUI+SH*ADD+ADDI checks from
running after the earlier code handled it.

The sequence would be the same length or longer so it wouldn't replace
the earlier sequence, but the assert happened before that was checked.

The vector holding the sequence also wasn't reset before the second
check so that guaranteed the sequence would never be found to be
shorter.

This patch fixes this by only trying the second expansion when the
earlier fails.

Fixes PR54812.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 8 2022, 10:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2022, 10:08 AM
craig.topper requested review of this revision.Apr 8 2022, 10:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2022, 10:08 AM
benshi001 accepted this revision.Apr 8 2022, 5:44 PM

Thanks for help me fix the assert failure. I really appreciate. :)

This revision is now accepted and ready to land.Apr 8 2022, 5:44 PM