https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126958

            Bug ID: 126958
           Summary: mul_hi/mul_lo match patterns could just use
                    wi::to_wide instead of tree_fits_uhwi_p/tree_to_uhwi
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: internal-improvement
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

```
/* High half: op >> N.  */
(match (mul_hi @op @0)
  (rshift @op INTEGER_CST@0)
  (with { tree op_type = TREE_TYPE (@op); }
  (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))))
/* Low half: op & mask.  */
(match (mul_lo @op @0)
  (bit_and @op INTEGER_CST@0)
  (with { tree op_type = TREE_TYPE (@op); }
  (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::mask (TYPE_PRECISION (op_type) / 2, false,
                        TYPE_PRECISION (op_type)))))))

```

Just use wi::to_wide.

Reply via email to