summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386
diff options
context:
space:
mode:
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-23 19:29:54 +0000
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-23 19:29:54 +0000
commit1004a2c190f6d7afe6333fcc272526dc3cbe026a (patch)
tree29cf21e49bab5fac830067dde7594db1a7c83533 /gcc/testsuite/gcc.target/i386
parentf74ea1c2a9293d0fc474e429b2728f348c53a8e9 (diff)
downloadgcc-1004a2c190f6d7afe6333fcc272526dc3cbe026a.tar.gz
Add AVX2 testcases.
gcc/ 2011-08-23 Kirill Yukhin <kirill.yukhin@intel.com> * config/i386/sse.md (<s>mul<mode>3_highpart): Update. gcc/testsuite/ 2011-08-23 Kirill Yukhin <kirill.yukhin@intel.com> * g++.dg/other/i386-2.C: Add -mavx2 check. * g++.dg/other/i386-3.C: Likewise. * gcc.target/i386/avx-1.c: Add AVX2. * gcc.target/i386/avx-2.c: Likewise. * gcc.target/i386/funcspec-5.c: Likewise. * gcc.target/i386/sse-12.c: Likewise. * gcc.target/i386/sse-13.c: Likewise. * gcc.target/i386/sse-14.c: Likewise. * gcc.target/i386/sse-22.c: Likewise. * gcc.target/i386/sse-23.c: Likewise. * gcc.target/i386/i386.exp (check_effective_target_avx2): Likewise. * gcc.target/i386/avx2-check.h: New. * gcc.target/i386/avx2-i32gatherd-1.c: Likewise. * gcc.target/i386/avx2-i32gatherd-2.c: Likewise. * gcc.target/i386/avx2-i32gatherd-3.c: Likewise. * gcc.target/i386/avx2-i32gatherd-4.c: Likewise. * gcc.target/i386/avx2-i32gatherd256-1.c: Likewise. * gcc.target/i386/avx2-i32gatherd256-2.c: Likewise. * gcc.target/i386/avx2-i32gatherd256-3.c: Likewise. * gcc.target/i386/avx2-i32gatherd256-4.c: Likewise. * gcc.target/i386/avx2-i32gatherpd-1.c: Likewise. * gcc.target/i386/avx2-i32gatherpd-2.c: Likewise. * gcc.target/i386/avx2-i32gatherpd-3.c: Likewise. * gcc.target/i386/avx2-i32gatherpd-4.c: Likewise. * gcc.target/i386/avx2-i32gatherpd256-1.c: Likewise. * gcc.target/i386/avx2-i32gatherpd256-2.c: Likewise. * gcc.target/i386/avx2-i32gatherpd256-3.c: Likewise. * gcc.target/i386/avx2-i32gatherpd256-4.c: Likewise. * gcc.target/i386/avx2-i32gatherps-1.c: Likewise. * gcc.target/i386/avx2-i32gatherps-2.c: Likewise. * gcc.target/i386/avx2-i32gatherps-3.c: Likewise. * gcc.target/i386/avx2-i32gatherps-4.c: Likewise. * gcc.target/i386/avx2-i32gatherps256-1.c: Likewise. * gcc.target/i386/avx2-i32gatherps256-2.c: Likewise. * gcc.target/i386/avx2-i32gatherps256-3.c: Likewise. * gcc.target/i386/avx2-i32gatherps256-4.c: Likewise. * gcc.target/i386/avx2-i32gatherq-1.c: Likewise. * gcc.target/i386/avx2-i32gatherq-2.c: Likewise. * gcc.target/i386/avx2-i32gatherq-3.c: Likewise. * gcc.target/i386/avx2-i32gatherq-4.c: Likewise. * gcc.target/i386/avx2-i32gatherq256-1.c: Likewise. * gcc.target/i386/avx2-i32gatherq256-2.c: Likewise. * gcc.target/i386/avx2-i32gatherq256-3.c: Likewise. * gcc.target/i386/avx2-i32gatherq256-4.c: Likewise. * gcc.target/i386/avx2-i64gatherd-1.c: Likewise. * gcc.target/i386/avx2-i64gatherd-2.c: Likewise. * gcc.target/i386/avx2-i64gatherd-3.c: Likewise. * gcc.target/i386/avx2-i64gatherd-4.c: Likewise. * gcc.target/i386/avx2-i64gatherd256-1.c: Likewise. * gcc.target/i386/avx2-i64gatherd256-2.c: Likewise. * gcc.target/i386/avx2-i64gatherd256-3.c: Likewise. * gcc.target/i386/avx2-i64gatherd256-4.c: Likewise. * gcc.target/i386/avx2-i64gatherpd-1.c: Likewise. * gcc.target/i386/avx2-i64gatherpd-2.c: Likewise. * gcc.target/i386/avx2-i64gatherpd-3.c: Likewise. * gcc.target/i386/avx2-i64gatherpd-4.c: Likewise. * gcc.target/i386/avx2-i64gatherpd256-1.c: Likewise. * gcc.target/i386/avx2-i64gatherpd256-2.c: Likewise. * gcc.target/i386/avx2-i64gatherpd256-3.c: Likewise. * gcc.target/i386/avx2-i64gatherpd256-4.c: Likewise. * gcc.target/i386/avx2-i64gatherps-1.c: Likewise. * gcc.target/i386/avx2-i64gatherps-2.c: Likewise. * gcc.target/i386/avx2-i64gatherps-3.c: Likewise. * gcc.target/i386/avx2-i64gatherps-4.c: Likewise. * gcc.target/i386/avx2-i64gatherps256-1.c: Likewise. * gcc.target/i386/avx2-i64gatherps256-2.c: Likewise. * gcc.target/i386/avx2-i64gatherps256-3.c: Likewise. * gcc.target/i386/avx2-i64gatherps256-4.c: Likewise. * gcc.target/i386/avx2-i64gatherq-1.c: Likewise. * gcc.target/i386/avx2-i64gatherq-2.c: Likewise. * gcc.target/i386/avx2-i64gatherq-3.c: Likewise. * gcc.target/i386/avx2-i64gatherq-4.c: Likewise. * gcc.target/i386/avx2-i64gatherq256-1.c: Likewise. * gcc.target/i386/avx2-i64gatherq256-2.c: Likewise. * gcc.target/i386/avx2-i64gatherq256-3.c: Likewise. * gcc.target/i386/avx2-i64gatherq256-4.c: Likewise. * gcc.target/i386/avx2-mpsadbw-1.c: Likewise. * gcc.target/i386/avx2-mpsadbw-2.c: Likewise. * gcc.target/i386/avx2-vbroadcastsd_pd-1.c: Likewise. * gcc.target/i386/avx2-vbroadcastsd_pd-2.c: Likewise. * gcc.target/i386/avx2-vbroadcastsi128-1.c: Likewise. * gcc.target/i386/avx2-vbroadcastsi128-2.c: Likewise. * gcc.target/i386/avx2-vbroadcastss_ps-1.c: Likewise. * gcc.target/i386/avx2-vbroadcastss_ps-2.c: Likewise. * gcc.target/i386/avx2-vbroadcastss_ps256-1.c: Likewise. * gcc.target/i386/avx2-vbroadcastss_ps256-2.c: Likewise. * gcc.target/i386/avx2-vextracti128-1.c: Likewise. * gcc.target/i386/avx2-vextracti128-2.c: Likewise. * gcc.target/i386/avx2-vinserti128-1.c: Likewise. * gcc.target/i386/avx2-vinserti128-2.c: Likewise. * gcc.target/i386/avx2-vmovmskb-2.c: Likewise. * gcc.target/i386/avx2-vmovntdqa-1.c: Likewise. * gcc.target/i386/avx2-vmovntdqa-2.c: Likewise. * gcc.target/i386/avx2-vpabsb256-1.c: Likewise. * gcc.target/i386/avx2-vpabsb256-2.c: Likewise. * gcc.target/i386/avx2-vpabsd256-1.c: Likewise. * gcc.target/i386/avx2-vpabsd256-2.c: Likewise. * gcc.target/i386/avx2-vpabsw256-1.c: Likewise. * gcc.target/i386/avx2-vpabsw256-2.c: Likewise. * gcc.target/i386/avx2-vpackssdw-1.c: Likewise. * gcc.target/i386/avx2-vpackssdw-2.c: Likewise. * gcc.target/i386/avx2-vpacksswb-1.c: Likewise. * gcc.target/i386/avx2-vpacksswb-2.c: Likewise. * gcc.target/i386/avx2-vpackusdw-1.c: Likewise. * gcc.target/i386/avx2-vpackusdw-2.c: Likewise. * gcc.target/i386/avx2-vpackuswb-1.c: Likewise. * gcc.target/i386/avx2-vpackuswb-2.c: Likewise. * gcc.target/i386/avx2-vpaddb-1.c: Likewise. * gcc.target/i386/avx2-vpaddb-2.c: Likewise. * gcc.target/i386/avx2-vpaddd-1.c: Likewise. * gcc.target/i386/avx2-vpaddd-2.c: Likewise. * gcc.target/i386/avx2-vpaddq-1.c: Likewise. * gcc.target/i386/avx2-vpaddq-2.c: Likewise. * gcc.target/i386/avx2-vpaddsb-1.c: Likewise. * gcc.target/i386/avx2-vpaddsb-2.c: Likewise. * gcc.target/i386/avx2-vpaddsw-1.c: Likewise. * gcc.target/i386/avx2-vpaddsw-2.c: Likewise. * gcc.target/i386/avx2-vpaddusb-1.c: Likewise. * gcc.target/i386/avx2-vpaddusb-2.c: Likewise. * gcc.target/i386/avx2-vpaddusw-1.c: Likewise. * gcc.target/i386/avx2-vpaddusw-2.c: Likewise. * gcc.target/i386/avx2-vpaddw-1.c: Likewise. * gcc.target/i386/avx2-vpaddw-2.c: Likewise. * gcc.target/i386/avx2-vpalignr256-1.c: Likewise. * gcc.target/i386/avx2-vpalignr256-2.c: Likewise. * gcc.target/i386/avx2-vpand-1.c: Likewise. * gcc.target/i386/avx2-vpand-2.c: Likewise. * gcc.target/i386/avx2-vpandn-1.c: Likewise. * gcc.target/i386/avx2-vpandn-2.c: Likewise. * gcc.target/i386/avx2-vpavgb-1.c: Likewise. * gcc.target/i386/avx2-vpavgb-2.c: Likewise. * gcc.target/i386/avx2-vpavgw-1.c: Likewise. * gcc.target/i386/avx2-vpavgw-2.c: Likewise. * gcc.target/i386/avx2-vpblendd128-1.c: Likewise. * gcc.target/i386/avx2-vpblendd128-2.c: Likewise. * gcc.target/i386/avx2-vpblendd256-1.c: Likewise. * gcc.target/i386/avx2-vpblendd256-2.c: Likewise. * gcc.target/i386/avx2-vpblendvb-1.c: Likewise. * gcc.target/i386/avx2-vpblendvb-2.c: Likewise. * gcc.target/i386/avx2-vpblendw-1.c: Likewise. * gcc.target/i386/avx2-vpblendw-2.c: Likewise. * gcc.target/i386/avx2-vpbroadcastb128-1.c: Likewise. * gcc.target/i386/avx2-vpbroadcastb128-2.c: Likewise. * gcc.target/i386/avx2-vpbroadcastb256-1.c: Likewise. * gcc.target/i386/avx2-vpbroadcastb256-2.c: Likewise. * gcc.target/i386/avx2-vpbroadcastd128-1.c: Likewise. * gcc.target/i386/avx2-vpbroadcastd128-2.c: Likewise. * gcc.target/i386/avx2-vpbroadcastd256-1.c: Likewise. * gcc.target/i386/avx2-vpbroadcastd256-2.c: Likewise. * gcc.target/i386/avx2-vpbroadcastq128-1.c: Likewise. * gcc.target/i386/avx2-vpbroadcastq128-2.c: Likewise. * gcc.target/i386/avx2-vpbroadcastq256-1.c: Likewise. * gcc.target/i386/avx2-vpbroadcastq256-2.c: Likewise. * gcc.target/i386/avx2-vpbroadcastw128-1.c: Likewise. * gcc.target/i386/avx2-vpbroadcastw128-2.c: Likewise. * gcc.target/i386/avx2-vpbroadcastw256-1.c: Likewise. * gcc.target/i386/avx2-vpbroadcastw256-2.c: Likewise. * gcc.target/i386/avx2-vpcmpeqb-1.c: Likewise. * gcc.target/i386/avx2-vpcmpeqb-2.c: Likewise. * gcc.target/i386/avx2-vpcmpeqd-1.c: Likewise. * gcc.target/i386/avx2-vpcmpeqd-2.c: Likewise. * gcc.target/i386/avx2-vpcmpeqq-1.c: Likewise. * gcc.target/i386/avx2-vpcmpeqq-2.c: Likewise. * gcc.target/i386/avx2-vpcmpeqw-1.c: Likewise. * gcc.target/i386/avx2-vpcmpeqw-2.c: Likewise. * gcc.target/i386/avx2-vpcmpgtb-1.c: Likewise. * gcc.target/i386/avx2-vpcmpgtb-2.c: Likewise. * gcc.target/i386/avx2-vpcmpgtd-1.c: Likewise. * gcc.target/i386/avx2-vpcmpgtd-2.c: Likewise. * gcc.target/i386/avx2-vpcmpgtq-1.c: Likewise. * gcc.target/i386/avx2-vpcmpgtq-2.c: Likewise. * gcc.target/i386/avx2-vpcmpgtw-1.c: Likewise. * gcc.target/i386/avx2-vpcmpgtw-2.c: Likewise. * gcc.target/i386/avx2-vperm2i128-1.c: Likewise. * gcc.target/i386/avx2-vperm2i128-2.c: Likewise. * gcc.target/i386/avx2-vpermd-1.c: Likewise. * gcc.target/i386/avx2-vpermd-2.c: Likewise. * gcc.target/i386/avx2-vpermpd-1.c: Likewise. * gcc.target/i386/avx2-vpermpd-2.c: Likewise. * gcc.target/i386/avx2-vpermps-1.c: Likewise. * gcc.target/i386/avx2-vpermps-2.c: Likewise. * gcc.target/i386/avx2-vpermq-1.c: Likewise. * gcc.target/i386/avx2-vpermq-2.c: Likewise. * gcc.target/i386/avx2-vphaddd-1.c: Likewise. * gcc.target/i386/avx2-vphaddd-2.c: Likewise. * gcc.target/i386/avx2-vphaddsw-1.c: Likewise. * gcc.target/i386/avx2-vphaddsw-2.c: Likewise. * gcc.target/i386/avx2-vphaddw-1.c: Likewise. * gcc.target/i386/avx2-vphaddw-2.c: Likewise. * gcc.target/i386/avx2-vphsubd-1.c: Likewise. * gcc.target/i386/avx2-vphsubd-2.c: Likewise. * gcc.target/i386/avx2-vphsubsw-1.c: Likewise. * gcc.target/i386/avx2-vphsubsw-2.c: Likewise. * gcc.target/i386/avx2-vphsubw-1.c: Likewise. * gcc.target/i386/avx2-vpmaddubsw-1.c: Likewise. * gcc.target/i386/avx2-vpmaddubsw-2.c: Likewise. * gcc.target/i386/avx2-vpmaddwd-1.c: Likewise. * gcc.target/i386/avx2-vpmaddwd-2.c: Likewise. * gcc.target/i386/avx2-vpmaskloadd-1.c: Likewise. * gcc.target/i386/avx2-vpmaskloadd-2.c: Likewise. * gcc.target/i386/avx2-vpmaskloadd256-1.c: Likewise. * gcc.target/i386/avx2-vpmaskloadd256-2.c: Likewise. * gcc.target/i386/avx2-vpmaskloadq-1.c: Likewise. * gcc.target/i386/avx2-vpmaskloadq-2.c: Likewise. * gcc.target/i386/avx2-vpmaskloadq256-1.c: Likewise. * gcc.target/i386/avx2-vpmaskloadq256-2.c: Likewise. * gcc.target/i386/avx2-vpmaskstored-1.c: Likewise. * gcc.target/i386/avx2-vpmaskstored-2.c: Likewise. * gcc.target/i386/avx2-vpmaskstored256-1.c: Likewise. * gcc.target/i386/avx2-vpmaskstored256-2.c: Likewise. * gcc.target/i386/avx2-vpmaskstoreq-1.c: Likewise. * gcc.target/i386/avx2-vpmaskstoreq-2.c: Likewise. * gcc.target/i386/avx2-vpmaskstoreq256-1.c: Likewise. * gcc.target/i386/avx2-vpmaskstoreq256-2.c: Likewise. * gcc.target/i386/avx2-vpmaxsb-1.c: Likewise. * gcc.target/i386/avx2-vpmaxsb-2.c: Likewise. * gcc.target/i386/avx2-vpmaxsd-1.c: Likewise. * gcc.target/i386/avx2-vpmaxsd-2.c: Likewise. * gcc.target/i386/avx2-vpmaxsw-1.c: Likewise. * gcc.target/i386/avx2-vpmaxsw-2.c: Likewise. * gcc.target/i386/avx2-vpmaxub-1.c: Likewise. * gcc.target/i386/avx2-vpmaxub-2.c: Likewise. * gcc.target/i386/avx2-vpmaxud-1.c: Likewise. * gcc.target/i386/avx2-vpmaxud-2.c: Likewise. * gcc.target/i386/avx2-vpmaxuw-1.c: Likewise. * gcc.target/i386/avx2-vpmaxuw-2.c: Likewise. * gcc.target/i386/avx2-vpminsb-1.c: Likewise. * gcc.target/i386/avx2-vpminsb-2.c: Likewise. * gcc.target/i386/avx2-vpminsd-1.c: Likewise. * gcc.target/i386/avx2-vpminsd-2.c: Likewise. * gcc.target/i386/avx2-vpminsw-1.c: Likewise. * gcc.target/i386/avx2-vpminsw-2.c: Likewise. * gcc.target/i386/avx2-vpminub-1.c: Likewise. * gcc.target/i386/avx2-vpminub-2.c: Likewise. * gcc.target/i386/avx2-vpminud-1.c: Likewise. * gcc.target/i386/avx2-vpminud-2.c: Likewise. * gcc.target/i386/avx2-vpminuw-1.c: Likewise. * gcc.target/i386/avx2-vpminuw-2.c: Likewise. * gcc.target/i386/avx2-vpmovmskb-1.c: Likewise. * gcc.target/i386/avx2-vpmovsxbd-1.c: Likewise. * gcc.target/i386/avx2-vpmovsxbd-2.c: Likewise. * gcc.target/i386/avx2-vpmovsxbq-1.c: Likewise. * gcc.target/i386/avx2-vpmovsxbq-2.c: Likewise. * gcc.target/i386/avx2-vpmovsxbw-1.c: Likewise. * gcc.target/i386/avx2-vpmovsxbw-2.c: Likewise. * gcc.target/i386/avx2-vpmovsxdq-1.c: Likewise. * gcc.target/i386/avx2-vpmovsxdq-2.c: Likewise. * gcc.target/i386/avx2-vpmovsxwd-1.c: Likewise. * gcc.target/i386/avx2-vpmovsxwd-2.c: Likewise. * gcc.target/i386/avx2-vpmovsxwq-1.c: Likewise. * gcc.target/i386/avx2-vpmovsxwq-2.c: Likewise. * gcc.target/i386/avx2-vpmovzxbd-1.c: Likewise. * gcc.target/i386/avx2-vpmovzxbd-2.c: Likewise. * gcc.target/i386/avx2-vpmovzxbq-1.c: Likewise. * gcc.target/i386/avx2-vpmovzxbq-2.c: Likewise. * gcc.target/i386/avx2-vpmovzxbw-1.c: Likewise. * gcc.target/i386/avx2-vpmovzxbw-2.c: Likewise. * gcc.target/i386/avx2-vpmovzxdq-1.c: Likewise. * gcc.target/i386/avx2-vpmovzxdq-2.c: Likewise. * gcc.target/i386/avx2-vpmovzxwd-1.c: Likewise. * gcc.target/i386/avx2-vpmovzxwd-2.c: Likewise. * gcc.target/i386/avx2-vpmovzxwq-1.c: Likewise. * gcc.target/i386/avx2-vpmovzxwq-2.c: Likewise. * gcc.target/i386/avx2-vpmuldq-1.c: Likewise. * gcc.target/i386/avx2-vpmuldq-2.c: Likewise. * gcc.target/i386/avx2-vpmulhrsw-1.c: Likewise. * gcc.target/i386/avx2-vpmulhrsw-2.c: Likewise. * gcc.target/i386/avx2-vpmulhuw-1.c: Likewise. * gcc.target/i386/avx2-vpmulhuw-2.c: Likewise. * gcc.target/i386/avx2-vpmulhw-1.c: Likewise. * gcc.target/i386/avx2-vpmulhw-2.c: Likewise. * gcc.target/i386/avx2-vpmulld-1.c: Likewise. * gcc.target/i386/avx2-vpmulld-2.c: Likewise. * gcc.target/i386/avx2-vpmullw-1.c: Likewise. * gcc.target/i386/avx2-vpmullw-2.c: Likewise. * gcc.target/i386/avx2-vpmuludq-1.c: Likewise. * gcc.target/i386/avx2-vpmuludq-2.c: Likewise. * gcc.target/i386/avx2-vpor-1.c: Likewise. * gcc.target/i386/avx2-vpor-2.c: Likewise. * gcc.target/i386/avx2-vpsadbw-1.c: Likewise. * gcc.target/i386/avx2-vpsadbw-2.c: Likewise. * gcc.target/i386/avx2-vpshufb-1.c: Likewise. * gcc.target/i386/avx2-vpshufb-2.c: Likewise. * gcc.target/i386/avx2-vpshufd-1.c: Likewise. * gcc.target/i386/avx2-vpshufd-2.c: Likewise. * gcc.target/i386/avx2-vpshufhw-1.c: Likewise. * gcc.target/i386/avx2-vpshufhw-2.c: Likewise. * gcc.target/i386/avx2-vpshuflw-1.c: Likewise. * gcc.target/i386/avx2-vpshuflw-2.c: Likewise. * gcc.target/i386/avx2-vpsignb-1.c: Likewise. * gcc.target/i386/avx2-vpsignb-2.c: Likewise. * gcc.target/i386/avx2-vpsignd-1.c: Likewise. * gcc.target/i386/avx2-vpsignd-2.c: Likewise. * gcc.target/i386/avx2-vpsignw-1.c: Likewise. * gcc.target/i386/avx2-vpsignw-2.c: Likewise. * gcc.target/i386/avx2-vpslld-1.c: Likewise. * gcc.target/i386/avx2-vpslld-2.c: Likewise. * gcc.target/i386/avx2-vpslldi-1.c: Likewise. * gcc.target/i386/avx2-vpslldi-2.c: Likewise. * gcc.target/i386/avx2-vpslldq-1.c: Likewise. * gcc.target/i386/avx2-vpslldq-2.c: Likewise. * gcc.target/i386/avx2-vpsllq-1.c: Likewise. * gcc.target/i386/avx2-vpsllq-2.c: Likewise. * gcc.target/i386/avx2-vpsllqi-1.c: Likewise. * gcc.target/i386/avx2-vpsllqi-2.c: Likewise. * gcc.target/i386/avx2-vpsllvd128-1.c: Likewise. * gcc.target/i386/avx2-vpsllvd128-2.c: Likewise. * gcc.target/i386/avx2-vpsllvd256-1.c: Likewise. * gcc.target/i386/avx2-vpsllvd256-2.c: Likewise. * gcc.target/i386/avx2-vpsllvq128-1.c: Likewise. * gcc.target/i386/avx2-vpsllvq128-2.c: Likewise. * gcc.target/i386/avx2-vpsllvq256-1.c: Likewise. * gcc.target/i386/avx2-vpsllvq256-2.c: Likewise. * gcc.target/i386/avx2-vpsllw-1.c: Likewise. * gcc.target/i386/avx2-vpsllw-2.c: Likewise. * gcc.target/i386/avx2-vpsllwi-1.c: Likewise. * gcc.target/i386/avx2-vpsllwi-2.c: Likewise. * gcc.target/i386/avx2-vpsrad-1.c: Likewise. * gcc.target/i386/avx2-vpsrad-2.c: Likewise. * gcc.target/i386/avx2-vpsradi-1.c: Likewise. * gcc.target/i386/avx2-vpsradi-2.c: Likewise. * gcc.target/i386/avx2-vpsravd128-1.c: Likewise. * gcc.target/i386/avx2-vpsravd128-2.c: Likewise. * gcc.target/i386/avx2-vpsravd256-1.c: Likewise. * gcc.target/i386/avx2-vpsravd256-2.c: Likewise. * gcc.target/i386/avx2-vpsraw-1.c: Likewise. * gcc.target/i386/avx2-vpsraw-2.c: Likewise. * gcc.target/i386/avx2-vpsrawi-1.c: Likewise. * gcc.target/i386/avx2-vpsrawi-2.c: Likewise. * gcc.target/i386/avx2-vpsrld-1.c: Likewise. * gcc.target/i386/avx2-vpsrld-2.c: Likewise. * gcc.target/i386/avx2-vpsrldi-1.c: Likewise. * gcc.target/i386/avx2-vpsrldi-2.c: Likewise. * gcc.target/i386/avx2-vpsrldq-1.c: Likewise. * gcc.target/i386/avx2-vpsrldq-2.c: Likewise. * gcc.target/i386/avx2-vpsrlq-1.c: Likewise. * gcc.target/i386/avx2-vpsrlq-2.c: Likewise. * gcc.target/i386/avx2-vpsrlqi-1.c: Likewise. * gcc.target/i386/avx2-vpsrlqi-2.c: Likewise. * gcc.target/i386/avx2-vpsrlvd128-1.c: Likewise. * gcc.target/i386/avx2-vpsrlvd128-2.c: Likewise. * gcc.target/i386/avx2-vpsrlvd256-1.c: Likewise. * gcc.target/i386/avx2-vpsrlvd256-2.c: Likewise. * gcc.target/i386/avx2-vpsrlvq128-1.c: Likewise. * gcc.target/i386/avx2-vpsrlvq128-2.c: Likewise. * gcc.target/i386/avx2-vpsrlvq256-1.c: Likewise. * gcc.target/i386/avx2-vpsrlvq256-2.c: Likewise. * gcc.target/i386/avx2-vpsrlw-1.c: Likewise. * gcc.target/i386/avx2-vpsrlw-2.c: Likewise. * gcc.target/i386/avx2-vpsrlwi-1.c: Likewise. * gcc.target/i386/avx2-vpsrlwi-2.c: Likewise. * gcc.target/i386/avx2-vpsubb-1.c: Likewise. * gcc.target/i386/avx2-vpsubb-2.c: Likewise. * gcc.target/i386/avx2-vpsubd-1.c: Likewise. * gcc.target/i386/avx2-vpsubd-2.c: Likewise. * gcc.target/i386/avx2-vpsubq-1.c: Likewise. * gcc.target/i386/avx2-vpsubq-2.c: Likewise. * gcc.target/i386/avx2-vpsubsb-1.c: Likewise. * gcc.target/i386/avx2-vpsubsb-2.c: Likewise. * gcc.target/i386/avx2-vpsubsw-1.c: Likewise. * gcc.target/i386/avx2-vpsubsw-2.c: Likewise. * gcc.target/i386/avx2-vpsubusb-1.c: Likewise. * gcc.target/i386/avx2-vpsubusb-2.c: Likewise. * gcc.target/i386/avx2-vpsubusw-1.c: Likewise. * gcc.target/i386/avx2-vpsubusw-2.c: Likewise. * gcc.target/i386/avx2-vpunpckhbw-1.c: Likewise. * gcc.target/i386/avx2-vpunpckhbw-2.c: Likewise. * gcc.target/i386/avx2-vpunpckhdq-1.c: Likewise. * gcc.target/i386/avx2-vpunpckhdq-2.c: Likewise. * gcc.target/i386/avx2-vpunpckhqdq-1.c: Likewise. * gcc.target/i386/avx2-vpunpckhqdq-2.c: Likewise. * gcc.target/i386/avx2-vpunpckhwd-1.c: Likewise. * gcc.target/i386/avx2-vpunpckhwd-2.c: Likewise. * gcc.target/i386/avx2-vpunpcklbw-1.c: Likewise. * gcc.target/i386/avx2-vpunpcklbw-2.c: Likewise. * gcc.target/i386/avx2-vpunpckldq-1.c: Likewise. * gcc.target/i386/avx2-vpunpckldq-2.c: Likewise. * gcc.target/i386/avx2-vpunpcklqdq-1.c: Likewise. * gcc.target/i386/avx2-vpunpcklqdq-2.c: Likewise. * gcc.target/i386/avx2-vpunpcklwd-1.c: Likewise. * gcc.target/i386/avx2-vpunpcklwd-2.c: Likewise. * gcc.target/i386/avx2-vpxor-1.c: Likewise. * gcc.target/i386/avx2-vpxor-2.c: Likewise. * gcc.target/i386/testimm-9.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178006 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.target/i386')
-rw-r--r--gcc/testsuite/gcc.target/i386/avx-1.c35
-rw-r--r--gcc/testsuite/gcc.target/i386/avx-2.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-check.h44
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherd-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherd-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherd-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherd-4.c50
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-4.c51
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-4.c51
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-4.c52
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherps-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherps-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherps-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherps-4.c51
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-4.c51
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherq-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherq-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherq-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherq-4.c53
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-4.c54
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherd-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherd-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherd-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherd-4.c51
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-4.c51
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-2.c40
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-4.c52
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-4.c52
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherps-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherps-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherps-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherps-4.c52
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-4.c52
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherq-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherq-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherq-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherq-4.c53
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-1.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-3.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-4.c55
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-mpsadbw-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-mpsadbw-2.c132
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vbroadcastsd_pd-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vbroadcastsd_pd-2.c32
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vbroadcastsi128-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vbroadcastsi128-2.c33
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps256-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps256-2.c32
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vextracti128-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vextracti128-2.c34
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vinserti128-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vinserti128-2.c37
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vmovmskb-2.c26
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vmovntdqa-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vmovntdqa-2.c26
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpabsb256-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpabsb256-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpabsd256-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpabsd256-2.c45
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpabsw256-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpabsw256-2.c47
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpackssdw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpackssdw-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpacksswb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpacksswb-2.c48
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpackusdw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpackusdw-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpackuswb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpackuswb-2.c48
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddb-2.c29
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddd-2.c24
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddq-2.c24
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddsb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddsb-2.c38
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddsw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddsw-2.c36
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddusb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddusb-2.c36
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddusw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddusw-2.c34
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpaddw-2.c26
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpalignr256-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpalignr256-2.c177
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpand-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpand-2.c28
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpandn-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpandn-2.c28
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpavgb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpavgb-2.c30
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpavgw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpavgw-2.c26
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpblendd128-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpblendd128-2.c54
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpblendd256-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpblendd256-2.c54
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpblendvb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpblendvb-2.c56
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpblendw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpblendw-2.c54
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb128-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb128-2.c48
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb256-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb256-2.c49
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd128-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd128-2.c48
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd256-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd256-2.c49
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq128-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq128-2.c48
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq256-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq256-2.c49
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw128-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw128-2.c48
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw256-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw256-2.c49
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpeqb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpeqb-2.c29
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpeqd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpeqd-2.c25
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpeqq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpeqq-2.c25
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpeqw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpeqw-2.c27
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpgtb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpgtb-2.c29
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpgtd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpgtd-2.c25
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpgtq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpgtq-2.c25
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpgtw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpcmpgtw-2.c27
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vperm2i128-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vperm2i128-2.c84
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpermd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpermd-2.c54
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpermpd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpermpd-2.c55
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpermps-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpermps-2.c55
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpermq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpermq-2.c54
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vphaddd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vphaddd-2.c49
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vphaddsw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vphaddsw-2.c61
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vphaddw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vphaddw-2.c48
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vphsubd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vphsubd-2.c49
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vphsubsw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vphsubsw-2.c60
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vphsubw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaddubsw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaddubsw-2.c59
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaddwd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaddwd-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd-2.c30
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd256-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd256-2.c32
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq-2.c30
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq256-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq256-2.c30
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskstored-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskstored-2.c32
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskstored256-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskstored256-2.c34
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq-2.c32
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq256-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq256-2.c32
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxsb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxsb-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxsd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxsd-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxsw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxsw-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxub-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxub-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxud-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxud-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxuw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmaxuw-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminsb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminsb-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminsd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminsd-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminsw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminsw-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminub-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminub-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminud-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminud-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminuw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpminuw-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovmskb-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxbd-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxbd-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxbq-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxbq-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxbw-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxbw-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxdq-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxdq-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxwd-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxwd-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxwq-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovsxwq-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxbd-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxbd-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxbq-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxbq-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxbw-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxbw-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxdq-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxdq-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxwd-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxwd-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxwq-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmovzxwq-2.c31
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmuldq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmuldq-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmulhrsw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmulhrsw-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmulhuw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmulhuw-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmulhw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmulhw-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmulld-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmulld-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmullw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmullw-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmuludq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpmuludq-2.c42
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpor-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpor-2.c41
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsadbw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsadbw-2.c57
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpshufb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpshufb-2.c54
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpshufd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpshufd-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpshufhw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpshufhw-2.c52
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpshuflw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpshuflw-2.c52
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsignb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsignb-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsignd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsignd-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsignw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsignw-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpslld-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpslld-2.c47
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpslldi-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpslldi-2.c45
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpslldq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpslldq-2.c47
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllq-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllq-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllqi-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllqi-2.c45
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllvd128-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllvd128-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllvd256-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllvd256-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllvq128-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllvq128-2.c47
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllvq256-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllvq256-2.c47
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllw-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllw-2.c53
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllwi-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsllwi-2.c45
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrad-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrad-2.c47
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsradi-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsradi-2.c45
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsravd128-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsravd128-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsravd256-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsravd256-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsraw-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsraw-2.c47
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrawi-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrawi-2.c45
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrld-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrld-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrldi-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrldi-2.c44
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrldq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrldq-2.c47
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlq-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlq-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlqi-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlqi-2.c44
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlvd128-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlvd128-2.c47
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlvd256-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlvd256-2.c46
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlvq128-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlvq128-2.c47
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlvq256-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlvq256-2.c47
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlw-1.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlw-2.c53
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlwi-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsrlwi-2.c44
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubb-2.c29
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubd-2.c24
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubq-2.c24
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubsb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubsb-2.c38
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubsw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubsw-2.c36
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubusb-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubusb-2.c36
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubusw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpsubusw-2.c34
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpckhbw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpckhbw-2.c50
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpckhdq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpckhdq-2.c50
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpckhqdq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpckhqdq-2.c44
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpckhwd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpckhwd-2.c50
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpcklbw-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpcklbw-2.c50
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpckldq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpckldq-2.c50
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpcklqdq-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpcklqdq-2.c44
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpcklwd-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpunpcklwd-2.c50
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpxor-1.c13
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-vpxor-2.c28
-rw-r--r--gcc/testsuite/gcc.target/i386/funcspec-5.c4
-rw-r--r--gcc/testsuite/gcc.target/i386/funcspec-6.c4
-rw-r--r--gcc/testsuite/gcc.target/i386/i386.exp12
-rw-r--r--gcc/testsuite/gcc.target/i386/sse-12.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/sse-13.c34
-rw-r--r--gcc/testsuite/gcc.target/i386/sse-14.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/sse-21.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/sse-22.c37
-rw-r--r--gcc/testsuite/gcc.target/i386/sse-23.c35
-rw-r--r--gcc/testsuite/gcc.target/i386/testimm-9.c33
384 files changed, 10781 insertions, 9 deletions
diff --git a/gcc/testsuite/gcc.target/i386/avx-1.c b/gcc/testsuite/gcc.target/i386/avx-1.c
index f76d02db858..4f40abb2605 100644
--- a/gcc/testsuite/gcc.target/i386/avx-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8 -m3dnow -mavx -maes -mpclmul" } */
+/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8 -m3dnow -mavx -mavx2 -maes -mpclmul" } */
#include <mm_malloc.h>
@@ -49,6 +49,39 @@
#define __builtin_ia32_vinsertf128_si256(X, Y, C) __builtin_ia32_vinsertf128_si256(X, Y, 1)
#define __builtin_ia32_roundpd256(V, M) __builtin_ia32_roundpd256(V, 1)
#define __builtin_ia32_roundps256(V, M) __builtin_ia32_roundps256(V, 1)
+#define __builtin_ia32_mpsadbw256(X, Y, M) __builtin_ia32_mpsadbw256(X, Y, 1)
+#define __builtin_ia32_palignr256(X, Y, M) __builtin_ia32_palignr256(X, Y, 8)
+#define __builtin_ia32_pblendw256(X, Y, M) __builtin_ia32_pblendw256(X, Y, 8)
+#define __builtin_ia32_pshufd256(X, M) __builtin_ia32_pshufd256(X, 8)
+#define __builtin_ia32_pshufhw256(X, M) __builtin_ia32_pshufhw256(X, 8)
+#define __builtin_ia32_pshuflw256(X, M) __builtin_ia32_pshuflw256(X, 8)
+#define __builtin_ia32_pslldqi256(X, M) __builtin_ia32_pslldqi256(X, 8)
+#define __builtin_ia32_psrldqi256(X, M) __builtin_ia32_psrldqi256(X, 8)
+#define __builtin_ia32_pblendd128(X, Y, M) __builtin_ia32_pblendd128(X, Y, 1)
+#define __builtin_ia32_pblendd256(X, Y, M) __builtin_ia32_pblendd256(X, Y, 1)
+#define __builtin_ia32_permdf256(X, M) __builtin_ia32_permdf256(X, 1)
+#define __builtin_ia32_permdi256(X, M) __builtin_ia32_permdi256(X, 1)
+#define __builtin_ia32_permti256(X, Y, M) __builtin_ia32_permti256(X, Y, 1)
+#define __builtin_ia32_extract128i256(X, M) __builtin_ia32_extract128i256(X, 1)
+#define __builtin_ia32_insert128i256(X, Y, M) __builtin_ia32_insert128i256(X, Y, 1)
+#define __builtin_ia32_gathersiv2df(A, B, C, D, M) __builtin_ia32_gathersiv2df(A, B, C, D, 1)
+#define __builtin_ia32_gathersiv4df(A, B, C, D, M) __builtin_ia32_gathersiv4df(A, B, C, D, 1)
+#define __builtin_ia32_gatherdiv2df(A, B, C, D, M) __builtin_ia32_gatherdiv2df(A, B, C, D, 1)
+#define __builtin_ia32_gatherdiv4df(A, B, C, D, M) __builtin_ia32_gatherdiv4df(A, B, C, D, 1)
+#define __builtin_ia32_gathersiv4sf(A, B, C, D, M) __builtin_ia32_gathersiv4sf(A, B, C, D, 1)
+#define __builtin_ia32_gathersiv8sf(A, B, C, D, M) __builtin_ia32_gathersiv8sf(A, B, C, D, 1)
+#define __builtin_ia32_gatherdiv4sf(A, B, C, D, M) __builtin_ia32_gatherdiv4sf(A, B, C, D, 1)
+#define __builtin_ia32_gatherdiv4sf256(A, B, C, D, M) \
+ __builtin_ia32_gatherdiv4sf256(A, B, C, D, 1)
+#define __builtin_ia32_gathersiv2di(A, B, C, D, M) __builtin_ia32_gathersiv2di(A, B, C, D, 1)
+#define __builtin_ia32_gathersiv4di(A, B, C, D, M) __builtin_ia32_gathersiv4di(A, B, C, D, 1)
+#define __builtin_ia32_gatherdiv2di(A, B, C, D, M) __builtin_ia32_gatherdiv2di(A, B, C, D, 1)
+#define __builtin_ia32_gatherdiv4di(A, B, C, D, M) __builtin_ia32_gatherdiv4di(A, B, C, D, 1)
+#define __builtin_ia32_gathersiv4si(A, B, C, D, M) __builtin_ia32_gathersiv4si(A, B, C, D, 1)
+#define __builtin_ia32_gathersiv8si(A, B, C, D, M) __builtin_ia32_gathersiv8si(A, B, C, D, 1)
+#define __builtin_ia32_gatherdiv4si(A, B, C, D, M) __builtin_ia32_gatherdiv4si(A, B, C, D, 1)
+#define __builtin_ia32_gatherdiv4si256(A, B, C, D, M) \
+ __builtin_ia32_gatherdiv4si256(A, B, C, D, 1)
/* wmmintrin.h */
#define __builtin_ia32_aeskeygenassist128(X, C) __builtin_ia32_aeskeygenassist128(X, 1)
diff --git a/gcc/testsuite/gcc.target/i386/avx-2.c b/gcc/testsuite/gcc.target/i386/avx-2.c
index c3616ba3403..17bc64e4deb 100644
--- a/gcc/testsuite/gcc.target/i386/avx-2.c
+++ b/gcc/testsuite/gcc.target/i386/avx-2.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O0 -Werror-implicit-function-declaration -march=k8 -m3dnow -mavx -msse4a -maes -mpclmul" } */
+/* { dg-options "-O0 -Werror-implicit-function-declaration -march=k8 -m3dnow -mavx -mavx2 -msse4a -maes -mpclmul" } */
#include <mm_malloc.h>
diff --git a/gcc/testsuite/gcc.target/i386/avx2-check.h b/gcc/testsuite/gcc.target/i386/avx2-check.h
new file mode 100644
index 00000000000..22c9b39da45
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-check.h
@@ -0,0 +1,44 @@
+#include <stdlib.h>
+#include "cpuid.h"
+#include "m256-check.h"
+#include "avx-os-support.h"
+
+static void avx2_test (void);
+
+static void __attribute__ ((noinline)) do_test (void)
+{
+ avx2_test ();
+}
+
+int
+main ()
+{
+ unsigned int eax, ebx, ecx, edx;
+
+ if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
+ return 0;
+
+ /* Run AVX2 test only if host has AVX2 support. */
+ if ((ecx & bit_OSXSAVE) == (bit_OSXSAVE))
+ {
+ __cpuid_count (7, 0, eax, ebx, ecx, edx);
+
+ if ((avx_os_support ()) && ((ebx & bit_AVX2) == bit_AVX2))
+ {
+ do_test ();
+#ifdef DEBUG
+ printf ("PASSED\n");
+#endif
+ return 0;
+ }
+#ifdef DEBUG
+ printf ("SKIPPED\n");
+#endif
+ }
+#ifdef DEBUG
+ else
+ printf ("SKIPPED\n");
+#endif
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-1.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-1.c
new file mode 100644
index 00000000000..8adddcfdc46
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherdd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+int *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_i32gather_epi32 (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-2.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-2.c
new file mode 100644
index 00000000000..7d3f3474d86
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherd (int *s1, int *s2, int scale, int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ r[i] = *(int *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_d idx;
+ union128i_d res;
+ int s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1973 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm_i32gather_epi32 (s1, idx.x, 2);
+
+ compute_i32gatherd (s1, idx.a, 2, res_ref);
+
+ if (check_union128i_d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-3.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-3.c
new file mode 100644
index 00000000000..f84c4a56463
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherdd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+int *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_mask_i32gather_epi32 (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-4.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-4.c
new file mode 100644
index 00000000000..2cc3a792ea2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd-4.c
@@ -0,0 +1,50 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherd (int *src, int *s1, int *s2, int *mask, int scale, int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ if ((mask[i] >> 31) & 1)
+ r[i] = *(int *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_d idx;
+ union128i_d res, src, mask;
+ int s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1973 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ ((int *) mask.a)[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm_mask_i32gather_epi32 (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i32gatherd (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union128i_d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-1.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-1.c
new file mode 100644
index 00000000000..a4bbb1d3878
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherdd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+int *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_i32gather_epi32 (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-2.c
new file mode 100644
index 00000000000..e5bcbee1fcf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherd256 (int *s1, int *s2, int scale, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; ++i)
+ r[i] = *(int *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_d idx;
+ union256i_d res;
+ int s1[8], res_ref[8] = { 0 };
+
+ for (i = 0; i < 8; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1973 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (32 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm256_i32gather_epi32 (s1, idx.x, 2);
+
+ compute_i32gatherd256 (s1, idx.a, 2, res_ref);
+
+ if (check_union256i_d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-3.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-3.c
new file mode 100644
index 00000000000..36df1f80cc1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherdd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m256i x;
+int *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mask_i32gather_epi32 (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-4.c
new file mode 100644
index 00000000000..a80530912d0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherd256-4.c
@@ -0,0 +1,51 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherd256 (int *src,
+ int *s1, int *s2, int *mask, int scale, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; ++i)
+ if ((mask[i] >> 31) & 1)
+ r[i] = *(int *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_d idx;
+ union256i_d res, src, mask;
+ int s1[8], res_ref[8] = { 0 };
+
+ for (i = 0; i < 8; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1973 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ mask.a[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (32 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm256_mask_i32gather_epi32 (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i32gatherd256 (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union256i_d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-1.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-1.c
new file mode 100644
index 00000000000..e9a3a0ecedd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherdpd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128d x;
+double *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_i32gather_pd (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-2.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-2.c
new file mode 100644
index 00000000000..475f623ec88
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherpd (double *s1, int *s2, int scale, double *r)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i)
+ r[i] = *(double *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_d idx;
+ union128d res;
+ double s1[2], res_ref[2] = { 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm_i32gather_pd (s1, idx.x, 2);
+
+ compute_i32gatherpd (s1, idx.a, 2, res_ref);
+
+ if (check_union128d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-3.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-3.c
new file mode 100644
index 00000000000..08d0de29b96
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherdpd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128d x;
+double *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_mask_i32gather_pd (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-4.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-4.c
new file mode 100644
index 00000000000..12c533f9d32
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd-4.c
@@ -0,0 +1,51 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherpd (double *src,
+ double *s1, int *s2, double *mask, int scale, double *r)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i)
+ if ((((long long *) mask)[i] >> 63) & 1)
+ r[i] = *(double *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_d idx;
+ union128d res, src, mask;
+ double s1[2], res_ref[2] = { 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ ((long long *) mask.a)[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm_mask_i32gather_pd (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i32gatherpd (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union128d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-1.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-1.c
new file mode 100644
index 00000000000..82edc5c5526
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherdpd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m256d x;
+double *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_i32gather_pd (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-2.c
new file mode 100644
index 00000000000..a45801ba94c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherpd256 (double *s1, int *s2, int scale, double *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ r[i] = *(double *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_d idx;
+ union256d res;
+ double s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (32 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm256_i32gather_pd (s1, idx.x, 2);
+
+ compute_i32gatherpd256 (s1, idx.a, 2, res_ref);
+
+ if (check_union256d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-3.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-3.c
new file mode 100644
index 00000000000..bc22fae9f5a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherdpd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m256d x;
+double *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mask_i32gather_pd (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-4.c
new file mode 100644
index 00000000000..f24acbd7fe1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherpd256-4.c
@@ -0,0 +1,52 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherpd256 (double *src,
+ double *s1,
+ int *s2, double *mask, int scale, double *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ if ((((long long *) mask)[i] >> 63) & 1)
+ r[i] = *(double *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_d idx;
+ union256d res, src, mask;
+ double s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ ((long long *) mask.a)[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order, divide by 2
+ to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm256_mask_i32gather_pd (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i32gatherpd256 (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union256d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-1.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-1.c
new file mode 100644
index 00000000000..5559cb198d2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherdps\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128 x;
+float *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_i32gather_ps (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-2.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-2.c
new file mode 100644
index 00000000000..1174ddad516
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherps (float *s1, int *s2, int scale, float *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ r[i] = *(float *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_d idx;
+ union128 res;
+ float s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm_i32gather_ps (s1, idx.x, 2);
+
+ compute_i32gatherps (s1, idx.a, 2, res_ref);
+
+ if (check_union128 (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-3.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-3.c
new file mode 100644
index 00000000000..0423d2c2345
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherdps\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128 x;
+float *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_mask_i32gather_ps (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-4.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-4.c
new file mode 100644
index 00000000000..94b9213d62e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps-4.c
@@ -0,0 +1,51 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherps (float *src,
+ float *s1, int *s2, float *mask, int scale, float *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ if ((((int *) mask)[i] >> 31) & 1)
+ r[i] = *(float *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_d idx;
+ union128 res, src, mask;
+ float s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ ((int *) mask.a)[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm_mask_i32gather_ps (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i32gatherps (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union128 (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-1.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-1.c
new file mode 100644
index 00000000000..ce77a398699
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherdps\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m256 x;
+float *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_i32gather_ps (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-2.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-2.c
new file mode 100644
index 00000000000..654c6f676e3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherps256 (float *s1, int *s2, int scale, float *r)
+{
+ int i;
+
+ for (i = 0; i < 8; ++i)
+ r[i] = *(float *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_d idx;
+ union256 res;
+ float s1[8], res_ref[8] = { 0 };
+
+ for (i = 0; i < 8; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (32 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm256_i32gather_ps (s1, idx.x, 2);
+
+ compute_i32gatherps256 (s1, idx.a, 2, res_ref);
+
+ if (check_union256 (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-3.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-3.c
new file mode 100644
index 00000000000..63879e09f93
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherdps\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m256 x;
+float *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mask_i32gather_ps (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-4.c
new file mode 100644
index 00000000000..07c2abacbf2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherps256-4.c
@@ -0,0 +1,51 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherps256 (float *src,
+ float *s1, int *s2, float *mask, int scale, float *r)
+{
+ int i;
+
+ for (i = 0; i < 8; ++i)
+ if ((((int *) mask)[i] >> 31) & 1)
+ r[i] = *(float *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_d idx;
+ union256 res, src, mask;
+ float s1[8], res_ref[8] = { 0 };
+
+ for (i = 0; i < 8; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ ((int *) mask.a)[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (32 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm256_mask_i32gather_ps (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i32gatherps256 (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union256 (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-1.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-1.c
new file mode 100644
index 00000000000..a31e07c3ada
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherdq\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+long long int *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_i32gather_epi64 (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-2.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-2.c
new file mode 100644
index 00000000000..54838e71024
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherpd (long long *s1, int *s2, int scale, long long *r)
+{
+ long long i;
+
+ for (i = 0; i < 2; ++i)
+ r[i] = *(long long *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ long long i;
+ union128i_d idx;
+ union128i_q res;
+ long long s1[2], res_ref[2] = { 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1983 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm_i32gather_epi64 ((long long int *) s1, idx.x, 2);
+
+ compute_i32gatherpd (s1, idx.a, 2, res_ref);
+
+ if (check_union128i_q (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-3.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-3.c
new file mode 100644
index 00000000000..b3cd6099544
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherdq\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+long long int *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_mask_i32gather_epi64 (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-4.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-4.c
new file mode 100644
index 00000000000..4770d0adaee
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq-4.c
@@ -0,0 +1,53 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherpd (long long *src,
+ long long *s1,
+ int *s2, long long *mask, int scale, long long *r)
+{
+ long long i;
+
+ for (i = 0; i < 2; ++i)
+ if ((mask[i] >> 63) & 1)
+ r[i] = *(long long *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ long long i;
+ union128i_d idx;
+ union128i_q res, src, mask;
+ long long s1[2], res_ref[2] = { 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1983 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ mask.a[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x =
+ _mm_mask_i32gather_epi64 (src.x, (long long int *) s1, idx.x, mask.x, 2);
+
+ compute_i32gatherpd (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union128i_q (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-1.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-1.c
new file mode 100644
index 00000000000..140036f921f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherdq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+long long int *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_i32gather_epi64 (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-2.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-2.c
new file mode 100644
index 00000000000..85e576797fb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherpd256 (long long *s1, int *s2, int scale, long long *r)
+{
+ long long i;
+
+ for (i = 0; i < 4; ++i)
+ r[i] = *(long long *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ long long i;
+ union128i_d idx;
+ union256i_q res;
+ long long s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1983 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (32 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm256_i32gather_epi64 ((long long int *) s1, idx.x, 2);
+
+ compute_i32gatherpd256 (s1, idx.a, 2, res_ref);
+
+ if (check_union256i_q (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-3.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-3.c
new file mode 100644
index 00000000000..345917cc2ea
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherdq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m256i x;
+long long int *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mask_i32gather_epi64 (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-4.c
new file mode 100644
index 00000000000..3eab9be5c96
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i32gatherq256-4.c
@@ -0,0 +1,54 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i32gatherpd256 (long long *src,
+ long long *s1,
+ int *s2, long long *mask, int scale, long long *r)
+{
+ long long i;
+
+ for (i = 0; i < 4; ++i)
+ if ((mask[i] >> 63) & 1)
+ r[i] = *(long long *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ long long i;
+ union128i_d idx;
+ union256i_q res, src, mask;
+ long long s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1983 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ mask.a[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order, divide by 2
+ to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm256_mask_i32gather_epi64 (src.x,
+ (long long int *) s1,
+ idx.x, mask.x, 2);
+
+ compute_i32gatherpd256 (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union256i_q (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-1.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-1.c
new file mode 100644
index 00000000000..333a7f84881
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherqd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+int *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_i64gather_epi32 (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-2.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-2.c
new file mode 100644
index 00000000000..f475a4a7340
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherps (int *s1, long long *s2, int scale, int *r)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i)
+ r[i] = *(int *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_q idx;
+ union128i_d res;
+ int s1[2], res_ref[4] = { 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1973 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (8 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm_i64gather_epi32 (s1, idx.x, 2);
+
+ compute_i64gatherps (s1, idx.a, 2, res_ref);
+
+ if (check_union128i_d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-3.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-3.c
new file mode 100644
index 00000000000..2c04422331f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherqd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+int *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_mask_i64gather_epi32 (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-4.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-4.c
new file mode 100644
index 00000000000..77c8747f071
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd-4.c
@@ -0,0 +1,51 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherps (int *src,
+ int *s1, long long *s2, int *mask, int scale, int *r)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i)
+ if ((mask[i] >> 31) & 1)
+ r[i] = *(int *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_q idx;
+ union128i_d res, src, mask;
+ int s1[2], res_ref[4] = { 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1973 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ mask.a[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (8 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm_mask_i64gather_epi32 (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i64gatherps (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union128i_d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-1.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-1.c
new file mode 100644
index 00000000000..d338d1bcd86
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherqd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+int *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_i64gather_epi32 (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-2.c
new file mode 100644
index 00000000000..0f88b20b2bb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherps256 (int *s1, long long *s2, int scale, int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ r[i] = *(int *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_q idx;
+ union128i_d res;
+ int s1[8], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1973 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm256_i64gather_epi32 (s1, idx.x, 2);
+
+ compute_i64gatherps256 (s1, idx.a, 2, res_ref);
+
+ if (check_union128i_d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-3.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-3.c
new file mode 100644
index 00000000000..50fbbf2eb74
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherqd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+int *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mask_i64gather_epi32 (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-4.c
new file mode 100644
index 00000000000..6c4bdd60ab1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherd256-4.c
@@ -0,0 +1,51 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherps256 (int *src,
+ int *s1, long long *s2, int *mask, int scale, int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ if ((mask[i] >> 31) & 1)
+ r[i] = *(int *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_q idx;
+ union128i_d res, src, mask;
+ int s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1973 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ mask.a[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm256_mask_i64gather_epi32 (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i64gatherps256 (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union128i_d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-1.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-1.c
new file mode 100644
index 00000000000..a8cc464f42d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherqpd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128d x;
+double *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_i64gather_pd (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-2.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-2.c
new file mode 100644
index 00000000000..5a119712e81
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-2.c
@@ -0,0 +1,40 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherpd (double *s1, long long *s2, int scale, double *r)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i)
+ r[i] = *(double *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_q idx;
+ union128d res;
+ double s1[2], res_ref[2] = { 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order, divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm_i64gather_pd (s1, idx.x, 2);
+
+ compute_i64gatherpd (s1, idx.a, 2, res_ref);
+
+ if (check_union128d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-3.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-3.c
new file mode 100644
index 00000000000..8cf10f3e7e7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherqpd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128d x;
+double *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_mask_i64gather_pd (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-4.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-4.c
new file mode 100644
index 00000000000..61cb1f8d0cf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd-4.c
@@ -0,0 +1,52 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherpd (double *src,
+ double *s1,
+ long long int *s2, double *mask, int scale, double *r)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i)
+ if ((((long long *) mask)[i] >> 63) & 1)
+ r[i] = *(double *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_q idx;
+ union128d res, src, mask;
+ double s1[2], res_ref[2] = { 0, 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ ((long long *) mask.a)[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm_mask_i64gather_pd (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i64gatherpd (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union128d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-1.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-1.c
new file mode 100644
index 00000000000..39e2370b2ff
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherqpd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m256d x;
+double *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_i64gather_pd (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-2.c
new file mode 100644
index 00000000000..99e192d7548
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherpd256 (double *s1, long long int *s2, int scale, double *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ r[i] = *(double *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_q idx;
+ union256d res;
+ double s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (32 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm256_i64gather_pd (s1, idx.x, 2);
+
+ compute_i64gatherpd256 (s1, idx.a, 2, res_ref);
+
+ if (check_union256d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-3.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-3.c
new file mode 100644
index 00000000000..83b31544c7b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherqpd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m256d x;
+double *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mask_i64gather_pd (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-4.c
new file mode 100644
index 00000000000..09a5f8a14e0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherpd256-4.c
@@ -0,0 +1,52 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherpd256 (double *src,
+ double *s1,
+ long long int *s2, double *mask, int scale, double *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ if ((((long long *) mask)[i] >> 63) & 1)
+ r[i] = *(double *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_q idx;
+ union256d res, src, mask;
+ double s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ ((long long *) mask.a)[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm256_mask_i64gather_pd (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i64gatherpd256 (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union256d (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-1.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-1.c
new file mode 100644
index 00000000000..2dccde6462d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherqps\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128 x;
+float *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_i64gather_ps (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-2.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-2.c
new file mode 100644
index 00000000000..527e4e81243
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherps (float *s1, long long *s2, int scale, float *r)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i)
+ r[i] = *(float *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_q idx;
+ union128 res;
+ float s1[2], res_ref[4] = { 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (8 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm_i64gather_ps (s1, idx.x, 2);
+
+ compute_i64gatherps (s1, idx.a, 2, res_ref);
+
+ if (check_union128 (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-3.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-3.c
new file mode 100644
index 00000000000..f69cc2636bf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherqps\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128 x;
+float *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_mask_i64gather_ps (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-4.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-4.c
new file mode 100644
index 00000000000..ada4e49ff44
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps-4.c
@@ -0,0 +1,52 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherps (float *src,
+ float *s1,
+ long long *s2, float *mask, int scale, float *r)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i)
+ if ((((int *) mask)[i] >> 31) & 1)
+ r[i] = *(float *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union128i_q idx;
+ union128 res, src, mask;
+ float s1[2], res_ref[4] = { 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ ((int *) mask.a)[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (8 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm_mask_i64gather_ps (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i64gatherps (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union128 (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-1.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-1.c
new file mode 100644
index 00000000000..59dd47d9113
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherqps\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128 x;
+float *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_i64gather_ps (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-2.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-2.c
new file mode 100644
index 00000000000..d2fe7c1fb54
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherps256 (float *s1, long long *s2, int scale, float *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ r[i] = *(float *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_q idx;
+ union128 res;
+ float s1[8], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm256_i64gather_ps (s1, idx.x, 2);
+
+ compute_i64gatherps256 (s1, idx.a, 2, res_ref);
+
+ if (check_union128 (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-3.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-3.c
new file mode 100644
index 00000000000..4ccc10a2b95
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vgatherqps\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128 x;
+float *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mask_i64gather_ps (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-4.c
new file mode 100644
index 00000000000..8185cd839c9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherps256-4.c
@@ -0,0 +1,52 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherps256 (float *src,
+ float *s1,
+ long long *s2, float *mask, int scale, float *r)
+{
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ if ((((int *) mask)[i] >> 31) & 1)
+ r[i] = *(float *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_q idx;
+ union128 res, src, mask;
+ float s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 2.718281828459045 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ ((int *) mask.a)[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 4) >> 1;
+ }
+
+ res.x = _mm256_mask_i64gather_ps (src.x, s1, idx.x, mask.x, 2);
+
+ compute_i64gatherps256 (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union128 (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-1.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-1.c
new file mode 100644
index 00000000000..7db1d924cf8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherqq\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+long long int *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_i64gather_epi64 (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-2.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-2.c
new file mode 100644
index 00000000000..a2d7a99686f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherpd (long long *s1, long long *s2, int scale, long long *r)
+{
+ long long i;
+
+ for (i = 0; i < 2; ++i)
+ r[i] = *(long long *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ long long i;
+ union128i_q idx;
+ union128i_q res;
+ long long s1[2], res_ref[2] = { 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1983 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm_i64gather_epi64 ((long long int *) s1, idx.x, 2);
+
+ compute_i64gatherpd (s1, idx.a, 2, res_ref);
+
+ if (check_union128i_q (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-3.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-3.c
new file mode 100644
index 00000000000..16e4fb8ce0e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherqq\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+long long int *base;
+__m128i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_mask_i64gather_epi64 (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-4.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-4.c
new file mode 100644
index 00000000000..cbc8e31f1ab
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq-4.c
@@ -0,0 +1,53 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherpd (long long *src,
+ long long *s1,
+ long long *s2, long long *mask, int scale, long long *r)
+{
+ long long i;
+
+ for (i = 0; i < 2; ++i)
+ if ((mask[i] >> 63) & 1)
+ r[i] = *(long long *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ long long i;
+ union128i_q idx;
+ union128i_q res, src, mask;
+ long long s1[2], res_ref[2] = { 0, 0 };
+
+ for (i = 0; i < 2; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1983 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ mask.a[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x =
+ _mm_mask_i64gather_epi64 (src.x, (long long int *) s1, idx.x, mask.x, 2);
+
+ compute_i64gatherpd (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union128i_q (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-1.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-1.c
new file mode 100644
index 00000000000..a9b09210070
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherqq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+long long int *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_i64gather_epi64 (base, idx, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-2.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-2.c
new file mode 100644
index 00000000000..3ac3e2e013f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherq256 (long long *s1, long long *s2, int scale, long long *r)
+{
+ long long i;
+
+ for (i = 0; i < 4; ++i)
+ r[i] = *(long long *) (((unsigned char *) s1) + s2[i] * scale);
+}
+
+void static
+avx2_test (void)
+{
+ long long i;
+ union256i_q idx;
+ union256i_q res;
+ long long s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1983 * (i + 1) * (i + 2);
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (32 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm256_i64gather_epi64 ((long long int *) s1, idx.x, 2);
+
+ compute_i64gatherq256 (s1, idx.a, 2, res_ref);
+
+ if (check_union256i_q (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-3.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-3.c
new file mode 100644
index 00000000000..fd96648fab1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-3.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpgatherqq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m256i x;
+long long int *base;
+__m256i idx;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mask_i64gather_epi64 (x, base, idx, x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-4.c b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-4.c
new file mode 100644
index 00000000000..355c8c2b062
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-i64gatherq256-4.c
@@ -0,0 +1,55 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_i64gatherq256 (long long *src,
+ long long *s1,
+ long long *s2,
+ long long *mask, int scale, long long *r)
+{
+ long long i;
+
+ for (i = 0; i < 4; ++i)
+ if ((mask[i] >> 63) & 1)
+ r[i] = *(long long *) (((unsigned char *) s1) + s2[i] * scale);
+ else
+ r[i] = src[i];
+}
+
+void static
+avx2_test (void)
+{
+ long long i;
+ union256i_q idx;
+ union256i_q res, src, mask;
+ long long s1[4], res_ref[4] = { 0 };
+
+ for (i = 0; i < 4; ++i)
+ {
+ /* Set some stuff */
+ s1[i] = 1983 * (i + 1) * (i + 2);
+
+ /* Set src as something different from s1 */
+ src.a[i] = -s1[i];
+
+ /* Mask out evens */
+ ((long long *) mask.a)[i] = i % 2 ? 0 : -1;
+
+ /* About to gather in reverse order,
+ divide by 2 to demonstrate scale */
+ idx.a[i] = (16 - (i + 1) * 8) >> 1;
+ }
+
+ res.x = _mm256_mask_i64gather_epi64 (src.x,
+ (long long int *) s1,
+ idx.x, mask.x, 2);
+
+ compute_i64gatherq256 (src.a, s1, idx.a, mask.a, 2, res_ref);
+
+ if (check_union256i_q (res, res_ref) != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-mpsadbw-1.c b/gcc/testsuite/gcc.target/i386/avx2-mpsadbw-1.c
new file mode 100644
index 00000000000..740e14163a8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-mpsadbw-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx2" } */
+/* { dg-final { scan-assembler "mpsadbw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ /* imm = 13 is arbitrary here */
+ x = _mm256_mpsadbw_epu8 (x, x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-mpsadbw-2.c b/gcc/testsuite/gcc.target/i386/avx2-mpsadbw-2.c
new file mode 100644
index 00000000000..18118e44202
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-mpsadbw-2.c
@@ -0,0 +1,132 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define msk0 0xC0
+#define msk1 0x01
+#define msk2 0xF2
+#define msk3 0x03
+#define msk4 0x84
+#define msk5 0x05
+#define msk6 0xE6
+#define msk7 0x67
+
+
+static void
+compute_mpsadbw (int *i1, int *i2, int mask, int *r)
+{
+ unsigned char s[4];
+ int i, j;
+ int offs1, offs2;
+ unsigned char *v1 = (char *) i1;
+ unsigned char *v2 = (char *) i2;
+ unsigned short *ret = (unsigned short *) r;
+
+ memset (ret, 0, 32);
+
+ /* Lower part */
+ offs2 = 4 * (mask & 3);
+ for (i = 0; i < 4; i++)
+ s[i] = v2[offs2 + i];
+
+ offs1 = 4 * ((mask & 4) >> 2);
+ for (j = 0; j < 8; j++)
+ for (i = 0; i < 4; i++)
+ ret[j] += abs (v1[offs1 + j + i] - s[i]);
+
+ /* Higher part */
+ offs2 = 4 * ((mask >> 3) & 3) + 16;
+ for (i = 0; i < 4; i++)
+ s[i] = v2[offs2 + i];
+
+ offs1 = 4 * ((mask & 0x20) >> 5) + 16;
+ for (j = 0; j < 8; j++)
+ for (i = 0; i < 4; i++)
+ ret[j + 8] += abs (v1[offs1 + j + i] - s[i]);
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d val1, val2, val3[8], res[8];
+ int tmp[8];
+ unsigned char masks[8];
+ int i, j;
+
+ val1.a[0] = 0x35251505;
+ val1.a[1] = 0x75655545;
+ val1.a[2] = 0xB5A59585;
+ val1.a[3] = 0xF5E5D5C5;
+
+ val1.a[4] = 0x35251505;
+ val1.a[5] = 0x75655545;
+ val1.a[6] = 0xB5A59585;
+ val1.a[7] = 0xF5E5D5C5;
+
+ val2.a[0] = 0x31211101;
+ val2.a[1] = 0x71615141;
+ val2.a[2] = 0xB1A19181;
+ val2.a[3] = 0xF1E1D1C1;
+
+ val2.a[4] = 0x31211101;
+ val2.a[5] = 0x71615141;
+ val2.a[6] = 0xB1A19181;
+ val2.a[7] = 0xF1E1D1C1;
+
+ for (i = 0; i < 8; i++)
+ switch (i % 3)
+ {
+ case 1:
+ val3[i].a[0] = 0xF1E1D1C1;
+ val3[i].a[1] = 0xB1A19181;
+ val3[i].a[2] = 0x71615141;
+ val3[i].a[3] = 0x31211101;
+ break;
+ default:
+ val3[i].x = val2.x;
+ break;
+ }
+
+ /* Check mpsadbw imm8, ymm, ymm. */
+ res[0].x = _mm256_mpsadbw_epu8 (val1.x, val2.x, msk0);
+ res[1].x = _mm256_mpsadbw_epu8 (val1.x, val2.x, msk1);
+ res[2].x = _mm256_mpsadbw_epu8 (val1.x, val2.x, msk2);
+ res[3].x = _mm256_mpsadbw_epu8 (val1.x, val2.x, msk3);
+ res[4].x = _mm256_mpsadbw_epu8 (val1.x, val2.x, msk4);
+ res[5].x = _mm256_mpsadbw_epu8 (val1.x, val2.x, msk5);
+ res[6].x = _mm256_mpsadbw_epu8 (val1.x, val2.x, msk6);
+ res[7].x = _mm256_mpsadbw_epu8 (val1.x, val2.x, msk7);
+
+ masks[0] = msk0;
+ masks[1] = msk1;
+ masks[2] = msk2;
+ masks[3] = msk3;
+ masks[4] = msk4;
+ masks[5] = msk5;
+ masks[6] = msk6;
+ masks[7] = msk7;
+
+ for (i = 0; i < 8; i++)
+ {
+ compute_mpsadbw (val1.a, val2.a, masks[i], tmp);
+ if (check_union256i_d (res[i], tmp))
+ abort ();
+ }
+
+ /* Check mpsadbw imm8, m256, ymm. */
+ for (i = 0; i < 8; i++)
+ {
+ res[i].x = _mm256_mpsadbw_epu8 (val1.x, val3[i].x, msk4);
+ masks[i] = msk4;
+ }
+
+ for (i = 0; i < 8; i++)
+ {
+ compute_mpsadbw (val1.a, val3[i].a, masks[i], tmp);
+ if (check_union256i_d (res[i], tmp))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsd_pd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsd_pd-1.c
new file mode 100644
index 00000000000..80964e39d26
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsd_pd-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vbroadcastsd\[ \\t\]+\[^\n\]*" } } */
+
+#include <immintrin.h>
+
+__m128d x;
+__m256d y;
+
+void extern
+avx2_test (void)
+{
+ y = _mm256_broadcastsd_pd (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsd_pd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsd_pd-2.c
new file mode 100644
index 00000000000..ee323f5af37
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsd_pd-2.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union128d s1;
+ union256d res;
+ double res_ref[4];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ s1.a[0] = i * 3.14;
+
+ res.x = _mm256_broadcastsd_pd (s1.x);
+
+ for (j = 0; j < 4; j++)
+ memcpy (res_ref + j, s1.a, 8);
+
+ fail += check_union256d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsi128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsi128-1.c
new file mode 100644
index 00000000000..c0592d50867
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsi128-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vbroadcasti128\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m128i y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_broadcastsi128_si256 (y);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsi128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsi128-2.c
new file mode 100644
index 00000000000..6d3af38ff24
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastsi128-2.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union128i_q s1;
+ union256i_q res;
+ long long int res_ref[4];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 2; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm_broadcastsi128_si256 (s1.x);
+
+ memcpy (res_ref, s1.a, 16);
+ memcpy (res_ref + 2, s1.a, 16);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps-1.c b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps-1.c
new file mode 100644
index 00000000000..d9d47e2a9ae
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vbroadcastss\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128 x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_broadcastss_ps (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps-2.c b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps-2.c
new file mode 100644
index 00000000000..1637e703bc7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union128 s1, res;
+ float res_ref[4];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ s1.a[0] = i * 3.14;
+
+ res.x = _mm_broadcastss_ps (s1.x);
+
+ for (j = 0; j < 4; j++)
+ memcpy (res_ref + j, s1.a, 4);
+
+ fail += check_union128 (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps256-1.c
new file mode 100644
index 00000000000..dfac3916b08
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps256-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vbroadcastss\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128 x;
+__m256 y;
+
+void extern
+avx2_test (void)
+{
+ y = _mm256_broadcastss_ps (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps256-2.c
new file mode 100644
index 00000000000..9f90e2e8527
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vbroadcastss_ps256-2.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union128 s1;
+ union256 res;
+ float res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ s1.a[0] = i * 3.14;
+
+ res.x = _mm256_broadcastss_ps (s1.x);
+
+ for (j = 0; j < 8; j++)
+ memcpy (res_ref + j, s1.a, 4);
+
+ fail += check_union256 (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vextracti128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vextracti128-1.c
new file mode 100644
index 00000000000..a032e3c9b3c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vextracti128-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vextracti128\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m128i y;
+
+void extern
+avx2_test (void)
+{
+ y = _mm256_extracti128_si256 (x, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vextracti128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vextracti128-2.c
new file mode 100644
index 00000000000..7d3c561a14f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vextracti128-2.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_q s1;
+ union128i_q res;
+ long long int res_ref[2];
+ int j;
+
+ for (j = 0; j < 4; j++)
+ s1.a[j] = j * j;
+
+ res.x = _mm256_extracti128_si256 (s1.x, 0);
+
+ memset (res_ref, 0, 16);
+ memcpy (res_ref, s1.a, 16);
+
+ if (check_union128i_q (res, res_ref))
+ abort ();
+
+ res.x = _mm256_extracti128_si256 (s1.x, 1);
+
+ memset (res_ref, 0, 16);
+ memcpy (res_ref, s1.a + 2, 16);
+
+ if (check_union128i_q (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vinserti128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vinserti128-1.c
new file mode 100644
index 00000000000..2d0f7c51afc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vinserti128-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vinserti128\[ \\t\]+\[^\n\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m128i y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_inserti128_si256 (x, y, 1);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vinserti128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vinserti128-2.c
new file mode 100644
index 00000000000..f6361cd4727
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vinserti128-2.c
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_q s1, res;
+ union128i_q s2;
+ long long int res_ref[4];
+ int j;
+
+ for (j = 0; j < 4; j++)
+ s1.a[j] = j * j;
+
+ for (j = 0; j < 2; j++)
+ s2.a[j] = j * j * j;
+
+ res.x = _mm256_inserti128_si256 (s1.x, s2.x, 0);
+
+ memcpy (res_ref, s1.a, 32);
+ memcpy (res_ref, s2.a, 16);
+
+ if (check_union256i_q (res, res_ref))
+ abort ();
+
+ res.x = _mm256_inserti128_si256 (s1.x, s2.x, 1);
+
+ memcpy (res_ref, s1.a, 32);
+ memcpy (res_ref + 2, s2.a, 16);
+
+ if (check_union256i_q (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vmovmskb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vmovmskb-2.c
new file mode 100644
index 00000000000..6637d0c8001
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vmovmskb-2.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vmovmskb" } } */
+
+#include "avx2-check.h"
+
+static void
+avx2_test (void)
+{
+ union256i_b s;
+ int res, res_ref;
+ int i, e = 0;
+
+ 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);
+
+ res = _mm256_movemask_epi8 (s.x);
+
+ for (i = 0; i < 32; i++)
+ if (s.a[i] & (1 << 7))
+ res_ref = res_ref | (1 << i);
+
+ if (res != res_ref)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vmovntdqa-1.c b/gcc/testsuite/gcc.target/i386/avx2-vmovntdqa-1.c
new file mode 100644
index 00000000000..4c44f082d65
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vmovntdqa-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vmovntdqa\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m256i *y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_stream_load_si256 (y);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vmovntdqa-2.c b/gcc/testsuite/gcc.target/i386/avx2-vmovntdqa-2.c
new file mode 100644
index 00000000000..f1eda70bd73
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vmovntdqa-2.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_q s1, res;
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm256_stream_load_si256 (&s1.x);
+
+ fail += check_union256i_q (res, s1.a);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpabsb256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpabsb256-1.c
new file mode 100644
index 00000000000..0607a886cc5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpabsb256-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpabsb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_abs_epi8 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpabsb256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpabsb256-2.c
new file mode 100644
index 00000000000..05db8a40723
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpabsb256-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "ssse3-vals.h"
+#include "avx2-check.h"
+
+/* Routine to manually compute the results */
+static void
+compute_pabs256 (int *i1, char *r)
+{
+ char *b1 = (char *) i1;
+ int i;
+
+ for (i = 0; i < 32; i++)
+ if (b1[i] < 0)
+ r[i] = -b1[i];
+ else
+ r[i] = b1[i];
+}
+
+static void
+avx2_test (void)
+{
+ int i;
+ char ck[32];
+ int fail = 0;
+
+ union256i_b s, d;
+
+ for (i = 0; i < 256; ++i)
+ {
+ /* Recompute the results for 256-bits */
+ compute_pabs256 (&vals[i], ck);
+
+ s.x = _mm256_loadu_si256 ((__m256i *) & vals[i]);
+
+ /* Run the 256-bit tests */
+ d.x = _mm256_abs_epi8 (s.x);
+
+ fail += check_union256i_b (d, ck);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpabsd256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpabsd256-1.c
new file mode 100644
index 00000000000..396077ff128
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpabsd256-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpabsd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_abs_epi32 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpabsd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpabsd256-2.c
new file mode 100644
index 00000000000..4c88024b58a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpabsd256-2.c
@@ -0,0 +1,45 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "ssse3-vals.h"
+#include "avx2-check.h"
+
+/* Routine to manually compute the results */
+static void
+compute_pabs256 (int *i1, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ if (i1[i] < 0)
+ r[i] = -i1[i];
+ else
+ r[i] = i1[i];
+}
+
+static void
+avx2_test (void)
+{
+ int i;
+ int ck[8];
+ int fail = 0;
+
+ union256i_d s, d;
+
+ for (i = 0; i < 256; ++i)
+ {
+ /* Recompute the results for 256-bits */
+ compute_pabs256 (&vals[i], ck);
+
+ s.x = _mm256_loadu_si256 ((__m256i *) & vals[i]);
+
+ /* Run the 256-bit tests */
+ d.x = _mm256_abs_epi32 (s.x);
+
+ fail += check_union256i_d (d, ck);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpabsw256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpabsw256-1.c
new file mode 100644
index 00000000000..2dc7692ce10
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpabsw256-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpabsw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_abs_epi16 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpabsw256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpabsw256-2.c
new file mode 100644
index 00000000000..fa4efd2984b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpabsw256-2.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "ssse3-vals.h"
+#include "avx2-check.h"
+
+/* Routine to manually compute the results */
+static void
+compute_pabs256 (int *i1, short *r)
+{
+ short *b1 = (short *) i1;
+ int i;
+
+ for (i = 0; i < 16; i++)
+ if (b1[i] < 0)
+ r[i] = -b1[i];
+ else
+ r[i] = b1[i];
+}
+
+static void
+avx2_test (void)
+{
+ int i;
+ short ck[16];
+ int fail = 0;
+
+ union256i_w s, d;
+
+ for (i = 0; i < 256; ++i)
+ {
+ /* Using only first 2 bytes of int */
+ /* Recompute the results for 256-bits */
+ compute_pabs256 (&vals[i], ck);
+
+ s.x = _mm256_loadu_si256 ((__m256i *) & vals[i]);
+
+ /* Run the 256-bit tests */
+ d.x = _mm256_abs_epi16 (s.x);
+
+ fail += check_union256i_w (d, ck);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpackssdw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpackssdw-1.c
new file mode 100644
index 00000000000..6d5667a6447
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpackssdw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpackssdw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_packs_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpackssdw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpackssdw-2.c
new file mode 100644
index 00000000000..16f0d23f615
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpackssdw-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static short
+int_to_short (int iVal)
+{
+ short sVal;
+
+ if (iVal < -32768)
+ sVal = -32768;
+ else if (iVal > 32767)
+ sVal = 32767;
+ else
+ sVal = iVal;
+
+ return sVal;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, s2;
+ union256i_w u;
+ short e[16];
+ int i;
+
+ s1.x = _mm256_set_epi32 (1, 2, 3, 4, 65000, 20, 30, 90);
+
+ s2.x = _mm256_set_epi32 (88, 44, 33, 22, 11, 98, 76, -65000);
+
+ u.x = _mm256_packs_epi32 (s1.x, s2.x);
+
+ for (i = 0; i < 4; i++)
+ {
+ e[i] = int_to_short (s1.a[i]);
+ e[i + 4] = int_to_short (s2.a[i]);
+ e[i + 8] = int_to_short (s1.a[i + 4]);
+ e[i + 12] = int_to_short (s2.a[i + 4]);
+ }
+
+ if (check_union256i_w (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpacksswb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpacksswb-1.c
new file mode 100644
index 00000000000..00faf844ad7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpacksswb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpacksswb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_packs_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpacksswb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpacksswb-2.c
new file mode 100644
index 00000000000..8b2a1c11184
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpacksswb-2.c
@@ -0,0 +1,48 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static char
+short_to_byte (short iVal)
+{
+ char sVal;
+
+ if (iVal < -128)
+ sVal = -128;
+ else if (iVal > 127)
+ sVal = 127;
+ else
+ sVal = iVal;
+
+ return sVal;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, s2;
+ union256i_b u;
+ char e[32];
+ int i;
+
+ s1.x = _mm256_set_epi16 (1, 2, 3, 4, 6500, 20, 30, 90,
+ 88, 44, 33, 22, 11, 98, 78, -1000);
+
+ s2.x = _mm256_set_epi16 (88, 44, 33, 22, 11, 98, 76, -650,
+ 1, 2, 3, 4, 6500, 20, 30, 90);
+
+ u.x = _mm256_packs_epi16 (s1.x, s2.x);
+
+ for (i = 0; i < 8; i++)
+ {
+ e[i] = short_to_byte (s1.a[i]);
+ e[i + 8] = short_to_byte (s2.a[i]);
+ e[i + 16] = short_to_byte (s1.a[i + 8]);
+ e[i + 24] = short_to_byte (s2.a[i + 8]);
+ }
+
+ if (check_union256i_b (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpackusdw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpackusdw-1.c
new file mode 100644
index 00000000000..1f0a7ff9de4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpackusdw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpackusdw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_packus_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpackusdw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpackusdw-2.c
new file mode 100644
index 00000000000..afc102610f3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpackusdw-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static unsigned short
+int_to_ushort (int iVal)
+{
+ unsigned short sVal;
+
+ if (iVal < 0)
+ sVal = 0;
+ else if (iVal > 65536)
+ sVal = 65535;
+ else
+ sVal = iVal;
+
+ return sVal;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, s2;
+ union256i_w u;
+ unsigned short e[16];
+ int i;
+
+ s1.x = _mm256_set_epi32 (1, 2, 3, 4, -65000, 20, 30, 90);
+
+ s2.x = _mm256_set_epi32 (88, 44, 33, 22, 11, 98, 76, 120000);
+
+ u.x = _mm256_packus_epi32 (s1.x, s2.x);
+
+ for (i = 0; i < 4; i++)
+ {
+ e[i] = int_to_ushort (s1.a[i]);
+ e[i + 4] = int_to_ushort (s2.a[i]);
+ e[i + 8] = int_to_ushort (s1.a[i + 4]);
+ e[i + 12] = int_to_ushort (s2.a[i + 4]);
+ }
+
+ if (check_union256i_w (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpackuswb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpackuswb-1.c
new file mode 100644
index 00000000000..7b30a66667b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpackuswb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpackuswb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_packus_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpackuswb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpackuswb-2.c
new file mode 100644
index 00000000000..abeee3e6d0a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpackuswb-2.c
@@ -0,0 +1,48 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static unsigned char
+short_to_ubyte (short iVal)
+{
+ unsigned char sVal;
+
+ if (iVal < 0)
+ sVal = 0;
+ else if (iVal > 255)
+ sVal = 255;
+ else
+ sVal = iVal;
+
+ return sVal;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, s2;
+ union256i_b u;
+ char e[32];
+ int i;
+
+ s1.x = _mm256_set_epi16 (1, 2, 3, 4, 6500, 20, 30, 90,
+ 88, 44, 33, 22, 11, 98, 78, -1000);
+
+ s2.x = _mm256_set_epi16 (88, 44, 33, 22, 11, 98, 76, -650,
+ 1, 2, 3, 4, 6500, 20, 30, 90);
+
+ u.x = _mm256_packus_epi16 (s1.x, s2.x);
+
+ for (i = 0; i < 8; i++)
+ {
+ e[i] = short_to_ubyte (s1.a[i]);
+ e[i + 8] = short_to_ubyte (s2.a[i]);
+ e[i + 16] = short_to_ubyte (s1.a[i + 8]);
+ e[i + 24] = short_to_ubyte (s2.a[i + 8]);
+ }
+
+ if (check_union256i_b (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddb-1.c
new file mode 100644
index 00000000000..b6ceef16f87
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpaddb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_add_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddb-2.c
new file mode 100644
index 00000000000..8abeb50c02d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddb-2.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_b u, s1, s2;
+ char e[32];
+ unsigned i;
+
+ s1.x = _mm256_set_epi8 (10, 74, 50, 4, 6, 99, 1, 4, 87, 83, 84,
+ 29, 81, 79, 1, 3, 1, 5, 2, 47, 20, 2, 72,
+ 92, 9, 4, 23, 17, 99, 43, 72, 17);
+
+ s2.x = _mm256_set_epi8 (88, 44, 33, 20, 56, 99, 2, 90, 38, 4, 200,
+ 17, 3, 39, 2, 37, 27, 95, 17, 74, 72, 43,
+ 27, 112, 71, 50, 32, 72, 84, 17, 27, 96);
+
+ u.x = _mm256_add_epi8 (s1.x, s2.x);
+
+ for (i = 0; i < 32; i++)
+ e[i] = s1.a[i] + s2.a[i];
+
+ if (check_union256i_b (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddd-1.c
new file mode 100644
index 00000000000..14142ec0ab5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpaddd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_add_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddd-2.c
new file mode 100644
index 00000000000..c3b1961965c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddd-2.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_d u, s1, s2;
+ int e[8];
+ unsigned i;
+
+ s1.x = _mm256_set_epi32 (100, 74, 50000, 4, 6999, 39999, 1000, 4);
+ s2.x = _mm256_set_epi32 (88, 44, 33, 220, 4556, 2999, 2, 9000000);
+
+ u.x = _mm256_add_epi32 (s1.x, s2.x);
+
+ for (i = 0; i < 8; i++)
+ e[i] = s1.a[i] + s2.a[i];
+
+ if (check_union256i_d (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddq-1.c
new file mode 100644
index 00000000000..9fcf9aaad06
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpaddq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_add_epi64 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddq-2.c
new file mode 100644
index 00000000000..03b011f3f55
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddq-2.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_q u, s1, s2;
+ long long e[4];
+ unsigned i;
+
+ s1.x = _mm256_set_epi64x (100, 74, 50000, 4);
+ s2.x = _mm256_set_epi64x (88, 44, 33, 220);
+
+ u.x = _mm256_add_epi64 (s1.x, s2.x);
+
+ for (i = 0; i < 4; i++)
+ e[i] = s1.a[i] + s2.a[i];
+
+ if (check_union256i_q (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddsb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddsb-1.c
new file mode 100644
index 00000000000..77978d93623
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddsb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpaddsb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_adds_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddsb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddsb-2.c
new file mode 100644
index 00000000000..d07a6a7814e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddsb-2.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_b u, s1, s2;
+ char e[32];
+ int i, tmp;
+
+ s1.x = _mm256_set_epi8 (1, 2, 3, 4, 10, 20, 30, 90, -80, -40, -100,
+ -15, 98, 25, 98, 7, 88, 44, 33, 22, 11, 98,
+ 76, -100, -34, -78, -39, 6, 3, 4, 5, 119);
+
+ s2.x = _mm256_set_epi8 (88, 44, 33, 22, 11, 98, 76, -100, -34, -78,
+ -39, 6, 3, 4, 5, 119, 1, 2, 3, 4, 10, 20,
+ 30, 90, -80, -40, -100, -15, 98, 25, 98, 7);
+
+ u.x = _mm256_adds_epi8 (s1.x, s2.x);
+
+ for (i = 0; i < 32; i++)
+ {
+ tmp = s1.a[i] + s2.a[i];
+
+ if (tmp > 127)
+ tmp = 127;
+ if (tmp < -128)
+ tmp = -128;
+
+ e[i] = tmp;
+ }
+
+ if (check_union256i_b (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddsw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddsw-1.c
new file mode 100644
index 00000000000..128f5309f4d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddsw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpaddsw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_adds_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddsw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddsw-2.c
new file mode 100644
index 00000000000..19bbe0a77c4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddsw-2.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_w u, s1, s2;
+ short e[16];
+ int i, tmp;
+
+ s1.x = _mm256_set_epi16 (1, 2, 3, 4, 10, 20, 30, 90, -80,
+ -40, -100, -15, 98, 25, 98, 7);
+
+ s2.x = _mm256_set_epi16 (88, 44, 33, 22, 11, 98, 76, -100,
+ -34, -78, -39, 6, 3, 4, 5, 119);
+
+ u.x = _mm256_adds_epi16 (s1.x, s2.x);
+
+ for (i = 0; i < 16; i++)
+ {
+ tmp = s1.a[i] + s2.a[i];
+
+ if (tmp > 32767)
+ tmp = 32767;
+ if (tmp < -32768)
+ tmp = -32768;
+
+ e[i] = tmp;
+ }
+
+ if (check_union256i_w (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddusb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddusb-1.c
new file mode 100644
index 00000000000..f6cf4019c47
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddusb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpaddusb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_adds_epu8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddusb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddusb-2.c
new file mode 100644
index 00000000000..68ad4f03fe5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddusb-2.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_b u, s1, s2;
+ unsigned char e[32];
+ unsigned i, tmp;
+
+ s1.x = _mm256_set_epi8 (1, 2, 3, 4, 10, 20, 30, 90, 80, 40, 100, 15,
+ 98, 25, 98, 7, 88, 44, 33, 22, 11, 98, 76,
+ 200, 34, 78, 39, 6, 3, 4, 5, 119);
+
+ s2.x = _mm256_set_epi8 (88, 44, 33, 220, 11, 98, 76, 100, 34, 78, 39,
+ 6, 3, 4, 5, 219, 1, 2, 3, 4, 10, 20, 30, 90,
+ 80, 40, 100, 15, 98, 25, 98, 7);
+
+ u.x = _mm256_adds_epu8 (s1.x, s2.x);
+
+ for (i = 0; i < 32; i++)
+ {
+ tmp = (unsigned char) s1.a[i] + (unsigned char) s2.a[i];
+
+ if (tmp > 255)
+ tmp = 255;
+
+ e[i] = tmp;
+ }
+
+ if (check_union256i_b (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddusw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddusw-1.c
new file mode 100644
index 00000000000..a4c1dd9bd23
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddusw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpaddusw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_adds_epu16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddusw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddusw-2.c
new file mode 100644
index 00000000000..937b93c21ac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddusw-2.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_w u, s1, s2;
+ unsigned short e[32];
+ unsigned i, tmp;
+
+ s1.x = _mm256_set_epi16 (1, 2, 3, 4, 10, 20, 30, 90,
+ 65531, 40, 100, 15, 98, 25, 98, 7);
+
+ s2.x = _mm256_set_epi16 (88, 44, 33, 220, 11, 98, 76, 100,
+ 34, 78, 39, 6, 3, 4, 5, 219);
+
+ u.x = _mm256_adds_epu16 (s1.x, s2.x);
+
+ for (i = 0; i < 16; i++)
+ {
+ tmp = (unsigned short) s1.a[i] + (unsigned short) s2.a[i];
+
+ if (tmp > 65535)
+ tmp = 65535;
+
+ e[i] = tmp;
+ }
+
+ if (check_union256i_w (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddw-1.c
new file mode 100644
index 00000000000..052e3a352a6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpaddw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_add_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddw-2.c
new file mode 100644
index 00000000000..f7dbf2053ac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddw-2.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_w u, s1, s2;
+ short e[16];
+ unsigned i;
+
+ s1.x = _mm256_set_epi16 (100, 74, 50000, 4, 6999, 39999, 1000, 4,
+ 874, 2783, 29884, 2904, 2889, 3279, 1, 3);
+ s2.x = _mm256_set_epi16 (88, 44, 33, 220, 4556, 2999, 2, 9000,
+ 238, 194, 274, 17, 3, 5739, 2, 379);
+
+ u.x = _mm256_add_epi16 (s1.x, s2.x);
+
+ for (i = 0; i < 16; i++)
+ e[i] = s1.a[i] + s2.a[i];
+
+ if (check_union256i_w (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpalignr256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpalignr256-1.c
new file mode 100644
index 00000000000..a87a207d4ea
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpalignr256-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx2" } */
+/* { dg-final { scan-assembler "vpalignr\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ /* imm = 13 is arbitrary here */
+ x = _mm256_alignr_epi8 (x, x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpalignr256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpalignr256-2.c
new file mode 100644
index 00000000000..5be64c0cf5d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpalignr256-2.c
@@ -0,0 +1,177 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "ssse3-vals.h"
+#include "avx2-check.h"
+
+/* Test the 256-bit form */
+static void
+avx2_test_palignr256 (__m256i t1, __m256i t2, unsigned int imm, __m256i * r)
+{
+ switch (imm)
+ {
+ case 0:
+ *r = _mm256_alignr_epi8 (t1, t2, 0);
+ break;
+ case 1:
+ *r = _mm256_alignr_epi8 (t1, t2, 1);
+ break;
+ case 2:
+ *r = _mm256_alignr_epi8 (t1, t2, 2);
+ break;
+ case 3:
+ *r = _mm256_alignr_epi8 (t1, t2, 3);
+ break;
+ case 4:
+ *r = _mm256_alignr_epi8 (t1, t2, 4);
+ break;
+ case 5:
+ *r = _mm256_alignr_epi8 (t1, t2, 5);
+ break;
+ case 6:
+ *r = _mm256_alignr_epi8 (t1, t2, 6);
+ break;
+ case 7:
+ *r = _mm256_alignr_epi8 (t1, t2, 7);
+ break;
+ case 8:
+ *r = _mm256_alignr_epi8 (t1, t2, 8);
+ break;
+ case 9:
+ *r = _mm256_alignr_epi8 (t1, t2, 9);
+ break;
+ case 10:
+ *r = _mm256_alignr_epi8 (t1, t2, 10);
+ break;
+ case 11:
+ *r = _mm256_alignr_epi8 (t1, t2, 11);
+ break;
+ case 12:
+ *r = _mm256_alignr_epi8 (t1, t2, 12);
+ break;
+ case 13:
+ *r = _mm256_alignr_epi8 (t1, t2, 13);
+ break;
+ case 14:
+ *r = _mm256_alignr_epi8 (t1, t2, 14);
+ break;
+ case 15:
+ *r = _mm256_alignr_epi8 (t1, t2, 15);
+ break;
+ case 16:
+ *r = _mm256_alignr_epi8 (t1, t2, 16);
+ break;
+ case 17:
+ *r = _mm256_alignr_epi8 (t1, t2, 17);
+ break;
+ case 18:
+ *r = _mm256_alignr_epi8 (t1, t2, 18);
+ break;
+ case 19:
+ *r = _mm256_alignr_epi8 (t1, t2, 19);
+ break;
+ case 20:
+ *r = _mm256_alignr_epi8 (t1, t2, 20);
+ break;
+ case 21:
+ *r = _mm256_alignr_epi8 (t1, t2, 21);
+ break;
+ case 22:
+ *r = _mm256_alignr_epi8 (t1, t2, 22);
+ break;
+ case 23:
+ *r = _mm256_alignr_epi8 (t1, t2, 23);
+ break;
+ case 24:
+ *r = _mm256_alignr_epi8 (t1, t2, 24);
+ break;
+ case 25:
+ *r = _mm256_alignr_epi8 (t1, t2, 25);
+ break;
+ case 26:
+ *r = _mm256_alignr_epi8 (t1, t2, 26);
+ break;
+ case 27:
+ *r = _mm256_alignr_epi8 (t1, t2, 27);
+ break;
+ case 28:
+ *r = _mm256_alignr_epi8 (t1, t2, 28);
+ break;
+ case 29:
+ *r = _mm256_alignr_epi8 (t1, t2, 29);
+ break;
+ case 30:
+ *r = _mm256_alignr_epi8 (t1, t2, 30);
+ break;
+ case 31:
+ *r = _mm256_alignr_epi8 (t1, t2, 31);
+ break;
+ default:
+ *r = _mm256_alignr_epi8 (t1, t2, 32);
+ break;
+ }
+}
+
+/* Routine to manually compute the results */
+static void
+compute_correct_result_256 (int *i1, int *i2, unsigned int imm, int *r)
+{
+ char buf[32];
+ char *bout = (char *) r;
+ int i;
+
+ /* Fill lowers 128 bit of ymm */
+ memcpy (&buf[0], i2, 16);
+ memcpy (&buf[16], i1, 16);
+
+ for (i = 0; i < 16; i++)
+ if (imm >= 32 || imm + i >= 32)
+ bout[i] = 0;
+ else
+ bout[i] = buf[imm + i];
+
+ /* Fill higher 128 bit of ymm */
+ bout += 16;
+ memcpy (&buf[0], i2 + 4, 16);
+ memcpy (&buf[16], i1 + 4, 16);
+
+ for (i = 0; i < 16; i++)
+ if (imm >= 32 || imm + i >= 32)
+ bout[i] = 0;
+ else
+ bout[i] = buf[imm + i];
+}
+
+static void
+avx2_test (void)
+{
+ int i;
+ int ck[8];
+ int r[8];
+ unsigned int imm;
+ int fail = 0;
+
+ union256i_q s1, s2, d;
+
+ for (i = 0; i < 256; i += 16)
+ for (imm = 0; imm < 100; imm++)
+ {
+ /* Recompute the results for 256-bits */
+ compute_correct_result_256 (&vals[i + 0], &vals[i + 8], imm, ck);
+
+ s1.x = _mm256_loadu_si256 ((__m256i *) & vals[i + 0]);
+ s2.x = _mm256_loadu_si256 ((__m256i *) & vals[i + 8]);
+
+ /* Run the 256-bit tests */
+ avx2_test_palignr256 (s1.x, s2.x, imm, &d.x);
+
+ _mm256_storeu_si256 ((__m256i *) r, d.x);
+
+ fail += checkVi (r, ck, 8);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpand-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpand-1.c
new file mode 100644
index 00000000000..e77e36982b4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpand-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpand\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_and_si256 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpand-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpand-2.c
new file mode 100644
index 00000000000..ffd3404e5d5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpand-2.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -mavx2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_q u, s1, s2;
+ int source1[8] = { 34545, 95567, 23443, 5675, 2323, 67, 2345, 45667 };
+ int source2[8] = { 674, 57897, 93459, 45624, 54674, 1237, 67436, 79608 };
+ int d[8];
+ int e[8];
+
+ s1.x = _mm256_loadu_si256 ((__m256i *) source1);
+ s2.x = _mm256_loadu_si256 ((__m256i *) source2);
+ u.x = _mm256_and_si256 (s1.x, s2.x);
+
+ _mm256_storeu_si256 ((__m256i *) d, u.x);
+
+ for (i = 0; i < 8; i++)
+ e[i] = source1[i] & source2[i];
+
+ if (checkVi (d, e, 8))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpandn-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpandn-1.c
new file mode 100644
index 00000000000..b0688988440
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpandn-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpandn\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_andnot_si256 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpandn-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpandn-2.c
new file mode 100644
index 00000000000..06d3cbd239d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpandn-2.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_q u, s1, s2;
+ int source1[8] = { 34545, 95567, 23443, 5675, 2323, 67, 2345, 45667 };
+ int source2[8] = { 674, 57897, 93459, 45624, 54674, 1237, 67436, 79608 };
+ int d[8];
+ int e[8];
+
+ s1.x = _mm256_loadu_si256 ((__m256i *) source1);
+ s2.x = _mm256_loadu_si256 ((__m256i *) source2);
+ u.x = _mm256_andnot_si256 (s1.x, s2.x);
+
+ _mm256_storeu_si256 ((__m256i *) d, u.x);
+
+ for (i = 0; i < 8; i++)
+ e[i] = (~source1[i]) & source2[i];
+
+ if (checkVi (d, e, 8))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpavgb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpavgb-1.c
new file mode 100644
index 00000000000..a7abd6751a8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpavgb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpavgb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_avg_epu8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpavgb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpavgb-2.c
new file mode 100644
index 00000000000..8519e9bc34f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpavgb-2.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_b u, s1, s2;
+ unsigned char e[32];
+ int tmp;
+ int i;
+
+ s1.x = _mm256_set_epi8 (1, 2, 3, 4, 10, 20, 30, 90, -80, -40, -100,
+ -15, 98, 25, 98, 7, 88, 44, 33, 22, 11, 98,
+ 76, -100, -34, -78, -39, 6, 3, 4, 5, 119);
+
+ s2.x = _mm256_set_epi8 (88, 44, 33, 22, 11, 98, 76, -100, -34, -78,
+ -39, 6, 3, 4, 5, 119, 1, 2, 3, 4, 10, 20,
+ 30, 90, -80, -40, -100, -15, 98, 25, 98, 7);
+
+ u.x = _mm256_avg_epu8 (s1.x, s2.x);
+
+ for (i = 0; i < 32; i++)
+ e[i] = ((unsigned char) s1.a[i] + (unsigned char) s2.a[i] + 1) >> 1;
+
+ if (check_union256i_b (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpavgw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpavgw-1.c
new file mode 100644
index 00000000000..dc68b8a6b0d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpavgw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpavgw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_avg_epu16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpavgw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpavgw-2.c
new file mode 100644
index 00000000000..d222a9d4a77
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpavgw-2.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_w u, s1, s2;
+ unsigned short e[32];
+ int i;
+
+ s1.x = _mm256_set_epi16 (1, 2, 3, 4, 10, 20, 30, 90, 80,
+ 40, 100, 15, 98, 25, 98, 7);
+ s2.x = _mm256_set_epi16 (88, 44, 33, 22, 11, 98, 76, 100,
+ 34, 78, 39, 6, 3, 4, 5, 119);
+
+ u.x = _mm256_avg_epu16 (s1.x, s2.x);
+
+ for (i = 0; i < 16; i++)
+ e[i] = (s1.a[i] + s2.a[i] + 1) >> 1;
+
+ if (check_union256i_w (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpblendd128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpblendd128-1.c
new file mode 100644
index 00000000000..92f7e1b8e23
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpblendd128-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpblendd\[ \\t\]+\[^\n\]*" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_blend_epi32 (x, x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpblendd128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpblendd128-2.c
new file mode 100644
index 00000000000..44732cc6f81
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpblendd128-2.c
@@ -0,0 +1,54 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 20
+
+#undef MASK
+#define MASK 0xf1
+
+static void
+init_pblendd128 (int *src1, int *src2, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 4; i++)
+ {
+ src1[i] = (i + seed) * (i + seed) * sign;
+ src2[i] = (i + seed + 20) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_pblendd128 (int *src1, int *src2, unsigned int mask, int *dst)
+{
+ int i;
+
+ memcpy (dst, src1, 16);
+ for (i = 0; i < 4; i++)
+ if (mask & (1 << i))
+ dst[i] = src2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_d src1, src2, dst;
+ int dst_ref[4];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pblendd128 (src1.a, src2.a, i);
+
+ dst.x = _mm_blend_epi32 (src1.x, src2.x, MASK);
+ calc_pblendd128 (src1.a, src2.a, MASK, dst_ref);
+
+ if (check_union128i_d (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpblendd256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpblendd256-1.c
new file mode 100644
index 00000000000..ab749885435
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpblendd256-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpblendd\[ \\t\]+\[^\n\]*" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_blend_epi32 (x, x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpblendd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpblendd256-2.c
new file mode 100644
index 00000000000..fc5e3f7be96
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpblendd256-2.c
@@ -0,0 +1,54 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 20
+
+#undef MASK
+#define MASK 0xf1
+
+static void
+init_pblendd256 (int *src1, int *src2, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 8; i++)
+ {
+ src1[i] = (i + seed) * (i + seed) * sign;
+ src2[i] = (i + seed + 20) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_pblendd256 (int *src1, int *src2, unsigned int mask, int *dst)
+{
+ int i;
+
+ memcpy (dst, src1, 32);
+ for (i = 0; i < 8; i++)
+ if (mask & (1 << i))
+ dst[i] = src2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d src1, src2, dst;
+ int dst_ref[8];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pblendd256 (src1.a, src2.a, i);
+
+ dst.x = _mm256_blend_epi32 (src1.x, src2.x, MASK);
+ calc_pblendd256 (src1.a, src2.a, MASK, dst_ref);
+
+ if (check_union256i_d (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpblendvb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpblendvb-1.c
new file mode 100644
index 00000000000..09ff4bccaec
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpblendvb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpblendvb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_blendv_epi8 (x, x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpblendvb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpblendvb-2.c
new file mode 100644
index 00000000000..c0e1d71ea62
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpblendvb-2.c
@@ -0,0 +1,56 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 20
+
+static void
+init_pblendb (char *src1, char *src2, char *mask, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 32; i++)
+ {
+ src1[i] = (i + seed) * (i + seed) * sign;
+ src2[i] = (i + seed + 20) * sign;
+ sign = -sign;
+
+ if (sign > 0)
+ mask[i] = 1 << 7;
+ else
+ mask[i] = 0;
+ }
+}
+
+static void
+calc_pblendb (char *src1, char *src2, char *mask, char *dst)
+{
+ int i;
+
+ memcpy (dst, src1, 32);
+ for (i = 0; i < 32; i++)
+ if (mask[i] & (1 << 7))
+ dst[i] = src2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_b src1, src2, mask, dst;
+ char dst_ref[32];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pblendb (src1.a, src2.a, mask.a, i);
+
+ dst.x = _mm256_blendv_epi8 (src1.x, src2.x, mask.x);
+ calc_pblendb (src1.a, src2.a, mask.a, dst_ref);
+
+ if (check_union256i_b (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpblendw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpblendw-1.c
new file mode 100644
index 00000000000..7bbb93e4a53
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpblendw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpblendw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_blend_epi16 (x, x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpblendw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpblendw-2.c
new file mode 100644
index 00000000000..0500d351e7c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpblendw-2.c
@@ -0,0 +1,54 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 20
+
+#undef MASK
+#define MASK 0xfe
+
+static void
+init_pblendw (short *src1, short *src2, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 16; i++)
+ {
+ src1[i] = (i + seed) * (i + seed) * sign;
+ src2[i] = (i + seed + 20) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_pblendw (short *src1, short *src2, unsigned int mask, short *dst)
+{
+ int i;
+
+ memcpy (dst, src1, 32);
+ for (i = 0; i < 16; i++)
+ if (mask & (1 << (i % 8)))
+ dst[i] = src2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w src1, src2, dst;
+ short dst_ref[16];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pblendw (src1.a, src2.a, i);
+
+ dst.x = _mm256_blend_epi16 (src1.x, src2.x, MASK);
+ calc_pblendw (src1.a, src2.a, MASK, dst_ref);
+
+ if (check_union256i_w (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb128-1.c
new file mode 100644
index 00000000000..14b9a7c0950
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb128-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpbroadcastb\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_broadcastb_epi8 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb128-2.c
new file mode 100644
index 00000000000..927755b2ae1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb128-2.c
@@ -0,0 +1,48 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+static void
+init_pbroadcastb128 (char *src, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 16; i++)
+ {
+ src[i] = (i + seed) * (i + seed) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_pbroadcastb128 (char *src, char *dst)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ dst[i] = src[0];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_b src, dst;
+ char dst_ref[16];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pbroadcastb128 (src.a, i);
+
+ dst.x = _mm_broadcastb_epi8 (src.x);
+ calc_pbroadcastb128 (src.a, dst_ref);
+
+ if (check_union128i_b (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb256-1.c
new file mode 100644
index 00000000000..8e1247aac4f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb256-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpbroadcastb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i y;
+
+void extern
+avx2_test (void)
+{
+ y = _mm256_broadcastb_epi8 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb256-2.c
new file mode 100644
index 00000000000..9b0e5646973
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb256-2.c
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+static void
+init_pbroadcastb256 (char *src, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 16; i++)
+ {
+ src[i] = (i + seed) * (i + seed) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_pbroadcastb256 (char *src, char *dst)
+{
+ int i;
+
+ for (i = 0; i < 32; i++)
+ dst[i] = src[0];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_b src;
+ union256i_b dst;
+ char dst_ref[32];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pbroadcastb256 (src.a, i);
+
+ dst.x = _mm256_broadcastb_epi8 (src.x);
+ calc_pbroadcastb256 (src.a, dst_ref);
+
+ if (check_union256i_b (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd128-1.c
new file mode 100644
index 00000000000..8a396678e6c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd128-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpbroadcastd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_broadcastd_epi32 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd128-2.c
new file mode 100644
index 00000000000..c9d2b46d21d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd128-2.c
@@ -0,0 +1,48 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+static void
+init_pbroadcastd128 (int *src, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 4; i++)
+ {
+ src[i] = (i + seed) * (i + seed) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_pbroadcastd128 (int *src, int *dst)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ dst[i] = src[0];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_d src, dst;
+ int dst_ref[4];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pbroadcastd128 (src.a, i);
+
+ dst.x = _mm_broadcastd_epi32 (src.x);
+ calc_pbroadcastd128 (src.a, dst_ref);
+
+ if (check_union128i_d (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd256-1.c
new file mode 100644
index 00000000000..57f1bc78e8d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd256-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpbroadcastd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i y;
+
+void extern
+avx2_test (void)
+{
+ y = _mm256_broadcastd_epi32 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd256-2.c
new file mode 100644
index 00000000000..fe009da1a5c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastd256-2.c
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+static void
+init_pbroadcastd256 (int *src, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 4; i++)
+ {
+ src[i] = (i + seed) * (i + seed) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_pbroadcastd256 (int *src, int *dst)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ dst[i] = src[0];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_d src;
+ union256i_d dst;
+ int dst_ref[8];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pbroadcastd256 (src.a, i);
+
+ dst.x = _mm256_broadcastd_epi32 (src.x);
+ calc_pbroadcastd256 (src.a, dst_ref);
+
+ if (check_union256i_d (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq128-1.c
new file mode 100644
index 00000000000..6714ae7ff71
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq128-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpbroadcastq\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_broadcastq_epi64 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq128-2.c
new file mode 100644
index 00000000000..e6446de7da9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq128-2.c
@@ -0,0 +1,48 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+static void
+init_pbroadcastq128 (long long int *src, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 2; i++)
+ {
+ src[i] = (i + seed) * (i + seed) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_pbroadcastq128 (long long int *src, long long int *dst)
+{
+ int i;
+
+ for (i = 0; i < 2; i++)
+ dst[i] = src[0];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_q src, dst;
+ long long int dst_ref[2];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pbroadcastq128 (src.a, i);
+
+ dst.x = _mm_broadcastq_epi64 (src.x);
+ calc_pbroadcastq128 (src.a, dst_ref);
+
+ if (check_union128i_q (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq256-1.c
new file mode 100644
index 00000000000..bf1532b1e8a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq256-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpbroadcastq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i y;
+
+void extern
+avx2_test (void)
+{
+ y = _mm256_broadcastq_epi64 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq256-2.c
new file mode 100644
index 00000000000..47026315655
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastq256-2.c
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+static void
+init_pbroadcastq256 (long long int *src, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 2; i++)
+ {
+ src[i] = (i + seed) * (i + seed) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_pbroadcastq256 (long long int *src, long long int *dst)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ dst[i] = src[0];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_q src;
+ union256i_q dst;
+ long long int dst_ref[4];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pbroadcastq256 (src.a, i);
+
+ dst.x = _mm256_broadcastq_epi64 (src.x);
+ calc_pbroadcastq256 (src.a, dst_ref);
+
+ if (check_union256i_q (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw128-1.c
new file mode 100644
index 00000000000..ff5ee87410d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw128-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpbroadcastw\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_broadcastw_epi16 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw128-2.c
new file mode 100644
index 00000000000..e8673a9dda9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw128-2.c
@@ -0,0 +1,48 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+static void
+init_pbroadcastw128 (short *src, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 8; i++)
+ {
+ src[i] = (i + seed) * (i + seed) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_pbroadcastw128 (short *src, short *dst)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ dst[i] = src[0];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_w src, dst;
+ short dst_ref[8];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pbroadcastw128 (src.a, i);
+
+ dst.x = _mm_broadcastw_epi16 (src.x);
+ calc_pbroadcastw128 (src.a, dst_ref);
+
+ if (check_union128i_w (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw256-1.c
new file mode 100644
index 00000000000..14462a19bc0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw256-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpbroadcastw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i y;
+
+void extern
+avx2_test (void)
+{
+ y = _mm256_broadcastw_epi16 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw256-2.c
new file mode 100644
index 00000000000..bac748fef5a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastw256-2.c
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+static void
+init_pbroadcastw256 (short *src, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 8; i++)
+ {
+ src[i] = (i + seed) * (i + seed) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_pbroadcastw256 (short *src, short *dst)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ dst[i] = src[0];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_w src;
+ union256i_w dst;
+ short dst_ref[16];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_pbroadcastw256 (src.a, i);
+
+ dst.x = _mm256_broadcastw_epi16 (src.x);
+ calc_pbroadcastw256 (src.a, dst_ref);
+
+ if (check_union256i_w (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqb-1.c
new file mode 100644
index 00000000000..063cb575006
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpcmpeqb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_cmpeq_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqb-2.c
new file mode 100644
index 00000000000..87a8fa42c15
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqb-2.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+avx2_test (void)
+{
+ union256i_b u, s1, s2;
+ char e[32];
+ int i;
+
+ s1.x = _mm256_set_epi8 (1, 2, 3, 4, 10, 20, 30, 90, -80, -40, -100,
+ -15, 98, 25, 98, 7, 88, 44, 33, 22, 11, 98,
+ 76, -100, -34, -78, -39, 6, 3, 25, 5, 119);
+
+ s2.x = _mm256_set_epi8 (88, 44, 3, 22, 11, 98, 76, -100, -34, -78,
+ -39, 6, 3, 4, 5, 119, 1, 2, 3, 4, 10, 20,
+ 30, 90, -80, -40, -100, -15, 98, 25, 98, 7);
+
+ u.x = _mm256_cmpeq_epi8 (s1.x, s2.x);
+
+ for (i = 0; i < 32; i++)
+ e[i] = (s1.a[i] == s2.a[i]) ? -1 : 0;
+
+ if (check_union256i_b (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqd-1.c
new file mode 100644
index 00000000000..002b6968609
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpcmpeqd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_cmpeq_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqd-2.c
new file mode 100644
index 00000000000..0cc10458fda
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqd-2.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+avx2_test (void)
+{
+ union256i_d u, s1, s2;
+ int e[8];
+ int i;
+
+ s1.x = _mm256_set_epi32 (1, 2, 3, 4, 10, 20, 30, 90000);
+
+ s2.x = _mm256_set_epi32 (88, 44, 3, 22, 11, 98, 76, -100);
+
+ u.x = _mm256_cmpeq_epi32 (s1.x, s2.x);
+
+ for (i = 0; i < 8; i++)
+ e[i] = (s1.a[i] == s2.a[i]) ? -1 : 0;
+
+ if (check_union256i_d (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqq-1.c
new file mode 100644
index 00000000000..196e3c311ff
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpcmpeqq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_cmpeq_epi64 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqq-2.c
new file mode 100644
index 00000000000..4abe7819867
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqq-2.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+avx2_test (void)
+{
+ union256i_q u, s1, s2;
+ long long int e[4];
+ int i;
+
+ s1.x = _mm256_set_epi64x (1, 2, 3, 4);
+
+ s2.x = _mm256_set_epi64x (88, 44, 3, 220000);
+
+ u.x = _mm256_cmpeq_epi64 (s1.x, s2.x);
+
+ for (i = 0; i < 4; i++)
+ e[i] = (s1.a[i] == s2.a[i]) ? -1 : 0;
+
+ if (check_union256i_q (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqw-1.c
new file mode 100644
index 00000000000..1efa2914315
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpcmpeqw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_cmpeq_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqw-2.c
new file mode 100644
index 00000000000..9fb38de2cd1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpeqw-2.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+avx2_test (void)
+{
+ union256i_w u, s1, s2;
+ short e[16];
+ int i;
+
+ s1.x = _mm256_set_epi16 (1, 2, 3, 4, 10, 20, 30, 90, -80, -40, -100,
+ 76, -100, -34, -78, -31000);
+
+ s2.x = _mm256_set_epi16 (88, 44, 3, 22, 11, 98, 76, -100, -34, -78,
+ 30, 90, -80, -40, -100, -15);
+
+ u.x = _mm256_cmpeq_epi16 (s1.x, s2.x);
+
+ for (i = 0; i < 16; i++)
+ e[i] = (s1.a[i] == s2.a[i]) ? -1 : 0;
+
+ if (check_union256i_w (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtb-1.c
new file mode 100644
index 00000000000..d8b35bba726
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpcmpgtb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_cmpgt_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtb-2.c
new file mode 100644
index 00000000000..b76077c2002
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtb-2.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+avx2_test (void)
+{
+ union256i_b u, s1, s2;
+ char e[32];
+ int i;
+
+ s1.x = _mm256_set_epi8 (1, 2, 3, 4, 10, 20, 30, 90, -80, -40, -100,
+ -15, 98, 25, 98, 7, 88, 44, 33, 22, 11, 98,
+ 76, -100, -34, -78, -39, 6, 3, 25, 5, 119);
+
+ s2.x = _mm256_set_epi8 (88, 44, 3, 22, 11, 98, 76, -100, -34, -78,
+ -39, 6, 3, 4, 5, 119, 1, 2, 3, 4, 10, 20,
+ 30, 90, -80, -40, -100, -15, 98, 25, 98, 7);
+
+ u.x = _mm256_cmpgt_epi8 (s1.x, s2.x);
+
+ for (i = 0; i < 32; i++)
+ e[i] = (s1.a[i] > s2.a[i]) ? -1 : 0;
+
+ if (check_union256i_b (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtd-1.c
new file mode 100644
index 00000000000..75e4b24e6f1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpcmpgtd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_cmpgt_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtd-2.c
new file mode 100644
index 00000000000..371bd79fa7f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtd-2.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+avx2_test (void)
+{
+ union256i_d u, s1, s2;
+ int e[8];
+ int i;
+
+ s1.x = _mm256_set_epi32 (1, 2, 3, 4, 10, 20, 30, 90000);
+
+ s2.x = _mm256_set_epi32 (88, 44, 3, 22, 11, 98, 76, -100);
+
+ u.x = _mm256_cmpgt_epi32 (s1.x, s2.x);
+
+ for (i = 0; i < 8; i++)
+ e[i] = (s1.a[i] > s2.a[i]) ? -1 : 0;
+
+ if (check_union256i_d (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtq-1.c
new file mode 100644
index 00000000000..7a983808b10
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpcmpgtq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_cmpgt_epi64 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtq-2.c
new file mode 100644
index 00000000000..8d5cf3ee863
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtq-2.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+avx2_test (void)
+{
+ union256i_q u, s1, s2;
+ long long int e[4];
+ int i;
+
+ s1.x = _mm256_set_epi64x (1, 2, 3, 4);
+
+ s2.x = _mm256_set_epi64x (88, 44, 3, 220000);
+
+ u.x = _mm256_cmpgt_epi64 (s1.x, s2.x);
+
+ for (i = 0; i < 4; i++)
+ e[i] = (s1.a[i] > s2.a[i]) ? -1 : 0;
+
+ if (check_union256i_q (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtw-1.c
new file mode 100644
index 00000000000..f2ed472983f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpcmpgtw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_cmpgt_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtw-2.c
new file mode 100644
index 00000000000..490878f8bc1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpcmpgtw-2.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+avx2_test (void)
+{
+ union256i_w u, s1, s2;
+ short e[16];
+ int i;
+
+ s1.x = _mm256_set_epi16 (1, 2, 3, 4, 10, 20, 30, 90, -80, -40, -100,
+ 76, -100, -34, -78, -31000);
+
+ s2.x = _mm256_set_epi16 (88, 44, 3, 22, 11, 98, 76, -100, -34, -78,
+ 30, 90, -80, -40, -100, -15);
+
+ u.x = _mm256_cmpgt_epi16 (s1.x, s2.x);
+
+ for (i = 0; i < 16; i++)
+ e[i] = (s1.a[i] > s2.a[i]) ? -1 : 0;
+
+ if (check_union256i_w (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vperm2i128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vperm2i128-1.c
new file mode 100644
index 00000000000..518ff333bd0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vperm2i128-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vperm2i128\[ \\t\]+\[^\n\]*" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_permute2x128_si256 (x, x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vperm2i128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vperm2i128-2.c
new file mode 100644
index 00000000000..96f32b8f05f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vperm2i128-2.c
@@ -0,0 +1,84 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+#define MASK 0xf1
+
+static void
+init_perm2i128 (unsigned long long *src1, unsigned long long *src2, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 4; i++)
+ {
+ src1[i] = (i + seed) * (i + seed) * sign;
+ src2[i] = (i + seed) * seed * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_perm2i128 (unsigned long long *src1,
+ unsigned long long *src2,
+ unsigned int mask, unsigned long long *dst)
+{
+ int i, temp;
+
+ temp = mask & 3;
+
+ switch (temp)
+ {
+ case 0:
+ memcpy (dst, src1, 16);
+ case 1:
+ memcpy (dst, src1 + 2, 16);
+ case 2:
+ memcpy (dst, src2, 16);
+ case 3:
+ memcpy (dst, src1 + 2, 16);
+ }
+
+ temp = (mask >> 4) & 3;
+
+ switch (temp)
+ {
+ case 0:
+ memcpy (dst + 2, src1, 16);
+ case 1:
+ memcpy (dst + 2, src1 + 2, 16);
+ case 2:
+ memcpy (dst + 2, src2, 16);
+ case 3:
+ memcpy (dst + 2, src1 + 2, 16);
+ }
+
+ if ((mask >> 3) & 1)
+ memset (dst, 0, 16);
+
+ if ((mask >> 7) & 1)
+ memset (dst + 2, 0, 16);
+}
+
+static void
+avx2_test (void)
+{
+ union256i_q src1, src2, dst;
+ unsigned long long dst_ref[4];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_perm2i128 (src1.a, src2.a, i);
+
+ dst.x = _mm256_permute2x128_si256 (src1.x, src2.x, MASK);
+ calc_perm2i128 (src1.a, src2.a, MASK, dst_ref);
+
+ if (check_union256i_q (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpermd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpermd-1.c
new file mode 100644
index 00000000000..939f3389533
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpermd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpermd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_permutevar8x32_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpermd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpermd-2.c
new file mode 100644
index 00000000000..4a4e73c78fb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpermd-2.c
@@ -0,0 +1,54 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+static void
+init_permd (int *src1, int *src2, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 8; i++)
+ {
+ src1[i] = (i + seed) * (i + seed) * sign;
+ src2[i] = (i + seed + 20) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_permd (int *src1, int *src2, int *dst)
+{
+ int i;
+ unsigned temp;
+
+ memcpy (dst, src1, 32);
+ for (i = 0; i < 8; i++)
+ {
+ temp = src1[i];
+ dst[i] = src2[temp & 7];
+ }
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d src1, src2, dst;
+ int dst_ref[8];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_permd (src1.a, src2.a, i);
+
+ dst.x = _mm256_permutevar8x32_epi32 (src1.x, src2.x);
+ calc_permd (src1.a, src2.a, dst_ref);
+
+ if (check_union256i_d (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpermpd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpermpd-1.c
new file mode 100644
index 00000000000..62ca67cc412
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpermpd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpermpd\[ \\t\]+\[^\n\]*" } } */
+
+#include <immintrin.h>
+
+__m256d x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_permute4x64_pd (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpermpd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpermpd-2.c
new file mode 100644
index 00000000000..1097e5cd18d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpermpd-2.c
@@ -0,0 +1,55 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define MASK 0x1a
+
+#define NUM 10
+
+static void
+init_permpd (double *src1, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 4; i++)
+ {
+ src1[i] = (i + seed) * (i + seed) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_permpd (double *src1, int mask, double *dst)
+{
+ int i;
+ unsigned temp;
+
+ memcpy (dst, src1, 32);
+ for (i = 0; i < 4; i++)
+ {
+ temp = mask >> (i * 2);
+ dst[i] = src1[temp & 3];
+ }
+}
+
+static void
+avx2_test (void)
+{
+ union256d src1, dst;
+ double dst_ref[4];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_permpd (src1.a, i);
+
+ dst.x = _mm256_permute4x64_pd (src1.x, MASK);
+ calc_permpd (src1.a, MASK, dst_ref);
+
+ if (check_union256d (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpermps-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpermps-1.c
new file mode 100644
index 00000000000..3346b23531f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpermps-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpermps\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m256 x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_permutevar8x32_ps (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpermps-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpermps-2.c
new file mode 100644
index 00000000000..f145aa1d214
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpermps-2.c
@@ -0,0 +1,55 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+static void
+init_permps (float *src1, float *src2, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 8; i++)
+ {
+ src1[i] = (i + seed) * (i + seed) * sign;
+ src2[i] = (i + seed + 20) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_permps (float *src1, float *src2, float *dst)
+{
+ int i;
+ unsigned temp;
+ unsigned *idx = (int *) src1;
+
+ memcpy (dst, src1, 32);
+ for (i = 0; i < 8; i++)
+ {
+ temp = idx[i];
+ dst[i] = src2[temp & 7];
+ }
+}
+
+static void
+avx2_test (void)
+{
+ union256 src1, src2, dst;
+ float dst_ref[8];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_permps (src1.a, src2.a, i);
+
+ dst.x = _mm256_permutevar8x32_ps (src1.x, src2.x);
+ calc_permps (src1.a, src2.a, dst_ref);
+
+ if (check_union256 (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpermq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpermq-1.c
new file mode 100644
index 00000000000..533af89a95b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpermq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpermq\[ \\t\]+\[^\n\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_permute4x64_epi64 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpermq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpermq-2.c
new file mode 100644
index 00000000000..2d8c3440280
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpermq-2.c
@@ -0,0 +1,54 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include <string.h>
+
+#define NUM 10
+
+#define MASK 0xf1
+
+static void
+init_permq (unsigned long long *src1, int seed)
+{
+ int i, sign = 1;
+
+ for (i = 0; i < 4; i++)
+ {
+ src1[i] = (i + seed) * (i + seed) * sign;
+ sign = -sign;
+ }
+}
+
+static void
+calc_permq (unsigned long long *src1, unsigned int mask,
+ unsigned long long *dst)
+{
+ int i, temp;
+
+ for (i = 0; i < 4; i++)
+ {
+ temp = (mask >> (2 * i)) & 3;
+ dst[i] = src1[temp];
+ }
+}
+
+static void
+avx2_test (void)
+{
+ union256i_q src1, dst;
+ unsigned long long dst_ref[4];
+ int i;
+
+ for (i = 0; i < NUM; i++)
+ {
+ init_permq (src1.a, i);
+
+ dst.x = _mm256_permute4x64_epi64 (src1.x, MASK);
+ calc_permq (src1.a, MASK, dst_ref);
+
+ if (check_union256i_q (dst, dst_ref))
+ abort ();
+ }
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vphaddd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vphaddd-1.c
new file mode 100644
index 00000000000..2fb0fd7f2f3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vphaddd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vphaddd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_hadd_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vphaddd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vphaddd-2.c
new file mode 100644
index 00000000000..0d686cb4f52
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vphaddd-2.c
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include "ssse3-vals.h"
+
+static void
+compute_phaddd256 (int *i1, int *i2, int *r)
+{
+ int i;
+
+ for (i = 0; i < 2; i++)
+ r[i + 0] = i1[2 * i] + i1[2 * i + 1];
+
+ for (i = 0; i < 2; i++)
+ r[i + 2] = i2[2 * i] + i2[2 * i + 1];
+
+ for (i = 0; i < 2; i++)
+ r[i + 4] = i1[2 * i + 4] + i1[2 * i + 5];
+
+ for (i = 0; i < 2; i++)
+ r[i + 6] = i2[2 * i + 4] + i2[2 * i + 5];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+
+ for (i = 0; i < 256; i += 16)
+ {
+ s1.x = _mm256_loadu_si256 ((__m256i *) & vals[i]);
+ s2.x = _mm256_loadu_si256 ((__m256i *) & vals[i + 8]);
+
+ res.x = _mm256_hadd_epi32 (s1.x, s2.x);
+
+ compute_phaddd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vphaddsw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vphaddsw-1.c
new file mode 100644
index 00000000000..dbedf69deac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vphaddsw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vphaddsw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_hadds_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vphaddsw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vphaddsw-2.c
new file mode 100644
index 00000000000..371984776f1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vphaddsw-2.c
@@ -0,0 +1,61 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include "ssse3-vals.h"
+
+static short
+signed_saturate_to_word (int x)
+{
+ if (x > (int) 0x7fff)
+ return 0x7fff;
+
+ if (x < (int) 0xffff8000)
+ return 0x8000;
+
+ return (short) x;
+}
+
+static void
+compute_phaddsw256 (short *i1, short *i2, short *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i + 0] = signed_saturate_to_word (i1[2 * i] + i1[2 * i + 1]);
+
+ for (i = 0; i < 4; i++)
+ r[i + 4] = signed_saturate_to_word (i2[2 * i] + i2[2 * i + 1]);
+
+ for (i = 0; i < 4; i++)
+ r[i + 8] = signed_saturate_to_word (i1[2 * i + 8] + i1[2 * i + 9]);
+
+ for (i = 0; i < 4; i++)
+ r[i + 12] = signed_saturate_to_word (i2[2 * i + 8] + i2[2 * i + 9]);
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+
+ for (i = 0; i < 256; i += 16)
+ {
+ s1.x = _mm256_loadu_si256 ((__m256i *) & vals[i]);
+ s2.x = _mm256_loadu_si256 ((__m256i *) & vals[i + 8]);
+
+ res.x = _mm256_hadds_epi16 (s1.x, s2.x);
+
+ compute_phaddsw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vphaddw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vphaddw-1.c
new file mode 100644
index 00000000000..c0bdac2f969
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vphaddw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vphaddw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_hadd_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vphaddw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vphaddw-2.c
new file mode 100644
index 00000000000..8811e99d691
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vphaddw-2.c
@@ -0,0 +1,48 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include "ssse3-vals.h"
+
+static void
+compute_phaddw256 (short *i1, short *i2, short *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i + 0] = i1[2 * i] + i1[2 * i + 1];
+
+ for (i = 0; i < 4; i++)
+ r[i + 4] = i2[2 * i] + i2[2 * i + 1];
+
+ for (i = 0; i < 4; i++)
+ r[i + 8] = i1[2 * i + 8] + i1[2 * i + 9];
+
+ for (i = 0; i < 4; i++)
+ r[i + 12] = i2[2 * i + 8] + i2[2 * i + 9];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short res_ref[16];
+ int i;
+ int fail = 0;
+
+ for (i = 0; i < 256; i += 16)
+ {
+ s1.x = _mm256_loadu_si256 ((__m256i *) & vals[i]);
+ s2.x = _mm256_loadu_si256 ((__m256i *) & vals[i + 8]);
+
+ res.x = _mm256_hadd_epi16 (s1.x, s2.x);
+
+ compute_phaddw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vphsubd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vphsubd-1.c
new file mode 100644
index 00000000000..d4ede9db012
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vphsubd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vphsubd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_hsub_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vphsubd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vphsubd-2.c
new file mode 100644
index 00000000000..ba493679228
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vphsubd-2.c
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include "ssse3-vals.h"
+
+static void
+compute_phsubd256 (int *i1, int *i2, int *r)
+{
+ int i;
+
+ for (i = 0; i < 2; i++)
+ r[i + 0] = i1[2 * i] - i1[2 * i + 1];
+
+ for (i = 0; i < 2; i++)
+ r[i + 2] = i2[2 * i] - i2[2 * i + 1];
+
+ for (i = 0; i < 2; i++)
+ r[i + 4] = i1[2 * i + 4] - i1[2 * i + 5];
+
+ for (i = 0; i < 2; i++)
+ r[i + 6] = i2[2 * i + 4] - i2[2 * i + 5];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+
+ for (i = 0; i < 256; i += 16)
+ {
+ s1.x = _mm256_loadu_si256 ((__m256i *) & vals[i]);
+ s2.x = _mm256_loadu_si256 ((__m256i *) & vals[i + 8]);
+
+ res.x = _mm256_hsub_epi32 (s1.x, s2.x);
+
+ compute_phsubd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vphsubsw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vphsubsw-1.c
new file mode 100644
index 00000000000..d941f44b3f3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vphsubsw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vphsubsw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_hsubs_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vphsubsw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vphsubsw-2.c
new file mode 100644
index 00000000000..1ed0990907f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vphsubsw-2.c
@@ -0,0 +1,60 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include "ssse3-vals.h"
+
+static short
+signed_saturate_to_word (int x)
+{
+ if (x > (int) 0x7fff)
+ return 0x7fff;
+
+ if (x < (int) 0xffff8000)
+ return 0x8000;
+
+ return (short) x;
+}
+
+static void
+compute_phsubsw256 (short *i1, short *i2, short *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i + 0] = signed_saturate_to_word (i1[2 * i] - i1[2 * i + 1]);
+
+ for (i = 0; i < 4; i++)
+ r[i + 4] = signed_saturate_to_word (i2[2 * i] - i2[2 * i + 1]);
+
+ for (i = 0; i < 4; i++)
+ r[i + 8] = signed_saturate_to_word (i1[2 * i + 8] - i1[2 * i + 9]);
+
+ for (i = 0; i < 4; i++)
+ r[i + 12] = signed_saturate_to_word (i2[2 * i + 8] - i2[2 * i + 9]);
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short res_ref[16];
+ int i;
+ int fail = 0;
+
+ for (i = 0; i < 256; i += 16)
+ {
+ s1.x = _mm256_loadu_si256 ((__m256i *) & vals[i]);
+ s2.x = _mm256_loadu_si256 ((__m256i *) & vals[i + 8]);
+
+ res.x = _mm256_hsubs_epi16 (s1.x, s2.x);
+
+ compute_phsubsw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vphsubw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vphsubw-1.c
new file mode 100644
index 00000000000..f336fad4879
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vphsubw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vphsubw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_hsub_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaddubsw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaddubsw-1.c
new file mode 100644
index 00000000000..6ab19103d32
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaddubsw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaddubsw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_maddubs_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaddubsw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaddubsw-2.c
new file mode 100644
index 00000000000..5761d8f4419
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaddubsw-2.c
@@ -0,0 +1,59 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include "ssse3-vals.h"
+
+static short
+signed_saturate_to_word (int x)
+{
+ if (x > (int) 0x7fff)
+ return 0x7fff;
+
+ if (x < (int) 0xffff8000)
+ return 0x8000;
+
+ return (short) x;
+}
+
+static void
+compute_pmaddubsw256 (short *i1, short *i2, short *r)
+{
+ unsigned char *ub1 = (unsigned char *) i1;
+ char *sb2 = (char *) i2;
+ short *sout = (short *) r;
+ int t0;
+ int i;
+
+ for (i = 0; i < 16; i++)
+ {
+ t0 = ((int) ub1[2 * i] * (int) sb2[2 * i] +
+ (int) ub1[2 * i + 1] * (int) sb2[2 * i + 1]);
+ sout[i] = signed_saturate_to_word (t0);
+ }
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short res_ref[16];
+ int i;
+ int fail = 0;
+
+ for (i = 0; i < 256; i += 16)
+ {
+ s1.x = _mm256_loadu_si256 ((__m256i *) & vals[i]);
+ s2.x = _mm256_loadu_si256 ((__m256i *) & vals[i + 8]);
+
+ res.x = _mm256_maddubs_epi16 (s1.x, s2.x);
+
+ compute_pmaddubsw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaddwd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaddwd-1.c
new file mode 100644
index 00000000000..97de707ba88
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaddwd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaddwd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_madd_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaddwd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaddwd-2.c
new file mode 100644
index 00000000000..d539d39433a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaddwd-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+#include "ssse3-vals.h"
+
+static void
+compute_pmaddwd256 (short *i1, short *i2, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ r[i] = ((int) i1[2 * i] * (int) i2[2 * i] +
+ (int) i1[2 * i + 1] * (int) i2[2 * i + 1]);
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2;
+ union256i_d res;
+ int res_ref[8];
+ int i;
+ int fail = 0;
+
+ for (i = 0; i < 256; i += 16)
+ {
+ s1.x = _mm256_loadu_si256 ((__m256i *) & vals[i]);
+ s2.x = _mm256_loadu_si256 ((__m256i *) & vals[i + 8]);
+
+ res.x = _mm256_madd_epi16 (s1.x, s2.x);
+
+ compute_pmaddwd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd-1.c
new file mode 100644
index 00000000000..917de5136df
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaskmovd\[ \\t\]+\[^\n\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+int *y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_maskload_epi32 (y, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd-2.c
new file mode 100644
index 00000000000..9bc3f31bed1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd-2.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+#ifndef MASK
+#define MASK 134
+#endif
+
+#define mask_v(pos) (((MASK & (0x1 << (pos))) >> (pos)) << 31)
+
+void static
+avx2_test (void)
+{
+ int i;
+ int m[4] = { mask_v (0), mask_v (1), mask_v (2), mask_v (3) };
+ int s[4] = { 1, 2, 3, 4 };
+ union128i_d u, mask;
+ int e[4] = { 0 };
+
+ mask.x = _mm_loadu_si128 ((__m128i *) m);
+ u.x = _mm_maskload_epi32 (s, mask.x);
+
+ for (i = 0; i < 4; i++)
+ e[i] = m[i] ? s[i] : 0;
+
+ if (check_union128i_d (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd256-1.c
new file mode 100644
index 00000000000..aa9438c93a7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd256-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaskmovd\[ \\t\]+\[^\n\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+int *y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_maskload_epi32 (y, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd256-2.c
new file mode 100644
index 00000000000..b5a82bddde2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadd256-2.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+#ifndef MASK
+#define MASK 134
+#endif
+
+#define mask_v(pos) (((MASK & (0x1 << (pos))) >> (pos)) << 31)
+
+void static
+avx2_test (void)
+{
+ int i;
+ int m[8] =
+ { mask_v (0), mask_v (1), mask_v (2), mask_v (3), mask_v (4), mask_v (5),
+mask_v (6), mask_v (7) };
+ int s[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ union256i_d u, mask;
+ int e[8] = { 0 };
+
+ mask.x = _mm256_loadu_si256 ((__m256i *) m);
+ u.x = _mm256_maskload_epi32 (s, mask.x);
+
+ for (i = 0; i < 8; i++)
+ e[i] = m[i] ? s[i] : 0;
+
+ if (check_union256i_d (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq-1.c
new file mode 100644
index 00000000000..24768b8f872
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaskmovq\[ \\t\]+\[^\n\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+long long int *y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_maskload_epi64 (y, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq-2.c
new file mode 100644
index 00000000000..ca7abadcac6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq-2.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+#ifndef MASK
+#define MASK 7
+#endif
+
+#define mask_v(pos) (((MASK & (0x1ULL << (pos))) >> (pos)) << 63)
+
+void static
+avx2_test (void)
+{
+ int i;
+ long long m[2] = { mask_v (0), mask_v (1) };
+ long long s[2] = { 1, 2 };
+ union128i_q u, mask;
+ long long e[2] = { 0 };
+
+ mask.x = _mm_loadu_si128 ((__m128i *) m);
+ u.x = _mm_maskload_epi64 (s, mask.x);
+
+ for (i = 0; i < 2; i++)
+ e[i] = m[i] ? s[i] : 0;
+
+ if (check_union128i_q (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq256-1.c
new file mode 100644
index 00000000000..9b824eb5764
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq256-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaskmovq\[ \\t\]+\[^\n\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+long long int *y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_maskload_epi64 (y, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq256-2.c
new file mode 100644
index 00000000000..c74d15304ec
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskloadq256-2.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+#ifndef MASK
+#define MASK 7
+#endif
+
+#define mask_v(pos) (((MASK & (0x1ULL << (pos))) >> (pos)) << 63)
+
+void static
+avx2_test (void)
+{
+ int i;
+ long long m[4] = { mask_v (0), mask_v (1), mask_v (2), mask_v (3) };
+ long long s[4] = { 1, 2, 3, 4 };
+ union256i_q u, mask;
+ long long e[4] = { 0 };
+
+ mask.x = _mm256_loadu_si256 ((__m256i *) m);
+ u.x = _mm256_maskload_epi64 (s, mask.x);
+
+ for (i = 0; i < 4; i++)
+ e[i] = m[i] ? s[i] : 0;
+
+ if (check_union256i_q (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored-1.c
new file mode 100644
index 00000000000..0731d1ae16d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaskmovd\[ \\t\]+\[^\n\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+int *y;
+
+void extern
+avx2_test (void)
+{
+ _mm_maskstore_epi32 (y, x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored-2.c
new file mode 100644
index 00000000000..89b54f59411
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored-2.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+#ifndef MASK
+#define MASK 214
+#endif
+
+#define mask_v(pos) (((MASK & (0x1 << (pos))) >> (pos)) << 31)
+
+void static
+avx2_test (void)
+{
+ int i;
+ int m[4] = { mask_v (0), mask_v (1), mask_v (2), mask_v (3) };
+ int s[4] = { 1, 2, 3, 4 };
+ union128i_d src, mask;
+ int e[4] = { 0 };
+ int d[4] = { 0 };
+
+ src.x = _mm_loadu_si128 ((__m128i *) s);
+ mask.x = _mm_loadu_si128 ((__m128i *) m);
+ _mm_maskstore_epi32 (d, mask.x, src.x);
+
+ for (i = 0; i < 4; i++)
+ e[i] = m[i] ? s[i] : 0;
+
+ if (checkVi (d, e, 4))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored256-1.c
new file mode 100644
index 00000000000..4e2944de071
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored256-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaskmovd\[ \\t\]+\[^\n\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+int *y;
+
+void extern
+avx2_test (void)
+{
+ _mm256_maskstore_epi32 (y, x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored256-2.c
new file mode 100644
index 00000000000..7b66a08977a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstored256-2.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+#ifndef MASK
+#define MASK 214
+#endif
+
+#define mask_v(pos) (((MASK & (0x1 << (pos))) >> (pos)) << 31)
+
+void static
+avx2_test (void)
+{
+ int i;
+ int m[8] =
+ { mask_v (0), mask_v (1), mask_v (2), mask_v (3), mask_v (4), mask_v (5),
+mask_v (6), mask_v (7) };
+ int s[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
+ union256i_d src, mask;
+ int e[8] = { 0 };
+ int d[8] = { 0 };
+
+ src.x = _mm256_loadu_si256 ((__m256i *) s);
+ mask.x = _mm256_loadu_si256 ((__m256i *) m);
+ _mm256_maskstore_epi32 (d, mask.x, src.x);
+
+ for (i = 0; i < 8; i++)
+ e[i] = m[i] ? s[i] : 0;
+
+ if (checkVi (d, e, 8))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq-1.c
new file mode 100644
index 00000000000..f1075bf253f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaskmovq\[ \\t\]+\[^\n\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+long long int *y;
+
+void extern
+avx2_test (void)
+{
+ _mm_maskstore_epi64 (y, x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq-2.c
new file mode 100644
index 00000000000..bd9e3947075
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq-2.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+#ifndef MASK
+#define MASK 6
+#endif
+
+#define mask_v(pos) (((MASK & (0x1ULL << (pos))) >> (pos)) << 63)
+
+void static
+avx2_test (void)
+{
+ int i;
+ long long m[2] = { mask_v (0), mask_v (1) };
+ long long s[2] = { 1, 2 };
+ long long e[2] = { 0 };
+ long long d[2] = { 0 };
+ union128i_q src, mask;
+
+ src.x = _mm_loadu_si128 ((__m128i *) s);
+ mask.x = _mm_loadu_si128 ((__m128i *) m);
+ _mm_maskstore_epi64 (d, mask.x, src.x);
+
+ for (i = 0; i < 2; i++)
+ e[i] = m[i] ? s[i] : 0;
+
+ if (checkVl (d, e, 2))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq256-1.c
new file mode 100644
index 00000000000..0d0520b81a6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq256-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaskmovq\[ \\t\]+\[^\n\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+long long int *y;
+
+void extern
+avx2_test (void)
+{
+ _mm256_maskstore_epi64 (y, x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq256-2.c
new file mode 100644
index 00000000000..091791ac637
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaskstoreq256-2.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+#ifndef MASK
+#define MASK 6
+#endif
+
+#define mask_v(pos) (((MASK & (0x1ULL << (pos))) >> (pos)) << 63)
+
+void static
+avx2_test (void)
+{
+ int i;
+ long long m[4] = { mask_v (0), mask_v (1), mask_v (2), mask_v (3) };
+ long long s[4] = { 1, 2, 3, 4 };
+ long long e[4] = { 0 };
+ long long d[4] = { 0 };
+ union256i_q src, mask;
+
+ src.x = _mm256_loadu_si256 ((__m256i *) s);
+ mask.x = _mm256_loadu_si256 ((__m256i *) m);
+ _mm256_maskstore_epi64 (d, mask.x, src.x);
+
+ for (i = 0; i < 4; i++)
+ e[i] = m[i] ? s[i] : 0;
+
+ if (checkVl (d, e, 4))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxsb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsb-1.c
new file mode 100644
index 00000000000..2cbbcff9dcb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaxsb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_max_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxsb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsb-2.c
new file mode 100644
index 00000000000..4b1b1dd2f87
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsb-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmaxsb256 (char *s1, char *s2, char *r)
+{
+ int i;
+
+ for (i = 0; i < 32; i++)
+ r[i] = s1[i] > s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_b s1, s2, res;
+ char res_ref[32];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (i + 20) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_max_epi8 (s1.x, s2.x);
+
+ compute_pmaxsb256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_b (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxsd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsd-1.c
new file mode 100644
index 00000000000..1b227e6145c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaxsd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_max_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxsd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsd-2.c
new file mode 100644
index 00000000000..e488a6ea152
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsd-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmaxsd256 (int *s1, int *s2, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ r[i] = s1[i] > s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ int res_ref[8];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (i + 2000) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_max_epi32 (s1.x, s2.x);
+
+ compute_pmaxsd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxsw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsw-1.c
new file mode 100644
index 00000000000..8fb2d29cd02
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaxsw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_max_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxsw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsw-2.c
new file mode 100644
index 00000000000..6ada1cd23c7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxsw-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmaxsw256 (short *s1, short *s2, short *r)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ r[i] = s1[i] > s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short res_ref[16];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (i + 2000) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_max_epi16 (s1.x, s2.x);
+
+ compute_pmaxsw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxub-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxub-1.c
new file mode 100644
index 00000000000..6d0fe9828d9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxub-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaxub\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_max_epu8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxub-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxub-2.c
new file mode 100644
index 00000000000..f0654e03277
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxub-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmaxub256 (unsigned char *s1, unsigned char *s2, unsigned char *r)
+{
+ int i;
+
+ for (i = 0; i < 32; i++)
+ r[i] = s1[i] > s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_b s1, s2, res;
+ unsigned char res_ref[32];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = i + 200;
+ }
+
+ res.x = _mm256_max_epu8 (s1.x, s2.x);
+
+ compute_pmaxub256 ((unsigned char *) s1.a,
+ (unsigned char *) s2.a, (unsigned char *) res_ref);
+
+ fail += check_union256i_b (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxud-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxud-1.c
new file mode 100644
index 00000000000..5784148c70b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxud-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaxud\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_max_epu32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxud-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxud-2.c
new file mode 100644
index 00000000000..a61314d193b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxud-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmaxud256 (unsigned int *s1, unsigned int *s2, unsigned int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ r[i] = s1[i] > s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ unsigned int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = i + 2000;
+ }
+
+ res.x = _mm256_max_epu32 (s1.x, s2.x);
+
+ compute_pmaxud256 ((unsigned *) s1.a, (unsigned *) s2.a,
+ (unsigned *) res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxuw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxuw-1.c
new file mode 100644
index 00000000000..dbadc254c62
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxuw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmaxuw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_max_epu16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmaxuw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmaxuw-2.c
new file mode 100644
index 00000000000..2631f0cf080
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmaxuw-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmaxuw256 (unsigned short *s1, unsigned short *s2, unsigned short *r)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ r[i] = s1[i] > s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ unsigned short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = i + 2000;
+ }
+
+ res.x = _mm256_max_epu16 (s1.x, s2.x);
+
+ compute_pmaxuw256 ((unsigned short *) s1.a,
+ (unsigned short *) s2.a, (unsigned short *) res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminsb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpminsb-1.c
new file mode 100644
index 00000000000..35cbdb31286
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminsb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpminsb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_min_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminsb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpminsb-2.c
new file mode 100644
index 00000000000..2dc5b109f01
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminsb-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pminsb256 (char *s1, char *s2, char *r)
+{
+ int i;
+
+ for (i = 0; i < 32; i++)
+ r[i] = s1[i] < s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_b s1, s2, res;
+ char res_ref[32];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (i + 20) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_min_epi8 (s1.x, s2.x);
+
+ compute_pminsb256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_b (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminsd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpminsd-1.c
new file mode 100644
index 00000000000..97c99f24c50
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminsd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpminsd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_min_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminsd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpminsd-2.c
new file mode 100644
index 00000000000..e2c69e7e87a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminsd-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pminsd256 (int *s1, int *s2, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ r[i] = s1[i] < s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ int res_ref[8];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (i + 2000) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_min_epi32 (s1.x, s2.x);
+
+ compute_pminsd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminsw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpminsw-1.c
new file mode 100644
index 00000000000..43f5c72ac05
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminsw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpminsw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_min_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminsw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpminsw-2.c
new file mode 100644
index 00000000000..05be8ce9056
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminsw-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pminsw256 (short *s1, short *s2, short *r)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ r[i] = s1[i] < s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short res_ref[16];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (i + 2000) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_min_epi16 (s1.x, s2.x);
+
+ compute_pminsw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminub-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpminub-1.c
new file mode 100644
index 00000000000..44663e8ad10
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminub-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpminub\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_min_epu8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminub-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpminub-2.c
new file mode 100644
index 00000000000..16c5f762863
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminub-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pminub256 (unsigned char *s1, unsigned char *s2, unsigned char *r)
+{
+ int i;
+
+ for (i = 0; i < 32; i++)
+ r[i] = s1[i] < s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_b s1, s2, res;
+ unsigned char res_ref[32];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = i + 200;
+ }
+
+ res.x = _mm256_min_epu8 (s1.x, s2.x);
+
+ compute_pminub256 ((unsigned char *) s1.a,
+ (unsigned char *) s2.a, (unsigned char *) res_ref);
+
+ fail += check_union256i_b (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminud-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpminud-1.c
new file mode 100644
index 00000000000..d6acb8b474b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminud-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpminud\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_min_epu32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminud-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpminud-2.c
new file mode 100644
index 00000000000..97ff7422661
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminud-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pminud256 (unsigned int *s1, unsigned int *s2, unsigned int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ r[i] = s1[i] < s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ unsigned int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = i + 2000;
+ }
+
+ res.x = _mm256_min_epu32 (s1.x, s2.x);
+
+ compute_pminud256 ((unsigned *) s1.a, (unsigned *) s2.a,
+ (unsigned *) res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminuw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpminuw-1.c
new file mode 100644
index 00000000000..c018a49c92b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminuw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpminuw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_min_epu16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpminuw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpminuw-2.c
new file mode 100644
index 00000000000..7de87d00dad
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpminuw-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pminuw256 (unsigned short *s1, unsigned short *s2, unsigned short *r)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ r[i] = s1[i] < s2[i] ? s1[i] : s2[i];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ unsigned short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = i + 2000;
+ }
+
+ res.x = _mm256_min_epu16 (s1.x, s2.x);
+
+ compute_pminuw256 ((unsigned short *) s1.a,
+ (unsigned short *) s2.a, (unsigned short *) res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovmskb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovmskb-1.c
new file mode 100644
index 00000000000..1a37b1bef26
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovmskb-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovmskb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+int res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_movemask_epi8 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbd-1.c
new file mode 100644
index 00000000000..d438248b5d0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbd-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovsxbd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepi8_epi32 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbd-2.c
new file mode 100644
index 00000000000..3b641b0ca07
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbd-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movsxbd (char *s, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_b s;
+ union256i_d res;
+ int res_ref[8];
+
+ s.x = _mm_set_epi8 (1, 2, 3, 4, 20, -50, 6, 8, 1, 2, 3, 4, -20, 5, 6, 8);
+
+ res.x = _mm256_cvtepi8_epi32 (s.x);
+
+ compute_movsxbd (s.a, res_ref);
+
+ if (check_union256i_d (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbq-1.c
new file mode 100644
index 00000000000..12c817ffb82
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbq-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovsxbq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepi8_epi64 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbq-2.c
new file mode 100644
index 00000000000..23aae5bdb67
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbq-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movsxbq (char *s, long long int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_b s;
+ union256i_q res;
+ long long int res_ref[4];
+
+ s.x = _mm_set_epi8 (1, 2, 3, 4, 20, -50, 6, 8, 1, 2, 3, 4, -20, 5, 6, 8);
+
+ res.x = _mm256_cvtepi8_epi64 (s.x);
+
+ compute_movsxbq (s.a, res_ref);
+
+ if (check_union256i_q (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbw-1.c
new file mode 100644
index 00000000000..bf98e3154c6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbw-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovsxbw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepi8_epi16 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbw-2.c
new file mode 100644
index 00000000000..d1c02ea8638
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxbw-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movsxbw (char *s, short *r)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_b s;
+ union256i_w res;
+ short res_ref[16];
+
+ s.x = _mm_set_epi8 (1, 2, 3, 4, 20, -50, 6, 8, 1, 2, 3, 4, -20, 5, 6, 8);
+
+ res.x = _mm256_cvtepi8_epi16 (s.x);
+
+ compute_movsxbw (s.a, res_ref);
+
+ if (check_union256i_w (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxdq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxdq-1.c
new file mode 100644
index 00000000000..9c72c41e188
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxdq-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovsxdq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepi32_epi64 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxdq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxdq-2.c
new file mode 100644
index 00000000000..7e87f316fb0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxdq-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movsxdq (int *s, long long int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_d s;
+ union256i_q res;
+ long long int res_ref[4];
+
+ s.x = _mm_set_epi32 (1, -2, 3, 4);
+
+ res.x = _mm256_cvtepi32_epi64 (s.x);
+
+ compute_movsxdq (s.a, res_ref);
+
+ if (check_union256i_q (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwd-1.c
new file mode 100644
index 00000000000..39627ced8c1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwd-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovsxwd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepi16_epi32 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwd-2.c
new file mode 100644
index 00000000000..5a95e376e19
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwd-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movsxwd (short *s, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_w s;
+ union256i_d res;
+ int res_ref[8];
+
+ s.x = _mm_set_epi16 (1, -2, 3, 4, 200, 5000, -6, 8);
+
+ res.x = _mm256_cvtepi16_epi32 (s.x);
+
+ compute_movsxwd (s.a, res_ref);
+
+ if (check_union256i_d (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwq-1.c
new file mode 100644
index 00000000000..9fa613b3420
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwq-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovsxwq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepi16_epi64 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwq-2.c
new file mode 100644
index 00000000000..f096de57762
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovsxwq-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movsxwq (short *s, long long int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_w s;
+ union256i_q res;
+ long long int res_ref[4];
+
+ s.x = _mm_set_epi16 (1, 2, 3, 4, -200, 50, 6, 8);
+
+ res.x = _mm256_cvtepi16_epi64 (s.x);
+
+ compute_movsxwq (s.a, res_ref);
+
+ if (check_union256i_q (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbd-1.c
new file mode 100644
index 00000000000..bde8c134dde
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbd-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovzxbd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepu8_epi32 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbd-2.c
new file mode 100644
index 00000000000..7a212c89dc4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbd-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movzxbd (unsigned char *s, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_b s;
+ union256i_d res;
+ int res_ref[8];
+
+ s.x = _mm_set_epi8 (1, 2, 3, 4, 20, 50, 6, 8, 1, 2, 3, 4, 200, 5, 6, 8);
+
+ res.x = _mm256_cvtepu8_epi32 (s.x);
+
+ compute_movzxbd (s.a, res_ref);
+
+ if (check_union256i_d (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbq-1.c
new file mode 100644
index 00000000000..da8e0584ab7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbq-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovzxbq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepu8_epi64 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbq-2.c
new file mode 100644
index 00000000000..c09c21d67e2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbq-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movzxbq (unsigned char *s, long long int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_b s;
+ union256i_q res;
+ long long int res_ref[4];
+
+ s.x = _mm_set_epi8 (1, 2, 3, 4, 20, 150, 6, 8, 1, 2, 3, 4, 20, 5, 6, 8);
+
+ res.x = _mm256_cvtepu8_epi64 (s.x);
+
+ compute_movzxbq (s.a, res_ref);
+
+ if (check_union256i_q (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbw-1.c
new file mode 100644
index 00000000000..f7a926de10f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbw-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovzxbw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepu8_epi16 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbw-2.c
new file mode 100644
index 00000000000..5ef4b153575
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxbw-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movzxbw (unsigned char *s, short *r)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_b s;
+ union256i_w res;
+ short res_ref[16];
+
+ s.x = _mm_set_epi8 (1, 2, 3, 4, 200, 50, 6, 8, 1, 2, 3, 4, 200, 5, 6, 8);
+
+ res.x = _mm256_cvtepu8_epi16 (s.x);
+
+ compute_movzxbw (s.a, res_ref);
+
+ if (check_union256i_w (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxdq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxdq-1.c
new file mode 100644
index 00000000000..3f0c400c3ae
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxdq-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovzxdq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepu32_epi64 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxdq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxdq-2.c
new file mode 100644
index 00000000000..20986b6448f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxdq-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movzxdq (unsigned *s, long long int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_d s;
+ union256i_q res;
+ long long int res_ref[4];
+
+ s.x = _mm_set_epi32 (1, 2, 3, 4);
+
+ res.x = _mm256_cvtepu32_epi64 (s.x);
+
+ compute_movzxdq (s.a, res_ref);
+
+ if (check_union256i_q (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwd-1.c
new file mode 100644
index 00000000000..902cd6df87f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwd-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovzxwd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepu16_epi32 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwd-2.c
new file mode 100644
index 00000000000..b4d2b2da685
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwd-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movzxwd (unsigned short *s, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_w s;
+ union256i_d res;
+ int res_ref[8];
+
+ s.x = _mm_set_epi16 (1, 2, 3, 4, 200, 5000, 6, 8);
+
+ res.x = _mm256_cvtepu16_epi32 (s.x);
+
+ compute_movzxwd (s.a, res_ref);
+
+ if (check_union256i_d (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwq-1.c
new file mode 100644
index 00000000000..4eaa65aebb1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwq-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmovzxwq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+__m256i res;
+
+void extern
+avx2_test (void)
+{
+ res = _mm256_cvtepu16_epi64 (x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwq-2.c
new file mode 100644
index 00000000000..8a9250aeca5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmovzxwq-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_movzxwq (unsigned short *s, long long int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i] = s[i];
+}
+
+static void
+avx2_test (void)
+{
+ union128i_w s;
+ union256i_q res;
+ long long int res_ref[4];
+
+ s.x = _mm_set_epi16 (1, 2, 3, 4, 200, 5000, 6, 8);
+
+ res.x = _mm256_cvtepu16_epi64 (s.x);
+
+ compute_movzxwq (s.a, res_ref);
+
+ if (check_union256i_q (res, res_ref))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmuldq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmuldq-1.c
new file mode 100644
index 00000000000..e1c232da321
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmuldq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmuldq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mul_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmuldq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmuldq-2.c
new file mode 100644
index 00000000000..b67f25fc4c0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmuldq-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmuldq256 (int *s1, int *s2, long long int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i] = s1[i * 2] * s2[i * 2];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d s1, s2;
+ union256i_q res;
+ long long int res_ref[4];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = i * j * sign;
+ s2.a[j] = (j + 20) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_mul_epi32 (s1.x, s2.x);
+ compute_pmuldq256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmulhrsw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmulhrsw-1.c
new file mode 100644
index 00000000000..7c6692b81d9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmulhrsw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmulhrsw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mulhrs_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmulhrsw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmulhrsw-2.c
new file mode 100644
index 00000000000..c6d87422245
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmulhrsw-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmulhrsw256 (short *s1, short *s2, short *r)
+{
+ int i;
+ int t0;
+
+ for (i = 0; i < 16; i++)
+ {
+ t0 = (((int) s1[i] * (int) s2[i]) >> 14) + 1;
+ r[i] = (short) (t0 >> 1);
+ }
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short res_ref[16];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = i * j * sign;
+ s2.a[j] = (j + 20) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_mulhrs_epi16 (s1.x, s2.x);
+
+ compute_pmulhrsw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmulhuw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmulhuw-1.c
new file mode 100644
index 00000000000..d9a2fa7ceef
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmulhuw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmulhuw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mulhi_epu16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmulhuw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmulhuw-2.c
new file mode 100644
index 00000000000..734b20cfb5c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmulhuw-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmulhuw256 (unsigned short *s1, unsigned short *s2, unsigned short *r)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ r[i] = (s1[i] * s2[i]) >> 16;
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ unsigned short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = i * j;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_mulhi_epu16 (s1.x, s2.x);
+
+ compute_pmulhuw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmulhw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmulhw-1.c
new file mode 100644
index 00000000000..a626f19199c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmulhw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmulhw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mulhi_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmulhw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmulhw-2.c
new file mode 100644
index 00000000000..ea0bde2bea9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmulhw-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmulhw256 (short *s1, short *s2, short *r)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ r[i] = (s1[i] * s2[i]) >> 16;
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short res_ref[16];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = i * j * sign;
+ s2.a[j] = (j + 20) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_mulhi_epi16 (s1.x, s2.x);
+
+ compute_pmulhw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmulld-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmulld-1.c
new file mode 100644
index 00000000000..4e2e5250fbd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmulld-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmulld\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mullo_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmulld-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmulld-2.c
new file mode 100644
index 00000000000..74443a24d87
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmulld-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmulld256 (int *s1, int *s2, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ r[i] = (int) ((long long int) s1[i] * (long long int) s2[i]);
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ int res_ref[8];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = i * j * sign;
+ s2.a[j] = (j + 20) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_mullo_epi32 (s1.x, s2.x);
+
+ compute_pmulld256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmullw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmullw-1.c
new file mode 100644
index 00000000000..61cc7588407
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmullw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmullw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mullo_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmullw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmullw-2.c
new file mode 100644
index 00000000000..81d05ccab2f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmullw-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmullw256 (short *s1, short *s2, short *r)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ r[i] = (short) ((int) s1[i] * (int) s2[i]);
+}
+
+static void
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short res_ref[16];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = i * j * sign;
+ s2.a[j] = (j + 20) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_mullo_epi16 (s1.x, s2.x);
+
+ compute_pmullw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmuludq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpmuludq-1.c
new file mode 100644
index 00000000000..4fa1bf155ac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmuludq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpmuludq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_mul_epu32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmuludq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpmuludq-2.c
new file mode 100644
index 00000000000..619b7358e78
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpmuludq-2.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+static void
+compute_pmuludq256 (unsigned int *s1, unsigned int *s2, unsigned long long *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i] = s1[i * 2] * s2[i * 2];
+}
+
+static void
+avx2_test (void)
+{
+ union256i_d s1, s2;
+ union256i_q res;
+ unsigned long long res_ref[4];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = i * j;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_mul_epu32 (s1.x, s2.x);
+
+ compute_pmuludq256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpor-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpor-1.c
new file mode 100644
index 00000000000..2e0f46d213c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpor-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpor\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_or_si256 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpor-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpor-2.c
new file mode 100644
index 00000000000..fd5da8335ca
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpor-2.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include "avx2-check.h"
+
+static void
+compute_por256 (long long int *s1, long long int *s2, long long int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i] = s1[i] | s2[i];
+}
+
+void static
+avx2_test (void)
+{
+ union256i_q s1, s2, res;
+ long long int res_ref[4];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ s1.a[j] = i * j * sign;
+ s2.a[j] = (j + 20) * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_or_si256 (s1.x, s2.x);
+ compute_por256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsadbw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsadbw-1.c
new file mode 100644
index 00000000000..1cd56661cdb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsadbw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsadbw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sad_epu8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsadbw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsadbw-2.c
new file mode 100644
index 00000000000..392613659aa
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsadbw-2.c
@@ -0,0 +1,57 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_sadbw256 (unsigned char *s1, unsigned char *s2, unsigned short *r)
+{
+ int i;
+ unsigned char tmp[32];
+
+ for (i = 0; i < 32; i++)
+ tmp[i] = s1[i] > s2[i] ? s1[i] - s2[i] : s2[i] - s1[i];
+
+ memset (r, 0, 32);
+
+ for (i = 0; i < 8; i++)
+ r[0] += tmp[i];
+
+ for (i = 8; i < 16; i++)
+ r[4] += tmp[i];
+
+ for (i = 16; i < 24; i++)
+ r[8] += tmp[i];
+
+ for (i = 24; i < 32; i++)
+ r[12] += tmp[i];
+}
+
+void static
+avx2_test (void)
+{
+ union256i_b s1, s2;
+ union256i_w res;
+ unsigned short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_sad_epu8 (s1.x, s2.x);;
+ compute_sadbw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpshufb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpshufb-1.c
new file mode 100644
index 00000000000..b94563d0ca1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpshufb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpshufb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_shuffle_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpshufb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpshufb-2.c
new file mode 100644
index 00000000000..ee91493950b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpshufb-2.c
@@ -0,0 +1,54 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_pshufb256 (char *s1, char *s2, char *r)
+{
+ int i;
+ char select;
+
+ for (i = 0; i < 16; i++)
+ {
+ select = s2[i];
+ if (select & 0x80)
+ r[i] = 0;
+ else
+ r[i] = s1[select & 0xf];
+
+ select = s2[i + 16];
+ if (select & 0x80)
+ r[i + 16] = 0;
+ else
+ r[i + 16] = s1[16 + (select & 0xf)];
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_b s1, s2, res;
+ char res_ref[32];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_shuffle_epi8 (s1.x, s2.x);
+ compute_pshufb256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_b (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpshufd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpshufd-1.c
new file mode 100644
index 00000000000..cdfde4654f5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpshufd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpshufd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_shuffle_epi32 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpshufd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpshufd-2.c
new file mode 100644
index 00000000000..e799ed78930
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpshufd-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0xec
+
+static void
+compute_pshufd256 (int *s1, unsigned char imm, int *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ r[i] = s1[((N & (0x3 << (2 * i))) >> (2 * i))];
+
+ for (i = 0; i < 4; i++)
+ r[i + 4] = s1[((N & (0x3 << (2 * i))) >> (2 * i)) + 4];
+}
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, res;
+ int res_ref[8];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = j * i * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_shuffle_epi32 (s1.x, N);
+ compute_pshufd256 (s1.a, N, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpshufhw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpshufhw-1.c
new file mode 100644
index 00000000000..fa3f809daa5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpshufhw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpshufhw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_shufflehi_epi16 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpshufhw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpshufhw-2.c
new file mode 100644
index 00000000000..a27ed03b3bd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpshufhw-2.c
@@ -0,0 +1,52 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0xec
+
+static void
+compute_pshuflw256 (short *s1, unsigned char imm, short *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ {
+ r[i] = s1[(imm >> (2 * i)) & 3];
+ r[i + 8] = s1[((imm >> (2 * i)) & 3) + 8];
+ }
+
+ for (i = 4; i < 8; i++)
+ {
+ r[i] = s1[i];
+ r[i + 8] = s1[i + 8];
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, res;
+ short res_ref[16];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 1; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = j * i * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_shufflelo_epi16 (s1.x, N);
+ compute_pshuflw256 (s1.a, N, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpshuflw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpshuflw-1.c
new file mode 100644
index 00000000000..24e75625ffe
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpshuflw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpshuflw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_shufflelo_epi16 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpshuflw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpshuflw-2.c
new file mode 100644
index 00000000000..144197348d4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpshuflw-2.c
@@ -0,0 +1,52 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0xec
+
+static void
+compute_pshufhw256 (short *s1, unsigned char imm, short *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ {
+ r[i] = s1[i];
+ r[i + 8] = s1[i + 8];
+ }
+
+ for (i = 4; i < 8; i++)
+ {
+ r[i] = s1[((imm >> (2 * (i - 4))) & 3) + 4];
+ r[i + 8] = s1[((imm >> (2 * (i - 4))) & 3) + 12];
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, res;
+ short res_ref[16];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 1; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = j * i * sign;
+ sign = -sign;
+ }
+
+ res.x = _mm256_shufflehi_epi16 (s1.x, N);
+ compute_pshufhw256 (s1.a, N, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsignb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsignb-1.c
new file mode 100644
index 00000000000..6cd7ca6e85c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsignb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsignb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sign_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsignb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsignb-2.c
new file mode 100644
index 00000000000..5e3d819fea8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsignb-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psignb256 (char *s1, char *s2, char *r)
+{
+ int i;
+
+ for (i = 0; i < 32; i++)
+ if (s2[i] < 0)
+ r[i] = -s1[i];
+ else if (s2[i] == 0)
+ r[i] = 0;
+ else
+ r[i] = s1[i];
+}
+
+void static
+avx2_test (void)
+{
+ union256i_b s1, s2, res;
+ char res_ref[32];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_sign_epi8 (s1.x, s2.x);
+ compute_psignb256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_b (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsignd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsignd-1.c
new file mode 100644
index 00000000000..dab81a3b160
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsignd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsignd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sign_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsignd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsignd-2.c
new file mode 100644
index 00000000000..14e61b014ee
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsignd-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psignd256 (int *s1, int *s2, int *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ if (s2[i] < 0)
+ r[i] = -s1[i];
+ else if (s2[i] == 0)
+ r[i] = 0;
+ else
+ r[i] = s1[i];
+}
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_sign_epi32 (s1.x, s2.x);
+ compute_psignd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsignw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsignw-1.c
new file mode 100644
index 00000000000..cae04c081b4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsignw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsignw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sign_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsignw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsignw-2.c
new file mode 100644
index 00000000000..bb96a1d53d2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsignw-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psignw256 (short int *s1, short int *s2, short int *r)
+{
+ int i;
+
+ for (i = 0; i < 16; i++)
+ if (s2[i] < 0)
+ r[i] = -s1[i];
+ else if (s2[i] == 0)
+ r[i] = 0;
+ else
+ r[i] = s1[i];
+}
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short int res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_sign_epi16 (s1.x, s2.x);
+ compute_psignw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpslld-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpslld-1.c
new file mode 100644
index 00000000000..5140d7ae076
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpslld-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpslld\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m128i y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sll_epi32 (x, y);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpslld-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpslld-2.c
new file mode 100644
index 00000000000..84c68feb550
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpslld-2.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_pslld256 (int *s1, long long int *s2, int *r)
+{
+ int i;
+ long long int count = s2[0];
+
+ memset (r, 0, 32);
+
+ if (count < 32)
+ for (i = 0; i < 8; ++i)
+ r[i] = s1[i] << count;
+}
+
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, res;
+ union128i_q s2;
+ int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ s1.a[j] = j * i;
+
+ s2.a[0] = i;
+
+ res.x = _mm256_sll_epi32 (s1.x, s2.x);
+
+ compute_pslld256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpslldi-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpslldi-1.c
new file mode 100644
index 00000000000..9cea0f67563
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpslldi-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O3" } */
+/* { dg-final { scan-assembler "vpslld\[ \\t\]+\[^\n\]*\\$\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_slli_epi32 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpslldi-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpslldi-2.c
new file mode 100644
index 00000000000..dfd7d9a0386
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpslldi-2.c
@@ -0,0 +1,45 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O3 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_pslldi256 (int *s1, int *r)
+{
+ int i;
+
+ memset (r, 0, 32);
+
+ if (N < 64)
+ for (i = 0; i < 8; ++i)
+ r[i] = s1[i] << N;
+}
+
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, res;
+ int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm256_slli_epi32 (s1.x, N);
+
+ compute_pslldi256 (s1.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpslldq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpslldq-1.c
new file mode 100644
index 00000000000..5a85a7982a1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpslldq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpslldq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+extern volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_slli_si256 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpslldq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpslldq-2.c
new file mode 100644
index 00000000000..7bfb5b185f4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpslldq-2.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_pslldq256 (char *s1, char *r)
+{
+ int i;
+
+ memset (r, 0, 32);
+
+ for (i = 0; i < 16 - N; i++)
+ r[i + N] = s1[i];
+
+ for (i = 0; i < 16 - N; i++)
+ r[i + 16 + N] = s1[i + 16];
+}
+
+
+void static
+avx2_test (void)
+{
+ union256i_b s1, res;
+ char res_ref[32];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 32; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm256_slli_si256 (s1.x, N);
+
+ compute_pslldq256 (s1.a, res_ref);
+
+ fail += check_union256i_b (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllq-1.c
new file mode 100644
index 00000000000..53417a1aced
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllq-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsllq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m128i y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sll_epi64 (x, y);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllq-2.c
new file mode 100644
index 00000000000..c0ac89bfe06
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllq-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psllq256 (long long int *s1, long long int *s2, long long int *r)
+{
+ int i;
+ long long int count = s2[0];
+
+ memset (r, 0, 32);
+
+ if (count < 64)
+ for (i = 0; i < 4; ++i)
+ r[i] = s1[i] << count;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_q s1, res;
+ union128i_q s2;
+ long long int res_ref[4];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ s1.a[j] = j * i;
+
+ s2.a[0] = i;
+
+ res.x = _mm256_sll_epi64 (s1.x, s2.x);
+
+ compute_psllq256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllqi-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllqi-1.c
new file mode 100644
index 00000000000..2851be5e2a4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllqi-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O3" } */
+/* { dg-final { scan-assembler "vpsllq\[ \\t\]+\[^\n\]*\\$\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_slli_epi64 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllqi-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllqi-2.c
new file mode 100644
index 00000000000..9ef49bdb9c0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllqi-2.c
@@ -0,0 +1,45 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O3 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_psllqi256 (long long int *s1, long long int *r)
+{
+ int i;
+
+ memset (r, 0, 32);
+
+ if (N < 64)
+ for (i = 0; i < 4; ++i)
+ r[i] = s1[i] << N;
+}
+
+
+void static
+avx2_test (void)
+{
+ union256i_q s1, res;
+ long long int res_ref[4];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm256_slli_epi64 (s1.x, N);
+
+ compute_psllqi256 (s1.a, res_ref);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllvd128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllvd128-1.c
new file mode 100644
index 00000000000..b57afc4af61
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllvd128-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsllvd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_sllv_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllvd128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllvd128-2.c
new file mode 100644
index 00000000000..5ab83ae20ca
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllvd128-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psllvd128 (int *s1, int *s2, int *r)
+{
+ int i, count;
+
+ for (i = 0; i < 4; ++i)
+ {
+ count = s2[i];
+ r[i] = s1[i] << count;
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union128i_d s1, s2, res;
+ int res_ref[4];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (j + i) >> 2;
+ sign = -sign;
+ }
+
+ res.x = _mm_sllv_epi32 (s1.x, s2.x);
+
+ compute_psllvd128 (s1.a, s2.a, res_ref);
+
+ fail += check_union128i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllvd256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllvd256-1.c
new file mode 100644
index 00000000000..59063d5c44a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllvd256-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsllvd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sllv_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllvd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllvd256-2.c
new file mode 100644
index 00000000000..407a8f3c5c6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllvd256-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psllvd256 (int *s1, int *s2, int *r)
+{
+ int i, count;
+
+ for (i = 0; i < 8; ++i)
+ {
+ count = s2[i];
+ r[i] = s1[i] << count;
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ int res_ref[8];
+ int i, j, sign = 1;;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (j + i) >> 2;
+ sign = -sign;
+ }
+
+ res.x = _mm256_sllv_epi32 (s1.x, s2.x);
+
+ compute_psllvd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllvq128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllvq128-1.c
new file mode 100644
index 00000000000..245aa5508d7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllvq128-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsllvq\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_sllv_epi64 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllvq128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllvq128-2.c
new file mode 100644
index 00000000000..422ddf5bf4d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllvq128-2.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psllvq128 (long long int *s1, long long int *s2, long long int *r)
+{
+ int i;
+ long long int count;
+
+ for (i = 0; i < 2; ++i)
+ {
+ count = s2[i];
+ r[i] = s1[i] << count;
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union128i_q s1, s2, res;
+ long long int res_ref[2];
+ int i, j, sign = 2;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 2; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (j + i) >> 2;
+ sign = -sign;
+ }
+
+ res.x = _mm_sllv_epi64 (s1.x, s2.x);
+
+ compute_psllvq128 (s1.a, s2.a, res_ref);
+
+ fail += check_union128i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllvq256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllvq256-1.c
new file mode 100644
index 00000000000..caae3f2fa4b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllvq256-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsllvq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sllv_epi64 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllvq256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllvq256-2.c
new file mode 100644
index 00000000000..c41597b16f3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllvq256-2.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psllvq256 (long long int *s1, long long int *s2, long long int *r)
+{
+ int i;
+ long long int count;
+
+ for (i = 0; i < 4; ++i)
+ {
+ count = s2[i];
+ r[i] = s1[i] << count;
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_q s1, s2, res;
+ long long int res_ref[4];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (j + i) >> 2;
+ sign = -sign;
+ }
+
+ res.x = _mm256_sllv_epi64 (s1.x, s2.x);
+
+ compute_psllvq256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllw-1.c
new file mode 100644
index 00000000000..2fbc43f48b8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllw-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsllw\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m128i y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sll_epi16 (x, y);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllw-2.c
new file mode 100644
index 00000000000..1b26330ddb8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllw-2.c
@@ -0,0 +1,53 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psllw256 (short *s1, long long int *s2, short *r)
+{
+ int i;
+ int count = s2[0];
+
+ memset (r, 0, 32);
+
+ if (count < 16)
+ for (i = 0; i < 16; ++i)
+ r[i] = s1[i] << count;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, res;
+ union128i_q s2;
+ short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ s1.a[j] = j * i;
+
+ s2.a[0] = i;
+
+ res.x = _mm256_sll_epi16 (s1.x, s2.x);
+
+ compute_psllw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+
+ if (fail)
+ {
+ for (j = 0; j < 16; ++j)
+ printf ("%d <->%d\n", res.a[j], res_ref[j]);
+ abort ();
+ }
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllwi-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllwi-1.c
new file mode 100644
index 00000000000..10bd08c34b0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllwi-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O3" } */
+/* { dg-final { scan-assembler "vpsllw\[ \\t\]+\[^\n\]*\\$\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_slli_epi16 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsllwi-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsllwi-2.c
new file mode 100644
index 00000000000..f1d3e110908
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsllwi-2.c
@@ -0,0 +1,45 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O3 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_psllwi256 (short *s1, short *r)
+{
+ int i;
+
+ memset (r, 0, 32);
+
+ if (N < 16)
+ for (i = 0; i < 16; ++i)
+ r[i] = s1[i] << N;
+}
+
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, res;
+ short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm256_slli_epi16 (s1.x, N);
+
+ compute_psllwi256 (s1.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrad-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrad-1.c
new file mode 100644
index 00000000000..673398e3d54
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrad-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsrad\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m128i y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sra_epi32 (x, y);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrad-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrad-2.c
new file mode 100644
index 00000000000..39a579e4f58
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrad-2.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psrad256 (int *s1, long long int *s2, int *r)
+{
+ int i;
+ long long int count = s2[0];
+
+ memset (r, 0, 32);
+
+ if (count < 32)
+ for (i = 0; i < 8; ++i)
+ r[i] = s1[i] >> count;
+}
+
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, res;
+ union128i_q s2;
+ int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ s1.a[j] = j * i;
+
+ s2.a[0] = i;
+
+ res.x = _mm256_sra_epi32 (s1.x, s2.x);
+
+ compute_psrad256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsradi-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsradi-1.c
new file mode 100644
index 00000000000..f6bb71a57a4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsradi-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O3" } */
+/* { dg-final { scan-assembler "vpsrad\[ \\t\]+\[^\n\]*" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srai_epi32 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsradi-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsradi-2.c
new file mode 100644
index 00000000000..b9cfc7afa87
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsradi-2.c
@@ -0,0 +1,45 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O3 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_psradi256 (int *s1, int *r)
+{
+ int i;
+
+ memset (r, 0, 32);
+
+ if (N < 32)
+ for (i = 0; i < 8; ++i)
+ r[i] = s1[i] >> N;
+}
+
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, res;
+ int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm256_srai_epi16 (s1.x, N);
+
+ compute_psradi256 (s1.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsravd128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsravd128-1.c
new file mode 100644
index 00000000000..a20a8868abe
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsravd128-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsravd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_srav_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsravd128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsravd128-2.c
new file mode 100644
index 00000000000..8438d9a4417
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsravd128-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psravd128 (int *s1, int *s2, int *r)
+{
+ int i, count;
+
+ for (i = 0; i < 4; ++i)
+ {
+ count = s2[i];
+ r[i] = s1[i] >> count;
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union128i_d s1, s2, res;
+ int res_ref[4];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (j + i) >> 2;
+ sign = -sign;
+ }
+
+ res.x = _mm_srav_epi32 (s1.x, s2.x);
+
+ compute_psravd128 (s1.a, s2.a, res_ref);
+
+ fail += check_union128i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsravd256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsravd256-1.c
new file mode 100644
index 00000000000..6adf3049ba6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsravd256-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsravd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srav_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsravd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsravd256-2.c
new file mode 100644
index 00000000000..0be75205b42
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsravd256-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psravd256 (int *s1, int *s2, int *r)
+{
+ int i, count;
+
+ for (i = 0; i < 8; ++i)
+ {
+ count = s2[i];
+ r[i] = s1[i] >> count;
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ int res_ref[8];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (j + i) >> 2;
+ sign = -sign;
+ }
+
+ res.x = _mm256_srav_epi32 (s1.x, s2.x);
+
+ compute_psravd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsraw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsraw-1.c
new file mode 100644
index 00000000000..2b1c3584bf2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsraw-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O3" } */
+/* { dg-final { scan-assembler "vpsraw\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m128i y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sra_epi16 (x, y);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsraw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsraw-2.c
new file mode 100644
index 00000000000..66fe8a95cf4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsraw-2.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psraw256 (short *s1, long long int *s2, short *r)
+{
+ int i;
+ long long int count = s2[0];
+
+ memset (r, 0, 32);
+
+ if (count < 16)
+ for (i = 0; i < 16; ++i)
+ r[i] = s1[i] >> count;
+}
+
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, res;
+ union128i_q s2;
+ short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ s1.a[j] = j * i;
+
+ s2.a[0] = i;
+
+ res.x = _mm256_sra_epi16 (s1.x, s2.x);
+
+ compute_psraw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrawi-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrawi-1.c
new file mode 100644
index 00000000000..e8558c35daf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrawi-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O3" } */
+/* { dg-final { scan-assembler "vpsraw\[ \\t\]+\[^\n\]*" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srai_epi16 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrawi-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrawi-2.c
new file mode 100644
index 00000000000..c135833a468
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrawi-2.c
@@ -0,0 +1,45 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O3 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_psrawi256 (short *s1, short *r)
+{
+ int i;
+
+ memset (r, 0, 32);
+
+ if (N < 16)
+ for (i = 0; i < 16; ++i)
+ r[i] = s1[i] >> N;
+}
+
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, res;
+ short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm256_srai_epi16 (s1.x, N);
+
+ compute_psrawi256 (s1.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrld-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrld-1.c
new file mode 100644
index 00000000000..5c0605cdd25
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrld-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsrld\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m128i y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srl_epi32 (x, y);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrld-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrld-2.c
new file mode 100644
index 00000000000..1fab08cd8ba
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrld-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psrld256 (int *s1, long long int *s2, int *r)
+{
+ int i;
+ long long int count = s2[0];
+
+ memset (r, 0, 32);
+
+ if (count < 32)
+ for (i = 0; i < 8; ++i)
+ r[i] = s1[i] >> count;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, res;
+ union128i_q s2;
+ int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ s1.a[j] = j * i;
+
+ s2.a[0] = i;
+
+ res.x = _mm256_srl_epi32 (s1.x, s2.x);
+
+ compute_psrld256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrldi-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrldi-1.c
new file mode 100644
index 00000000000..feac4c92005
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrldi-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O3" } */
+/* { dg-final { scan-assembler "vpsrld\[ \\t\]+\[^\n\]*\\$\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srli_epi32 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrldi-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrldi-2.c
new file mode 100644
index 00000000000..0f109feb387
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrldi-2.c
@@ -0,0 +1,44 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O3 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_psrldi256 (int *s1, int *r)
+{
+ int i;
+
+ memset (r, 0, 32);
+
+ if (N < 64)
+ for (i = 0; i < 8; ++i)
+ r[i] = s1[i] >> N;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, res;
+ int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm256_srli_epi32 (s1.x, N);
+
+ compute_psrldi256 (s1.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrldq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrldq-1.c
new file mode 100644
index 00000000000..dd804e04f65
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrldq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsrldq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+extern volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srli_si256 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrldq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrldq-2.c
new file mode 100644
index 00000000000..4c2850903f5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrldq-2.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_psrldq256 (char *s1, char *r)
+{
+ int i;
+
+ memset (r, 0, 32);
+
+ for (i = 0; i < 16 - N; i++)
+ r[i] = s1[i + N];
+
+ for (i = 0; i < 16 - N; i++)
+ r[i + 16] = s1[i + N + 16];
+}
+
+
+void static
+avx2_test (void)
+{
+ union256i_b s1, res;
+ char res_ref[32];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 32; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm256_srli_si256 (s1.x, N);
+
+ compute_psrldq256 (s1.a, res_ref);
+
+ fail += check_union256i_b (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlq-1.c
new file mode 100644
index 00000000000..c19d067a761
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlq-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsrlq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m128i y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srl_epi64 (x, y);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlq-2.c
new file mode 100644
index 00000000000..e02da78f65f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlq-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psrlq256 (long long int *s1, long long int *s2, long long int *r)
+{
+ int i;
+ long long int count = s2[0];
+
+ memset (r, 0, 32);
+
+ if (count < 64)
+ for (i = 0; i < 4; ++i)
+ r[i] = s1[i] >> count;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_q s1, res;
+ union128i_q s2;
+ long long int res_ref[4];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ s1.a[j] = j * i;
+
+ s2.a[0] = i;
+
+ res.x = _mm256_srl_epi64 (s1.x, s2.x);
+
+ compute_psrlq256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlqi-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlqi-1.c
new file mode 100644
index 00000000000..3cab1dc0e7c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlqi-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O3" } */
+/* { dg-final { scan-assembler "vpsrlq\[ \\t\]+\[^\n\]*\\$\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srli_epi64 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlqi-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlqi-2.c
new file mode 100644
index 00000000000..1aa23fedc5d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlqi-2.c
@@ -0,0 +1,44 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O3 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_psrlqi256 (long long int *s1, long long int *r)
+{
+ int i;
+
+ memset (r, 0, 32);
+
+ if (N < 64)
+ for (i = 0; i < 4; ++i)
+ r[i] = s1[i] >> N;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_q s1, res;
+ long long int res_ref[4];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm256_srli_epi64 (s1.x, N);
+
+ compute_psrlqi256 (s1.a, res_ref);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd128-1.c
new file mode 100644
index 00000000000..d4d03584298
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd128-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsrlvd\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_srlv_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd128-2.c
new file mode 100644
index 00000000000..c7674c02cb4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd128-2.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psrlvd128 (int *s1, int *s2, int *r)
+{
+ int i, count;
+
+ for (i = 0; i < 4; ++i)
+ {
+ count = s2[i];
+ r[i] = ((unsigned) s1[i]) >> count;
+ }
+}
+
+
+void static
+avx2_test (void)
+{
+ union128i_d s1, s2, res;
+ int res_ref[4];
+ int i, j, sign;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (j + i) >> 2;
+ sign = -sign;
+ }
+
+ res.x = _mm_srlv_epi32 (s1.x, s2.x);
+
+ compute_psrlvd128 (s1.a, s2.a, res_ref);
+
+ fail += check_union128i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd256-1.c
new file mode 100644
index 00000000000..ce76c8f80f5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd256-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsrlvd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srlv_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd256-2.c
new file mode 100644
index 00000000000..e3c3c484150
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvd256-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psrlvd256 (int *s1, int *s2, int *r)
+{
+ int i, count;
+
+ for (i = 0; i < 8; ++i)
+ {
+ count = s2[i];
+ r[i] = ((unsigned) s1[i]) >> count;
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ int res_ref[8];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (j + i) >> 2;
+ sign = -sign;
+ }
+
+ res.x = _mm256_srlv_epi32 (s1.x, s2.x);
+
+ compute_psrlvd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq128-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq128-1.c
new file mode 100644
index 00000000000..64d7c28efe6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq128-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsrlvq\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+__m128i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm_srlv_epi64 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq128-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq128-2.c
new file mode 100644
index 00000000000..842559ff2d7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq128-2.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psrlvq128 (long long int *s1, long long int *s2, long long int *r)
+{
+ int i;
+ long long int count;
+
+ for (i = 0; i < 2; ++i)
+ {
+ count = s2[i];
+ r[i] = ((unsigned long long int) s1[i]) >> count;
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union128i_q s1, s2, res;
+ long long int res_ref[2];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 2; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (j + i) >> 2;
+ sign = -sign;
+ }
+
+ res.x = _mm_srlv_epi64 (s1.x, s2.x);
+
+ compute_psrlvq128 (s1.a, s2.a, res_ref);
+
+ fail += check_union128i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq256-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq256-1.c
new file mode 100644
index 00000000000..4e00736e812
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq256-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsrlvq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srlv_epi64 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq256-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq256-2.c
new file mode 100644
index 00000000000..e006d7c275a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlvq256-2.c
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psrlvq256 (long long int *s1, long long int *s2, long long int *r)
+{
+ int i;
+ long long int count;
+
+ for (i = 0; i < 4; ++i)
+ {
+ count = s2[i];
+ r[i] = ((unsigned long long) s1[i]) >> count;
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_q s1, s2, res;
+ long long int res_ref[4];
+ int i, j, sign = 1;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ s1.a[j] = j * i * sign;
+ s2.a[j] = (j + i) >> 2;
+ sign = -sign;
+ }
+
+ res.x = _mm256_srlv_epi64 (s1.x, s2.x);
+
+ compute_psrlvq256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlw-1.c
new file mode 100644
index 00000000000..f69edbc6984
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlw-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsrlw\[ \\t\]+\[^\n\]*%xmm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+__m128i y;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srl_epi16 (x, y);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlw-2.c
new file mode 100644
index 00000000000..fb7526c0e4e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlw-2.c
@@ -0,0 +1,53 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+static void
+compute_psrlw256 (short *s1, long long int *s2, short *r)
+{
+ int i;
+ int count = s2[0];
+
+ memset (r, 0, 32);
+
+ if (count < 16)
+ for (i = 0; i < 16; ++i)
+ r[i] = s1[i] >> count;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, res;
+ union128i_q s2;
+ short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ s1.a[j] = j * i;
+
+ s2.a[0] = i;
+
+ res.x = _mm256_srl_epi16 (s1.x, s2.x);
+
+ compute_psrlw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+
+ if (fail)
+ {
+ for (j = 0; j < 16; ++j)
+ printf ("%d <->%d\n", res.a[j], res_ref[j]);
+ abort ();
+ }
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlwi-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlwi-1.c
new file mode 100644
index 00000000000..823d81eb42e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlwi-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O3" } */
+/* { dg-final { scan-assembler "vpsrlw\[ \\t\]+\[^\n\]*\\$\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_srli_epi16 (x, 13);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlwi-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlwi-2.c
new file mode 100644
index 00000000000..9baf2dadca0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlwi-2.c
@@ -0,0 +1,44 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O3 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_psrlwi256 (short *s1, short *r)
+{
+ int i;
+
+ memset (r, 0, 32);
+
+ if (N < 16)
+ for (i = 0; i < 16; ++i)
+ r[i] = s1[i] >> N;
+}
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, res;
+ short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ s1.a[j] = j * i;
+
+ res.x = _mm256_srli_epi16 (s1.x, N);
+
+ compute_psrlwi256 (s1.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubb-1.c
new file mode 100644
index 00000000000..e5ccd6be8c8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsubb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sub_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubb-2.c
new file mode 100644
index 00000000000..14da9e02c13
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubb-2.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_b u, s1, s2;
+ char e[32];
+ unsigned i;
+
+ s1.x = _mm256_set_epi8 (10, 74, 50, 4, 6, 99, 1, 4, 87, 83, 84,
+ 29, 81, 79, 1, 3, 1, 5, 2, 47, 20, 2, 72,
+ 92, 9, 4, 23, 17, 99, 43, 72, 17);
+
+ s2.x = _mm256_set_epi8 (88, 44, 33, 20, 56, 99, 2, 90, 38, 4, 200,
+ 17, 3, 39, 2, 37, 27, 95, 17, 74, 72, 43,
+ 27, 112, 71, 50, 32, 72, 84, 17, 27, 96);
+
+ u.x = _mm256_sub_epi8 (s1.x, s2.x);
+
+ for (i = 0; i < 32; i++)
+ e[i] = s1.a[i] - s2.a[i];
+
+ if (check_union256i_b (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubd-1.c
new file mode 100644
index 00000000000..150f4cbcf89
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsubd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sub_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubd-2.c
new file mode 100644
index 00000000000..74a6fec01ef
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubd-2.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_d u, s1, s2;
+ int e[8];
+ unsigned i;
+
+ s1.x = _mm256_set_epi32 (100, 74, 50000, 4, 6999, 39999, 1000, 4);
+ s2.x = _mm256_set_epi32 (88, 44, 33, 220, 4556, 2999, 2, 9000000);
+
+ u.x = _mm256_sub_epi32 (s1.x, s2.x);
+
+ for (i = 0; i < 8; i++)
+ e[i] = s1.a[i] - s2.a[i];
+
+ if (check_union256i_d (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubq-1.c
new file mode 100644
index 00000000000..9460b0d84af
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsubq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_sub_epi64 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubq-2.c
new file mode 100644
index 00000000000..aa869252ae8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubq-2.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_q u, s1, s2;
+ long long e[4];
+ unsigned i;
+
+ s1.x = _mm256_set_epi64x (100, 74, 50000, 4);
+ s2.x = _mm256_set_epi64x (88, 44, 33, 220);
+
+ u.x = _mm256_sub_epi64 (s1.x, s2.x);
+
+ for (i = 0; i < 4; i++)
+ e[i] = s1.a[i] - s2.a[i];
+
+ if (check_union256i_q (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubsb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubsb-1.c
new file mode 100644
index 00000000000..ad1b986f76d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubsb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsubsb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_subs_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubsb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubsb-2.c
new file mode 100644
index 00000000000..5f33f6b89dd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubsb-2.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_b u, s1, s2;
+ char e[32];
+ int i, tmp;
+
+ s1.x = _mm256_set_epi8 (1, 2, 3, 4, 10, 20, 30, 90, -80, -40, -100,
+ -15, 98, 25, 98, 7, 88, 44, 33, 22, 11, 98,
+ 76, -100, -34, -78, -39, 6, 3, 4, 5, 119);
+
+ s2.x = _mm256_set_epi8 (88, 44, 33, 22, 11, 98, 76, -100, -34, -78,
+ -39, 6, 3, 4, 5, 119, 1, 2, 3, 4, 10, 20,
+ 30, 90, -80, -40, -100, -15, 98, 25, 98, 7);
+
+ u.x = _mm256_subs_epi8 (s1.x, s2.x);
+
+ for (i = 0; i < 32; i++)
+ {
+ tmp = s1.a[i] - s2.a[i];
+
+ if (tmp > 127)
+ tmp = 127;
+ if (tmp < -128)
+ tmp = -128;
+
+ e[i] = tmp;
+ }
+
+ if (check_union256i_b (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubsw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubsw-1.c
new file mode 100644
index 00000000000..c02d275515e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubsw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsubsw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_subs_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubsw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubsw-2.c
new file mode 100644
index 00000000000..2f2fc7d6045
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubsw-2.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_w u, s1, s2;
+ short e[16];
+ int i, tmp;
+
+ s1.x = _mm256_set_epi16 (1, 2, 3, 4, 10, 20, 30, 90, -80,
+ -40, -100, -15, 98, 25, 98, 7);
+
+ s2.x = _mm256_set_epi16 (88, 44, 33, 22, 11, 98, 76, -100,
+ -34, -78, -39, 6, 3, 4, 5, 119);
+
+ u.x = _mm256_subs_epi16 (s1.x, s2.x);
+
+ for (i = 0; i < 16; i++)
+ {
+ tmp = s1.a[i] - s2.a[i];
+
+ if (tmp > 32767)
+ tmp = 32767;
+ if (tmp < -32768)
+ tmp = -32768;
+
+ e[i] = tmp;
+ }
+
+ if (check_union256i_w (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubusb-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubusb-1.c
new file mode 100644
index 00000000000..917ffa9a89c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubusb-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsubusb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_subs_epu8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubusb-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubusb-2.c
new file mode 100644
index 00000000000..bffb5b6f52d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubusb-2.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_b u, s1, s2;
+ unsigned char e[32];
+ int i, tmp;
+
+ s1.x = _mm256_set_epi8 (1, 2, 3, 4, 10, 20, 30, 90, 80, 40, 100, 15,
+ 98, 25, 98, 7, 88, 44, 33, 22, 11, 98, 76,
+ 200, 34, 78, 39, 6, 3, 4, 5, 119);
+
+ s2.x = _mm256_set_epi8 (88, 44, 33, 220, 11, 98, 76, 100, 34, 78, 39,
+ 6, 3, 4, 5, 219, 1, 2, 3, 4, 10, 20, 30, 90,
+ 80, 40, 100, 15, 98, 25, 98, 7);
+
+ u.x = _mm256_subs_epu8 (s1.x, s2.x);
+
+ for (i = 0; i < 32; i++)
+ {
+ tmp = (unsigned char) s1.a[i] - (unsigned char) s2.a[i];
+
+ if (tmp < 0)
+ tmp = 0;
+
+ e[i] = tmp;
+ }
+
+ if (check_union256i_b (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubusw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubusw-1.c
new file mode 100644
index 00000000000..bc0e3df63cc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubusw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpsubusw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_subs_epu16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubusw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubusw-2.c
new file mode 100644
index 00000000000..7fd16400a91
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubusw-2.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ union256i_w u, s1, s2;
+ unsigned short e[16];
+ int i, tmp;
+
+ s1.x = _mm256_set_epi16 (1, 2, 3, 4, 10, 20, 30, 90,
+ 65531, 40, 100, 15, 98, 25, 98, 7);
+
+ s2.x = _mm256_set_epi16 (88, 44, 33, 220, 11, 98, 76, 100,
+ 34, 78, 39, 6, 3, 4, 5, 219);
+
+ u.x = _mm256_subs_epu16 (s1.x, s2.x);
+
+ for (i = 0; i < 16; i++)
+ {
+ tmp = (unsigned short) s1.a[i] - (unsigned short) s2.a[i];
+
+ if (tmp < 0)
+ tmp = 0;
+
+ e[i] = tmp;
+ }
+
+ if (check_union256i_w (u, e))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpckhbw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhbw-1.c
new file mode 100644
index 00000000000..2c7c9bd113c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhbw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpunpckhbw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_unpackhi_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpckhbw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhbw-2.c
new file mode 100644
index 00000000000..3d3f849340f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhbw-2.c
@@ -0,0 +1,50 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_punpckhbw256 (char *s1, char *s2, char *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ {
+ r[2 * i] = s1[i + 8];
+ r[2 * i + 1] = s2[i + 8];
+
+ r[2 * i + 16] = s1[i + 24];
+ r[2 * i + 16 + 1] = s2[i + 24];
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_b s1, s2, res;
+ char res_ref[32];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_unpackhi_epi8 (s1.x, s2.x);
+
+ compute_punpckhbw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_b (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpckhdq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhdq-1.c
new file mode 100644
index 00000000000..e1e65eae394
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhdq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpunpckhdq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_unpackhi_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpckhdq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhdq-2.c
new file mode 100644
index 00000000000..34499f01aa2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhdq-2.c
@@ -0,0 +1,50 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_punpckhwd256 (int *s1, int *s2, int *r)
+{
+ int i;
+
+ for (i = 0; i < 2; i++)
+ {
+ r[2 * i] = s1[i + 2];
+ r[2 * i + 1] = s2[i + 2];
+
+ r[2 * i + 4] = s1[i + 2 + 4];
+ r[2 * i + 4 + 1] = s2[i + 2 + 4];
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_unpackhi_epi32 (s1.x, s2.x);
+
+ compute_punpckhwd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpckhqdq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhqdq-1.c
new file mode 100644
index 00000000000..a8a5f37ad4c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhqdq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpunpckhqdq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_unpackhi_epi64 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpckhqdq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhqdq-2.c
new file mode 100644
index 00000000000..4668571c482
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhqdq-2.c
@@ -0,0 +1,44 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_punpckhqdq256 (long long int *s1, long long int *s2, long long int *r)
+{
+ r[0] = s1[1];
+ r[1] = s2[1];
+ r[2] = s1[3];
+ r[3] = s2[3];
+}
+
+void static
+avx2_test (void)
+{
+ union256i_q s1, s2, res;
+ long long int res_ref[4];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_unpackhi_epi64 (s1.x, s2.x);
+
+ compute_punpckhqdq256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpckhwd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhwd-1.c
new file mode 100644
index 00000000000..1ab034407d1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhwd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpunpckhwd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_unpackhi_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpckhwd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhwd-2.c
new file mode 100644
index 00000000000..59c4ed89c8e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpckhwd-2.c
@@ -0,0 +1,50 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_punpckhwd256 (short *s1, short *s2, short *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ {
+ r[2 * i] = s1[i + 4];
+ r[2 * i + 1] = s2[i + 4];
+
+ r[2 * i + 8] = s1[i + 4 + 8];
+ r[2 * i + 8 + 1] = s2[i + 4 + 8];
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_unpackhi_epi16 (s1.x, s2.x);
+
+ compute_punpckhwd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpcklbw-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklbw-1.c
new file mode 100644
index 00000000000..45db9a41e6d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklbw-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpunpcklbw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_unpacklo_epi8 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpcklbw-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklbw-2.c
new file mode 100644
index 00000000000..49e41212f01
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklbw-2.c
@@ -0,0 +1,50 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_punpcklbw256 (char *s1, char *s2, char *r)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ {
+ r[2 * i] = s1[i];
+ r[2 * i + 1] = s2[i];
+
+ r[2 * i + 16] = s1[i + 16];
+ r[2 * i + 16 + 1] = s2[i + 16];
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_b s1, s2, res;
+ char res_ref[32];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 32; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_unpacklo_epi8 (s1.x, s2.x);
+
+ compute_punpcklbw256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_b (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpckldq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpckldq-1.c
new file mode 100644
index 00000000000..aff815b2959
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpckldq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpunpckldq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_unpacklo_epi32 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpckldq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpckldq-2.c
new file mode 100644
index 00000000000..aba5e8092ea
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpckldq-2.c
@@ -0,0 +1,50 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_punpcklwd256 (int *s1, int *s2, int *r)
+{
+ int i;
+
+ for (i = 0; i < 2; i++)
+ {
+ r[2 * i] = s1[i];
+ r[2 * i + 1] = s2[i];
+
+ r[2 * i + 4] = s1[i + 4];
+ r[2 * i + 4 + 1] = s2[i + 4];
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_d s1, s2, res;
+ int res_ref[8];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_unpacklo_epi32 (s1.x, s2.x);
+
+ compute_punpcklwd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_d (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpcklqdq-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklqdq-1.c
new file mode 100644
index 00000000000..e8dd06da8e5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklqdq-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpunpcklqdq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_unpacklo_epi64 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpcklqdq-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklqdq-2.c
new file mode 100644
index 00000000000..1c6db718a48
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklqdq-2.c
@@ -0,0 +1,44 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_punpcklqdq256 (long long int *s1, long long int *s2, long long int *r)
+{
+ r[0] = s1[0];
+ r[1] = s2[0];
+ r[2] = s1[2];
+ r[3] = s2[2];
+}
+
+void static
+avx2_test (void)
+{
+ union256i_q s1, s2, res;
+ long long int res_ref[4];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_unpacklo_epi64 (s1.x, s2.x);
+
+ compute_punpcklqdq256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_q (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpcklwd-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklwd-1.c
new file mode 100644
index 00000000000..6bcdf9bf94b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklwd-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpunpcklwd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_unpacklo_epi16 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpunpcklwd-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklwd-2.c
new file mode 100644
index 00000000000..9f6f9c0d66a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpunpcklwd-2.c
@@ -0,0 +1,50 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-options "-O2 -mavx2" } */
+
+#include <string.h>
+#include "avx2-check.h"
+
+#define N 0x5
+
+static void
+compute_punpcklwd256 (short *s1, short *s2, short *r)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ {
+ r[2 * i] = s1[i];
+ r[2 * i + 1] = s2[i];
+
+ r[2 * i + 8] = s1[i + 8];
+ r[2 * i + 8 + 1] = s2[i + 8];
+ }
+}
+
+void static
+avx2_test (void)
+{
+ union256i_w s1, s2, res;
+ short res_ref[16];
+ int i, j;
+ int fail = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ s1.a[j] = j * i;
+ s2.a[j] = j + 20;
+ }
+
+ res.x = _mm256_unpacklo_epi16 (s1.x, s2.x);
+
+ compute_punpcklwd256 (s1.a, s2.a, res_ref);
+
+ fail += check_union256i_w (res, res_ref);
+ }
+
+ if (fail != 0)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpxor-1.c b/gcc/testsuite/gcc.target/i386/avx2-vpxor-1.c
new file mode 100644
index 00000000000..cfd43b0fc4c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpxor-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O2" } */
+/* { dg-final { scan-assembler "vpxor\[ \\t\]+\[^\n\]*%ymm\[0-9\]" } } */
+
+#include <immintrin.h>
+
+volatile __m256i x;
+
+void extern
+avx2_test (void)
+{
+ x = _mm256_xor_si256 (x, x);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpxor-2.c b/gcc/testsuite/gcc.target/i386/avx2-vpxor-2.c
new file mode 100644
index 00000000000..be326449825
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx2-vpxor-2.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -mavx2" } */
+/* { dg-require-effective-target avx2 } */
+
+#include "avx2-check.h"
+
+void static
+avx2_test (void)
+{
+ int i;
+ union256i_q u, s1, s2;
+ int source1[8] = { 34545, 95567, 23443, 5675, 2323, 67, 2345, 45667 };
+ int source2[8] = { 674, 57897, 93459, 45624, 54674, 1237, 67436, 79608 };
+ int d[8];
+ int e[8];
+
+ s1.x = _mm256_loadu_si256 ((__m256i *) source1);
+ s2.x = _mm256_loadu_si256 ((__m256i *) source2);
+ u.x = _mm256_xor_si256 (s1.x, s2.x);
+
+ _mm256_storeu_si256 ((__m256i *) d, u.x);
+
+ for (i = 0; i < 8; i++)
+ e[i] = source1[i] ^ source2[i];
+
+ if (checkVi (d, e, 8))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.target/i386/funcspec-5.c b/gcc/testsuite/gcc.target/i386/funcspec-5.c
index 8dd17e5ab09..df97a2d7bdb 100644
--- a/gcc/testsuite/gcc.target/i386/funcspec-5.c
+++ b/gcc/testsuite/gcc.target/i386/funcspec-5.c
@@ -20,6 +20,8 @@ extern void test_sse4a (void) __attribute__((__target__("sse4a")));
extern void test_fma4 (void) __attribute__((__target__("fma4")));
extern void test_ssse3 (void) __attribute__((__target__("ssse3")));
extern void test_tbm (void) __attribute__((__target__("tbm")));
+extern void test_avx (void) __attribute__((__target__("avx")));
+extern void test_avx2 (void) __attribute__((__target__("avx2")));
extern void test_no_abm (void) __attribute__((__target__("no-abm")));
extern void test_no_aes (void) __attribute__((__target__("no-aes")));
@@ -38,6 +40,8 @@ extern void test_no_sse4a (void) __attribute__((__target__("no-sse4a")));
extern void test_no_fma4 (void) __attribute__((__target__("no-fma4")));
extern void test_no_ssse3 (void) __attribute__((__target__("no-ssse3")));
extern void test_no_tbm (void) __attribute__((__target__("no-tbm")));
+extern void test_no_avx (void) __attribute__((__target__("no-avx")));
+extern void test_no_avx2 (void) __attribute__((__target__("no-avx2")));
extern void test_arch_i386 (void) __attribute__((__target__("arch=i386")));
extern void test_arch_i486 (void) __attribute__((__target__("arch=i486")));
diff --git a/gcc/testsuite/gcc.target/i386/funcspec-6.c b/gcc/testsuite/gcc.target/i386/funcspec-6.c
index 62818d902f9..e28b38c4400 100644
--- a/gcc/testsuite/gcc.target/i386/funcspec-6.c
+++ b/gcc/testsuite/gcc.target/i386/funcspec-6.c
@@ -19,6 +19,8 @@ extern void test_sse4a (void) __attribute__((__target__("sse4a")));
extern void test_fma4 (void) __attribute__((__target__("fma4")));
extern void test_ssse3 (void) __attribute__((__target__("ssse3")));
extern void test_tbm (void) __attribute__((__target__("tbm")));
+extern void test_avx (void) __attribute__((__target__("avx")));
+extern void test_avx2 (void) __attribute__((__target__("avx2")));
extern void test_no_abm (void) __attribute__((__target__("no-abm")));
extern void test_no_aes (void) __attribute__((__target__("no-aes")));
@@ -37,6 +39,8 @@ extern void test_no_sse4a (void) __attribute__((__target__("no-sse4a")));
extern void test_no_fma4 (void) __attribute__((__target__("no-fma4")));
extern void test_no_ssse3 (void) __attribute__((__target__("no-ssse3")));
extern void test_no_tbm (void) __attribute__((__target__("no-tbm")));
+extern void test_no_avx (void) __attribute__((__target__("no-avx")));
+extern void test_no_avx2 (void) __attribute__((__target__("no-avx2")));
extern void test_arch_nocona (void) __attribute__((__target__("arch=nocona")));
extern void test_arch_core2 (void) __attribute__((__target__("arch=core2")));
diff --git a/gcc/testsuite/gcc.target/i386/i386.exp b/gcc/testsuite/gcc.target/i386/i386.exp
index cff8a9a3cba..6517d45bfdd 100644
--- a/gcc/testsuite/gcc.target/i386/i386.exp
+++ b/gcc/testsuite/gcc.target/i386/i386.exp
@@ -196,6 +196,18 @@ proc check_effective_target_lzcnt { } {
} "-mlzcnt" ]
}
+# Return 1 if avx2 instructions can be compiled.
+proc check_effective_target_avx2 { } {
+ return [check_no_compiler_messages avx2 object {
+ typedef long long __v4di __attribute__ ((__vector_size__ (32)));
+ __v4di
+ mm256_is32_andnotsi256 (__v4di __X, __v4di __Y)
+ {
+ return __builtin_ia32_andnotsi256 (__X, __Y);
+ }
+ } "-O0 -mavx2" ]
+}
+
# Return 1 if bmi instructions can be compiled.
proc check_effective_target_bmi { } {
return [check_no_compiler_messages bmi object {
diff --git a/gcc/testsuite/gcc.target/i386/sse-12.c b/gcc/testsuite/gcc.target/i386/sse-12.c
index db949839eed..9f3713c6808 100644
--- a/gcc/testsuite/gcc.target/i386/sse-12.c
+++ b/gcc/testsuite/gcc.target/i386/sse-12.c
@@ -3,7 +3,7 @@
popcntintrin.h and mm_malloc.h are usable
with -O -std=c89 -pedantic-errors. */
/* { dg-do compile } */
-/* { dg-options "-O -std=c89 -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c" } */
+/* { dg-options "-O -std=c89 -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c" } */
#include <x86intrin.h>
diff --git a/gcc/testsuite/gcc.target/i386/sse-13.c b/gcc/testsuite/gcc.target/i386/sse-13.c
index 6b02df7b4ba..134905d54fe 100644
--- a/gcc/testsuite/gcc.target/i386/sse-13.c
+++ b/gcc/testsuite/gcc.target/i386/sse-13.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8 -msse4a -m3dnow -mavx -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c" } */
+/* { dg-options "-O2 -Werror-implicit-function-declaration -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c" } */
#include <mm_malloc.h>
@@ -147,5 +147,37 @@
#define __builtin_ia32_bextri_u32(X, Y) __builtin_ia32_bextri_u32 (X, 1)
#define __builtin_ia32_bextri_u64(X, Y) __builtin_ia32_bextri_u64 (X, 1)
+/* avx2intrin.h */
+#define __builtin_ia32_mpsadbw256(X, Y, Z) __builtin_ia32_mpsadbw256 (X, Y, 1)
+#define __builtin_ia32_palignr256(X, Y, Z) __builtin_ia32_palignr256 (X, Y, 8)
+#define __builtin_ia32_pblendw256(X, Y, Z) __builtin_ia32_pblendw256 (X, Y, 1)
+#define __builtin_ia32_pshufd256(X, Y) __builtin_ia32_pshufd256(X, 1)
+#define __builtin_ia32_pshufhw256(X, Y) __builtin_ia32_pshufhw256(X, 1)
+#define __builtin_ia32_pshuflw256(X, Y) __builtin_ia32_pshuflw256(X, 1)
+#define __builtin_ia32_pslldqi256(X, Y) __builtin_ia32_pslldqi256(X, 8)
+#define __builtin_ia32_psrldqi256(X, Y) __builtin_ia32_psrldqi256(X, 8)
+#define __builtin_ia32_pblendd128(X, Y, Z) __builtin_ia32_pblendd128(X, Y, 1)
+#define __builtin_ia32_pblendd256(X, Y, Z) __builtin_ia32_pblendd256(X, Y, 1)
+#define __builtin_ia32_permdf256(X, Y) __builtin_ia32_permdf256(X, 1)
+#define __builtin_ia32_permdi256(X, Y) __builtin_ia32_permdi256(X, 1)
+#define __builtin_ia32_permti256(X, Y, Z) __builtin_ia32_permti256(X, Y, 1)
+#define __builtin_ia32_extract128i256(X, Y) __builtin_ia32_extract128i256(X, 1)
+#define __builtin_ia32_insert128i256(X, Y, Z) __builtin_ia32_insert128i256(X, Y, 1)
+#define __builtin_ia32_gathersiv2df(X, Y, Z, K, M) __builtin_ia32_gathersiv2df(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv4df(X, Y, Z, K, M) __builtin_ia32_gathersiv4df(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv2df(X, Y, Z, K, M) __builtin_ia32_gatherdiv2df(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4df(X, Y, Z, K, M) __builtin_ia32_gatherdiv4df(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv4sf(X, Y, Z, K, M) __builtin_ia32_gathersiv4sf(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv8sf(X, Y, Z, K, M) __builtin_ia32_gathersiv8sf(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4sf(X, Y, Z, K, M) __builtin_ia32_gatherdiv4sf(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4sf256(X, Y, Z, K, M) __builtin_ia32_gatherdiv4sf256(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv2di(X, Y, Z, K, M) __builtin_ia32_gathersiv2di(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv4di(X, Y, Z, K, M) __builtin_ia32_gathersiv4di(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv2di(X, Y, Z, K, M) __builtin_ia32_gatherdiv2di(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4di(X, Y, Z, K, M) __builtin_ia32_gatherdiv4di(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv4si(X, Y, Z, K, M) __builtin_ia32_gathersiv4si(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv8si(X, Y, Z, K, M) __builtin_ia32_gathersiv8si(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4si(X, Y, Z, K, M) __builtin_ia32_gatherdiv4si(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4si256(X, Y, Z, K, M) __builtin_ia32_gatherdiv4si256(X, Y, Z, K, 1)
#include <x86intrin.h>
diff --git a/gcc/testsuite/gcc.target/i386/sse-14.c b/gcc/testsuite/gcc.target/i386/sse-14.c
index e5216b1aeaa..c1f10f1648e 100644
--- a/gcc/testsuite/gcc.target/i386/sse-14.c
+++ b/gcc/testsuite/gcc.target/i386/sse-14.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O0 -Werror-implicit-function-declaration -march=k8 -msse4a -m3dnow -mavx -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c" } */
+/* { dg-options "-O0 -Werror-implicit-function-declaration -march=k8 -msse4a -m3dnow -mavx -mavx2 -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mlzcnt -mbmi -mbmi2 -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c" } */
#include <mm_malloc.h>
diff --git a/gcc/testsuite/gcc.target/i386/sse-21.c b/gcc/testsuite/gcc.target/i386/sse-21.c
index ca4c114d8bb..d006cdc0a46 100644
--- a/gcc/testsuite/gcc.target/i386/sse-21.c
+++ b/gcc/testsuite/gcc.target/i386/sse-21.c
@@ -1,6 +1,6 @@
/* Test that we don't generate a fisttp instruction when -mno-sse3. */
/* { dg-do compile } */
-/* { dg-options "-O -mfpmath=387 -march=nocona -mno-sse3" } */
+/* { dg-options "-O -mfpmath=387 -march=nocona -mno-sse3 -mno-avx" } */
/* { dg-final { scan-assembler-not "fisttp" } } */
struct foo
{
diff --git a/gcc/testsuite/gcc.target/i386/sse-22.c b/gcc/testsuite/gcc.target/i386/sse-22.c
index 4660ba0b15a..5b45c485f55 100644
--- a/gcc/testsuite/gcc.target/i386/sse-22.c
+++ b/gcc/testsuite/gcc.target/i386/sse-22.c
@@ -46,7 +46,7 @@
#ifndef DIFFERENT_PRAGMAS
-#pragma GCC target ("sse4a,3dnow,avx,fma4,xop,aes,pclmul,popcnt,abm,lzcnt,bmi,bmi2,tbm,lwp,fsgsbase,rdrnd,f16c")
+#pragma GCC target ("sse4a,3dnow,avx,avx2,fma4,xop,aes,pclmul,popcnt,abm,lzcnt,bmi,bmi2,tbm,lwp,fsgsbase,rdrnd,f16c")
#endif
/* Following intrinsics require immediate arguments. They
@@ -159,7 +159,7 @@ test_4 (_mm_cmpestro, int, __m128i, int, __m128i, int, 1)
test_4 (_mm_cmpestrs, int, __m128i, int, __m128i, int, 1)
test_4 (_mm_cmpestrz, int, __m128i, int, __m128i, int, 1)
-/* immintrin.h (AVX/RDRND/FSGSBASE/F16C) */
+/* immintrin.h (AVX/AVX2/RDRND/FSGSBASE/F16C) */
#ifdef DIFFERENT_PRAGMAS
#pragma GCC target ("avx,rdrnd,fsgsbase,f16c")
#endif
@@ -248,3 +248,36 @@ test_1 ( __bextri_u32, unsigned int, unsigned int, 1)
#ifdef __x86_64__
test_1 ( __bextri_u64, unsigned long long, unsigned long long, 1)
#endif
+
+/* avx2intrin.h */
+test_2 ( _mm256_mpsadbw_epu8, __m256i, __m256i, __m256i, 1)
+test_2 ( _mm256_alignr_epi8, __m256i, __m256i, __m256i, 1)
+test_2 ( _mm256_blend_epi16, __m256i, __m256i, __m256i, 1)
+test_1 ( _mm256_shuffle_epi32, __m256i, __m256i, 1)
+test_1 ( _mm256_shufflehi_epi16, __m256i, __m256i, 1)
+test_1 ( _mm256_shufflelo_epi16, __m256i, __m256i, 1)
+test_1 ( _mm256_slli_si256, __m256i, __m256i, 8)
+test_1 ( _mm256_srli_si256, __m256i, __m256i, 8)
+test_2 ( _mm_blend_epi32, __m128i, __m128i, __m128i, 1)
+test_2 ( _mm256_blend_epi32, __m256i, __m256i, __m256, 1)
+test_1 ( _mm256_permute4x64_pd, __m256d, __m256d, 1)
+test_1 ( _mm256_permute4x64_epi64, __m256i, __m256i, 1)
+test_2 ( _mm256_permute2x128_si256, __m256i, __m256i, __m256i, 1)
+test_1 ( _mm256_extracti128_si256, __m128i, __m256i, 1)
+test_2 ( _mm256_inserti128_si256, __m256i, __m256i, __m128i, 1)
+test_2 ( _mm_i32gather_pd, __m128d, double const *, __m128i, 1)
+test_2 ( _mm256_i32gather_pd, __m256d, double const *, __m128i, 1)
+test_2 ( _mm_i64gather_pd, __m128d, double const *, __m128i, 1)
+test_2 ( _mm256_i64gather_pd, __m256d, double const *, __m256i, 1)
+test_2 ( _mm_i32gather_ps, __m128, float const *, __m128i, 1)
+test_2 ( _mm256_i32gather_ps, __m256, float const *, __m256i, 1)
+test_2 ( _mm_i64gather_ps, __m128, float const *, __m128i, 1)
+test_2 ( _mm256_i64gather_ps, __m128, float const *, __m256i, 1)
+test_2 ( _mm_i32gather_epi64, __m128i, long long int const *, __m128i, 1)
+test_2 ( _mm256_i32gather_epi64, __m256i, long long int const *, __m128i, 1)
+test_2 ( _mm_i64gather_epi64, __m128i, long long int const *, __m128i, 1)
+test_2 ( _mm256_i64gather_epi64, __m256i, long long int const *, __m256i, 1)
+test_2 ( _mm_i32gather_epi32, __m128i, int const *, __m128i, 1)
+test_2 ( _mm256_i32gather_epi32, __m256i, int const *, __m256i, 1)
+test_2 ( _mm_i64gather_epi32, __m128i, int const *, __m128i, 1)
+test_2 ( _mm256_i64gather_epi32, __m128i, int const *, __m256i, 1)
diff --git a/gcc/testsuite/gcc.target/i386/sse-23.c b/gcc/testsuite/gcc.target/i386/sse-23.c
index b2e52550c16..ef2471c7133 100644
--- a/gcc/testsuite/gcc.target/i386/sse-23.c
+++ b/gcc/testsuite/gcc.target/i386/sse-23.c
@@ -147,7 +147,40 @@
#define __builtin_ia32_bextri_u32(X, Y) __builtin_ia32_bextr_u32 (X, 1)
#define __builtin_ia32_bextri_u64(X, Y) __builtin_ia32_bextr_u64 (X, 1)
-#pragma GCC target ("sse4a,3dnow,avx,fma4,xop,aes,pclmul,popcnt,abm,lzcnt,bmi,bmi2,tbm,lwp,fsgsbase,rdrnd,f16c")
+/* avx2intrin.h */
+#define __builtin_ia32_mpsadbw256(X, Y, Z) __builtin_ia32_mpsadbw256 (X, Y, 1)
+#define __builtin_ia32_palignr256(X, Y, Z) __builtin_ia32_palignr256 (X, Y, 8)
+#define __builtin_ia32_pblendw256(X, Y, Z) __builtin_ia32_pblendw256 (X, Y, 1)
+#define __builtin_ia32_pshufd256(X, Y) __builtin_ia32_pshufd256(X, 1)
+#define __builtin_ia32_pshufhw256(X, Y) __builtin_ia32_pshufhw256(X, 1)
+#define __builtin_ia32_pshuflw256(X, Y) __builtin_ia32_pshuflw256(X, 1)
+#define __builtin_ia32_pslldqi256(X, Y) __builtin_ia32_pslldqi256(X, 8)
+#define __builtin_ia32_psrldqi256(X, Y) __builtin_ia32_psrldqi256(X, 8)
+#define __builtin_ia32_pblendd128(X, Y, Z) __builtin_ia32_pblendd128(X, Y, 1)
+#define __builtin_ia32_pblendd256(X, Y, Z) __builtin_ia32_pblendd256(X, Y, 1)
+#define __builtin_ia32_permdf256(X, Y) __builtin_ia32_permdf256(X, 1)
+#define __builtin_ia32_permdi256(X, Y) __builtin_ia32_permdi256(X, 1)
+#define __builtin_ia32_permti256(X, Y, Z) __builtin_ia32_permti256(X, Y, 1)
+#define __builtin_ia32_extract128i256(X, Y) __builtin_ia32_extract128i256(X, 1)
+#define __builtin_ia32_insert128i256(X, Y, Z) __builtin_ia32_insert128i256(X, Y, 1)
+#define __builtin_ia32_gathersiv2df(X, Y, Z, K, M) __builtin_ia32_gathersiv2df(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv4df(X, Y, Z, K, M) __builtin_ia32_gathersiv4df(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv2df(X, Y, Z, K, M) __builtin_ia32_gatherdiv2df(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4df(X, Y, Z, K, M) __builtin_ia32_gatherdiv4df(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv4sf(X, Y, Z, K, M) __builtin_ia32_gathersiv4sf(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv8sf(X, Y, Z, K, M) __builtin_ia32_gathersiv8sf(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4sf(X, Y, Z, K, M) __builtin_ia32_gatherdiv4sf(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4sf256(X, Y, Z, K, M) __builtin_ia32_gatherdiv4sf256(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv2di(X, Y, Z, K, M) __builtin_ia32_gathersiv2di(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv4di(X, Y, Z, K, M) __builtin_ia32_gathersiv4di(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv2di(X, Y, Z, K, M) __builtin_ia32_gatherdiv2di(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4di(X, Y, Z, K, M) __builtin_ia32_gatherdiv4di(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv4si(X, Y, Z, K, M) __builtin_ia32_gathersiv4si(X, Y, Z, K, 1)
+#define __builtin_ia32_gathersiv8si(X, Y, Z, K, M) __builtin_ia32_gathersiv8si(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4si(X, Y, Z, K, M) __builtin_ia32_gatherdiv4si(X, Y, Z, K, 1)
+#define __builtin_ia32_gatherdiv4si256(X, Y, Z, K, M) __builtin_ia32_gatherdiv4si256(X, Y, Z, K, 1)
+
+#pragma GCC target ("sse4a,3dnow,avx,avx2,fma4,xop,aes,pclmul,popcnt,abm,lzcnt,bmi,bmi2,tbm,lwp,fsgsbase,rdrnd,f16c")
#include <wmmintrin.h>
#include <smmintrin.h>
#include <mm3dnow.h>
diff --git a/gcc/testsuite/gcc.target/i386/testimm-9.c b/gcc/testsuite/gcc.target/i386/testimm-9.c
new file mode 100644
index 00000000000..a9b4fe9e3bb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/testimm-9.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -mavx2" } */
+
+#include <x86intrin.h>
+
+__m128i i1, i2, i3, i4;
+__m256i l1, l2, l3, l4;
+__m256d e1, e2, e3, e4;
+
+void
+test8bit (void)
+{
+ l1 = _mm256_mpsadbw_epu8 (l2, l3, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ l1 = _mm256_alignr_epi8 (l2, l3, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ i1 = _mm_blend_epi32 (i1, i1, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ l1 = _mm256_blend_epi32 (l2, l3, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ l1 = _mm256_blend_epi16(l2, l3, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ l1 = _mm256_permute2x128_si256 (l2, l3, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ e1 = _mm256_permute4x64_pd (e2, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ l1 = _mm256_permute4x64_epi64 (l2, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ l1 = _mm256_shuffle_epi32 (l2, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ l1 = _mm256_shufflehi_epi16 (l2, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ l1 = _mm256_shufflelo_epi16 (l2, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ l1 = _mm256_slli_si256 (l2, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+ l1 = _mm256_srli_si256 (l2, 256); /* { dg-error "the last argument must be an 8-bit immediate" } */
+}
+
+void
+test1bit (void)
+{
+ i1 = _mm256_extracti128_si256 (l1, 2); /* { dg-error "the last argument must be an 1-bit immediate" } */
+ l1 = _mm256_inserti128_si256 (l1, i2, 2); /* { dg-error "the last argument must be an 1-bit immediate" } */
+}