https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29756
--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
Like
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c (revision 236441)
+++ gcc/config/i386/i386.c (working copy)
@@ -37745,6 +37745,23 @@ ix86_fold_builtin (tree fndecl, int n_ar
gcc_assert (n_args == 1);
return fold_builtin_cpu (fndecl, args);
}
+ if (fn_code == IX86_BUILTIN_SHUFPS
+ && n_args == 3
+ && TREE_CODE (args[2]) == INTEGER_CST)
+ {
+ tree mask[4];
+ tree mtype = build_vector_type (integer_type_node, 4);
+ mask[0] = build_int_cst (integer_type_node,
+ TREE_INT_CST_LOW (args[2]) & 3);
+ mask[1] = build_int_cst (integer_type_node,
+ (TREE_INT_CST_LOW (args[2]) >> 2) & 3);
+ mask[2] = build_int_cst (integer_type_node,
+ ((TREE_INT_CST_LOW (args[2]) >> 4) & 3) +
4);
+ mask[3] = build_int_cst (integer_type_node,
+ ((TREE_INT_CST_LOW (args[2]) >> 6) & 3) +
4);
+ return fold_build3 (VEC_PERM_EXPR, TREE_TYPE (TREE_TYPE (fndecl)),
+ args[0], args[1], build_vector (mtype, mask));
+ }
}
#ifdef SUBTARGET_FOLD_BUILTIN
given the plethora of shuffling intrinsics this might be quite tedious work...