[llvm] [RISCV] Handle more (add x, C) -> (sub x, -C) cases (PR #138705)

Piotr Fusik via llvm-commits llvm-commits at lists.llvm.org
Mon May 12 03:47:20 PDT 2025


================
@@ -907,6 +907,19 @@ foreach vti = AllIntegerVectors in {
   }
 }
 
+// (add v, C) -> (sub v, -C) if -C cheaper to materialize
+foreach vti = I64IntegerVectors in {
+  let Predicates = [HasVInstructionsI64] in {
+    def : Pat<(add (vti.Vector vti.RegClass:$rs1),
+                   (vti.Vector (SplatPat (i64 negImm:$rs2)))),
+//                 (riscv_vmv_v_x_vl undef, negImm:$rs2, srcvalue)),
----------------
pfusik wrote:

Resolved by adding a combined ComplexPattern.
Pity there's no TableGen diagnostic for nested ComplexPatterns.

https://github.com/llvm/llvm-project/pull/138705


More information about the llvm-commits mailing list