]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Rename and improve aarch64_split_imm24
authorRichard Henderson <richard.henderson@linaro.org>
Tue, 5 Aug 2025 21:17:33 +0000 (21:17 +0000)
committerRichard Henderson <richard.henderson@linaro.org>
Mon, 11 Aug 2025 23:25:09 +0000 (23:25 +0000)
Two of the three uses of aarch64_imm24 included the important follow-up
tests vs aarch64_move_imm and aarch64_plus_operand.  Lack of the exclusion
within aarch64_if_then_else_costs produced incorrect costing.

Since aarch64_split_imm24 has already matched a non-negative CONST_INT,
drill down from aarch64_plus_operand to aarch64_uimm12_shift.

gcc:
* config/aarch64/predicates.md (aarch64_split_imm24): Rename from
aarch64_imm24; exclude aarch64_move_imm and aarch64_uimm12_shift.
* config/aarch64/aarch64.md (*aarch64_bcond_wide_imm<GPI>):
Update for aarch64_split_imm24.
(*compare_cstore<GPI>_insn): Likewise.
* config/aarch64/aarch64.cc (aarch64_if_then_else_costs): Likewise.

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

index cb38870e6088b56a05b7b58008523c9fb94eec50..cd66f55f170e4c5f1e862202ecd6bf00239c7247 100644 (file)
@@ -14414,7 +14414,7 @@ aarch64_if_then_else_costs (rtx op0, rtx op1, rtx op2, int *cost, bool speed)
 
       if ((cmpcode == NE || cmpcode == EQ)
          && (cmpmode == SImode || cmpmode == DImode)
-         && aarch64_imm24 (comparator, cmpmode))
+         && aarch64_split_imm24 (comparator, cmpmode))
        {
          /* SUB and SUBS.  */
          *cost += rtx_cost (inner, cmpmode, cmpcode, 0, speed);
index 7fbd07ebfc3a00c63e3f7506635c0fb0078d93bf..c97dbe67c6244b390f2e3a22d6ff3790b045b559 100644 (file)
 ;;     b<ne,eq> .Label
 (define_insn_and_split "*aarch64_bcond_wide_imm<GPI:mode>"
   [(set (pc) (if_then_else (EQL (match_operand:GPI 0 "register_operand" "r")
-                               (match_operand:GPI 1 "aarch64_imm24" "n"))
+                               (match_operand:GPI 1 "aarch64_split_imm24" "n"))
                           (label_ref:P (match_operand 2))
                           (pc)))]
-  "!aarch64_move_imm (INTVAL (operands[1]), <GPI:MODE>mode)
-   && !aarch64_plus_operand (operands[1], <GPI:MODE>mode)
-   && !reload_completed"
+  "!reload_completed"
   "#"
   "&& true"
   [(const_int 0)]
 (define_insn_and_split "*compare_cstore<mode>_insn"
   [(set (match_operand:GPI 0 "register_operand" "=r")
         (EQL:GPI (match_operand:GPI 1 "register_operand" "r")
-                 (match_operand:GPI 2 "aarch64_imm24" "n")))
+                 (match_operand:GPI 2 "aarch64_split_imm24" "n")))
    (clobber (reg:CC CC_REGNUM))]
-  "!aarch64_move_imm (INTVAL (operands[2]), <MODE>mode)
-   && !aarch64_plus_operand (operands[2], <MODE>mode)
-   && !reload_completed"
+  "!reload_completed"
   "#"
   "&& true"
   [(const_int 0)]
index 4d5d57f1e5d62490122bce8d80feeff3ad0a624d..af6f00e7353e34350fc95f909c0964584bae2137 100644 (file)
   (and (match_code "const_int")
        (match_test "UINTVAL (op) <= 7")))
 
-;; An immediate that fits into 24 bits.
-(define_predicate "aarch64_imm24"
-  (and (match_code "const_int")
-       (match_test "IN_RANGE (UINTVAL (op), 0, 0xffffff)")))
+;; An immediate that fits into 24 bits, but needs splitting.
+(define_predicate "aarch64_split_imm24"
+  (match_code "const_int")
+{
+  unsigned HOST_WIDE_INT i = UINTVAL (op);
+  return (IN_RANGE (i, 0, 0xffffff)
+          && !aarch64_move_imm (i, mode)
+          && !aarch64_uimm12_shift (i));
+})
 
 (define_predicate "aarch64_mem_pair_offset"
   (and (match_code "const_int")