b/gcc/config/aarch64/aarch64-protos.h
@@ -246,6 +246,8 @@ void aarch64_init_expanders (void);
void aarch64_print_operand (FILE *, rtx, char);
void aarch64_print_operand_address (FILE *, rtx);
+bool aarch64_uimm5 (HOST_WIDE_INT);
+
/* Initialize builtins for SIMD intrinsics. */
void init_aarch64_simd_builtins (void);
@@ -9566,6 +9566,13 @@ aarch64_expand_movmem (rtx *operands)
return true;
}
+/* Return true if val can be encoded as a 5-bit unsigned immediate. */
+bool
+aarch64_uimm5 (HOST_WIDE_INT val)
+{
+ return (val & (HOST_WIDE_INT) 0x1f) == val;
+}
+
#undef TARGET_ADDRESS_COST
#define TARGET_ADDRESS_COST aarch64_address_cost
b/gcc/config/aarch64/constraints.md
@@ -89,6 +89,11 @@
(and (match_code "const_int")
(match_test "(unsigned HOST_WIDE_INT) ival < 32")))
+(define_constraint "Usn"
+ "A constant that can be used with a CCMN operation (once negated)."
+ (and (match_code "const_int")
+ (match_test "aarch64_uimm5 (-ival)")))
+
(define_constraint "Usd"
"@internal
A constraint that matches an immediate shift constant in DImode."
@@ -30,6 +30,15 @@
(ior (match_code "symbol_ref")
(match_operand 0 "register_operand")))
+(define_predicate "aarch64_ccmp_immediate"
+ (and (match_code "const_int")
+ (ior (match_test "aarch64_uimm5 (INTVAL (op))")
+ (match_test "aarch64_uimm5 (-INTVAL (op))"))))
+
+(define_predicate "aarch64_ccmp_operand"
+ (ior (match_operand 0 "register_operand")
+ (match_operand 0 "aarch64_ccmp_immediate")))
+
(define_predicate "aarch64_simd_register"
(and (match_code "reg")
(ior (match_test "REGNO_REG_CLASS (REGNO (op)) == FP_LO_REGS")