Skip to content

Conversation

@topperc
Copy link
Collaborator

@topperc topperc commented Jan 31, 2025

We have ComplexPatterns that reduce 3 patterns to 1, by handling the ==/!= 0, imm, and register cases. These are used for XTHeadCondMove, Zicond, XVentanaCondOps, and our basic seteq/setne patterns.

We have ComplexPatterns that reduce 3 patterns to 1, by handling
the ==/!= 0, imm, and register cases. These are used for
XTHeadCondMove, Zicond, XVentanaCondOps, and our basic
seteq/setne patterns.
@llvmbot
Copy link
Member

llvmbot commented Jan 31, 2025

@llvm/pr-subscribers-backend-risc-v

Author: Craig Topper (topperc)

Changes

We have ComplexPatterns that reduce 3 patterns to 1, by handling the ==/!= 0, imm, and register cases. These are used for XTHeadCondMove, Zicond, XVentanaCondOps, and our basic seteq/setne patterns.


Full diff: https://github.com/llvm/llvm-project/pull/125318.diff

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td (+3-14)
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td
index f53a887f62d464..9be424310d6600 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td
@@ -116,24 +116,13 @@ def MIPS_CCMOV : RVInstR4<0b11, 0b011, OPC_CUSTOM_0, (outs GPR:$rd),
 }
 
 let Predicates = [UseCCMovInsn] in {
-def : Pat<(select (XLenVT (setne (XLenVT GPR:$rs2), (XLenVT 0))),
+def : Pat<(select (riscv_setne (XLenVT GPR:$rs2)),
                   (XLenVT GPR:$rs1), (XLenVT GPR:$rs3)),
           (MIPS_CCMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
-def : Pat<(select (XLenVT (setne (XLenVT GPR:$x), (XLenVT simm12_plus1:$y))),
-                  (XLenVT GPR:$rs1), (XLenVT GPR:$rs3)),
-          (MIPS_CCMOV GPR:$rs1, (ADDI GPR:$x, (NegImm simm12_plus1:$y)), GPR:$rs3)>;
-def : Pat<(select (XLenVT (setne (XLenVT GPR:$x), (XLenVT GPR:$y))),
-                  (XLenVT GPR:$rs1), (XLenVT GPR:$rs3)),
-          (MIPS_CCMOV GPR:$rs1, (XOR GPR:$x, GPR:$y), GPR:$rs3)>;
-def : Pat<(select (XLenVT (seteq (XLenVT GPR:$rs2), (XLenVT 0))),
+def : Pat<(select (riscv_seteq (XLenVT GPR:$rs2)),
                   (XLenVT GPR:$rs3), (XLenVT GPR:$rs1)),
           (MIPS_CCMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
-def : Pat<(select (XLenVT (seteq (XLenVT GPR:$x), (XLenVT simm12_plus1:$y))),
-                  (XLenVT GPR:$rs3), (XLenVT GPR:$rs1)),
-          (MIPS_CCMOV GPR:$rs1, (ADDI GPR:$x, (NegImm simm12_plus1:$y)), GPR:$rs3)>;
-def : Pat<(select (XLenVT (seteq (XLenVT GPR:$x), (XLenVT GPR:$y))),
-                  (XLenVT GPR:$rs3), (XLenVT GPR:$rs1)),
-          (MIPS_CCMOV GPR:$rs1, (XOR GPR:$x, GPR:$y), GPR:$rs3)>;
+
 def : Pat<(select (XLenVT GPR:$rs2), (XLenVT GPR:$rs1), (XLenVT GPR:$rs3)),
           (MIPS_CCMOV GPR:$rs1, GPR:$rs2, GPR:$rs3)>;
 }

Copy link
Collaborator

@djtodoro djtodoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, lgtm as well, thanks!

@topperc topperc merged commit 1533682 into llvm:main Feb 1, 2025
10 checks passed
@topperc topperc deleted the pr/mips-cmov branch February 1, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants