aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-08-04 11:33:18 +0200
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 15:07:30 -0300
commita5759050fd9f6e3a1457d08b6e04190b8ea242dd (patch)
treeaea4f75e6734338e8d595720b2575e86dfd47e74
parentff5adb514c98dcac7cecbf2ea3f79e912838f931 (diff)
downloadgcc-a5759050fd9f6e3a1457d08b6e04190b8ea242dd.zip
gcc-a5759050fd9f6e3a1457d08b6e04190b8ea242dd.tar.gz
gcc-a5759050fd9f6e3a1457d08b6e04190b8ea242dd.tar.bz2
veclower: Don't ICE on .VEC_CONVERT calls with no lhs [PR96426]
.VEC_CONVERT is a const internal call, so normally if the lhs is not used, we'd DCE it far before getting to veclower, but with -O0 (or perhaps -fno-tree-dce and some other -fno-* options) it can happen. But as the internal fn needs the lhs to know the type to which the conversion is done (and I think that is a reasonable representation, having some magic another argument and having to create constants with that type looks overkill to me), we just should DCE those calls ourselves. During veclower, we can't really remove insns, as the callers would be upset, so this just replaces it with a GIMPLE_NOP. 2020-08-04 Jakub Jelinek <jakub@redhat.com> PR middle-end/96426 * tree-vect-generic.c (expand_vector_conversion): Replace .VEC_CONVERT call with GIMPLE_NOP if there is no lhs. * gcc.c-torture/compile/pr96426.c: New test.
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr96426.c10
-rw-r--r--gcc/tree-vect-generic.c6
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr96426.c b/gcc/testsuite/gcc.c-torture/compile/pr96426.c
new file mode 100644
index 0000000..bd573fe
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr96426.c
@@ -0,0 +1,10 @@
+/* PR middle-end/96426 */
+
+typedef long long V __attribute__((vector_size(16)));
+typedef double W __attribute__((vector_size(16)));
+
+void
+foo (V *v)
+{
+ __builtin_convertvector (*v, W);
+}
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index fe6477c..6d5d651 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -1775,6 +1775,12 @@ expand_vector_conversion (gimple_stmt_iterator *gsi)
gimple *stmt = gsi_stmt (*gsi);
gimple *g;
tree lhs = gimple_call_lhs (stmt);
+ if (lhs == NULL_TREE)
+ {
+ g = gimple_build_nop ();
+ gsi_replace (gsi, g, false);
+ return;
+ }
tree arg = gimple_call_arg (stmt, 0);
tree ret_type = TREE_TYPE (lhs);
tree arg_type = TREE_TYPE (arg);