[llvm] 350ab4e - [RISCV] Use OperandTransform field of ImmLeaf to slightly simplify a couple bitmanip patterns. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 10 17:52:32 PST 2021
Author: Craig Topper
Date: 2021-02-10T17:52:07-08:00
New Revision: 350ab4e617ba99a78ea5397a51333091559fada4
URL: https://github.com/llvm/llvm-project/commit/350ab4e617ba99a78ea5397a51333091559fada4
DIFF: https://github.com/llvm/llvm-project/commit/350ab4e617ba99a78ea5397a51333091559fada4.diff
LOG: [RISCV] Use OperandTransform field of ImmLeaf to slightly simplify a couple bitmanip patterns. NFC
This binds the SDNodeXForm to the ImmLeaf so we only need to mention
the ImmLeaf in both the input and output pattern.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
index a312d23f15b5..3a415b37188e 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -47,20 +47,6 @@ def shfl_uimm : Operand<XLenVT>, ImmLeaf<XLenVT, [{
}];
}
-// Checks if this mask has a single 0 bit and cannot be used with ANDI.
-def BCLRMask : ImmLeaf<XLenVT, [{
- if (Subtarget->is64Bit())
- return !isInt<12>(Imm) && isPowerOf2_64(~Imm);
- return !isInt<12>(Imm) && isPowerOf2_32(~Imm);
-}]>;
-
-// Checks if this mask has a single 1 bit and cannot be used with ORI/XORI.
-def BSETINVMask : ImmLeaf<XLenVT, [{
- if (Subtarget->is64Bit())
- return !isInt<12>(Imm) && isPowerOf2_64(Imm);
- return !isInt<12>(Imm) && isPowerOf2_32(Imm);
-}]>;
-
def BCLRXForm : SDNodeXForm<imm, [{
// Find the lowest 0.
return CurDAG->getTargetConstant(N->getAPIntValue().countTrailingOnes(),
@@ -73,6 +59,20 @@ def BSETINVXForm : SDNodeXForm<imm, [{
SDLoc(N), N->getValueType(0));
}]>;
+// Checks if this mask has a single 0 bit and cannot be used with ANDI.
+def BCLRMask : ImmLeaf<XLenVT, [{
+ if (Subtarget->is64Bit())
+ return !isInt<12>(Imm) && isPowerOf2_64(~Imm);
+ return !isInt<12>(Imm) && isPowerOf2_32(~Imm);
+}], BCLRXForm>;
+
+// Checks if this mask has a single 1 bit and cannot be used with ORI/XORI.
+def BSETINVMask : ImmLeaf<XLenVT, [{
+ if (Subtarget->is64Bit())
+ return !isInt<12>(Imm) && isPowerOf2_64(Imm);
+ return !isInt<12>(Imm) && isPowerOf2_32(Imm);
+}], BSETINVXForm>;
+
//===----------------------------------------------------------------------===//
// Instruction class templates
//===----------------------------------------------------------------------===//
@@ -648,11 +648,11 @@ def : Pat<(shiftop<shl> 1, GPR:$rs2),
(BSET X0, GPR:$rs2)>;
def : Pat<(and GPR:$rs1, BCLRMask:$mask),
- (BCLRI GPR:$rs1, (BCLRXForm imm:$mask))>;
+ (BCLRI GPR:$rs1, BCLRMask:$mask)>;
def : Pat<(or GPR:$rs1, BSETINVMask:$mask),
- (BSETI GPR:$rs1, (BSETINVXForm imm:$mask))>;
+ (BSETI GPR:$rs1, BSETINVMask:$mask)>;
def : Pat<(xor GPR:$rs1, BSETINVMask:$mask),
- (BINVI GPR:$rs1, (BSETINVXForm imm:$mask))>;
+ (BINVI GPR:$rs1, BSETINVMask:$mask)>;
def : Pat<(and (srl GPR:$rs1, uimmlog2xlen:$shamt), (XLenVT 1)),
(BEXTI GPR:$rs1, uimmlog2xlen:$shamt)>;
More information about the llvm-commits
mailing list