[llvm] [RISCV] Select unsigned bitfield extract for Xqcibm (PR #143354)
Jim Lin via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 9 02:14:32 PDT 2025
================
@@ -674,12 +674,24 @@ bool RISCVDAGToDAGISel::trySignedBitfieldExtract(SDNode *Node) {
bool RISCVDAGToDAGISel::tryUnsignedBitfieldExtract(SDNode *Node, SDLoc DL,
MVT VT, SDValue X,
unsigned Msb, unsigned Lsb) {
- // Only supported with XTHeadBb/XAndesPerf at the moment.
- if (!Subtarget->hasVendorXTHeadBb() && !Subtarget->hasVendorXAndesPerf())
+ bool IsXTheadBb = Subtarget->hasVendorXTHeadBb();
+ bool IsXAndesPerf = Subtarget->hasVendorXAndesPerf();
+ bool IsXqcibm = Subtarget->hasVendorXqcibm();
+
+ // Only supported with XTHeadBb/XAndesPerf/Xqcibm at the moment.
+ if (!IsXTheadBb && !IsXAndesPerf && !IsXqcibm)
return false;
- unsigned Opc =
- Subtarget->hasVendorXTHeadBb() ? RISCV::TH_EXTU : RISCV::NDS_BFOZ;
+ if (IsXqcibm) {
+ // QC.EXTU X, width, shamt
+ // shamt is the same as Lsb
+ // width is the number of bits to extract from the Lsb
+ Msb = Msb - Lsb + 1;
+ }
+
+ unsigned Opc = IsXTheadBb ? RISCV::TH_EXTU
+ : IsXAndesPerf ? RISCV::NDS_BFOZ
+ : RISCV::QC_EXTU;
----------------
tclin914 wrote:
```suggestion
if (Opc == RISCV::QC_EXTU) {
// QC.EXTU X, width, shamt
// shamt is the same as Lsb
// width is the number of bits to extract from the Lsb
Msb = Msb - Lsb + 1;
}
```
https://github.com/llvm/llvm-project/pull/143354
More information about the llvm-commits
mailing list