Hi! 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.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-02-24 Jakub Jelinek <ja...@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. --- gcc/builtins.cc.jj 2024-02-06 08:43:14.843888851 +0100 +++ gcc/builtins.cc 2024-02-23 22:02:48.245611359 +0100 @@ -9326,7 +9326,7 @@ fold_builtin_isascii (location_t loc, tr /* 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); } --- gcc/combine.cc.jj 2024-01-03 11:51:34.028696534 +0100 +++ gcc/combine.cc 2024-02-23 22:03:36.895923405 +0100 @@ -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) --- gcc/double-int.cc.jj 2024-01-03 11:51:42.086584698 +0100 +++ gcc/double-int.cc 2024-02-23 22:04:30.586164187 +0100 @@ -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; --- gcc/genattrtab.cc.jj 2024-01-03 11:51:38.125639672 +0100 +++ gcc/genattrtab.cc 2024-02-23 22:05:38.043210294 +0100 @@ -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 --- gcc/genautomata.cc.jj 2024-01-03 11:51:32.524717408 +0100 +++ gcc/genautomata.cc 2024-02-23 22:07:04.667985357 +0100 @@ -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. */ --- gcc/ipa-strub.cc.jj 2024-02-22 10:10:19.053027064 +0100 +++ gcc/ipa-strub.cc 2024-02-23 22:07:23.584717862 +0100 @@ -940,7 +940,7 @@ can_strub_internally_p (cgraph_node *nod } 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; --- gcc/loop-iv.cc.jj 2024-01-03 11:51:24.283831784 +0100 +++ gcc/loop-iv.cc 2024-02-23 22:07:53.047301241 +0100 @@ -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)); --- gcc/pretty-print.cc.jj 2024-02-14 14:35:29.288989166 +0100 +++ gcc/pretty-print.cc 2024-02-23 22:09:59.570532912 +0100 @@ -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); --- gcc/rtlanal.cc.jj 2024-01-03 11:51:26.331803360 +0100 +++ gcc/rtlanal.cc 2024-02-23 22:10:24.102190967 +0100 @@ -5184,7 +5184,7 @@ nonzero_bits1 (const_rtx x, scalar_int_m 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: --- gcc/tree.cc.jj 2024-02-10 11:25:09.711478022 +0100 +++ gcc/tree.cc 2024-02-23 22:11:02.386657314 +0100 @@ -2691,7 +2691,7 @@ build_replicated_int_cst (tree type, uns 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); } --- gcc/tree.h.jj 2024-01-03 11:51:37.836643683 +0100 +++ gcc/tree.h 2024-02-23 22:13:21.059724337 +0100 @@ -3020,7 +3020,7 @@ extern void decl_value_expr_insert (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) \ --- gcc/tree-ssa-structalias.cc.jj 2024-01-03 11:51:34.357691968 +0100 +++ gcc/tree-ssa-structalias.cc 2024-02-23 22:12:08.586734545 +0100 @@ -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"); --- gcc/wide-int.cc.jj 2024-02-07 09:44:24.549718682 +0100 +++ gcc/wide-int.cc 2024-02-23 22:12:31.757411566 +0100 @@ -1713,8 +1713,7 @@ divmod_internal_2 (unsigned HOST_HALF_WI 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. */ --- gcc/config/i386/constraints.md.jj 2024-02-09 11:02:15.103831962 +0100 +++ gcc/config/i386/constraints.md 2024-02-23 22:15:27.031968402 +0100 @@ -280,7 +280,7 @@ (define_constraint "L" (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)." --- gcc/config/i386/i386.md.jj 2024-02-09 11:02:15.217830366 +0100 +++ gcc/config/i386/i386.md 2024-02-23 22:16:03.006466951 +0100 @@ -2689,7 +2689,7 @@ (define_peephole2 && !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))) @@ -3542,7 +3542,7 @@ (define_peephole2 [(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); }) --- gcc/config/i386/predicates.md.jj 2024-02-23 18:54:37.909974991 +0100 +++ gcc/config/i386/predicates.md 2024-02-23 22:16:32.047062151 +0100 @@ -309,7 +309,7 @@ (define_predicate "x86_64_zext_immediate 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. */ @@ -839,7 +839,7 @@ (define_predicate "const128_operand" (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" --- gcc/objc/objc-encoding.cc.jj 2024-01-03 12:07:01.699740753 +0100 +++ gcc/objc/objc-encoding.cc 2024-02-23 22:14:08.266066329 +0100 @@ -391,10 +391,10 @@ encode_array (tree type, int curtype, in /* 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) Jakub