aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-patterns.cc
diff options
context:
space:
mode:
authorPan Li <pan2.li@intel.com>2024-08-06 20:59:37 +0800
committerxuli <xuli1@eswincomputing.com>2024-08-07 01:13:04 +0000
commit06d3f31384a89039c510531cf8012caed05b2ffd (patch)
tree66247acc1f52e303574e646e0dc8875d5a04fcfa /gcc/tree-vect-patterns.cc
parent1b5c57e53e7ee4087e10f51fcf74968d950d3d83 (diff)
downloadgcc-06d3f31384a89039c510531cf8012caed05b2ffd.zip
gcc-06d3f31384a89039c510531cf8012caed05b2ffd.tar.gz
gcc-06d3f31384a89039c510531cf8012caed05b2ffd.tar.bz2
Vect: Make sure the lhs type of .SAT_TRUNC has its mode precision [PR116202]
The .SAT_TRUNC vect pattern recog is valid when the lhs type has its mode precision. For example as below, QImode with 1 bit precision like _Bool is invalid here. g_12 = (long unsigned int) _2; _13 = MIN_EXPR <g_12, 1>; _3 = (_Bool) _13; The above pattern cannot be recog as .SAT_TRUNC (g_12) because the dest only has 1 bit precision with QImode mode. Aka the type doesn't have the mode precision. The below tests are passed for this patch. 1. The rv64gcv fully regression tests. 2. The x86 bootstrap tests. 3. The x86 fully regression tests. PR target/116202 gcc/ChangeLog: * tree-vect-patterns.cc (vect_recog_sat_trunc_pattern): Add the type_has_mode_precision_p check for the lhs type. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/pr116202-run-1.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com>
Diffstat (limited to 'gcc/tree-vect-patterns.cc')
-rw-r--r--gcc/tree-vect-patterns.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index b2c83cf..87b3dc4 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -4697,11 +4697,12 @@ vect_recog_sat_trunc_pattern (vec_info *vinfo, stmt_vec_info stmt_vinfo,
tree ops[1];
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)
+ && type_has_mode_precision_p (otype))
{
tree itype = TREE_TYPE (ops[0]);
- tree otype = TREE_TYPE (lhs);
tree v_itype = get_vectype_for_scalar_type (vinfo, itype);
tree v_otype = get_vectype_for_scalar_type (vinfo, otype);
internal_fn fn = IFN_SAT_TRUNC;