[llvm] [RISCV][GISEL] Fix legalization for G_MERGE/UNMERGE_VALUES (PR #75619)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 15 10:11:18 PST 2023
================
@@ -85,14 +85,16 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
// Merge/Unmerge
for (unsigned Op : {G_MERGE_VALUES, G_UNMERGE_VALUES}) {
- unsigned BigTyIdx = Op == G_MERGE_VALUES ? 0 : 1;
- unsigned LitTyIdx = Op == G_MERGE_VALUES ? 1 : 0;
auto &MergeUnmergeActions = getActionDefinitionsBuilder(Op);
if (XLen == 32 && ST.hasStdExtD()) {
- LLT IdxZeroTy = G_MERGE_VALUES ? s64 : s32;
- LLT IdxOneTy = G_MERGE_VALUES ? s32 : s64;
- MergeUnmergeActions.legalFor({IdxZeroTy, IdxOneTy});
+ // Only need to legalize on IdxZeroTy since there is no way to construct
+ // a valid MERGE/UNMERGE where the types don't combine/decompose as
+ // expected.
+ LLT IdxZeroTy = Op == G_MERGE_VALUES ? s64 : s32;
+ MergeUnmergeActions.legalFor({IdxZeroTy});
----------------
topperc wrote:
> I have updated the code to do this, but I suppose there could be a case where you want to mark a type index as legal, regardless of what the other type index is.
You couldn't make type index 1 legal and ignore type index 0 though. So it would be inconsistent if that was the intent.
https://github.com/llvm/llvm-project/pull/75619
More information about the llvm-commits
mailing list