On 5/27/26 08:55, Philipp Tomsich wrote:
+;; Conditional increment of a sub-int value: split the fused
+;; ANY_EXTEND (plus:SHORT (cond) (val)) into a wide cinc and the extension.
+(define_insn_and_split "*cinc_ext_<SHORT:mode>_<GPI:mode>"
+  [(set (match_operand:GPI 0 "register_operand" "=r")
+       (ANY_EXTEND:GPI
+         (plus:SHORT
+           (match_operand:SHORT 1 "aarch64_comparison_operation" "")
+           (match_operand:SHORT 2 "register_operand" "r"))))
+   (clobber (match_scratch:GPI 3 "=r"))]
+  ""
+  "#"
+  "&& 1"
+  [(set (match_dup 3) (plus:GPI (match_dup 1) (match_dup 2)))
+   (set (match_dup 0) (ANY_EXTEND:GPI (match_dup 4)))]
+  {
+    if (GET_CODE (operands[3]) == SCRATCH)
+      operands[3] = gen_reg_rtx (<GPI:MODE>mode);
+    operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), <GPI:MODE>mode,
+                                 XEXP (operands[1], 0), XEXP (operands[1], 1));
+    /* Can't use gen_lowpart_SUBREG: the operand may already be a subreg.  */
+    operands[2] = lowpart_subreg (<GPI:MODE>mode, operands[2], 
<SHORT:MODE>mode);
+    operands[4] = gen_lowpart_SUBREG (<SHORT:MODE>mode, operands[3]);
+  }

These don't actually need a scratch, since the first insn of the expansion consumes all of the inputs. Thus the second insn can be (%0 (extend (subreg %0))).

But if you had needed a scratch, you would have needed to use =&r to get a non-overlapping scratch.


r~

Reply via email to