re PR target/85317 (missing constant propagation on _mm(256)_movemask_*)
PR target/85317 * config/i386/i386.c (ix86_fold_builtin): Handle IX86_BUILTIN_{,P}MOVMSK{PS,PD,B}{,128,256}. * gcc.target/i386/pr85317.c: New test. * gcc.target/i386/avx2-vpmovmskb-2.c (avx2_test): Add asm volatile optimization barrier to avoid optimizing away the expected insn. From-SVN: r260040
This commit is contained in:
parent
294c6f6637
commit
ac68185918
5 changed files with 79 additions and 0 deletions
|
@ -1,5 +1,9 @@
|
|||
2018-05-08 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR target/85317
|
||||
* config/i386/i386.c (ix86_fold_builtin): Handle
|
||||
IX86_BUILTIN_{,P}MOVMSK{PS,PD,B}{,128,256}.
|
||||
|
||||
PR target/85480
|
||||
* config/i386/sse.md (ssequaterinsnmode): New mode attribute.
|
||||
(*<extract_type>_vinsert<shuffletype><extract_suf>_0): New pattern.
|
||||
|
|
|
@ -33477,6 +33477,37 @@ ix86_fold_builtin (tree fndecl, int n_args,
|
|||
}
|
||||
break;
|
||||
|
||||
case IX86_BUILTIN_MOVMSKPS:
|
||||
case IX86_BUILTIN_PMOVMSKB:
|
||||
case IX86_BUILTIN_MOVMSKPD:
|
||||
case IX86_BUILTIN_PMOVMSKB128:
|
||||
case IX86_BUILTIN_MOVMSKPD256:
|
||||
case IX86_BUILTIN_MOVMSKPS256:
|
||||
case IX86_BUILTIN_PMOVMSKB256:
|
||||
gcc_assert (n_args == 1);
|
||||
if (TREE_CODE (args[0]) == VECTOR_CST)
|
||||
{
|
||||
HOST_WIDE_INT res = 0;
|
||||
for (unsigned i = 0; i < VECTOR_CST_NELTS (args[0]); ++i)
|
||||
{
|
||||
tree e = VECTOR_CST_ELT (args[0], i);
|
||||
if (TREE_CODE (e) == INTEGER_CST && !TREE_OVERFLOW (e))
|
||||
{
|
||||
if (wi::neg_p (wi::to_wide (e)))
|
||||
res |= HOST_WIDE_INT_1 << i;
|
||||
}
|
||||
else if (TREE_CODE (e) == REAL_CST && !TREE_OVERFLOW (e))
|
||||
{
|
||||
if (TREE_REAL_CST (e).sign)
|
||||
res |= HOST_WIDE_INT_1 << i;
|
||||
}
|
||||
else
|
||||
return NULL_TREE;
|
||||
}
|
||||
return build_int_cst (TREE_TYPE (TREE_TYPE (fndecl)), res);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
2018-05-08 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR target/85317
|
||||
* gcc.target/i386/pr85317.c: New test.
|
||||
* gcc.target/i386/avx2-vpmovmskb-2.c (avx2_test): Add asm volatile
|
||||
optimization barrier to avoid optimizing away the expected insn.
|
||||
|
||||
PR target/85480
|
||||
* gcc.target/i386/avx512dq-pr85480-1.c: New test.
|
||||
* gcc.target/i386/avx512dq-pr85480-2.c: New test.
|
||||
|
|
|
@ -14,6 +14,7 @@ avx2_test (void)
|
|||
s.x = _mm256_set_epi8 (1, 2, 3, 4, 10, 20, 30, 90, -80, -40, -100,
|
||||
15, 98, 25, 98, 7, 1, 2, 3, 4, 10, 20, 30, 90,
|
||||
-80, -40, -100, -15, 98, 25, 98, 7);
|
||||
__asm volatile ("" : "+m" (s) : : "memory");
|
||||
|
||||
res = _mm256_movemask_epi8 (s.x);
|
||||
|
||||
|
|
38
gcc/testsuite/gcc.target/i386/pr85317.c
Normal file
38
gcc/testsuite/gcc.target/i386/pr85317.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* PR target/85317 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -mavx2 -fdump-tree-optimized" } */
|
||||
/* { dg-final { scan-tree-dump-not "link_error" "optimized" } } */
|
||||
|
||||
#include <x86intrin.h>
|
||||
|
||||
extern void link_error (void);
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int a = _mm_movemask_pd (_mm_set_pd (-2.0, 2.0));
|
||||
if (a != 2) link_error ();
|
||||
int b = _mm_movemask_pd (_mm_set_pd (0.0, __builtin_copysign (0.0, -4.0)));
|
||||
if (b != 1) link_error ();
|
||||
int c = _mm_movemask_ps (_mm_set_ps (__builtin_copysignf (0.0f, -4.0f), 0.0f,
|
||||
-4.0f, 4.0f));
|
||||
if (c != 10) link_error ();
|
||||
int d = _mm_movemask_epi8 (_mm_set_epi8 (-4, 8, -8, -12, 12, 15, 0, -1, -3,
|
||||
-128, 127, 126, 120, -120, 0, 5));
|
||||
if (d != 0xb1c4) link_error ();
|
||||
int e = _mm256_movemask_pd (_mm256_set_pd (-4.0, 0.0, 4.0,
|
||||
__builtin_copysign (0.0, -4.0)));
|
||||
if (e != 9) link_error ();
|
||||
int f = _mm256_movemask_ps (_mm256_set_ps (-8.0f, -16.0f, 12.0f, 127.0f,
|
||||
-4.0f, 0.0f, 4.0f,
|
||||
__builtin_copysign (0.0f,
|
||||
-4.0f)));
|
||||
if (f != 0xc9) link_error ();
|
||||
int g = _mm256_movemask_epi8 (_mm256_set_epi8 (-4, 8, -8, -12, 12, 15, 0, -1,
|
||||
-3, -128, 127, 126, 120, -120,
|
||||
0, 5, 12, 100, -20, -50, -70,
|
||||
2, -65, 0, -1, 1, 2, -2, -9,
|
||||
-9, 19, -64));
|
||||
if (g != (int) 0xb1c43a9dU) link_error ();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue