diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZb.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZb.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoZb.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZb.td @@ -232,6 +232,12 @@ N->getValueType(0)); }]>; +// Pattern to exclude simm12 immediates from matching. +def non_imm12 : PatLeaf<(XLenVT GPR:$a), [{ + auto *C = dyn_cast(N); + return !C || !isInt<12>(C->getSExtValue()); +}]>; + //===----------------------------------------------------------------------===// // Instruction class templates //===----------------------------------------------------------------------===// @@ -1042,12 +1048,6 @@ let Predicates = [HasStdExtZbbOrZbp, IsRV64] in def : Pat<(i64 (and GPR:$rs, 0xFFFF)), (ZEXT_H_RV64 GPR:$rs)>; -// Pattern to exclude simm12 immediates from matching. -def non_imm12 : PatLeaf<(XLenVT GPR:$a), [{ - auto *C = dyn_cast(N); - return !C || !isInt<12>(C->getSExtValue()); -}]>; - let Predicates = [HasStdExtZba] in { def : Pat<(add (shl GPR:$rs1, (XLenVT 1)), non_imm12:$rs2), (SH1ADD GPR:$rs1, GPR:$rs2)>;