This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fix a few corner case bugs in RISCVMergeBaseOffsetOpt::matchLargeOffset
ClosedPublic

Authored by craig.topper on May 30 2022, 12:47 AM.

Details

Summary

The immediate for LUI is stored as 20-bit unsigned value. We need
to sign extend if after shifting by 12 to match the instruction
behavior.

If we find an LUI+ADDI on RV64, it means the constant isn't a
simm32. If it was we would have emitted LUI+ADDIW from constant
materialization. Make sure the constant is a simm32 before folding.
This appears to match gcc.

A future patch will add support for LUI+ADDIW on RV64.

Test cases have not been committd yet. Patch shows the diffs

Diff Detail

Event Timeline

craig.topper created this revision.May 30 2022, 12:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 30 2022, 12:47 AM
craig.topper requested review of this revision.May 30 2022, 12:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 30 2022, 12:47 AM
luismarques accepted this revision.May 31 2022, 2:47 AM

LGTM.

llvm/test/CodeGen/RISCV/hoist-global-addr-base.ll
217–229

I'm surprised this issue wasn't noticed before.

This revision is now accepted and ready to land.May 31 2022, 2:47 AM