This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Implement RISCVTargetLowering::getTargetConstantFromLoad.
ClosedPublic

Authored by craig.topper on Jun 13 2022, 11:53 AM.

Details

Summary

This allows computeKnownBits to see the constant being loaded.

This recovers the rv64zbp test case changes from D127520.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 13 2022, 11:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2022, 11:53 AM
craig.topper requested review of this revision.Jun 13 2022, 11:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2022, 11:53 AM
reames added inline comments.Jun 13 2022, 12:26 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
9395

I may be missing the obvious here, but... if we peak back through an add to find the constant pool entry, don't we need to account for the offset when processing the constant?

(e.g. if the constant is 8 bytes, but the addi offset was 4, aren't we only loading 4 out of the bytes not the whole constant?)

craig.topper added inline comments.Jun 13 2022, 12:31 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
9395

The constant pool operand is in the immediate operand of the ADDI. The register source should be an LUI pointing to the same constant pool. So there is no offset in the ADDI itself. I do check the offset in the constant pool reference below.

craig.topper planned changes to this revision.Jun 13 2022, 8:15 PM
reames accepted this revision.Jun 15 2022, 1:36 PM

LGTM - mostly I'm deferring to you on the direction. I have no objection here, and the code looks reasonable. I just don't have sufficient context to have any confidence this is or isn't the right approach.

This revision is now accepted and ready to land.Jun 15 2022, 1:36 PM
This revision was landed with ongoing or failed builds.Jun 16 2022, 3:15 PM
This revision was automatically updated to reflect the committed changes.