From: "H.J. Lu" <hjl.tools@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: Uros Bizjak <ubizjak@gmail.com>
Subject: [PATCH 14/42] i386: Emulate MMX pshufw with SSE
Date: Fri, 15 Feb 2019 13:58:00 -0000 [thread overview]
Message-ID: <20190215135812.32306-15-hjl.tools@gmail.com> (raw)
In-Reply-To: <20190215135812.32306-1-hjl.tools@gmail.com>
Emulate MMX pshufw with SSE. Only SSE register source operand is allowed.
PR target/89021
* config/i386/mmx.md (mmx_pshufw): Also check TARGET_MMX and
TARGET_MMX_WITH_SSE.
(mmx_pshufw_1): Add SSE emulation.
(*vec_dupv4hi): Changed to define_insn_and_split and also allow
TARGET_MMX_WITH_SSE to support SSE emulation.
---
gcc/config/i386/mmx.md | 79 ++++++++++++++++++++++++++++++++++--------
1 file changed, 64 insertions(+), 15 deletions(-)
diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
index f07e1104ae8..3ea64e9aabe 100644
--- a/gcc/config/i386/mmx.md
+++ b/gcc/config/i386/mmx.md
@@ -1325,7 +1325,8 @@
[(match_operand:V4HI 0 "register_operand")
(match_operand:V4HI 1 "nonimmediate_operand")
(match_operand:SI 2 "const_int_operand")]
- "TARGET_SSE || TARGET_3DNOW_A"
+ "(TARGET_MMX || TARGET_MMX_WITH_SSE)
+ && (TARGET_SSE || TARGET_3DNOW_A)"
{
int mask = INTVAL (operands[2]);
emit_insn (gen_mmx_pshufw_1 (operands[0], operands[1],
@@ -1337,14 +1338,15 @@
})
(define_insn "mmx_pshufw_1"
- [(set (match_operand:V4HI 0 "register_operand" "=y")
+ [(set (match_operand:V4HI 0 "register_operand" "=y,Yv")
(vec_select:V4HI
- (match_operand:V4HI 1 "nonimmediate_operand" "ym")
+ (match_operand:V4HI 1 "nonimmediate_operand" "ym,Yv")
(parallel [(match_operand 2 "const_0_to_3_operand")
(match_operand 3 "const_0_to_3_operand")
(match_operand 4 "const_0_to_3_operand")
(match_operand 5 "const_0_to_3_operand")])))]
- "TARGET_SSE || TARGET_3DNOW_A"
+ "(TARGET_MMX || TARGET_MMX_WITH_SSE)
+ && (TARGET_SSE || TARGET_3DNOW_A)"
{
int mask = 0;
mask |= INTVAL (operands[2]) << 0;
@@ -1353,11 +1355,20 @@
mask |= INTVAL (operands[5]) << 6;
operands[2] = GEN_INT (mask);
- return "pshufw\t{%2, %1, %0|%0, %1, %2}";
+ switch (which_alternative)
+ {
+ case 0:
+ return "pshufw\t{%2, %1, %0|%0, %1, %2}";
+ case 1:
+ return "%vpshuflw\t{%2, %1, %0|%0, %1, %2}";
+ default:
+ gcc_unreachable ();
+ }
}
- [(set_attr "type" "mmxcvt")
+ [(set_attr "mmx_isa" "native,x64")
+ (set_attr "type" "mmxcvt,sselog")
(set_attr "length_immediate" "1")
- (set_attr "mode" "DI")])
+ (set_attr "mode" "DI,TI")])
(define_insn "mmx_pswapdv2si2"
[(set (match_operand:V2SI 0 "register_operand" "=y")
@@ -1370,16 +1381,54 @@
(set_attr "prefix_extra" "1")
(set_attr "mode" "DI")])
-(define_insn "*vec_dupv4hi"
- [(set (match_operand:V4HI 0 "register_operand" "=y")
+(define_insn_and_split "*vec_dupv4hi"
+ [(set (match_operand:V4HI 0 "register_operand" "=y,Yv,Yw")
(vec_duplicate:V4HI
(truncate:HI
- (match_operand:SI 1 "register_operand" "0"))))]
- "TARGET_SSE || TARGET_3DNOW_A"
- "pshufw\t{$0, %0, %0|%0, %0, 0}"
- [(set_attr "type" "mmxcvt")
- (set_attr "length_immediate" "1")
- (set_attr "mode" "DI")])
+ (match_operand:SI 1 "register_operand" "0,Yv,r"))))]
+ "(TARGET_MMX || TARGET_MMX_WITH_SSE)
+ && (TARGET_SSE || TARGET_3DNOW_A)"
+ "@
+ pshufw\t{$0, %0, %0|%0, %0, 0}
+ #
+ #"
+ "TARGET_MMX_WITH_SSE && reload_completed"
+ [(const_int 0)]
+{
+ rtx op;
+ operands[0] = lowpart_subreg (V8HImode, operands[0],
+ GET_MODE (operands[0]));
+ if (TARGET_AVX2)
+ {
+ operands[1] = lowpart_subreg (HImode, operands[1],
+ GET_MODE (operands[1]));
+ op = gen_rtx_VEC_DUPLICATE (V8HImode, operands[1]);
+ }
+ else
+ {
+ operands[1] = lowpart_subreg (V8HImode, operands[1],
+ GET_MODE (operands[1]));
+ rtx mask = gen_rtx_PARALLEL (VOIDmode,
+ gen_rtvec (8,
+ GEN_INT (0),
+ GEN_INT (0),
+ GEN_INT (0),
+ GEN_INT (0),
+ GEN_INT (4),
+ GEN_INT (5),
+ GEN_INT (6),
+ GEN_INT (7)));
+
+ op = gen_rtx_VEC_SELECT (V8HImode, operands[1], mask);
+ }
+ rtx insn = gen_rtx_SET (operands[0], op);
+ emit_insn (insn);
+ DONE;
+}
+ [(set_attr "mmx_isa" "native,x64,x64_avx")
+ (set_attr "type" "mmxcvt,sselog1,ssemov")
+ (set_attr "length_immediate" "1,1,0")
+ (set_attr "mode" "DI,TI,TI")])
(define_insn_and_split "*vec_dupv2si"
[(set (match_operand:V2SI 0 "register_operand" "=y,x,Yv,Yw")
--
2.20.1
next prev parent reply other threads:[~2019-02-15 13:58 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-15 13:58 [PATCH 00/40] V6: Emulate MMX intrinsics " H.J. Lu
2019-02-15 13:58 ` [PATCH 22/42] i386: Emulate MMX maskmovq with SSE2 maskmovdqu H.J. Lu
2019-02-15 13:58 ` [PATCH 15/42] i386: Emulate MMX sse_cvtps2pi/sse_cvttps2pi with SSE H.J. Lu
2019-02-15 13:58 ` [PATCH 16/42] i386: Emulate MMX sse_cvtpi2ps " H.J. Lu
2019-02-15 13:58 ` [PATCH 13/42] i386: Emulate MMX vec_dupv2si " H.J. Lu
2019-02-15 13:58 ` [PATCH 34/42] i386: Emulate MMX ssse3_psign<mode>3 " H.J. Lu
2019-02-15 13:58 ` [PATCH 05/42] i386: Emulate MMX plusminus/sat_plusminus " H.J. Lu
2019-02-15 13:58 ` [PATCH 11/42] i386: Emulate MMX mmx_andnot<mode>3 " H.J. Lu
2019-02-15 13:58 ` [PATCH 12/42] i386: Emulate MMX mmx_eq/mmx_gt<mode>3 " H.J. Lu
2019-02-15 13:58 ` H.J. Lu [this message]
2019-02-15 13:58 ` [PATCH 18/42] i386: Emulate MMX mmx_pinsrw " H.J. Lu
2019-02-15 13:58 ` [PATCH 08/42] i386: Emulate MMX mmx_pmaddwd " H.J. Lu
2019-02-15 13:58 ` [PATCH 10/42] i386: Emulate MMX <any_logic><mode>3 " H.J. Lu
2019-02-15 13:58 ` [PATCH 03/42] i386: Emulate MMX packsswb/packssdw/packuswb with SSE2 H.J. Lu
2019-02-15 13:58 ` [PATCH 07/42] i386: Emulate MMX smulv4hi3_highpart with SSE H.J. Lu
2019-02-15 13:58 ` [PATCH 35/42] i386: Emulate MMX ssse3_palignrdi " H.J. Lu
2019-02-15 13:58 ` [PATCH 06/42] i386: Emulate MMX mulv4hi3 " H.J. Lu
2019-02-15 13:58 ` [PATCH 26/42] i386: Emulate MMX movntq with SSE2 movntidi H.J. Lu
2019-02-15 13:58 ` [PATCH 31/42] i386: Emulate MMX ssse3_pmaddubsw with SSE H.J. Lu
2019-02-15 13:58 ` [PATCH 39/42] i386: Allow MMX vector expanders with TARGET_MMX_WITH_SSE H.J. Lu
2019-02-15 13:58 ` [PATCH 02/42] i386: Add mmx_nonimmediate_operand H.J. Lu
2019-02-15 16:50 ` Uros Bizjak
2019-02-15 13:58 ` [PATCH 01/42] i386: Allow MMX register modes in SSE registers H.J. Lu
2019-02-15 13:58 ` [PATCH 19/42] i386: Emulate MMX V4HI smaxmin/V8QI umaxmin with SSE H.J. Lu
2019-02-15 13:58 ` [PATCH 09/42] i386: Emulate MMX ashr<mode>3/<shift_insn><mode>3 " H.J. Lu
2019-02-15 13:58 ` [PATCH 04/42] i386: Emulate MMX punpcklXX/punpckhXX with SSE punpcklXX H.J. Lu
2019-02-15 14:03 ` [PATCH 33/42] i386: Emulate MMX pshufb with SSE version H.J. Lu
2019-02-15 14:03 ` [PATCH 36/42] i386: Emulate MMX abs<mode>2 with SSE H.J. Lu
2019-02-15 14:03 ` [PATCH 23/42] i386: Emulate MMX mmx_uavgv8qi3 " H.J. Lu
2019-02-15 14:04 ` [PATCH 40/42] i386: Allow MMX intrinsic emulation " H.J. Lu
2019-02-15 14:04 ` [PATCH 17/42] i386: Emulate MMX mmx_pextrw " H.J. Lu
2019-02-15 16:01 ` H.J. Lu
2019-02-15 14:04 ` [PATCH 21/42] i386: Emulate MMX mmx_umulv4hi3_highpart " H.J. Lu
2019-02-15 14:04 ` [PATCH 29/42] i386: Emulate MMX ssse3_ph<plusminus_mnemonic>wv4hi3 " H.J. Lu
2019-02-15 14:04 ` [PATCH 24/42] i386: Emulate MMX mmx_uavgv4hi3 " H.J. Lu
2019-02-15 14:04 ` [PATCH 41/42] i386: Enable TM MMX intrinsics with SSE2 H.J. Lu
2019-02-15 14:04 ` [PATCH 28/42] i386: Make _mm_empty () as NOP when MMX is disabled H.J. Lu
2019-02-15 17:24 ` Uros Bizjak
2019-02-15 14:04 ` [PATCH 27/42] i386: Emulate MMX umulv1siv1di3 with SSE2 H.J. Lu
2019-02-15 14:04 ` [PATCH 42/42] i386: Add tests for MMX intrinsic emulations with SSE H.J. Lu
2019-02-15 17:41 ` Uros Bizjak
2019-02-15 14:04 ` [PATCH 37/42] Prevent allocation of MMX registers with TARGET_MMX_WITH_SSE H.J. Lu
2019-02-15 14:04 ` [PATCH 25/42] i386: Emulate MMX mmx_psadbw with SSE H.J. Lu
2019-02-15 14:04 ` [PATCH 38/42] i386: Allow MMXMODE moves with TARGET_MMX_WITH_SSE H.J. Lu
2019-02-15 14:04 ` [PATCH 32/42] i386: Emulate MMX ssse3_pmulhrswv4hi3 with SSE H.J. Lu
2019-02-15 14:04 ` [PATCH 20/42] i386: Emulate MMX mmx_pmovmskb " H.J. Lu
2019-02-15 14:04 ` [PATCH 30/42] i386: Emulate MMX ssse3_ph<plusminus_mnemonic>dv2si3 " H.J. Lu
2019-02-15 17:50 ` [PATCH 00/40] V6: Emulate MMX intrinsics " Uros Bizjak
2019-02-15 18:20 ` H.J. Lu
2019-02-15 18:31 ` Uros Bizjak
2019-02-16 0:53 ` H.J. Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190215135812.32306-15-hjl.tools@gmail.com \
--to=hjl.tools@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ubizjak@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).