public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH]i386: Optimize pmovskb on zero_extend of subreg HI of the result [PR98461]
@ 2021-01-04  5:56 Hongtao Liu
  2021-01-04  7:40 ` Uros Bizjak
  2021-01-04  8:49 ` Jakub Jelinek
  0 siblings, 2 replies; 11+ messages in thread
From: Hongtao Liu @ 2021-01-04  5:56 UTC (permalink / raw)
  To: GCC Patches, Kirill Yukhin, Uros Bizjak; +Cc: H. J. Lu, Jakub Jelinek

Hi:
  The following patch adds define_insn_and_split to optimize

       vpmovmskb       %xmm0, %eax
-       movzwl  %ax, %eax
        notl    %eax

  Bootstrapped/regtested on x86_64-linux-gnu {,-m32}.
  Ok for trunk?

gcc/ChangeLog
        PR target/98461
        * config/i386/sse.md (*sse2_pmovskb_zexthisi): New
        define_insn_and_split for zero_extend of subreg HI of pmovskb
        result.

gcc/testsuite/ChangeLog
        * gcc.target/i386/sse-pr98461-2.c: New test.
---
 gcc/config/i386/sse.md                         | 11 +++++++++++
 gcc/testsuite/gcc.target/i386/sse2-pr98461-2.c | 13 +++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/sse2-pr98461-2.c

diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index d84103807ff..4ed6b9ae476 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -16099,6 +16099,17 @@ (define_insn "*sse2_pmovmskb_ext"
    (set_attr "prefix" "maybe_vex")
    (set_attr "mode" "SI")])

+(define_insn_and_split "*sse2_pmovskb_zexthisi"
+  [(set (match_operand:SI 0 "register_operand")
+       (zero_extend:SI (subreg:HI (unspec:SI
+         [(match_operand:V16QI 1 "register_operand")]
+          UNSPEC_MOVMSK) 0)))]
+  "TARGET_SSE2"
+  "#"
+  "&& 1"
+  [(set (match_dup 0)
+       (unspec:SI [(match_dup 1)] UNSPEC_MOVMSK))])
+
 (define_split
   [(set (match_operand:SI 0 "register_operand")
        (unspec:SI
diff --git a/gcc/testsuite/gcc.target/i386/sse2-pr98461-2.c
b/gcc/testsuite/gcc.target/i386/sse2-pr98461-2.c
new file mode 100644
index 00000000000..60fc1f3e9c1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/sse2-pr98461-2.c
@@ -0,0 +1,13 @@
+/* PR target/98461 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2 -mno-sse3 -masm=att" } */
+/* { dg-final { scan-assembler-times "\tpmovmskb\t" 1 } } */
+/* { dg-final { scan-assembler-not "\tmovzwl" } } */
+/* { dg-final { scan-assembler-times "\tnotl" 1 } } */
+
+#include <immintrin.h>
+
+unsigned int movemask_not1(__m128i logical) {
+  unsigned short res = (unsigned short)(_mm_movemask_epi8(logical));
+  return ~res;
+}
-- 
2.18.1


-- 
BR,
Hongtao

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-01-05 10:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04  5:56 [PATCH]i386: Optimize pmovskb on zero_extend of subreg HI of the result [PR98461] Hongtao Liu
2021-01-04  7:40 ` Uros Bizjak
2021-01-04  7:54   ` Hongtao Liu
2021-01-04  8:42     ` Uros Bizjak
2021-01-04  8:49 ` Jakub Jelinek
2021-01-04  8:59   ` Hongtao Liu
2021-01-05  6:32     ` Hongtao Liu
2021-01-05  7:04       ` Uros Bizjak
2021-01-05  7:19         ` Uros Bizjak
2021-01-05 10:28           ` Hongtao Liu
2021-01-05 10:30             ` Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).