This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Move creation of constant pools from isel to lowering.
ClosedPublic

Authored by craig.topper on Jun 10 2022, 11:51 AM.

Details

Summary

This simplifies the isel code by removing the manual load creation.
It also improves our ability to use 0 strided loads for vector splats.

There is an assumption here that Mask and ShiftedMask constants are
cheap enough that they don't become constant pool loads so that our
isel optimizations involving And still work. I believe those constants
are 3 instructions in the worst case.

The rv64zbp-intrinsic.ll changes is a regression caused by intrinsics
being expanded to RISCVISD also occuring during lowering. So the optimizations
were only happening during the last DAGCombine, which can't see through the
load. I believe we can fix this test by implementing
TargetLowering::getTargetConstantFromLoad for RISC-V or by adding the intrinsic
to computeKnownBitsForTargetNode to enable earlier DAG combine. Since Zbp is not
a ratified extension, I don't view these as blocking this patch.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 10 2022, 11:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2022, 11:51 AM
craig.topper requested review of this revision.Jun 10 2022, 11:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2022, 11:51 AM

Move getAddr back to being a private member of RISCVTargetLowering

wangpc added inline comments.Jun 11 2022, 11:28 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
3642

I think these instantiations can be removed now.

Remove unneeded temporary instantiations

reames accepted this revision.Jun 13 2022, 7:54 AM

LGTM

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
2973

Minor: This check should be redundant except maybe as a minor compile time win assuming the count threshold just below is at least 2.

This revision is now accepted and ready to land.Jun 13 2022, 7:54 AM
craig.topper added inline comments.Jun 13 2022, 8:49 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
2973

Agreed, I mainly did it for the compile time win. getMaxBuildIntsCost has a max with 2 in it.