From: Uros Bizjak Date: Wed, 23 Jan 2019 19:10:58 +0000 (+0100) Subject: re PR target/88998 (bad codegen with mmx instructions for unordered_map) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3274c5a342cee8da86682f9dc8a320c1d8df565a;p=gcc.git re PR target/88998 (bad codegen with mmx instructions for unordered_map) PR target/88998 * config/i386/sse.md (sse2_cvtpi2pd): Add SSE alternatives. Disparage MMX alternative. (sse2_cvtpd2pi): Ditto. (sse2_cvttpd2pi): Ditto. testsuite/ChangeLog: PR target/88998 * g++.target/i386/pr88998.c: New test. From-SVN: r268195 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 312a04f18cb..5befc93d0ef 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-01-23 Uroš Bizjak + + PR target/88998 + * config/i386/sse.md (sse2_cvtpi2pd): Add SSE alternatives. + Disparage MMX alternative. + (sse2_cvtpd2pi): Ditto. + (sse2_cvttpd2pi): Ditto. + 2019-01-23 David Malcolm PR driver/89014 diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 3af4adc63dd..a027de43268 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -4997,37 +4997,49 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define_insn "sse2_cvtpi2pd" - [(set (match_operand:V2DF 0 "register_operand" "=x,x") - (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand" "y,m")))] + [(set (match_operand:V2DF 0 "register_operand" "=v,x") + (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand" "vBm,?!y")))] "TARGET_SSE2" - "cvtpi2pd\t{%1, %0|%0, %1}" + "@ + %vcvtdq2pd\t{%1, %0|%0, %1} + cvtpi2pd\t{%1, %0|%0, %1}" [(set_attr "type" "ssecvt") - (set_attr "unit" "mmx,*") - (set_attr "prefix_data16" "1,*") + (set_attr "unit" "*,mmx") + (set_attr "prefix_data16" "*,1") + (set_attr "prefix" "maybe_vex,*") (set_attr "mode" "V2DF")]) (define_insn "sse2_cvtpd2pi" - [(set (match_operand:V2SI 0 "register_operand" "=y") - (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")] + [(set (match_operand:V2SI 0 "register_operand" "=v,?!y") + (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "vBm,xm")] UNSPEC_FIX_NOTRUNC))] "TARGET_SSE2" - "cvtpd2pi\t{%1, %0|%0, %1}" + "@ + * return TARGET_AVX ? \"vcvtpd2dq{x}\t{%1, %0|%0, %1}\" : \"cvtpd2dq\t{%1, %0|%0, %1}\"; + cvtpd2pi\t{%1, %0|%0, %1}" [(set_attr "type" "ssecvt") - (set_attr "unit" "mmx") + (set_attr "unit" "*,mmx") + (set_attr "amdfam10_decode" "double") + (set_attr "athlon_decode" "vector") (set_attr "bdver1_decode" "double") - (set_attr "btver2_decode" "direct") - (set_attr "prefix_data16" "1") - (set_attr "mode" "DI")]) + (set_attr "prefix_data16" "*,1") + (set_attr "prefix" "maybe_vex,*") + (set_attr "mode" "TI")]) (define_insn "sse2_cvttpd2pi" - [(set (match_operand:V2SI 0 "register_operand" "=y") - (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm")))] + [(set (match_operand:V2SI 0 "register_operand" "=v,?!y") + (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "vBm,xm")))] "TARGET_SSE2" - "cvttpd2pi\t{%1, %0|%0, %1}" + "@ + * return TARGET_AVX ? \"vcvttpd2dq{x}\t{%1, %0|%0, %1}\" : \"cvttpd2dq\t{%1, %0|%0, %1}\"; + cvttpd2pi\t{%1, %0|%0, %1}" [(set_attr "type" "ssecvt") - (set_attr "unit" "mmx") + (set_attr "unit" "*,mmx") + (set_attr "amdfam10_decode" "double") + (set_attr "athlon_decode" "vector") (set_attr "bdver1_decode" "double") - (set_attr "prefix_data16" "1") + (set_attr "prefix_data16" "*,1") + (set_attr "prefix" "maybe_vex,*") (set_attr "mode" "TI")]) (define_insn "sse2_cvtsi2sd" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b0b1afa9cf0..977009dc7f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-23 Uroš Bizjak + + PR target/88998 + * g++.target/i386/pr88998.c: New test. + 2019-01-23 Marek Polacek PR c++/88757 - qualified name treated wrongly as type. diff --git a/gcc/testsuite/g++.target/i386/pr88998.C b/gcc/testsuite/g++.target/i386/pr88998.C new file mode 100644 index 00000000000..4ac54ff71ed --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr88998.C @@ -0,0 +1,31 @@ +// PR target/88998 +// { dg-do run { target sse2_runtime } } +// { dg-options "-O2 -msse2 -mfpmath=387" } +// { dg-require-effective-target c++11 } + +#include +#include +#include + +double +__attribute__((noinline)) +prepare (int a, int b) +{ + __m128i is = _mm_setr_epi32 (a, b, 0, 0); + __m128d ds = _mm_cvtepi32_pd (is); + return ds[0] + ds[1]; +} + +int +main (int, char **) +{ + double d = prepare (1, 2); + + std::unordered_map < int, int >m; + m.insert ({0, 0}); + m.insert ({1, 1}); + assert (m.load_factor () <= m.max_load_factor ()); + + assert (d == 3); + return 0; +}