From e0ad3e6bd66b1c025cf2666f23596cefc8cde695 Mon Sep 17 00:00:00 2001 From: Will Schmidt Date: Wed, 15 Aug 2018 20:24:57 +0000 Subject: [PATCH] rs600.c (rs6000_gimple_fold_builtin): Add entries to allow folding of mergeh() and mergel() for the float and double... [gcc] 2018-08-07 Will Schmidt * config/rs6000/rs600.c (rs6000_gimple_fold_builtin): Add entries to allow folding of mergeh() and mergel() for the float and double types. (fold_mergehl_helper): Rework to handle building a permute tree for float vectors. From-SVN: r263569 --- gcc/ChangeLog | 7 +++++++ gcc/config/rs6000/rs6000.c | 28 ++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d922dee87b3..b257e694aba 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-08-15 Will Schmidt + + * config/rs6000/rs600.c (rs6000_gimple_fold_builtin): Add entries to + allow folding of mergeh() and mergel() for the float and double types. + (fold_mergehl_helper): Rework to handle building a permute tree + for float vectors. + 2018-08-15 Uros Bizjak * config/i386/i386.c (expand_vec_perm_movs): Enable V4SFmode diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index aa707b2555e..97b922fa7f4 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -15122,7 +15122,6 @@ fold_mergehl_helper (gimple_stmt_iterator *gsi, gimple *stmt, int use_high) tree arg1 = gimple_call_arg (stmt, 1); tree lhs = gimple_call_lhs (stmt); tree lhs_type = TREE_TYPE (lhs); - tree lhs_type_type = TREE_TYPE (lhs_type); int n_elts = TYPE_VECTOR_SUBPARTS (lhs_type); int midpoint = n_elts / 2; int offset = 0; @@ -15130,12 +15129,29 @@ fold_mergehl_helper (gimple_stmt_iterator *gsi, gimple *stmt, int use_high) if (use_high == 1) offset = midpoint; - tree_vector_builder elts (lhs_type, VECTOR_CST_NELTS (arg0), 1); + /* The permute_type will match the lhs for integral types. For double and + float types, the permute type needs to map to the V2 or V4 type that + matches size. */ + tree permute_type; + if (INTEGRAL_TYPE_P (TREE_TYPE (lhs_type))) + permute_type = lhs_type; + else + { + if (TREE_TYPE (lhs_type) == TREE_TYPE (V2DF_type_node)) + permute_type = V2DI_type_node; + else if (TREE_TYPE (lhs_type) == TREE_TYPE (V4SF_type_node)) + permute_type = V4SI_type_node; + else + gcc_unreachable (); + } + tree_vector_builder elts (permute_type, VECTOR_CST_NELTS (arg0), 1); for (int i = 0; i < midpoint; i++) { - elts.safe_push (build_int_cst (lhs_type_type, offset + i)); - elts.safe_push (build_int_cst (lhs_type_type, offset + n_elts + i)); + elts.safe_push (build_int_cst (TREE_TYPE (permute_type), + offset + i)); + elts.safe_push (build_int_cst (TREE_TYPE (permute_type), + offset + n_elts + i)); } tree permute = elts.build (); @@ -15760,6 +15776,8 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) case VSX_BUILTIN_XXMRGLW_4SI: case ALTIVEC_BUILTIN_VMRGLB: case VSX_BUILTIN_VEC_MERGEL_V2DI: + case VSX_BUILTIN_XXMRGLW_4SF: + case VSX_BUILTIN_VEC_MERGEL_V2DF: fold_mergehl_helper (gsi, stmt, 1); return true; /* vec_mergeh (integrals). */ @@ -15768,6 +15786,8 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) case VSX_BUILTIN_XXMRGHW_4SI: case ALTIVEC_BUILTIN_VMRGHB: case VSX_BUILTIN_VEC_MERGEH_V2DI: + case VSX_BUILTIN_XXMRGHW_4SF: + case VSX_BUILTIN_VEC_MERGEH_V2DF: fold_mergehl_helper (gsi, stmt, 0); return true; -- 2.30.2