]> git.ipfire.org Git - thirdparty/gcc.git/commit
Match: Support imm form for unsigned scalar .SAT_ADD
authorPan Li <pan2.li@intel.com>
Fri, 28 Jun 2024 03:33:41 +0000 (11:33 +0800)
committerPan Li <pan2.li@intel.com>
Sat, 29 Jun 2024 10:37:32 +0000 (18:37 +0800)
commit21e3565927eda5ce9907d91100623052fa8182cd
treebd6d3a40fc045391d937f3c1c292e2165ed116c6
parent45e74d5dfa4c5f372df0d3545bc342b6a2505e71
Match: Support imm form for unsigned scalar .SAT_ADD

This patch would like to support the form of unsigned scalar .SAT_ADD
when one of the op is IMM.  For example as below:

Form IMM:
  #define DEF_SAT_U_ADD_IMM_FMT_1(T)       \
  T __attribute__((noinline))              \
  sat_u_add_imm_##T##_fmt_1 (T x)          \
  {                                        \
    return (T)(x + 9) >= x ? (x + 9) : -1; \
  }

DEF_SAT_U_ADD_IMM_FMT_1(uint64_t)

Before this patch:
__attribute__((noinline))
uint64_t sat_u_add_imm_uint64_t_fmt_1 (uint64_t x)
{
  long unsigned int _1;
  uint64_t _3;

;;   basic block 2, loop depth 0
;;    pred:       ENTRY
  _1 = MIN_EXPR <x_2(D), 18446744073709551606>;
  _3 = _1 + 9;
  return _3;
;;    succ:       EXIT

}

After this patch:
__attribute__((noinline))
uint64_t sat_u_add_imm_uint64_t_fmt_1 (uint64_t x)
{
  uint64_t _3;

;;   basic block 2, loop depth 0
;;    pred:       ENTRY
  _3 = .SAT_ADD (x_2(D), 9); [tail call]
  return _3;
;;    succ:       EXIT

}

The below test suites are passed for this patch:
1. The rv64gcv fully regression test with newlib.
2. The x86 bootstrap test.
3. The x86 fully regression test.

gcc/ChangeLog:

* match.pd: Add imm form for .SAT_ADD matching.
* tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children):
Add .SAT_ADD matching under PLUS_EXPR.

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