]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Use HOST_WIDE_INT_{C,UC,0,0U,1,1U} macros some more
authorJakub Jelinek <jakub@redhat.com>
Sat, 24 Feb 2024 11:45:40 +0000 (12:45 +0100)
committerJakub Jelinek <jakub@redhat.com>
Sat, 24 Feb 2024 11:45:40 +0000 (12:45 +0100)
I've searched for some uses of (HOST_WIDE_INT) constant or (unsigned
HOST_WIDE_INT) constant and turned them into uses of the appropriate
macros.
THere are quite a few cases in non-i386 backends but I've left that out
for now.
The only behavior change is in build_replicated_int_cst where the
left shift was done in HOST_WIDE_INT type but assigned to unsigned
HOST_WIDE_INT, which I've changed into unsigned HOST_WIDE_INT shift.

2024-02-24  Jakub Jelinek  <jakub@redhat.com>

gcc/
* builtins.cc (fold_builtin_isascii): Use HOST_WIDE_INT_UC macro.
* combine.cc (make_field_assignment): Use HOST_WIDE_INT_1U macro.
* double-int.cc (double_int::mask): Use HOST_WIDE_INT_UC macros.
* genattrtab.cc (attr_alt_complement): Use HOST_WIDE_INT_1 macro.
(mk_attr_alt): Use HOST_WIDE_INT_0 macro.
* genautomata.cc (bitmap_set_bit, CLEAR_BIT): Use HOST_WIDE_INT_1
macros.
* ipa-strub.cc (can_strub_internally_p): Use HOST_WIDE_INT_1 macro.
* loop-iv.cc (implies_p): Use HOST_WIDE_INT_1U macro.
* pretty-print.cc (test_pp_format): Use HOST_WIDE_INT_C and
HOST_WIDE_INT_UC macros.
* rtlanal.cc (nonzero_bits1): Use HOST_WIDE_INT_UC macro.
* tree.cc (build_replicated_int_cst): Use HOST_WIDE_INT_1U macro.
* tree.h (DECL_OFFSET_ALIGN): Use HOST_WIDE_INT_1U macro.
* tree-ssa-structalias.cc (dump_varinfo): Use ~HOST_WIDE_INT_0U
macros.
* wide-int.cc (divmod_internal_2): Use HOST_WIDE_INT_1U macro.
* config/i386/constraints.md (define_constraint "L"): Use
HOST_WIDE_INT_C macro.
* config/i386/i386.md (movabsq split peephole2): Use HOST_WIDE_INT_C
macro.
(movl + movb peephole2): Likewise.
* config/i386/predicates.md (x86_64_zext_immediate_operand): Likewise.
(const_32bit_mask): Likewise.
gcc/objc/
* objc-encoding.cc (encode_array): Use HOST_WIDE_INT_0 macros.

17 files changed:
gcc/builtins.cc
gcc/combine.cc
gcc/config/i386/constraints.md
gcc/config/i386/i386.md
gcc/config/i386/predicates.md
gcc/double-int.cc
gcc/genattrtab.cc
gcc/genautomata.cc
gcc/ipa-strub.cc
gcc/loop-iv.cc
gcc/objc/objc-encoding.cc
gcc/pretty-print.cc
gcc/rtlanal.cc
gcc/tree-ssa-structalias.cc
gcc/tree.cc
gcc/tree.h
gcc/wide-int.cc

index 4c04ae03321fdce86a1b495d425a105a20c3e203..eda8bea9c4be7422e51900ce19e8d9a303cd2c7f 100644 (file)
@@ -9326,7 +9326,7 @@ fold_builtin_isascii (location_t loc, tree arg)
       /* Transform isascii(c) -> ((c & ~0x7f) == 0).  */
       arg = fold_build2 (BIT_AND_EXPR, integer_type_node, arg,
                         build_int_cst (integer_type_node,
-                                       ~ (unsigned HOST_WIDE_INT) 0x7f));
+                                       ~ HOST_WIDE_INT_UC (0x7f)));
       return fold_build2_loc (loc, EQ_EXPR, integer_type_node,
                              arg, integer_zero_node);
     }
index 812553c091e6f758a0f811395ec98b9f97ef87e2..76543d85b7c8ba3b591b64a29a9d205ea973bc6a 100644 (file)
@@ -9745,7 +9745,7 @@ make_field_assignment (rtx x)
       if (width >= HOST_BITS_PER_WIDE_INT)
        ze_mask = -1;
       else
-       ze_mask = ((unsigned HOST_WIDE_INT)1 << width) - 1;
+       ze_mask = (HOST_WIDE_INT_1U << width) - 1;
 
       /* Complete overlap.  We can remove the source AND.  */
       if ((and_mask & ze_mask) == ze_mask)
index 64702d9c0a880350dda9115599cede1edd597a83..7508d7a58bd76223ef3b37319949aa1da0525884 100644 (file)
   (and (match_code "const_int")
        (ior (match_test "ival == 0xff")
            (match_test "ival == 0xffff")
-           (match_test "ival == (HOST_WIDE_INT) 0xffffffff"))))
+           (match_test "ival == HOST_WIDE_INT_C (0xffffffff)"))))
 
 (define_constraint "M"
   "0, 1, 2, or 3 (shifts for the @code{lea} instruction)."
index d5db538bb6a120ed4ea8ff6150414eb2ec3adf7e..6a26d966a0e3d66f9a8c6b0fda5ab66b3078b60a 100644 (file)
    && !x86_64_immediate_operand (operands[1], DImode)
    && !x86_64_zext_immediate_operand (operands[1], DImode)
    && !((UINTVAL (operands[1]) >> ctz_hwi (UINTVAL (operands[1])))
-        & ~(HOST_WIDE_INT) 0xffffffff)
+       & ~HOST_WIDE_INT_C (0xffffffff))
    && peep2_regno_dead_p (0, FLAGS_REG)"
   [(set (match_dup 0) (match_dup 1))
    (parallel [(set (match_dup 0) (ashift:DI (match_dup 0) (match_dup 2)))
   [(set (match_operand:SWI48 0 "general_reg_operand")
        (match_dup 4))]
 {
-  HOST_WIDE_INT tmp = INTVAL (operands[1]) & ~(HOST_WIDE_INT)0xff00;
+  HOST_WIDE_INT tmp = INTVAL (operands[1]) & ~HOST_WIDE_INT_C (0xff00);
   tmp |= (INTVAL (operands[3]) & 0xff) << 8;
   operands[4] = gen_int_mode (tmp, <SWI48:MODE>mode);
 })
index 391f108c360cfca1841d1320d466130e3c7e6b49..2a97776fc3206d886941d8839e573966fd02ace4 100644 (file)
   switch (GET_CODE (op))
     {
     case CONST_INT:
-      return !(INTVAL (op) & ~(HOST_WIDE_INT) 0xffffffff);
+      return !(INTVAL (op) & ~HOST_WIDE_INT_C (0xffffffff));
 
     case SYMBOL_REF:
       /* TLS symbols are not constant.  */
 (define_predicate "const_32bit_mask"
   (and (match_code "const_int")
        (match_test "trunc_int_for_mode (INTVAL (op), DImode)
-                   == (HOST_WIDE_INT) 0xffffffff")))
+                   == HOST_WIDE_INT_C (0xffffffff)")))
 
 ;; Match 2, 4, or 8.  Used for leal multiplicands.
 (define_predicate "const248_operand"
index 08b0f7625f3bb7a4345e70a08f06f6c51a982eb4..e5c442f8e5bc277a51b40317a8444c0a800afdf6 100644 (file)
@@ -671,14 +671,14 @@ double_int::mask (unsigned prec)
   if (prec > HOST_BITS_PER_WIDE_INT)
     {
       prec -= HOST_BITS_PER_WIDE_INT;
-      m = ((unsigned HOST_WIDE_INT) 2 << (prec - 1)) - 1;
+      m = (HOST_WIDE_INT_UC (2) << (prec - 1)) - 1;
       mask.high = (HOST_WIDE_INT) m;
       mask.low = ALL_ONES;
     }
   else
     {
       mask.high = 0;
-      mask.low = prec ? ((unsigned HOST_WIDE_INT) 2 << (prec - 1)) - 1 : 0;
+      mask.low = prec ? (HOST_WIDE_INT_UC (2) << (prec - 1)) - 1 : 0;
     }
 
   return mask;
index 12082c1e357022c71ddd4b547010ab32738e8d29..03c7d6c74a3bc723159abd4ede6a232304838b58 100644 (file)
@@ -2392,7 +2392,7 @@ static rtx
 attr_alt_complement (rtx s)
 {
   return attr_rtx (EQ_ATTR_ALT, XWINT (s, 0),
-                   ((HOST_WIDE_INT) 1) - XWINT (s, 1));
+                  HOST_WIDE_INT_1 - XWINT (s, 1));
 }
 
 /* Return EQ_ATTR_ALT expression representing set containing elements set
@@ -2401,7 +2401,7 @@ attr_alt_complement (rtx s)
 static rtx
 mk_attr_alt (alternative_mask e)
 {
-  return attr_rtx (EQ_ATTR_ALT, (HOST_WIDE_INT) e, (HOST_WIDE_INT) 0);
+  return attr_rtx (EQ_ATTR_ALT, (HOST_WIDE_INT) e, HOST_WIDE_INT_0);
 }
 
 /* Given an expression, see if it can be simplified for a particular insn
index c66298d9064f63e0351ee0967ca9bdd64d1151fd..ec1e5331a4b09dcfe790c8eadf34ce071098d9e0 100644 (file)
@@ -3416,13 +3416,13 @@ finish_alt_states (void)
 
 /* Set bit number bitno in the bit string.  The macro is not side
    effect proof.  */
-#define bitmap_set_bit(bitstring, bitno)                                         \
+#define bitmap_set_bit(bitstring, bitno)                                 \
   ((bitstring)[(bitno) / (sizeof (*(bitstring)) * CHAR_BIT)] |=                  \
-       (HOST_WIDE_INT)1 << (bitno) % (sizeof (*(bitstring)) * CHAR_BIT))
+       HOST_WIDE_INT_1 << (bitno) % (sizeof (*(bitstring)) * CHAR_BIT))
 
 #define CLEAR_BIT(bitstring, bitno)                                      \
   ((bitstring)[(bitno) / (sizeof (*(bitstring)) * CHAR_BIT)] &=                  \
-       ~((HOST_WIDE_INT)1 << (bitno) % (sizeof (*(bitstring)) * CHAR_BIT)))
+       ~(HOST_WIDE_INT_1 << (bitno) % (sizeof (*(bitstring)) * CHAR_BIT)))
 
 /* Test if bit number bitno in the bitstring is set.  The macro is not
    side effect proof.  */
index 09db1e04431939be0cff940159b8f09e7b363256..dff94222351adeadf5099c219afca43806aa91f7 100644 (file)
@@ -940,7 +940,7 @@ can_strub_internally_p (cgraph_node *node, bool report = false)
     }
 
   if (list_length (TYPE_ARG_TYPES (TREE_TYPE (node->decl)))
-      >= (((HOST_WIDE_INT) 1 << IPA_PARAM_MAX_INDEX_BITS)
+      >= ((HOST_WIDE_INT_1 << IPA_PARAM_MAX_INDEX_BITS)
          - STRUB_INTERNAL_MAX_EXTRA_ARGS))
     {
       result = false;
index eb7e923a38b0fe11d3fcd63d22f306cb0cd31fd0..f56cc5e1db676ce3ed12be87898ed9fa56c15cd2 100644 (file)
@@ -1577,7 +1577,7 @@ implies_p (rtx a, rtx b)
       && CONST_INT_P (XEXP (opb0, 1))
       /* Avoid overflows.  */
       && ((unsigned HOST_WIDE_INT) INTVAL (XEXP (opb0, 1))
-         != ((unsigned HOST_WIDE_INT)1
+         != (HOST_WIDE_INT_1U
              << (HOST_BITS_PER_WIDE_INT - 1)) - 1)
       && INTVAL (XEXP (opb0, 1)) + 1 == -INTVAL (op1))
     return rtx_equal_p (op0, XEXP (opb0, 0));
index 18a3ea6832eb36b8c3004807189ed92e9f72076a..7cb0e5add7baf7b7626728858f1bc0fc2e9a106b 100644 (file)
@@ -391,10 +391,10 @@ encode_array (tree type, int curtype, int format)
 
       /* Else, we are in a struct, and we encode it as a zero-length
         array.  */
-      sprintf (buffer, "[" HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)0);
+      sprintf (buffer, "[" HOST_WIDE_INT_PRINT_DEC, HOST_WIDE_INT_0);
     }
   else if (TREE_INT_CST_LOW (TYPE_SIZE (array_of)) == 0)
-   sprintf (buffer, "[" HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)0);
+   sprintf (buffer, "[" HOST_WIDE_INT_PRINT_DEC, HOST_WIDE_INT_0);
   else
     sprintf (buffer, "[" HOST_WIDE_INT_PRINT_DEC,
             TREE_INT_CST_LOW (an_int_cst)
index 67c213bbaf2107099c3d711e845bc7c35d74c129..eb59bf424b7c6534d0511a24bc843456242a1a82 100644 (file)
@@ -2813,13 +2813,16 @@ test_pp_format ()
   ASSERT_PP_FORMAT_2 ("17 12345678", "%llo %x", (long long)15, 0x12345678);
   ASSERT_PP_FORMAT_2 ("cafebabe 12345678", "%llx %x", (long long)0xcafebabe,
                      0x12345678);
-  ASSERT_PP_FORMAT_2 ("-27 12345678", "%wd %x", (HOST_WIDE_INT)-27, 0x12345678);
-  ASSERT_PP_FORMAT_2 ("-5 12345678", "%wi %x", (HOST_WIDE_INT)-5, 0x12345678);
-  ASSERT_PP_FORMAT_2 ("10 12345678", "%wu %x", (unsigned HOST_WIDE_INT)10,
+  ASSERT_PP_FORMAT_2 ("-27 12345678", "%wd %x", HOST_WIDE_INT_C (-27),
                      0x12345678);
-  ASSERT_PP_FORMAT_2 ("17 12345678", "%wo %x", (HOST_WIDE_INT)15, 0x12345678);
-  ASSERT_PP_FORMAT_2 ("0xcafebabe 12345678", "%wx %x", (HOST_WIDE_INT)0xcafebabe,
+  ASSERT_PP_FORMAT_2 ("-5 12345678", "%wi %x", HOST_WIDE_INT_C (-5),
                      0x12345678);
+  ASSERT_PP_FORMAT_2 ("10 12345678", "%wu %x", HOST_WIDE_INT_UC (10),
+                     0x12345678);
+  ASSERT_PP_FORMAT_2 ("17 12345678", "%wo %x", HOST_WIDE_INT_C (15),
+                     0x12345678);
+  ASSERT_PP_FORMAT_2 ("0xcafebabe 12345678", "%wx %x",
+                     HOST_WIDE_INT_C (0xcafebabe), 0x12345678);
   ASSERT_PP_FORMAT_2 ("-27 12345678", "%zd %x", (ssize_t)-27, 0x12345678);
   ASSERT_PP_FORMAT_2 ("-5 12345678", "%zi %x", (ssize_t)-5, 0x12345678);
   ASSERT_PP_FORMAT_2 ("10 12345678", "%zu %x", (size_t)10, 0x12345678);
index ec65cf173b46d176844a9df0d6418554f91f1fec..d38455bc559b020a3d293a3fc09067c6b7c2d88e 100644 (file)
@@ -5184,7 +5184,7 @@ nonzero_bits1 (const_rtx x, scalar_int_mode mode, const_rtx known_x,
     case FFS:
     case POPCOUNT:
       /* This is at most the number of bits in the mode.  */
-      nonzero = ((unsigned HOST_WIDE_INT) 2 << (floor_log2 (mode_width))) - 1;
+      nonzero = (HOST_WIDE_INT_UC (2) << (floor_log2 (mode_width))) - 1;
       break;
 
     case CLZ:
index 0647152f0ba28b58e82095fe6bd3f858b87e0d0f..9c63305063c11753e952d164276572831219dbc6 100644 (file)
@@ -8179,10 +8179,9 @@ dump_varinfo (FILE *file, varinfo_t vi)
     fprintf (file, "%shead:%u", sep, vi->head);
   if (vi->offset)
     fprintf (file, "%soffset:" HOST_WIDE_INT_PRINT_DEC, sep, vi->offset);
-  if (vi->size != ~(unsigned HOST_WIDE_INT)0)
+  if (vi->size != ~HOST_WIDE_INT_0U)
     fprintf (file, "%ssize:" HOST_WIDE_INT_PRINT_DEC, sep, vi->size);
-  if (vi->fullsize != ~(unsigned HOST_WIDE_INT)0
-      && vi->fullsize != vi->size)
+  if (vi->fullsize != ~HOST_WIDE_INT_0U && vi->fullsize != vi->size)
     fprintf (file, "%sfullsize:" HOST_WIDE_INT_PRINT_DEC, sep,
             vi->fullsize);
   fprintf (file, "\n");
index 046a558d1b07bf414fbf4f27c1953c0b7f8f8a66..f801712c9ddd1c2c688a8de01be1706262e277ba 100644 (file)
@@ -2691,7 +2691,7 @@ build_replicated_int_cst (tree type, unsigned int width, HOST_WIDE_INT value)
     low = value;
   else
     {
-      mask = ((HOST_WIDE_INT)1 << width) - 1;
+      mask = (HOST_WIDE_INT_1U << width) - 1;
       low = (unsigned HOST_WIDE_INT) ~0 / mask * (value & mask);
     }
 
index 972a067a1f7ad5388c1bdf5021c2076d6bc84b69..e1fc6c2221ddaf87daaacf93438acc7c791f32cd 100644 (file)
@@ -3020,7 +3020,7 @@ extern void decl_value_expr_insert (tree, tree);
    DECL_OFFSET_ALIGN thus returns the alignment that DECL_FIELD_OFFSET
    has.  */
 #define DECL_OFFSET_ALIGN(NODE) \
-  (((unsigned HOST_WIDE_INT)1) << FIELD_DECL_CHECK (NODE)->decl_common.off_align)
+  (HOST_WIDE_INT_1U << FIELD_DECL_CHECK (NODE)->decl_common.off_align)
 
 /* Specify that DECL_OFFSET_ALIGN(NODE) is X.  */
 #define SET_DECL_OFFSET_ALIGN(NODE, X) \
index a8a6443ff7f9199104d48cd1a825325e817dc57f..9c6eba807aadbbb7615c1e11061553cf7e815e1b 100644 (file)
@@ -1713,8 +1713,7 @@ divmod_internal_2 (unsigned HOST_HALF_WIDE_INT *b_quotient,
      HOST_WIDE_INT and stored in the lower bits of each word.  This
      algorithm should work properly on both 32 and 64 bit
      machines.  */
-  unsigned HOST_WIDE_INT b
-    = (unsigned HOST_WIDE_INT)1 << HOST_BITS_PER_HALF_WIDE_INT;
+  unsigned HOST_WIDE_INT b = HOST_WIDE_INT_1U << HOST_BITS_PER_HALF_WIDE_INT;
   unsigned HOST_WIDE_INT qhat;   /* Estimate of quotient digit.  */
   unsigned HOST_WIDE_INT rhat;   /* A remainder.  */
   unsigned HOST_WIDE_INT p;      /* Product of two digits.  */