]> git.ipfire.org Git - thirdparty/gcc.git/commit
Widening-Mul: Support unsigned scalar SAT_MUL form 1
authorPan Li <pan2.li@intel.com>
Wed, 2 Jul 2025 01:59:26 +0000 (09:59 +0800)
committerPan Li <pan2.li@intel.com>
Mon, 7 Jul 2025 13:15:25 +0000 (21:15 +0800)
commitdc30f404170f538af6bf2457ccff252b08302dec
tree7157e1ad852cf688f09486a6889f8fdad8c03e31
parent35f5a18872127e18aadcbbc08df7885974280c79
Widening-Mul: Support unsigned scalar SAT_MUL form 1

This patch would like to try to match the SAT_MUL during
widening-mul pass, aka below pattern.

  NT __attribute__((noinline))
  sat_u_mul_##NT##_fmt_1 (NT a, NT b)
  {
    uint128_t x = (uint128_t)a * (uint128_t)b;
    NT max = -1;
    if (x > (uint128_t)(max))
      return max;
    else
      return (NT)x;
  }

while the NT can be uint8_t, uint16_t, uint32_t and uint64_t.

gcc/ChangeLog:

* match.pd: Add new match pattern for unsigned SAT_MUL.
* tree-ssa-math-opts.cc (gimple_unsigned_integer_sat_mul):
new decl for pattern match func.
(match_unsigned_saturation_mul): Add new func to match unsigned
SAT_MUL.
(math_opts_dom_walker::after_dom_children): Try to match
unsigned SAT_MUL on NOP.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/match.pd
gcc/tree-ssa-math-opts.cc