From: Karl Meakin <[email protected]>
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 | 24 ++++++------------------
gcc/config/aarch64/predicates.md | 15 +++++++++++++++
2 files changed, 21 insertions(+), 18 deletions(-)
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 "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")))]
""
@@ -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 "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")))]
""
@@ -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 "<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")))]
""
@@ -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"))