[gcc r17-3538] match: Use wi::to_wide more

Andrea Pinski via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:e9d53a1d2a3becc26bcc98f3e85a87854660a2fc

commit r17-3538-ge9d53a1d2a3becc26bcc98f3e85a87854660a2fc
Author: Andrea Pinski <[email protected]>
Date:   Fri Aug 21 20:03:32 2026 -0700

    match: Use wi::to_wide more
    
    Just like the previous case just missed when reading the code.
    Also changes `& 3` into `% 4` for easier to understand what the
    test was testing. It was testing to see if it is a multiple of 4
    (or rather then value/2 is even).
    
    Pushed as obvious after a bootstrap/test on x86_64-linux-gnu.
    
    gcc/ChangeLog:
    
            * match.pd (mul_carry_cross_sum): Use wi::to_wide instead
            of tree_to_uhwi.
            (long_mul_high_chain): Likewise and use `% 4`.
    
    Signed-off-by: Andrea Pinski <[email protected]>

Diff:
---
 gcc/match.pd | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index fc49146c6c11..db1938f6f881 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -12873,8 +12873,7 @@ and,
   (if (INTEGRAL_TYPE_P (op_type)
        && TYPE_UNSIGNED (op_type)
        && TYPE_PRECISION (op_type) % 2 == 0
-       && tree_fits_uhwi_p (@0)
-       && tree_to_uhwi (@0) == TYPE_PRECISION (op_type) / 2))))
+       && wi::to_wide (@0) == TYPE_PRECISION (op_type) / 2))))
 /* Carry from addition overflow: (cast?) (a > a + b).
    :c on gt also matches the LT form: (cast?) (a + b < a).  */
 (match (mul_carry_low @0 @1)
@@ -12950,9 +12949,8 @@ and,
        && type_has_mode_precision_p (wide_type)
        && TREE_CODE (wide_type) != BITINT_TYPE
        && TYPE_PRECISION (wide_type) >= 8
-       && (TYPE_PRECISION (wide_type) & 3) == 0
-       && tree_fits_uhwi_p (@2)
-       && tree_to_uhwi (@2) * 2 == TYPE_PRECISION (wide_type)))))
+       && TYPE_PRECISION (wide_type) % 4 == 0
+       && wi::to_wide (@2) == TYPE_PRECISION (wide_type) / 2))))
 
 /* Floatint point/integer comparison and integer->integer
    or floating point -> float point conversion.  */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.