]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Vect: Try the pattern of vector signed integer SAT_TRUNC
authorPan Li <pan2.li@intel.com>
Mon, 14 Oct 2024 02:09:31 +0000 (10:09 +0800)
committerPan Li <pan2.li@intel.com>
Mon, 21 Oct 2024 14:12:08 +0000 (22:12 +0800)
Almost the same as vector unsigned integer SAT_TRUNC, try to match
the signed version during the vector pattern matching.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

* tree-vect-patterns.cc (gimple_signed_integer_sat_trunc): Add
new func decl for signed SAT_TRUNC.
(vect_recog_sat_trunc_pattern): Try signed match pattern for
the SAT_TRUNC.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/tree-vect-patterns.cc

index 746f100a0842090953571b535ff05375f46033c0..ce5a528141f742fd8ed9077dd93c628d5f868f9b 100644 (file)
@@ -4539,6 +4539,7 @@ extern bool gimple_unsigned_integer_sat_trunc (tree, tree*, tree (*)(tree));
 
 extern bool gimple_signed_integer_sat_add (tree, tree*, tree (*)(tree));
 extern bool gimple_signed_integer_sat_sub (tree, tree*, tree (*)(tree));
+extern bool gimple_signed_integer_sat_trunc (tree, tree*, tree (*)(tree));
 
 static gimple *
 vect_recog_build_binary_gimple_stmt (vec_info *vinfo, stmt_vec_info stmt_info,
@@ -4770,7 +4771,8 @@ vect_recog_sat_trunc_pattern (vec_info *vinfo, stmt_vec_info stmt_vinfo,
   tree lhs = gimple_assign_lhs (last_stmt);
   tree otype = TREE_TYPE (lhs);
 
-  if (gimple_unsigned_integer_sat_trunc (lhs, ops, NULL)
+  if ((gimple_unsigned_integer_sat_trunc (lhs, ops, NULL)
+       || gimple_signed_integer_sat_trunc (lhs, ops, NULL))
       && type_has_mode_precision_p (otype))
     {
       tree itype = TREE_TYPE (ops[0]);