Fixes https://github.com/llvm/llvm-project/issues/62734.
This patch handles addimm chains in SelectAddrRegImm to better reuse materialized constant when the offset is larger than the maximum immediate.
Paths
| Differential D150665
[RISCV] Handle addimm chains in SelectAddrRegImm AbandonedPublic Authored by dtcxzyw on May 16 2023, 6:03 AM.
Details
Summary Fixes https://github.com/llvm/llvm-project/issues/62734. This patch handles addimm chains in SelectAddrRegImm to better reuse materialized constant when the offset is larger than the maximum immediate.
Diff Detail
Event TimelineComment Actions Can this create additional LUIs if the lower 12-bits wrap around? That defeats the point of the common base optimization. Does this prevent using C.LW/C.SW/C.LD/C.SD because we've increased the size of the offsets? Comment Actions
Comment Actions I feel like this should be handled where the chain was formed or in DAG combine. The whole reason the chain exists is to provide a common base. If the common base isn't right we should fix that.
Comment Actions
I cannot find code about forming chains in RISCVISelLowering.cpp and RISCVISelDAGToDAG.cpp. Should I implement some virtual member functions of class TargetLowering? Comment Actions
I think the splitting is done by CodeGenPrepare::splitLargeGEPOffsets() Comment Actions
I think we can select a better offset by calling a new virtual function like TLI->selectBaseOffset() instead of just using GEP with the smallest offset.
Revision Contents
Diff 523265 llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/test/CodeGen/RISCV/split-offsets.ll
|
Zcf and Zcd imply Zca so I don't think you need to check them. You can also hasStdExtCOrZca.