Adds support for i64 constant. It uses the same pattern-based
approach as in SDAG (see PPCISelDAGToDAG::selectI64ImmDirect(),
PPCISelDAGToDAG::selectI64Imm()). It does not support the
prefixed instructions.
Details
Diff Detail
Event Timeline
- Use uint32_t in findContiguousZerosAtLeast()
- Replace use of constrainSelectedInstRegOperands() with constrainAllUses()
- Uses std::optional<bool> instead of MI parameter
llvm/lib/Target/PowerPC/GISel/PPCInstructionSelector.cpp | ||
---|---|---|
706 | I don't understand the point of the optional, just make it a bool |
llvm/lib/Target/PowerPC/GISel/PPCInstructionSelector.cpp | ||
---|---|---|
706 | The function has 3 outcomes: It returns the result from constrainAllUses() (a bool), but it can also fail to produce a an instruction if none of the pattern the pattern matches. |
llvm/lib/Target/PowerPC/GISel/PPCInstructionSelector.cpp | ||
---|---|---|
691–692 | You can just unconditionally erase, if it failed the whole function's getting deleted anyway |
hmm, so many duplicated codes, but seems there is no simple way to avoid this.
D139813 adds some improvement for i64 materialization in DAG ISel. That should be adopted to GISel too.
This reminds me there was a proposal (https://reviews.llvm.org/D82709#2137837) for PPC target that PPC can materialize the i64 imm after ISEL and in ISEL just lower the i64 imm to a pseudo instruction. So we can avoid the duplication here and also some other remat issue in register allocation. But that may require big effort...
I agree that the code duplication is unfortune. There is also the comment in PPCInstrInfo::materializeImmPostRA():
// FIXME: Materialization here is not optimal. // For some special bit patterns we can use less instructions. // See `selectI64ImmDirect` in PPCISelDAGToDAG.cpp.
Well, we would need:
- a new pseudo instruction loadimmi64
- a pass to expand the pseudo after ISEL
- in best case the implementation is shareable with materializeImmPostRA()
Sounds doable.
Stick with uint32_t return type?