This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][GlobalISel] Select G_CONSTANT, G_ANYEXT, COPY
ClosedPublic

Authored by nitinjohnraj on Aug 22 2023, 3:55 AM.

Details

Summary

We select G_CONSTANT generic opcodes by materializing the constant in a
register. G_ANYEXT is replaced with COPY.

Diff Detail

Event Timeline

nitinjohnraj created this revision.Aug 22 2023, 3:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 3:55 AM
nitinjohnraj published this revision for review.Aug 22 2023, 10:33 AM
nitinjohnraj edited the summary of this revision. (Show Details)
nitinjohnraj added a reviewer: arsenm.
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 10:34 AM
craig.topper added inline comments.Aug 22 2023, 10:39 AM
llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
259

Declare Result inside the loop.

262

Declare i here instead of outside the loop

263

Declare DstReg here instead of outside the loop.

llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/constant32.mir
3

What about riscv64?

nitinjohnraj marked 4 inline comments as done.

Addressed comments: Refactoring and added rv64 test

craig.topper added inline comments.Aug 22 2023, 12:21 PM
llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
262

const RISCVMatInt::Inst &I

llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/constant64.mir
2

Need s32/i32 tests too since i32 is legal on RV64.

Addressed comments

nitinjohnraj marked an inline comment as done.

Addressed comment

craig.topper added inline comments.Aug 22 2023, 12:32 PM
llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
262

Should be a reference.

Addressed comment

craig.topper added inline comments.Aug 22 2023, 1:04 PM
llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/constant64.mir
2

Did you miss this comment?

nitinjohnraj planned changes to this revision.Aug 22 2023, 1:06 PM

In order to add s32 tests for rv64 we need to select for G_ANYEXT instructions (to return the s32 constant).

llvm/test/CodeGen/RISCV/GlobalISel/instruction-select/constant64.mir
2

Sorry, was still working on this when I submitted, I forgot to change the status of the issue.
In order to return the constant, I need to select G_ANYEXT as well.

Added selection from COPY, G_ANYEXT and G_TRUNC

nitinjohnraj planned changes to this revision.Aug 22 2023, 6:14 PM
nitinjohnraj retitled this revision from [RISCV][GlobalISel] Select G_CONSTANT to [RISCV][GlobalISel] Select G_CONSTANT, G_ANYEXT, G_TRUNC, COPY.
nitinjohnraj edited the summary of this revision. (Show Details)
nitinjohnraj retitled this revision from [RISCV][GlobalISel] Select G_CONSTANT, G_ANYEXT, G_TRUNC, COPY to [RISCV][GlobalISel] Select G_CONSTANT, G_ANYEXT, COPY.Aug 22 2023, 6:44 PM
nitinjohnraj edited the summary of this revision. (Show Details)

Removed G_TRUNC, will address in another patch (with tests).

nitinjohnraj marked 3 inline comments as done.Aug 23 2023, 1:05 AM
This revision is now accepted and ready to land.Aug 23 2023, 9:43 AM
This revision was landed with ongoing or failed builds.Aug 23 2023, 3:34 PM
This revision was automatically updated to reflect the committed changes.