From: Uros Bizjak Date: Mon, 12 Jul 2021 19:06:32 +0000 (+0200) Subject: i386: Fix vec_set expanders [PR101424] X-Git-Tag: basepoints/gcc-13~6054 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d980e84240c82502661758fbecd5f456018ea89;p=thirdparty%2Fgcc.git i386: Fix vec_set expanders [PR101424] AVX does not support 32-byte integer compares, required by ix86_expand_vector_set_var. The following patch fixes vec_set expanders by introducing new vec_setm_avx2_operand predicate for AVX vector modes. gcc/ 2021-07-12 Uroš Bizjak PR target/101424 * config/i386/predicates.md (vec_setm_sse41_operand): Rename from vec_setm_operand. (vec_setm_avx2_operand): New predicate. * config/i386/sse.md (vec_set): Use V_128 mode iterator. Use vec_setm_sse41_operand as operand 2 predicate. (vec_set PR target/101424 * gcc.target/i386/pr101424.c: New test. --- diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md index 986b758396a4..0984f7cc44dc 100644 --- a/gcc/config/i386/mmx.md +++ b/gcc/config/i386/mmx.md @@ -3604,7 +3604,7 @@ (define_expand "vec_setv2hi" [(match_operand:V2HI 0 "register_operand") (match_operand:HI 1 "register_operand") - (match_operand 2 "vec_setm_operand")] + (match_operand 2 "vec_setm_sse41_operand")] "TARGET_SSE2" { if (CONST_INT_P (operands[2])) diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 9488632ce24a..6aa1ea326270 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -1021,11 +1021,16 @@ }) ;; True for registers, or const_int_operand, used to vec_setm expander. -(define_predicate "vec_setm_operand" +(define_predicate "vec_setm_sse41_operand" (ior (and (match_operand 0 "register_operand") (match_test "TARGET_SSE4_1")) (match_code "const_int"))) +(define_predicate "vec_setm_avx2_operand" + (ior (and (match_operand 0 "register_operand") + (match_test "TARGET_AVX2")) + (match_code "const_int"))) + (define_predicate "vec_setm_mmx_operand" (ior (and (match_operand 0 "register_operand") (match_test "TARGET_SSE4_1") diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 17c9e571d5d7..ab29999023dc 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -8486,9 +8486,9 @@ (set_attr "mode" "DF")]) (define_expand "vec_set" - [(match_operand:V 0 "register_operand") + [(match_operand:V_128 0 "register_operand") (match_operand: 1 "register_operand") - (match_operand 2 "vec_setm_operand")] + (match_operand 2 "vec_setm_sse41_operand")] "TARGET_SSE" { if (CONST_INT_P (operands[2])) @@ -8499,6 +8499,20 @@ DONE; }) +(define_expand "vec_set" + [(match_operand:V_256_512 0 "register_operand") + (match_operand: 1 "register_operand") + (match_operand 2 "vec_setm_avx2_operand")] + "TARGET_AVX" +{ + if (CONST_INT_P (operands[2])) + ix86_expand_vector_set (false, operands[0], operands[1], + INTVAL (operands[2])); + else + ix86_expand_vector_set_var (operands[0], operands[1], operands[2]); + DONE; +}) + (define_insn_and_split "*vec_extractv4sf_0" [(set (match_operand:SF 0 "nonimmediate_operand" "=v,m,f,r") (vec_select:SF diff --git a/gcc/testsuite/gcc.target/i386/pr101424.c b/gcc/testsuite/gcc.target/i386/pr101424.c new file mode 100644 index 000000000000..28bb7230e471 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr101424.c @@ -0,0 +1,15 @@ +/* PR target/101424 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ + +typedef int v4df __attribute__((vector_size(32))); + +int foo_v4df_b, foo_v4df_c; + +v4df +__attribute__foo_v4df () +{ + v4df a; + a[foo_v4df_c] = foo_v4df_b; + return a; +}