From: Karl Meakin Date: Fri, 17 Oct 2025 13:32:59 +0000 (+0000) Subject: aarch64: Add `aarch64_comparison_operator_cc` X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c131624ba4e93cb36319a021c513fc7851016450;p=thirdparty%2Fgcc.git aarch64: Add `aarch64_comparison_operator_cc` Deduplicate the checks against `ccmode` by extracting to a new predicate. gcc/ChangeLog: * config/aarch64/aarch64.md(movcc): Use new predicate. (movcc): Likewise. (cc): Likewise. * config/aarch64/predicates.md (aarch64_comparison_operator_cc): New predicate. --- diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 1e14b1dc4f2..9203609a068 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -4799,7 +4799,7 @@ (define_expand "movcc" [(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")))] "" @@ -4808,11 +4808,7 @@ 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); @@ -4822,7 +4818,7 @@ (define_expand "movcc" [(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")))] "" @@ -4831,11 +4827,7 @@ 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); @@ -4845,7 +4837,7 @@ (define_expand "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")))] "" @@ -4854,11 +4846,7 @@ 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); diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md index 42304cef439..3214476497c 100644 --- a/gcc/config/aarch64/predicates.md +++ b/gcc/config/aarch64/predicates.md @@ -459,6 +459,21 @@ 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"))