diff options
author | Christoph Müllner <christoph.muellner@vrull.eu> | 2025-01-15 14:53:27 +0100 |
---|---|---|
committer | Christoph Müllner <christoph.muellner@vrull.eu> | 2025-01-16 09:51:12 +0100 |
commit | 57de373426e27395c0ef581c8a8300ec74c1bb59 (patch) | |
tree | c799db79fa5e0dcb02be11de5242d40ad5b7b72f | |
parent | ea1deefe54ea1c5182bfa179abf36469c9ec6974 (diff) | |
download | gcc-57de373426e27395c0ef581c8a8300ec74c1bb59.zip gcc-57de373426e27395c0ef581c8a8300ec74c1bb59.tar.gz gcc-57de373426e27395c0ef581c8a8300ec74c1bb59.tar.bz2 |
forwprop: Eliminate redundant calls to to_constant()
When extracting the amount of vector elements, we currently
first check if the value is a contant with is_constant(),
followed by obtaining the value with to_constant(),
which internally calls is_constant() again.
We can address this by using is_constant (T*), which also
provides the constant value.
gcc/ChangeLog:
* tree-ssa-forwprop.cc (recognise_vec_perm_simplify_seq):
Eliminate redundant calls to to_constant().
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
-rw-r--r-- | gcc/tree-ssa-forwprop.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc index 0d62f2b..2f82f06 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -3530,6 +3530,8 @@ fwprop_ssa_val (tree name) static bool recognise_vec_perm_simplify_seq (gassign *stmt, vec_perm_simplify_seq *seq) { + unsigned HOST_WIDE_INT nelts; + gcc_checking_assert (stmt); gcc_checking_assert (gimple_assign_rhs_code (stmt) == VEC_PERM_EXPR); basic_block bb = gimple_bb (stmt); @@ -3539,15 +3541,13 @@ recognise_vec_perm_simplify_seq (gassign *stmt, vec_perm_simplify_seq *seq) tree v_y = gimple_assign_rhs2 (stmt); tree sel = gimple_assign_rhs3 (stmt); - if (!VECTOR_CST_NELTS (sel).is_constant () + if (!VECTOR_CST_NELTS (sel).is_constant (&nelts) || TREE_CODE (v_x) != SSA_NAME || TREE_CODE (v_y) != SSA_NAME || !has_single_use (v_x) || !has_single_use (v_y)) return false; - unsigned int nelts = VECTOR_CST_NELTS (sel).to_constant (); - /* Don't analyse sequences with many lanes. */ if (nelts > 4) return false; @@ -3614,12 +3614,12 @@ recognise_vec_perm_simplify_seq (gassign *stmt, vec_perm_simplify_seq *seq) || v_in != gimple_assign_rhs2 (v_2_stmt)) return false; - if (!VECTOR_CST_NELTS (v_1_sel).is_constant () - || !VECTOR_CST_NELTS (v_2_sel).is_constant ()) + unsigned HOST_WIDE_INT v_1_nelts, v_2_nelts; + if (!VECTOR_CST_NELTS (v_1_sel).is_constant (&v_1_nelts) + || !VECTOR_CST_NELTS (v_2_sel).is_constant (&v_2_nelts)) return false; - if (nelts != VECTOR_CST_NELTS (v_1_sel).to_constant () - || nelts != VECTOR_CST_NELTS (v_2_sel).to_constant ()) + if (nelts != v_1_nelts || nelts != v_2_nelts) return false; /* Create the new selector. */ |