]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Add `aarch64_comparison_operator_cc`
authorKarl Meakin <karl.meakin@arm.com>
Fri, 17 Oct 2025 13:32:59 +0000 (13:32 +0000)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 15 Nov 2025 05:15:54 +0000 (21:15 -0800)
Deduplicate the checks against `ccmode` by extracting to a new
predicate.

gcc/ChangeLog:

* config/aarch64/aarch64.md(mov<ALLI_GPF:mode>cc): Use new predicate.
(mov<GPF:mode><GPI:mode>cc): Likewise.
(<neg_not_op><mode>cc): Likewise.
* config/aarch64/predicates.md (aarch64_comparison_operator_cc):
New predicate.

gcc/config/aarch64/aarch64.md
gcc/config/aarch64/predicates.md

index 1e14b1dc4f297e64bca93fc4404d317990f902c4..9203609a0686a50ecc9680dfd49bfecbac4221a2 100644 (file)
 
 (define_expand "mov<ALLI_GPF:mode>cc"
   [(set (match_operand:ALLI_GPF 0 "register_operand")
-       (if_then_else:ALLI_GPF (match_operand 1 "aarch64_comparison_operator")
+       (if_then_else:ALLI_GPF (match_operand 1 "aarch64_comparison_operator_cc")
                           (match_operand:ALLI_GPF 2 "register_operand")
                           (match_operand:ALLI_GPF 3 "register_operand")))]
   ""
     rtx ccreg = XEXP (operands[1], 0);
     enum machine_mode ccmode = GET_MODE (ccreg);
 
-    if (GET_MODE_CLASS (ccmode) == MODE_CC)
-      gcc_assert (XEXP (operands[1], 1) == const0_rtx);
-    else if (ccmode == QImode || ccmode == HImode)
-      FAIL;
-    else
+    if (GET_MODE_CLASS (ccmode) != MODE_CC)
       {
        ccreg = aarch64_gen_compare_reg (code, ccreg, XEXP (operands[1], 1));
        operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx);
 
 (define_expand "mov<GPF:mode><GPI:mode>cc"
   [(set (match_operand:GPI 0 "register_operand")
-       (if_then_else:GPI (match_operand 1 "aarch64_comparison_operator")
+       (if_then_else:GPI (match_operand 1 "aarch64_comparison_operator_cc")
                          (match_operand:GPF 2 "register_operand")
                          (match_operand:GPF 3 "register_operand")))]
   ""
 
     rtx ccreg = XEXP (operands[1], 0);
     enum machine_mode ccmode = GET_MODE (ccreg);
-    if (GET_MODE_CLASS (ccmode) == MODE_CC)
-      gcc_assert (XEXP (operands[1], 1) == const0_rtx);
-    else if (ccmode == QImode || ccmode == HImode)
-      FAIL;
-    else
+    if (GET_MODE_CLASS (ccmode) != MODE_CC)
       {
        ccreg = aarch64_gen_compare_reg (code, ccreg, XEXP (operands[1], 1));
        operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx);
 
 (define_expand "<neg_not_op><mode>cc"
   [(set (match_operand:GPI 0 "register_operand")
-       (if_then_else:GPI (match_operand 1 "aarch64_comparison_operator")
+       (if_then_else:GPI (match_operand 1 "aarch64_comparison_operator_cc")
                          (NEG_NOT:GPI (match_operand:GPI 2 "register_operand"))
                          (match_operand:GPI 3 "register_operand")))]
   ""
 
     rtx ccreg = XEXP (operands[1], 0);
     enum machine_mode ccmode = GET_MODE (ccreg);
-    if (GET_MODE_CLASS (ccmode) == MODE_CC)
-      gcc_assert (XEXP (operands[1], 1) == const0_rtx);
-    else if (ccmode == QImode || ccmode == HImode)
-      FAIL;
-    else
+    if (GET_MODE_CLASS (ccmode) != MODE_CC)
       {
        ccreg = aarch64_gen_compare_reg (code, ccreg, XEXP (operands[1], 1));
        operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx);
index 42304cef4391e15598bcd22da590c8663f3ffaa5..3214476497c6ac72649123b9399e73b3ff0ccbee 100644 (file)
   return aarch64_get_condition_code (op) >= 0;
 })
 
+(define_predicate "aarch64_comparison_operator_cc"
+  (match_code "eq,ne,le,lt,ge,gt,geu,gtu,leu,ltu,unordered,
+              ordered,unlt,unle,unge,ungt")
+{
+  rtx ccreg = XEXP (op, 0);
+  enum machine_mode ccmode = GET_MODE (ccreg);
+
+   if (GET_MODE_CLASS (ccmode) == MODE_CC)
+    gcc_assert (XEXP (op, 1) == const0_rtx);
+  else if (ccmode == QImode || ccmode == HImode)
+    return false;
+
+  return true;
+})
+
 (define_special_predicate "aarch64_equality_operator"
   (match_code "eq,ne"))