[PATCH] D90546: [RISCV] Remove custom isel for (srl (shl val, 32), imm). Use pattern instead. NFCI
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 4 10:00:06 PST 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3701e33a2213: [RISCV] Remove custom isel for (srl (shl val, 32), imm). Use pattern instead. (authored by craig.topper).
Changed prior to commit:
https://reviews.llvm.org/D90546?vs=302122&id=302881#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90546/new/
https://reviews.llvm.org/D90546
Files:
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
Index: llvm/lib/Target/RISCV/RISCVInstrInfoB.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -40,12 +40,6 @@
}];
}
-// Return an immediate value minus 32.
-def ImmSub32 : SDNodeXForm<imm, [{
- return CurDAG->getTargetConstant(N->getSExtValue() - 32, SDLoc(N),
- N->getValueType(0));
-}]>;
-
// Convert rotl immediate to a rotr immediate.
def ImmROTL2R : SDNodeXForm<imm, [{
@@ -1043,9 +1037,9 @@
(FSRW GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
def : Pat<(sext_inreg (fshr (assertsexti32 GPR:$rs1),
(shl (assertsexti32 GPR:$rs2), (i64 32)),
- uimmlog2xlen:$shamt),
+ uimm6gt32:$shamt),
i32),
- (FSRIW GPR:$rs1, GPR:$rs2, (ImmSub32 uimm5:$shamt))>;
+ (FSRIW GPR:$rs1, GPR:$rs2, (ImmSub32 uimm6gt32:$shamt))>;
} // Predicates = [HasStdExtZbt, IsRV64]
let Predicates = [HasStdExtZbb, IsRV64] in {
Index: llvm/lib/Target/RISCV/RISCVInstrInfo.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -291,6 +291,11 @@
return countTrailingOnes<uint64_t>(Imm) >= 5;
}]>;
+// A 6-bit constant greater than 32.
+def uimm6gt32 : ImmLeaf<XLenVT, [{
+ return isUInt<6>(Imm) && Imm > 32;
+}]>;
+
// Addressing modes.
// Necessary because a frameindex can't be matched directly in a pattern.
def AddrFI : ComplexPattern<iPTR, 1, "SelectAddrFI", [frameindex], []>;
@@ -316,6 +321,12 @@
N->getValueType(0));
}]>;
+// Return an immediate value minus 32.
+def ImmSub32 : SDNodeXForm<imm, [{
+ return CurDAG->getTargetConstant(N->getSExtValue() - 32, SDLoc(N),
+ N->getValueType(0));
+}]>;
+
//===----------------------------------------------------------------------===//
// Instruction Formats
//===----------------------------------------------------------------------===//
@@ -1128,6 +1139,8 @@
(SLLIW GPR:$rs1, uimm5:$shamt)>;
// (srl (zexti32 ...), uimm5:$shamt) is matched with custom code due to the
// need to undo manipulation of the mask value performed by DAGCombine.
+def : Pat<(srl (shl GPR:$rs1, (i64 32)), uimm6gt32:$shamt),
+ (SRLIW GPR:$rs1, (ImmSub32 uimm6gt32:$shamt))>;
def : Pat<(sra (sext_inreg GPR:$rs1, i32), uimm5:$shamt),
(SRAIW GPR:$rs1, uimm5:$shamt)>;
Index: llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -141,20 +141,6 @@
return;
}
}
- // Match (srl (shl val, 32), imm).
- if (Op0->getOpcode() == ISD::SHL &&
- isa<ConstantSDNode>(Op0->getOperand(1)) &&
- isa<ConstantSDNode>(Node->getOperand(1))) {
- uint64_t ShlAmt = Op0->getConstantOperandVal(1);
- uint64_t SrlAmt = Node->getConstantOperandVal(1);
- if (ShlAmt == 32 && SrlAmt > 32) {
- SDValue SrlAmtSub32Val =
- CurDAG->getTargetConstant(SrlAmt - 32, SDLoc(Node), XLenVT);
- CurDAG->SelectNodeTo(Node, RISCV::SRLIW, XLenVT, Op0->getOperand(0),
- SrlAmtSub32Val);
- return;
- }
- }
break;
}
case RISCVISD::READ_CYCLE_WIDE:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90546.302881.patch
Type: text/x-patch
Size: 3509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201104/5e99269c/attachment-0001.bin>
More information about the llvm-commits
mailing list