[llvm] [RISCV] Simplify PatSetCC_m and PatFprFprDynFrm_m (PR #68562)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 01:06:43 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
<details>
<summary>Changes</summary>
1. Use `Ext.PrimaryVT` in `PatSetCC_m `
2. Merge `PatFprFprDynFrm` from Zfh/Zhinx two locations into `PatFprFprDynFrm_m`.
---
Full diff: https://github.com/llvm/llvm-project/pull/68562.diff
3 Files Affected:
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoD.td (+6-6)
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoF.td (+12-12)
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td (+17-20)
``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td
index aeb9ebc56a975e0..59312f02aeceb77 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td
@@ -397,12 +397,12 @@ foreach Ext = DExts in {
// Match non-signaling FEQ_D
foreach Ext = DExts in {
- defm : PatSetCC_m<any_fsetcc, SETEQ, FEQ_D, Ext, f64>;
- defm : PatSetCC_m<any_fsetcc, SETOEQ, FEQ_D, Ext, f64>;
- defm : PatSetCC_m<strict_fsetcc, SETLT, PseudoQuietFLT_D, Ext, f64>;
- defm : PatSetCC_m<strict_fsetcc, SETOLT, PseudoQuietFLT_D, Ext, f64>;
- defm : PatSetCC_m<strict_fsetcc, SETLE, PseudoQuietFLE_D, Ext, f64>;
- defm : PatSetCC_m<strict_fsetcc, SETOLE, PseudoQuietFLE_D, Ext, f64>;
+ defm : PatSetCC_m<any_fsetcc, SETEQ, FEQ_D, Ext>;
+ defm : PatSetCC_m<any_fsetcc, SETOEQ, FEQ_D, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETLT, PseudoQuietFLT_D, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETOLT, PseudoQuietFLT_D, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETLE, PseudoQuietFLE_D, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETOLE, PseudoQuietFLE_D, Ext>;
}
let Predicates = [HasStdExtD] in {
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td
index 6ff6e4e5f3a7238..8726245f1602ebf 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td
@@ -481,10 +481,10 @@ class PatSetCC<DAGOperand Ty, SDPatternOperator OpNode, CondCode Cond,
RVInst Inst, ValueType vt>
: Pat<(XLenVT (OpNode (vt Ty:$rs1), Ty:$rs2, Cond)), (Inst $rs1, $rs2)>;
multiclass PatSetCC_m<SDPatternOperator OpNode, CondCode Cond,
- RVInst Inst, ExtInfo Ext, ValueType vt> {
+ RVInst Inst, ExtInfo Ext> {
let Predicates = Ext.Predicates in
def Ext.Suffix : PatSetCC<Ext.PrimaryTy, OpNode, Cond,
- !cast<RVInst>(Inst#Ext.Suffix), vt>;
+ !cast<RVInst>(Inst#Ext.Suffix), Ext.PrimaryVT>;
}
class PatFprFpr<SDPatternOperator OpNode, RVInstR Inst,
@@ -606,12 +606,12 @@ foreach Ext = FExts in {
// Match non-signaling FEQ_S
foreach Ext = FExts in {
- defm : PatSetCC_m<any_fsetcc, SETEQ, FEQ_S, Ext, f32>;
- defm : PatSetCC_m<any_fsetcc, SETOEQ, FEQ_S, Ext, f32>;
- defm : PatSetCC_m<strict_fsetcc, SETLT, PseudoQuietFLT_S, Ext, f32>;
- defm : PatSetCC_m<strict_fsetcc, SETOLT, PseudoQuietFLT_S, Ext, f32>;
- defm : PatSetCC_m<strict_fsetcc, SETLE, PseudoQuietFLE_S, Ext, f32>;
- defm : PatSetCC_m<strict_fsetcc, SETOLE, PseudoQuietFLE_S, Ext, f32>;
+ defm : PatSetCC_m<any_fsetcc, SETEQ, FEQ_S, Ext>;
+ defm : PatSetCC_m<any_fsetcc, SETOEQ, FEQ_S, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETLT, PseudoQuietFLT_S, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETOLT, PseudoQuietFLT_S, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETLE, PseudoQuietFLE_S, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETOLE, PseudoQuietFLE_S, Ext>;
}
let Predicates = [HasStdExtF] in {
@@ -645,10 +645,10 @@ def : Pat<(XLenVT (strict_fsetccs FPR32INX:$rs1, FPR32INX:$rs1, SETOEQ)),
} // Predicates = [HasStdExtZfinx]
foreach Ext = FExts in {
- defm : PatSetCC_m<any_fsetccs, SETLT, FLT_S, Ext, f32>;
- defm : PatSetCC_m<any_fsetccs, SETOLT, FLT_S, Ext, f32>;
- defm : PatSetCC_m<any_fsetccs, SETLE, FLE_S, Ext, f32>;
- defm : PatSetCC_m<any_fsetccs, SETOLE, FLE_S, Ext, f32>;
+ defm : PatSetCC_m<any_fsetccs, SETLT, FLT_S, Ext>;
+ defm : PatSetCC_m<any_fsetccs, SETOLT, FLT_S, Ext>;
+ defm : PatSetCC_m<any_fsetccs, SETLE, FLE_S, Ext>;
+ defm : PatSetCC_m<any_fsetccs, SETOLE, FLE_S, Ext>;
}
let Predicates = [HasStdExtF] in {
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
index c53462a74f36264..b65e9f5af033194 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
@@ -248,7 +248,6 @@ def PseudoQuietFLT_H_INX : PseudoQuietFCMP<FPR16INX>;
// Pseudo-instructions and codegen patterns
//===----------------------------------------------------------------------===//
-let Predicates = [HasStdExtZfh] in {
/// Float conversion operations
@@ -257,11 +256,14 @@ let Predicates = [HasStdExtZfh] in {
/// Float arithmetic operations
-def : PatFprFprDynFrm<any_fadd, FADD_H, FPR16, f16>;
-def : PatFprFprDynFrm<any_fsub, FSUB_H, FPR16, f16>;
-def : PatFprFprDynFrm<any_fmul, FMUL_H, FPR16, f16>;
-def : PatFprFprDynFrm<any_fdiv, FDIV_H, FPR16, f16>;
+foreach Ext = ZfhExts in {
+ defm : PatFprFprDynFrm_m<any_fadd, FADD_H, Ext>;
+ defm : PatFprFprDynFrm_m<any_fsub, FSUB_H, Ext>;
+ defm : PatFprFprDynFrm_m<any_fmul, FMUL_H, Ext>;
+ defm : PatFprFprDynFrm_m<any_fdiv, FDIV_H, Ext>;
+}
+let Predicates = [HasStdExtZfh] in {
def : Pat<(f16 (any_fsqrt FPR16:$rs1)), (FSQRT_H FPR16:$rs1, FRM_DYN)>;
def : Pat<(f16 (fneg FPR16:$rs1)), (FSGNJN_H $rs1, $rs1)>;
@@ -304,11 +306,6 @@ let Predicates = [HasStdExtZhinx] in {
/// Float arithmetic operations
-def : PatFprFprDynFrm<any_fadd, FADD_H_INX, FPR16INX, f16>;
-def : PatFprFprDynFrm<any_fsub, FSUB_H_INX, FPR16INX, f16>;
-def : PatFprFprDynFrm<any_fmul, FMUL_H_INX, FPR16INX, f16>;
-def : PatFprFprDynFrm<any_fdiv, FDIV_H_INX, FPR16INX, f16>;
-
def : Pat<(any_fsqrt FPR16INX:$rs1), (FSQRT_H_INX FPR16INX:$rs1, FRM_DYN)>;
def : Pat<(fneg FPR16INX:$rs1), (FSGNJN_H_INX $rs1, $rs1)>;
@@ -358,12 +355,12 @@ foreach Ext = ZfhExts in {
// Match non-signaling FEQ_D
foreach Ext = ZfhExts in {
- defm : PatSetCC_m<any_fsetcc, SETEQ, FEQ_H, Ext, f16>;
- defm : PatSetCC_m<any_fsetcc, SETOEQ, FEQ_H, Ext, f16>;
- defm : PatSetCC_m<strict_fsetcc, SETLT, PseudoQuietFLT_H, Ext, f16>;
- defm : PatSetCC_m<strict_fsetcc, SETOLT, PseudoQuietFLT_H, Ext, f16>;
- defm : PatSetCC_m<strict_fsetcc, SETLE, PseudoQuietFLE_H, Ext, f16>;
- defm : PatSetCC_m<strict_fsetcc, SETOLE, PseudoQuietFLE_H, Ext, f16>;
+ defm : PatSetCC_m<any_fsetcc, SETEQ, FEQ_H, Ext>;
+ defm : PatSetCC_m<any_fsetcc, SETOEQ, FEQ_H, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETLT, PseudoQuietFLT_H, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETOLT, PseudoQuietFLT_H, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETLE, PseudoQuietFLE_H, Ext>;
+ defm : PatSetCC_m<strict_fsetcc, SETOLE, PseudoQuietFLE_H, Ext>;
}
let Predicates = [HasStdExtZfh] in {
@@ -397,10 +394,10 @@ def : Pat<(XLenVT (strict_fsetccs FPR16INX:$rs1, FPR16INX:$rs1, SETOEQ)),
} // Predicates = [HasStdExtZhinx]
foreach Ext = ZfhExts in {
- defm : PatSetCC_m<any_fsetccs, SETLT, FLT_H, Ext, f16>;
- defm : PatSetCC_m<any_fsetccs, SETOLT, FLT_H, Ext, f16>;
- defm : PatSetCC_m<any_fsetccs, SETLE, FLE_H, Ext, f16>;
- defm : PatSetCC_m<any_fsetccs, SETOLE, FLE_H, Ext, f16>;
+ defm : PatSetCC_m<any_fsetccs, SETLT, FLT_H, Ext>;
+ defm : PatSetCC_m<any_fsetccs, SETOLT, FLT_H, Ext>;
+ defm : PatSetCC_m<any_fsetccs, SETLE, FLE_H, Ext>;
+ defm : PatSetCC_m<any_fsetccs, SETOLE, FLE_H, Ext>;
}
let Predicates = [HasStdExtZfh] in {
``````````
</details>
https://github.com/llvm/llvm-project/pull/68562
More information about the llvm-commits
mailing list