aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-06-18 12:08:06 +0200
committerJakub Jelinek <jakub@redhat.com>2020-06-18 12:12:43 +0200
commit9a875db43cd4210843c480c8df26a1d6624d057d (patch)
treed65bc1452fa2804adeb33052525ab377885579dc /gcc
parent5553433d7b38379f8dac17502f55fff1c9cf3827 (diff)
downloadgcc-9a875db43cd4210843c480c8df26a1d6624d057d.zip
gcc-9a875db43cd4210843c480c8df26a1d6624d057d.tar.gz
gcc-9a875db43cd4210843c480c8df26a1d6624d057d.tar.bz2
forwprop: simplify_vector_constructor follow-up fix [PR95713]
As the following testcase shows, the exception for the aarch64 vec_pack_trunc_di is not sufficient on x86, the halfvectype "vectors" have SImode but the x86 vec_pack_trunc_si meant for the bool bitmasks combines 2x SImode into DImode, while in the testcase the halfvectype is 1x SImode "vector" with SImode and result is 2x HImode "vector" with SImode. Richard Sandiford's reply: FWIW, since the aarch64 case was only found by inspection and might not be useful, personally I'd prefer to drop that case after all. 2020-06-18 Jakub Jelinek <jakub@redhat.com> PR target/95713 * tree-ssa-forwprop.c (simplify_vector_constructor): Don't allow scalar mode halfvectype other than vector boolean for VEC_PACK_TRUNC_EXPR. * gcc.dg/pr95713.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/pr95713.c15
-rw-r--r--gcc/tree-ssa-forwprop.c11
2 files changed, 19 insertions, 7 deletions
diff --git a/gcc/testsuite/gcc.dg/pr95713.c b/gcc/testsuite/gcc.dg/pr95713.c
new file mode 100644
index 0000000..b167842
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr95713.c
@@ -0,0 +1,15 @@
+/* PR target/95713 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-psabi -w" } */
+/* { dg-additional-options "-mavx512bw" { target i?86-*-* x86_64-*-* } } */
+
+typedef int v2si __attribute__((vector_size (8)));
+typedef short int v2hi __attribute__((vector_size (4)));
+void foo (v2hi);
+
+void
+bar (v2si x)
+{
+ v2hi a = (v2hi) { (short) x[0], (short) x[1] };
+ foo (4 > a);
+}
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index 0ab8267..a4aed3c 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -2401,8 +2401,8 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
&& (dblvectype
= build_vector_type (TREE_TYPE (TREE_TYPE (orig[0])),
nelts * 2))
- /* Only use it for vector modes or for vector booleans represented
- as scalar bitmasks. See PR95528. */
+ /* Only use it for vector modes or for vector booleans
+ represented as scalar bitmasks. See PR95528. */
&& (VECTOR_MODE_P (TYPE_MODE (dblvectype))
|| VECTOR_BOOLEAN_TYPE_P (dblvectype))
&& (optab = optab_for_tree_code (FLOAT_TYPE_P (TREE_TYPE (type))
@@ -2447,12 +2447,9 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
= build_vector_type (TREE_TYPE (TREE_TYPE (orig[0])),
nelts / 2))
/* Only use it for vector modes or for vector booleans
- represented as scalar bitmasks, or allow halfvectype
- be the element mode. See PR95528. */
+ represented as scalar bitmasks. See PR95528. */
&& (VECTOR_MODE_P (TYPE_MODE (halfvectype))
- || VECTOR_BOOLEAN_TYPE_P (halfvectype)
- || (TYPE_MODE (halfvectype)
- == TYPE_MODE (TREE_TYPE (halfvectype))))
+ || VECTOR_BOOLEAN_TYPE_P (halfvectype))
&& (optab = optab_for_tree_code (VEC_PACK_TRUNC_EXPR,
halfvectype,
optab_default))