diff options
author | Will Schmidt <will_schmidt@vnet.ibm.com> | 2018-08-13 19:23:38 +0000 |
---|---|---|
committer | Will Schmidt <willschm@gcc.gnu.org> | 2018-08-13 19:23:38 +0000 |
commit | d20d6e550c0c0e88b1bfcccce6ef4d4d392149ea (patch) | |
tree | ff967ca6d12a5300aba054abff5da371bfe26e09 | |
parent | 67bfa03ad15f3d104f162454c7f88fdf0d9a0749 (diff) | |
download | gcc-d20d6e550c0c0e88b1bfcccce6ef4d4d392149ea.zip gcc-d20d6e550c0c0e88b1bfcccce6ef4d4d392149ea.tar.gz gcc-d20d6e550c0c0e88b1bfcccce6ef4d4d392149ea.tar.bz2 |
rs6000.c (rs6000_gimple_fold_builtin): Add support for folding vec_perm.
[gcc]
2018-07-06 Will Schmidt <will_schmidt@vnet.ibm.com>
* gcc/config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add support
for folding vec_perm.
From-SVN: r263520
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 31 |
2 files changed, 36 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1e407ea..f0a30b9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-08-13 Will Schmidt <will_schmidt@vnet.ibm.com> + + * gcc/config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add support + for folding vec_perm. + 2018-08-13 Will Schmidt <will_schmidt@vnet.ibm.com> * config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index cd6c75a..aa707b2 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -15823,6 +15823,37 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) case ALTIVEC_BUILTIN_VUPKLPX: return false; + /* vec_perm. */ + case ALTIVEC_BUILTIN_VPERM_16QI: + case ALTIVEC_BUILTIN_VPERM_8HI: + case ALTIVEC_BUILTIN_VPERM_4SI: + case ALTIVEC_BUILTIN_VPERM_2DI: + case ALTIVEC_BUILTIN_VPERM_4SF: + case ALTIVEC_BUILTIN_VPERM_2DF: + { + arg0 = gimple_call_arg (stmt, 0); + arg1 = gimple_call_arg (stmt, 1); + tree permute = gimple_call_arg (stmt, 2); + lhs = gimple_call_lhs (stmt); + location_t loc = gimple_location (stmt); + gimple_seq stmts = NULL; + // convert arg0 and arg1 to match the type of the permute + // for the VEC_PERM_EXPR operation. + tree permute_type = (TREE_TYPE (permute)); + tree arg0_ptype = gimple_convert (&stmts, loc, permute_type, arg0); + tree arg1_ptype = gimple_convert (&stmts, loc, permute_type, arg1); + tree lhs_ptype = gimple_build (&stmts, loc, VEC_PERM_EXPR, + permute_type, arg0_ptype, arg1_ptype, + permute); + // Convert the result back to the desired lhs type upon completion. + tree temp = gimple_convert (&stmts, loc, TREE_TYPE (lhs), lhs_ptype); + gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); + g = gimple_build_assign (lhs, temp); + gimple_set_location (g, loc); + gsi_replace (gsi, g, true); + return true; + } + default: if (TARGET_DEBUG_BUILTIN) fprintf (stderr, "gimple builtin intrinsic not matched:%d %s %s\n", |