[gcc r17-3530] match: Use wi::to_wide instead of tree_to_uhwi in mul_hi/mul_lo [PR126958]

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

commit r17-3530-g9f82055b86c06511ff4f19939cbd7765bf3395fe
Author: Andrea Pinski <[email protected]>
Date:   Fri Aug 21 00:09:37 2026 -0700

    match: Use wi::to_wide instead of tree_to_uhwi in mul_hi/mul_lo [PR126958]
    
    Just a small compile time optimization because wi::to_wide should have almost
    no overhead in this case when comparing against a constant and/or a generated
    mask.
    
    Pushed as obvious after a bootstrap/test on x86_64-linux-gnu.
    
            PR tree-optimization/126958
    
    gcc/ChangeLog:
    
            * match.pd (mul_hi): Use wi::to_wide instead of
            tree_fits_uhwi_p/tree_to_uhwi.
            (mul_lo): Likewise.
    
    Signed-off-by: Andrea Pinski <[email protected]>

Diff:
---
 gcc/match.pd | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 2615da2ba7cd..1f031e93a7ff 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -12813,8 +12813,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))))
 /* Low half: op & mask.  */
 (match (mul_lo @op @0)
   (bit_and @op INTEGER_CST@0)
@@ -12822,8 +12821,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)
+       && (wi::to_wide (@0)
 	   == wi::mask (TYPE_PRECISION (op_type) / 2, false,
 			TYPE_PRECISION (op_type)))))))
 /* Cross product: high(op0) * low(op1).  */
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.