[llvm] [Sparc] Optimize compare instruction (PR #167140)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 8 07:47:00 PST 2025
================
@@ -914,8 +914,17 @@ let Defs = [ICC], hasPostISelHook = true in
let Uses = [ICC] in
defm SUBC : F3_12np <"subx", 0b001100>;
-def : Pat<(SPcmpicc i32:$lhs, i32:$rhs), (SUBCCrr $lhs, $rhs)>;
-def : Pat<(SPcmpicc i32:$lhs, (i32 simm13:$rhs)), (SUBCCri $lhs, imm:$rhs)>;
+// cmp (from Section A.3) is a specialized alias for subcc
+let Defs = [ICC], rd = 0, isCompare = 1 in {
+ def CMPrr : F3_1<2, 0b010100,
+ (outs), (ins IntRegs:$rs1, IntRegs:$rs2),
+ "cmp $rs1, $rs2",
+ [(SPcmpicc i32:$rs1, i32:$rs2)]>;
+ def CMPri : F3_2<2, 0b010100,
+ (outs), (ins IntRegs:$rs1, simm13Op:$simm13),
+ "cmp $rs1, $simm13",
+ [(SPcmpicc i32:$rs1, (i32 simm13:$simm13))]>;
+}
----------------
s-barannikov wrote:
These instructions don't exist, that's why I removed them.
If the only reason you added them back is `isCompare` flag, it should be set on the corresponding real instructions.
https://github.com/llvm/llvm-project/pull/167140
More information about the llvm-commits
mailing list