diff options
author | Will Schmidt <will_schmidt@vnet.ibm.com> | 2018-08-13 19:18:53 +0000 |
---|---|---|
committer | Will Schmidt <willschm@gcc.gnu.org> | 2018-08-13 19:18:53 +0000 |
commit | 67bfa03ad15f3d104f162454c7f88fdf0d9a0749 (patch) | |
tree | 2f921e6feb6e2d989c06d925890de343d91b7ab9 | |
parent | ca086dda978dd10e7f26cf29aefa923d02cc1131 (diff) | |
download | gcc-67bfa03ad15f3d104f162454c7f88fdf0d9a0749.zip gcc-67bfa03ad15f3d104f162454c7f88fdf0d9a0749.tar.gz gcc-67bfa03ad15f3d104f162454c7f88fdf0d9a0749.tar.bz2 |
rs6000.c (rs6000_gimple_fold_builtin): Add support for gimple-folding of vec_pack() and vec_unpack() intrinsics.
[gcc]
2018-08-13 Will Schmidt <will_schmidt@vnet.ibm.com>
* config/rs6000/rs6000.c (rs6000_gimple_fold_builtin):
Add support for gimple-folding of vec_pack() and vec_unpack()
intrinsics.
From-SVN: r263519
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 53 |
2 files changed, 59 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 00b03c9..1e407ea 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-08-13 Will Schmidt <will_schmidt@vnet.ibm.com> + + * config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): + Add support for gimple-folding of vec_pack() and vec_unpack() + intrinsics. + 2018-08-13 Will Schmidt <will_schmidt@vnet.ibm.com> * config/rs6000/rs6000.c (rs6000_builtin_valid_without_lhs): Add diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 9a1fb7d..cd6c75a 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -15770,6 +15770,59 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi) case VSX_BUILTIN_VEC_MERGEH_V2DI: fold_mergehl_helper (gsi, stmt, 0); return true; + + /* d = vec_pack (a, b) */ + case P8V_BUILTIN_VPKUDUM: + case ALTIVEC_BUILTIN_VPKUHUM: + case ALTIVEC_BUILTIN_VPKUWUM: + { + arg0 = gimple_call_arg (stmt, 0); + arg1 = gimple_call_arg (stmt, 1); + lhs = gimple_call_lhs (stmt); + gimple *g = gimple_build_assign (lhs, VEC_PACK_TRUNC_EXPR, arg0, arg1); + gimple_set_location (g, gimple_location (stmt)); + gsi_replace (gsi, g, true); + return true; + } + + /* d = vec_unpackh (a) */ + /* Note that the UNPACK_{HI,LO}_EXPR used in the gimple_build_assign call + in this code is sensitive to endian-ness, and needs to be inverted to + handle both LE and BE targets. */ + case ALTIVEC_BUILTIN_VUPKHSB: + case ALTIVEC_BUILTIN_VUPKHSH: + case P8V_BUILTIN_VUPKHSW: + { + arg0 = gimple_call_arg (stmt, 0); + lhs = gimple_call_lhs (stmt); + if (BYTES_BIG_ENDIAN) + g = gimple_build_assign (lhs, VEC_UNPACK_HI_EXPR, arg0); + else + g = gimple_build_assign (lhs, VEC_UNPACK_LO_EXPR, arg0); + gimple_set_location (g, gimple_location (stmt)); + gsi_replace (gsi, g, true); + return true; + } + /* d = vec_unpackl (a) */ + case ALTIVEC_BUILTIN_VUPKLSB: + case ALTIVEC_BUILTIN_VUPKLSH: + case P8V_BUILTIN_VUPKLSW: + { + arg0 = gimple_call_arg (stmt, 0); + lhs = gimple_call_lhs (stmt); + if (BYTES_BIG_ENDIAN) + g = gimple_build_assign (lhs, VEC_UNPACK_LO_EXPR, arg0); + else + g = gimple_build_assign (lhs, VEC_UNPACK_HI_EXPR, arg0); + gimple_set_location (g, gimple_location (stmt)); + gsi_replace (gsi, g, true); + return true; + } + /* There is no gimple type corresponding with pixel, so just return. */ + case ALTIVEC_BUILTIN_VUPKHPX: + case ALTIVEC_BUILTIN_VUPKLPX: + return false; + default: if (TARGET_DEBUG_BUILTIN) fprintf (stderr, "gimple builtin intrinsic not matched:%d %s %s\n", |