aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/optabs-query.c3
-rw-r--r--gcc/optabs.c3
3 files changed, 10 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 821442f..c7091a9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2018-01-02 Richard Sandiford <richard.sandiford@linaro.org>
+ * optabs-query.c (can_vec_perm_var_p): Check whether lowering
+ to qimode could truncate the indices.
+ * optabs.c (expand_vec_perm_var): Likewise.
+
+2018-01-02 Richard Sandiford <richard.sandiford@linaro.org>
+
* Makefile.in (OBJS): Add vec-perm-indices.o.
* vec-perm-indices.h: New file.
* vec-perm-indices.c: Likewise.
diff --git a/gcc/optabs-query.c b/gcc/optabs-query.c
index 4060b4f..7396664 100644
--- a/gcc/optabs-query.c
+++ b/gcc/optabs-query.c
@@ -390,7 +390,8 @@ can_vec_perm_var_p (machine_mode mode)
/* We allow fallback to a QI vector mode, and adjust the mask. */
machine_mode qimode;
- if (!qimode_for_vec_perm (mode).exists (&qimode))
+ if (!qimode_for_vec_perm (mode).exists (&qimode)
+ || GET_MODE_NUNITS (qimode) > GET_MODE_MASK (QImode) + 1)
return false;
if (direct_optab_handler (vec_perm_optab, qimode) == CODE_FOR_nothing)
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 9099ba2..3a41a65 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -5623,7 +5623,8 @@ expand_vec_perm_var (machine_mode mode, rtx v0, rtx v1, rtx sel, rtx target)
/* As a special case to aid several targets, lower the element-based
permutation to a byte-based permutation and try again. */
machine_mode qimode;
- if (!qimode_for_vec_perm (mode).exists (&qimode))
+ if (!qimode_for_vec_perm (mode).exists (&qimode)
+ || GET_MODE_NUNITS (qimode) > GET_MODE_MASK (QImode) + 1)
return NULL_RTX;
icode = direct_optab_handler (vec_perm_optab, qimode);
if (icode == CODE_FOR_nothing)