From: Pan Li <[email protected]>

Per-suggestion from Pinski, add the tree_fits_uhwi_p before the
call to tree_to_uhwi.  For making sure the precondition of
the tree_to_uhwi is met.

gcc/ChangeLog:

        * match-sat-alu.pd: Add fits check before call to
        tree_to_uhwi.

Signed-off-by: Pan Li <[email protected]>
---
 gcc/match-sat-alu.pd | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/match-sat-alu.pd b/gcc/match-sat-alu.pd
index c47d73f958d..6e6fd2afda7 100644
--- a/gcc/match-sat-alu.pd
+++ b/gcc/match-sat-alu.pd
@@ -512,7 +512,7 @@ along with GCC; see the file COPYING3.  If not see
                               INTEGER_CST@2)
                       integer_zerop)
                   @3 INTEGER_CST@4))
-   (if (types_match (type, @0, @1))
+   (if (types_match (type, @0, @1) && tree_fits_uhwi_p (@2))
     (with
      {
       unsigned prec = TYPE_PRECISION (type);
@@ -562,7 +562,7 @@ along with GCC; see the file COPYING3.  If not see
      (negate
       (convert (ne (convert2? (rshift @3 INTEGER_CST@2)) integer_zerop))))
     (convert (usmul_widen_mult@3 @0 @1)))
-   (if (types_match (type, @0, @1))
+   (if (types_match (type, @0, @1) && tree_fits_uhwi_p (@2))
     (with
      {
       unsigned prec = TYPE_PRECISION (type);
-- 
2.43.0

Reply via email to