This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Improve constant materialization for stores of i16 or i32 negative constants.
ClosedPublic

Authored by craig.topper on Aug 13 2021, 12:43 PM.

Details

Summary

DAGCombiner::visitStore can clear the upper bits of constants
used by stores. This leads prevents them from being recognized as
sign extended negative values making them more expensive to
materialize.

This patch uses the hasAllNBitUsers method from D107658 to make
a negative constant if none of the users care about the upper bits.

Diff Detail

Event Timeline

craig.topper created this revision.Aug 13 2021, 12:43 PM
craig.topper requested review of this revision.Aug 13 2021, 12:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2021, 12:43 PM
Herald added a subscriber: MaskRay. · View Herald Transcript

Update comment

luismarques accepted this revision.Aug 18 2021, 5:18 AM

LGTM.

I wondered if we could avoid this in the first place. I looked at the DAGCombiner::visitSTORE transformation some days ago but it wasn't obvious to me what could be done there. (BTW, can we even access the TargetTransformInfo from there, e.g. to call getIntMatCost?)

llvm/test/CodeGen/RISCV/imm.ll
481

Remove comment.

498

Ditto.

This revision is now accepted and ready to land.Aug 18 2021, 5:18 AM