Skip to content

[RISCV] Reorder insert_subvector and bitcast in getDeinterleaveShiftAndTrunc. #127258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Feb 14, 2025

Put the bitcast before the insert_subvector. It's more likely the insert subvector can be combined with other nodes. The insert_subvector only needed sometimes, and I'm considering reusing this function which might require pulling the insert_subvector out.

…ndTrunc.

Put the bitcast before the insert_subvector. It's more likely the
insert subvector can be combined with other nodes.
@llvmbot
Copy link
Member

llvmbot commented Feb 14, 2025

@llvm/pr-subscribers-backend-risc-v

Author: Craig Topper (topperc)

Changes

Put the bitcast before the insert_subvector. It's more likely the insert subvector can be combined with other nodes. The insert_subvector only needed sometimes, and I'm considering reusing this function which might require pulling the insert_subvector out.


Full diff: https://github.com/llvm/llvm-project/pull/127258.diff

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVISelLowering.cpp (+4-4)
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index da04880348af6..9784ef13f3782 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -4660,10 +4660,10 @@ static SDValue getDeinterleaveShiftAndTrunc(const SDLoc &DL, MVT VT,
   SDValue Res = DAG.getNode(ISD::SRL, DL, WideSrcVT, Src,
                             DAG.getConstant(Shift, DL, WideSrcVT));
   Res = DAG.getNode(ISD::TRUNCATE, DL, ResVT, Res);
-  MVT IntVT = VT.changeVectorElementTypeToInteger();
-  Res = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, IntVT, DAG.getUNDEF(IntVT), Res,
-                    DAG.getVectorIdxConstant(0, DL));
-  return DAG.getBitcast(VT, Res);
+  MVT CastVT = ResVT.changeVectorElementType(VT.getVectorElementType());
+  Res = DAG.getBitcast(CastVT, Res);
+  return DAG.getNode(ISD::INSERT_SUBVECTOR, DL, VT, DAG.getUNDEF(VT), Res,
+                     DAG.getVectorIdxConstant(0, DL));
 }
 
 // Lower the following shuffle to vslidedown.

Copy link
Collaborator

@preames preames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@topperc topperc merged commit 7a6d150 into llvm:main Feb 15, 2025
10 checks passed
@topperc topperc deleted the pr/reorder-deinterleave branch February 15, 2025 02:46
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
…ndTrunc. (llvm#127258)

Put the bitcast before the insert_subvector. It's more likely the insert
subvector can be combined with other nodes. The insert_subvector is only
needed sometimes, and I'm considering reusing this function which might
require pulling the insert_subvector out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants