xref: /dragonfly/contrib/gcc-4.7/gcc/config/i386/mmx.md (revision e4b17023)
1*e4b17023SJohn Marino;; GCC machine description for MMX and 3dNOW! instructions
2*e4b17023SJohn Marino;; Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011
3*e4b17023SJohn Marino;; Free Software Foundation, Inc.
4*e4b17023SJohn Marino;;
5*e4b17023SJohn Marino;; This file is part of GCC.
6*e4b17023SJohn Marino;;
7*e4b17023SJohn Marino;; GCC is free software; you can redistribute it and/or modify
8*e4b17023SJohn Marino;; it under the terms of the GNU General Public License as published by
9*e4b17023SJohn Marino;; the Free Software Foundation; either version 3, or (at your option)
10*e4b17023SJohn Marino;; any later version.
11*e4b17023SJohn Marino;;
12*e4b17023SJohn Marino;; GCC is distributed in the hope that it will be useful,
13*e4b17023SJohn Marino;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14*e4b17023SJohn Marino;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*e4b17023SJohn Marino;; GNU General Public License for more details.
16*e4b17023SJohn Marino;;
17*e4b17023SJohn Marino;; You should have received a copy of the GNU General Public License
18*e4b17023SJohn Marino;; along with GCC; see the file COPYING3.  If not see
19*e4b17023SJohn Marino;; <http://www.gnu.org/licenses/>.
20*e4b17023SJohn Marino
21*e4b17023SJohn Marino;; The MMX and 3dNOW! patterns are in the same file because they use
22*e4b17023SJohn Marino;; the same register file, and 3dNOW! adds a number of extensions to
23*e4b17023SJohn Marino;; the base integer MMX isa.
24*e4b17023SJohn Marino
25*e4b17023SJohn Marino;; Note!  Except for the basic move instructions, *all* of these
26*e4b17023SJohn Marino;; patterns are outside the normal optabs namespace.  This is because
27*e4b17023SJohn Marino;; use of these registers requires the insertion of emms or femms
28*e4b17023SJohn Marino;; instructions to return to normal fpu mode.  The compiler doesn't
29*e4b17023SJohn Marino;; know how to do that itself, which means it's up to the user.  Which
30*e4b17023SJohn Marino;; means that we should never use any of these patterns except at the
31*e4b17023SJohn Marino;; direction of the user via a builtin.
32*e4b17023SJohn Marino
33*e4b17023SJohn Marino(define_c_enum "unspec" [
34*e4b17023SJohn Marino  UNSPEC_MOVNTQ
35*e4b17023SJohn Marino  UNSPEC_PFRCP
36*e4b17023SJohn Marino  UNSPEC_PFRCPIT1
37*e4b17023SJohn Marino  UNSPEC_PFRCPIT2
38*e4b17023SJohn Marino  UNSPEC_PFRSQRT
39*e4b17023SJohn Marino  UNSPEC_PFRSQIT1
40*e4b17023SJohn Marino])
41*e4b17023SJohn Marino
42*e4b17023SJohn Marino(define_c_enum "unspecv" [
43*e4b17023SJohn Marino  UNSPECV_EMMS
44*e4b17023SJohn Marino  UNSPECV_FEMMS
45*e4b17023SJohn Marino])
46*e4b17023SJohn Marino
47*e4b17023SJohn Marino;; 8 byte integral modes handled by MMX (and by extension, SSE)
48*e4b17023SJohn Marino(define_mode_iterator MMXMODEI [V8QI V4HI V2SI])
49*e4b17023SJohn Marino(define_mode_iterator MMXMODEI8 [V8QI V4HI V2SI V1DI])
50*e4b17023SJohn Marino
51*e4b17023SJohn Marino;; All 8-byte vector modes handled by MMX
52*e4b17023SJohn Marino(define_mode_iterator MMXMODE [V8QI V4HI V2SI V1DI V2SF])
53*e4b17023SJohn Marino
54*e4b17023SJohn Marino;; Mix-n-match
55*e4b17023SJohn Marino(define_mode_iterator MMXMODE12 [V8QI V4HI])
56*e4b17023SJohn Marino(define_mode_iterator MMXMODE24 [V4HI V2SI])
57*e4b17023SJohn Marino(define_mode_iterator MMXMODE248 [V4HI V2SI V1DI])
58*e4b17023SJohn Marino
59*e4b17023SJohn Marino;; Mapping from integer vector mode to mnemonic suffix
60*e4b17023SJohn Marino(define_mode_attr mmxvecsize [(V8QI "b") (V4HI "w") (V2SI "d") (V1DI "q")])
61*e4b17023SJohn Marino
62*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
63*e4b17023SJohn Marino;;
64*e4b17023SJohn Marino;; Move patterns
65*e4b17023SJohn Marino;;
66*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
67*e4b17023SJohn Marino
68*e4b17023SJohn Marino;; All of these patterns are enabled for MMX as well as 3dNOW.
69*e4b17023SJohn Marino;; This is essential for maintaining stable calling conventions.
70*e4b17023SJohn Marino
71*e4b17023SJohn Marino(define_expand "mov<mode>"
72*e4b17023SJohn Marino  [(set (match_operand:MMXMODEI8 0 "nonimmediate_operand" "")
73*e4b17023SJohn Marino	(match_operand:MMXMODEI8 1 "nonimmediate_operand" ""))]
74*e4b17023SJohn Marino  "TARGET_MMX"
75*e4b17023SJohn Marino{
76*e4b17023SJohn Marino  ix86_expand_vector_move (<MODE>mode, operands);
77*e4b17023SJohn Marino  DONE;
78*e4b17023SJohn Marino})
79*e4b17023SJohn Marino
80*e4b17023SJohn Marino;; movd instead of movq is required to handle broken assemblers.
81*e4b17023SJohn Marino(define_insn "*mov<mode>_internal_rex64"
82*e4b17023SJohn Marino  [(set (match_operand:MMXMODEI8 0 "nonimmediate_operand"
83*e4b17023SJohn Marino	 "=rm,r,!?y,!y,!?y,m  ,!y ,*x,x,x ,m,r ,Yi")
84*e4b17023SJohn Marino	(match_operand:MMXMODEI8 1 "vector_move_operand"
85*e4b17023SJohn Marino	 "Cr ,m,C  ,!y,m  ,!?y,*x,!y ,C,xm,x,Yi,r"))]
86*e4b17023SJohn Marino  "TARGET_64BIT && TARGET_MMX
87*e4b17023SJohn Marino   && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
88*e4b17023SJohn Marino  "@
89*e4b17023SJohn Marino    mov{q}\t{%1, %0|%0, %1}
90*e4b17023SJohn Marino    mov{q}\t{%1, %0|%0, %1}
91*e4b17023SJohn Marino    pxor\t%0, %0
92*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
93*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
94*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
95*e4b17023SJohn Marino    movdq2q\t{%1, %0|%0, %1}
96*e4b17023SJohn Marino    movq2dq\t{%1, %0|%0, %1}
97*e4b17023SJohn Marino    %vpxor\t%0, %d0
98*e4b17023SJohn Marino    %vmovq\t{%1, %0|%0, %1}
99*e4b17023SJohn Marino    %vmovq\t{%1, %0|%0, %1}
100*e4b17023SJohn Marino    %vmovd\t{%1, %0|%0, %1}
101*e4b17023SJohn Marino    %vmovd\t{%1, %0|%0, %1}"
102*e4b17023SJohn Marino  [(set (attr "type")
103*e4b17023SJohn Marino     (cond [(eq_attr "alternative" "0,1")
104*e4b17023SJohn Marino	      (const_string "imov")
105*e4b17023SJohn Marino	    (eq_attr "alternative" "2")
106*e4b17023SJohn Marino	      (const_string "mmx")
107*e4b17023SJohn Marino	    (eq_attr "alternative" "3,4,5")
108*e4b17023SJohn Marino	      (const_string "mmxmov")
109*e4b17023SJohn Marino	    (eq_attr "alternative" "6,7")
110*e4b17023SJohn Marino	      (const_string "ssecvt")
111*e4b17023SJohn Marino	    (eq_attr "alternative" "8")
112*e4b17023SJohn Marino	      (const_string "sselog1")
113*e4b17023SJohn Marino	   ]
114*e4b17023SJohn Marino	   (const_string "ssemov")))
115*e4b17023SJohn Marino   (set (attr "unit")
116*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "6,7")
117*e4b17023SJohn Marino       (const_string "mmx")
118*e4b17023SJohn Marino       (const_string "*")))
119*e4b17023SJohn Marino   (set (attr "prefix_rep")
120*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "6,7,9")
121*e4b17023SJohn Marino       (const_string "1")
122*e4b17023SJohn Marino       (const_string "*")))
123*e4b17023SJohn Marino   (set (attr "prefix_data16")
124*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "10,11,12")
125*e4b17023SJohn Marino       (const_string "1")
126*e4b17023SJohn Marino       (const_string "*")))
127*e4b17023SJohn Marino   (set (attr "prefix_rex")
128*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "9,10")
129*e4b17023SJohn Marino       (symbol_ref "x86_extended_reg_mentioned_p (insn)")
130*e4b17023SJohn Marino       (const_string "*")))
131*e4b17023SJohn Marino   (set (attr "prefix")
132*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "8,9,10,11,12")
133*e4b17023SJohn Marino       (const_string "maybe_vex")
134*e4b17023SJohn Marino       (const_string "orig")))
135*e4b17023SJohn Marino   (set_attr "mode" "DI")])
136*e4b17023SJohn Marino
137*e4b17023SJohn Marino(define_insn "*mov<mode>_internal"
138*e4b17023SJohn Marino  [(set (match_operand:MMXMODEI8 0 "nonimmediate_operand"
139*e4b17023SJohn Marino	 "=!?y,!y,!?y,m  ,!y,*x,*x,*x ,m ,*x,*x,*x,m ,r  ,m")
140*e4b17023SJohn Marino	(match_operand:MMXMODEI8 1 "vector_move_operand"
141*e4b17023SJohn Marino	 "C   ,!y,m  ,!?y,*x,!y,C ,*xm,*x,C ,*x,m ,*x,irm,r"))]
142*e4b17023SJohn Marino  "!TARGET_64BIT && TARGET_MMX
143*e4b17023SJohn Marino   && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
144*e4b17023SJohn Marino  "@
145*e4b17023SJohn Marino    pxor\t%0, %0
146*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
147*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
148*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
149*e4b17023SJohn Marino    movdq2q\t{%1, %0|%0, %1}
150*e4b17023SJohn Marino    movq2dq\t{%1, %0|%0, %1}
151*e4b17023SJohn Marino    %vpxor\t%0, %d0
152*e4b17023SJohn Marino    %vmovq\t{%1, %0|%0, %1}
153*e4b17023SJohn Marino    %vmovq\t{%1, %0|%0, %1}
154*e4b17023SJohn Marino    xorps\t%0, %0
155*e4b17023SJohn Marino    movaps\t{%1, %0|%0, %1}
156*e4b17023SJohn Marino    movlps\t{%1, %0|%0, %1}
157*e4b17023SJohn Marino    movlps\t{%1, %0|%0, %1}
158*e4b17023SJohn Marino    #
159*e4b17023SJohn Marino    #"
160*e4b17023SJohn Marino  [(set (attr "isa")
161*e4b17023SJohn Marino     (cond [(eq_attr "alternative" "4,5,6,7,8")
162*e4b17023SJohn Marino	      (const_string "sse2")
163*e4b17023SJohn Marino	    (eq_attr "alternative" "9,10,11,12")
164*e4b17023SJohn Marino	      (const_string "noavx")
165*e4b17023SJohn Marino	   ]
166*e4b17023SJohn Marino           (const_string "*")))
167*e4b17023SJohn Marino   (set (attr "type")
168*e4b17023SJohn Marino     (cond [(eq_attr "alternative" "0")
169*e4b17023SJohn Marino	      (const_string "mmx")
170*e4b17023SJohn Marino	    (eq_attr "alternative" "1,2,3")
171*e4b17023SJohn Marino	      (const_string "mmxmov")
172*e4b17023SJohn Marino	    (eq_attr "alternative" "4,5")
173*e4b17023SJohn Marino	      (const_string "ssecvt")
174*e4b17023SJohn Marino	    (eq_attr "alternative" "6,9")
175*e4b17023SJohn Marino	      (const_string "sselog1")
176*e4b17023SJohn Marino	    (eq_attr "alternative" "13,14")
177*e4b17023SJohn Marino	      (const_string "multi")
178*e4b17023SJohn Marino	   ]
179*e4b17023SJohn Marino	   (const_string "ssemov")))
180*e4b17023SJohn Marino   (set (attr "unit")
181*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "4,5")
182*e4b17023SJohn Marino       (const_string "mmx")
183*e4b17023SJohn Marino       (const_string "*")))
184*e4b17023SJohn Marino   (set (attr "prefix_rep")
185*e4b17023SJohn Marino     (if_then_else
186*e4b17023SJohn Marino       (ior (eq_attr "alternative" "4,5")
187*e4b17023SJohn Marino	    (and (eq_attr "alternative" "7")
188*e4b17023SJohn Marino		 (not (match_test "TARGET_AVX"))))
189*e4b17023SJohn Marino       (const_string "1")
190*e4b17023SJohn Marino       (const_string "*")))
191*e4b17023SJohn Marino   (set (attr "prefix_data16")
192*e4b17023SJohn Marino     (if_then_else
193*e4b17023SJohn Marino       (and (eq_attr "alternative" "8")
194*e4b17023SJohn Marino	    (not (match_test "TARGET_AVX")))
195*e4b17023SJohn Marino       (const_string "1")
196*e4b17023SJohn Marino       (const_string "*")))
197*e4b17023SJohn Marino   (set (attr "prefix")
198*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "6,7,8")
199*e4b17023SJohn Marino       (const_string "maybe_vex")
200*e4b17023SJohn Marino       (const_string "orig")))
201*e4b17023SJohn Marino   (set_attr "mode" "DI,DI,DI,DI,DI,DI,TI,DI,DI,V4SF,V4SF,V2SF,V2SF,DI,DI")])
202*e4b17023SJohn Marino
203*e4b17023SJohn Marino(define_expand "movv2sf"
204*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "nonimmediate_operand" "")
205*e4b17023SJohn Marino	(match_operand:V2SF 1 "nonimmediate_operand" ""))]
206*e4b17023SJohn Marino  "TARGET_MMX"
207*e4b17023SJohn Marino{
208*e4b17023SJohn Marino  ix86_expand_vector_move (V2SFmode, operands);
209*e4b17023SJohn Marino  DONE;
210*e4b17023SJohn Marino})
211*e4b17023SJohn Marino
212*e4b17023SJohn Marino;; movd instead of movq is required to handle broken assemblers.
213*e4b17023SJohn Marino(define_insn "*movv2sf_internal_rex64"
214*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "nonimmediate_operand"
215*e4b17023SJohn Marino	 "=rm,r,!?y,!y,!?y,m  ,!y,*x,x,x,x,m,r ,Yi")
216*e4b17023SJohn Marino        (match_operand:V2SF 1 "vector_move_operand"
217*e4b17023SJohn Marino	 "Cr ,m,C  ,!y,m  ,!?y,*x,!y,C,x,m,x,Yi,r"))]
218*e4b17023SJohn Marino  "TARGET_64BIT && TARGET_MMX
219*e4b17023SJohn Marino   && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
220*e4b17023SJohn Marino  "@
221*e4b17023SJohn Marino    mov{q}\t{%1, %0|%0, %1}
222*e4b17023SJohn Marino    mov{q}\t{%1, %0|%0, %1}
223*e4b17023SJohn Marino    pxor\t%0, %0
224*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
225*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
226*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
227*e4b17023SJohn Marino    movdq2q\t{%1, %0|%0, %1}
228*e4b17023SJohn Marino    movq2dq\t{%1, %0|%0, %1}
229*e4b17023SJohn Marino    %vxorps\t%0, %d0
230*e4b17023SJohn Marino    %vmovaps\t{%1, %0|%0, %1}
231*e4b17023SJohn Marino    %vmovlps\t{%1, %d0|%d0, %1}
232*e4b17023SJohn Marino    %vmovlps\t{%1, %0|%0, %1}
233*e4b17023SJohn Marino    %vmovd\t{%1, %0|%0, %1}
234*e4b17023SJohn Marino    %vmovd\t{%1, %0|%0, %1}"
235*e4b17023SJohn Marino  [(set (attr "type")
236*e4b17023SJohn Marino     (cond [(eq_attr "alternative" "0,1")
237*e4b17023SJohn Marino	      (const_string "imov")
238*e4b17023SJohn Marino	    (eq_attr "alternative" "2")
239*e4b17023SJohn Marino	      (const_string "mmx")
240*e4b17023SJohn Marino	    (eq_attr "alternative" "3,4,5")
241*e4b17023SJohn Marino	      (const_string "mmxmov")
242*e4b17023SJohn Marino	    (eq_attr "alternative" "6,7")
243*e4b17023SJohn Marino	      (const_string "ssecvt")
244*e4b17023SJohn Marino	    (eq_attr "alternative" "9")
245*e4b17023SJohn Marino	      (const_string "sselog1")
246*e4b17023SJohn Marino	   ]
247*e4b17023SJohn Marino	   (const_string "ssemov")))
248*e4b17023SJohn Marino   (set (attr "unit")
249*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "6,7")
250*e4b17023SJohn Marino       (const_string "mmx")
251*e4b17023SJohn Marino       (const_string "*")))
252*e4b17023SJohn Marino   (set (attr "prefix_rep")
253*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "6,7")
254*e4b17023SJohn Marino       (const_string "1")
255*e4b17023SJohn Marino       (const_string "*")))
256*e4b17023SJohn Marino   (set (attr "length_vex")
257*e4b17023SJohn Marino     (if_then_else
258*e4b17023SJohn Marino       (and (eq_attr "alternative" "12,13")
259*e4b17023SJohn Marino	    (match_test "TARGET_AVX"))
260*e4b17023SJohn Marino       (const_string "4")
261*e4b17023SJohn Marino       (const_string "*")))
262*e4b17023SJohn Marino   (set (attr "prefix")
263*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "8,9,10,11,12,13")
264*e4b17023SJohn Marino       (const_string "maybe_vex")
265*e4b17023SJohn Marino       (const_string "orig")))
266*e4b17023SJohn Marino   (set_attr "mode" "DI,DI,DI,DI,DI,DI,DI,DI,V4SF,V4SF,V2SF,V2SF,DI,DI")])
267*e4b17023SJohn Marino
268*e4b17023SJohn Marino(define_insn "*movv2sf_internal"
269*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "nonimmediate_operand"
270*e4b17023SJohn Marino	 "=!?y,!y,!?y,m  ,!y,*x,*x,*x,*x,m ,r  ,m")
271*e4b17023SJohn Marino        (match_operand:V2SF 1 "vector_move_operand"
272*e4b17023SJohn Marino	 "C   ,!y,m  ,!?y,*x,!y,C ,*x,m ,*x,irm,r"))]
273*e4b17023SJohn Marino  "!TARGET_64BIT && TARGET_MMX
274*e4b17023SJohn Marino   && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
275*e4b17023SJohn Marino  "@
276*e4b17023SJohn Marino    pxor\t%0, %0
277*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
278*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
279*e4b17023SJohn Marino    movq\t{%1, %0|%0, %1}
280*e4b17023SJohn Marino    movdq2q\t{%1, %0|%0, %1}
281*e4b17023SJohn Marino    movq2dq\t{%1, %0|%0, %1}
282*e4b17023SJohn Marino    %vxorps\t%0, %d0
283*e4b17023SJohn Marino    %vmovaps\t{%1, %0|%0, %1}
284*e4b17023SJohn Marino    %vmovlps\t{%1, %d0|%d0, %1}
285*e4b17023SJohn Marino    %vmovlps\t{%1, %0|%0, %1}
286*e4b17023SJohn Marino    #
287*e4b17023SJohn Marino    #"
288*e4b17023SJohn Marino  [(set (attr "isa")
289*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "4,5")
290*e4b17023SJohn Marino       (const_string "sse2")
291*e4b17023SJohn Marino       (const_string "*")))
292*e4b17023SJohn Marino   (set (attr "type")
293*e4b17023SJohn Marino     (cond [(eq_attr "alternative" "0")
294*e4b17023SJohn Marino	      (const_string "mmx")
295*e4b17023SJohn Marino	    (eq_attr "alternative" "1,2,3")
296*e4b17023SJohn Marino	      (const_string "mmxmov")
297*e4b17023SJohn Marino	    (eq_attr "alternative" "4,5")
298*e4b17023SJohn Marino	      (const_string "ssecvt")
299*e4b17023SJohn Marino	    (eq_attr "alternative" "6")
300*e4b17023SJohn Marino	      (const_string "sselog1")
301*e4b17023SJohn Marino	    (eq_attr "alternative" "10,11")
302*e4b17023SJohn Marino	      (const_string "multi")
303*e4b17023SJohn Marino	   ]
304*e4b17023SJohn Marino	   (const_string "ssemov")))
305*e4b17023SJohn Marino   (set (attr "unit")
306*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "4,5")
307*e4b17023SJohn Marino       (const_string "mmx")
308*e4b17023SJohn Marino       (const_string "*")))
309*e4b17023SJohn Marino   (set (attr "prefix_rep")
310*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "4,5")
311*e4b17023SJohn Marino       (const_string "1")
312*e4b17023SJohn Marino       (const_string "*")))
313*e4b17023SJohn Marino   (set (attr "prefix")
314*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "6,7,8,9")
315*e4b17023SJohn Marino       (const_string "maybe_vex")
316*e4b17023SJohn Marino       (const_string "orig")))
317*e4b17023SJohn Marino   (set_attr "mode" "DI,DI,DI,DI,DI,DI,V4SF,V4SF,V2SF,V2SF,DI,DI")])
318*e4b17023SJohn Marino
319*e4b17023SJohn Marino;; %%% This multiword shite has got to go.
320*e4b17023SJohn Marino(define_split
321*e4b17023SJohn Marino  [(set (match_operand:MMXMODE 0 "nonimmediate_operand" "")
322*e4b17023SJohn Marino        (match_operand:MMXMODE 1 "general_operand" ""))]
323*e4b17023SJohn Marino  "!TARGET_64BIT && reload_completed
324*e4b17023SJohn Marino   && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0])
325*e4b17023SJohn Marino	|| MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
326*e4b17023SJohn Marino  [(const_int 0)]
327*e4b17023SJohn Marino  "ix86_split_long_move (operands); DONE;")
328*e4b17023SJohn Marino
329*e4b17023SJohn Marino(define_expand "push<mode>1"
330*e4b17023SJohn Marino  [(match_operand:MMXMODE 0 "register_operand" "")]
331*e4b17023SJohn Marino  "TARGET_MMX"
332*e4b17023SJohn Marino{
333*e4b17023SJohn Marino  ix86_expand_push (<MODE>mode, operands[0]);
334*e4b17023SJohn Marino  DONE;
335*e4b17023SJohn Marino})
336*e4b17023SJohn Marino
337*e4b17023SJohn Marino(define_expand "movmisalign<mode>"
338*e4b17023SJohn Marino  [(set (match_operand:MMXMODE 0 "nonimmediate_operand" "")
339*e4b17023SJohn Marino	(match_operand:MMXMODE 1 "nonimmediate_operand" ""))]
340*e4b17023SJohn Marino  "TARGET_MMX"
341*e4b17023SJohn Marino{
342*e4b17023SJohn Marino  ix86_expand_vector_move (<MODE>mode, operands);
343*e4b17023SJohn Marino  DONE;
344*e4b17023SJohn Marino})
345*e4b17023SJohn Marino
346*e4b17023SJohn Marino(define_insn "sse_movntq"
347*e4b17023SJohn Marino  [(set (match_operand:DI 0 "memory_operand" "=m")
348*e4b17023SJohn Marino	(unspec:DI [(match_operand:DI 1 "register_operand" "y")]
349*e4b17023SJohn Marino		   UNSPEC_MOVNTQ))]
350*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
351*e4b17023SJohn Marino  "movntq\t{%1, %0|%0, %1}"
352*e4b17023SJohn Marino  [(set_attr "type" "mmxmov")
353*e4b17023SJohn Marino   (set_attr "mode" "DI")])
354*e4b17023SJohn Marino
355*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
356*e4b17023SJohn Marino;;
357*e4b17023SJohn Marino;; Parallel single-precision floating point arithmetic
358*e4b17023SJohn Marino;;
359*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
360*e4b17023SJohn Marino
361*e4b17023SJohn Marino(define_expand "mmx_addv2sf3"
362*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "")
363*e4b17023SJohn Marino	(plus:V2SF
364*e4b17023SJohn Marino	  (match_operand:V2SF 1 "nonimmediate_operand" "")
365*e4b17023SJohn Marino	  (match_operand:V2SF 2 "nonimmediate_operand" "")))]
366*e4b17023SJohn Marino  "TARGET_3DNOW"
367*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (PLUS, V2SFmode, operands);")
368*e4b17023SJohn Marino
369*e4b17023SJohn Marino(define_insn "*mmx_addv2sf3"
370*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
371*e4b17023SJohn Marino	(plus:V2SF (match_operand:V2SF 1 "nonimmediate_operand" "%0")
372*e4b17023SJohn Marino		   (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
373*e4b17023SJohn Marino  "TARGET_3DNOW && ix86_binary_operator_ok (PLUS, V2SFmode, operands)"
374*e4b17023SJohn Marino  "pfadd\t{%2, %0|%0, %2}"
375*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
376*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
377*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
378*e4b17023SJohn Marino
379*e4b17023SJohn Marino(define_expand "mmx_subv2sf3"
380*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "")
381*e4b17023SJohn Marino        (minus:V2SF (match_operand:V2SF 1 "register_operand" "")
382*e4b17023SJohn Marino		    (match_operand:V2SF 2 "nonimmediate_operand" "")))]
383*e4b17023SJohn Marino  "TARGET_3DNOW")
384*e4b17023SJohn Marino
385*e4b17023SJohn Marino(define_expand "mmx_subrv2sf3"
386*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "")
387*e4b17023SJohn Marino        (minus:V2SF (match_operand:V2SF 2 "register_operand" "")
388*e4b17023SJohn Marino		    (match_operand:V2SF 1 "nonimmediate_operand" "")))]
389*e4b17023SJohn Marino  "TARGET_3DNOW")
390*e4b17023SJohn Marino
391*e4b17023SJohn Marino(define_insn "*mmx_subv2sf3"
392*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y,y")
393*e4b17023SJohn Marino        (minus:V2SF (match_operand:V2SF 1 "nonimmediate_operand" "0,ym")
394*e4b17023SJohn Marino		    (match_operand:V2SF 2 "nonimmediate_operand" "ym,0")))]
395*e4b17023SJohn Marino  "TARGET_3DNOW && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
396*e4b17023SJohn Marino  "@
397*e4b17023SJohn Marino   pfsub\t{%2, %0|%0, %2}
398*e4b17023SJohn Marino   pfsubr\t{%1, %0|%0, %1}"
399*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
400*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
401*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
402*e4b17023SJohn Marino
403*e4b17023SJohn Marino(define_expand "mmx_mulv2sf3"
404*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "")
405*e4b17023SJohn Marino	(mult:V2SF (match_operand:V2SF 1 "nonimmediate_operand" "")
406*e4b17023SJohn Marino		   (match_operand:V2SF 2 "nonimmediate_operand" "")))]
407*e4b17023SJohn Marino  "TARGET_3DNOW"
408*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (MULT, V2SFmode, operands);")
409*e4b17023SJohn Marino
410*e4b17023SJohn Marino(define_insn "*mmx_mulv2sf3"
411*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
412*e4b17023SJohn Marino	(mult:V2SF (match_operand:V2SF 1 "nonimmediate_operand" "%0")
413*e4b17023SJohn Marino		   (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
414*e4b17023SJohn Marino  "TARGET_3DNOW && ix86_binary_operator_ok (MULT, V2SFmode, operands)"
415*e4b17023SJohn Marino  "pfmul\t{%2, %0|%0, %2}"
416*e4b17023SJohn Marino  [(set_attr "type" "mmxmul")
417*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
418*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
419*e4b17023SJohn Marino
420*e4b17023SJohn Marino;; ??? For !flag_finite_math_only, the representation with SMIN/SMAX
421*e4b17023SJohn Marino;; isn't really correct, as those rtl operators aren't defined when
422*e4b17023SJohn Marino;; applied to NaNs.  Hopefully the optimizers won't get too smart on us.
423*e4b17023SJohn Marino
424*e4b17023SJohn Marino(define_expand "mmx_<code>v2sf3"
425*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "")
426*e4b17023SJohn Marino        (smaxmin:V2SF
427*e4b17023SJohn Marino	  (match_operand:V2SF 1 "nonimmediate_operand" "")
428*e4b17023SJohn Marino	  (match_operand:V2SF 2 "nonimmediate_operand" "")))]
429*e4b17023SJohn Marino  "TARGET_3DNOW"
430*e4b17023SJohn Marino{
431*e4b17023SJohn Marino  if (!flag_finite_math_only)
432*e4b17023SJohn Marino    operands[1] = force_reg (V2SFmode, operands[1]);
433*e4b17023SJohn Marino  ix86_fixup_binary_operands_no_copy (<CODE>, V2SFmode, operands);
434*e4b17023SJohn Marino})
435*e4b17023SJohn Marino
436*e4b17023SJohn Marino(define_insn "*mmx_<code>v2sf3_finite"
437*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
438*e4b17023SJohn Marino        (smaxmin:V2SF
439*e4b17023SJohn Marino	  (match_operand:V2SF 1 "nonimmediate_operand" "%0")
440*e4b17023SJohn Marino	  (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
441*e4b17023SJohn Marino  "TARGET_3DNOW && flag_finite_math_only
442*e4b17023SJohn Marino   && ix86_binary_operator_ok (<CODE>, V2SFmode, operands)"
443*e4b17023SJohn Marino  "pf<maxmin_float>\t{%2, %0|%0, %2}"
444*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
445*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
446*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
447*e4b17023SJohn Marino
448*e4b17023SJohn Marino(define_insn "*mmx_<code>v2sf3"
449*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
450*e4b17023SJohn Marino        (smaxmin:V2SF
451*e4b17023SJohn Marino	  (match_operand:V2SF 1 "register_operand" "0")
452*e4b17023SJohn Marino	  (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
453*e4b17023SJohn Marino  "TARGET_3DNOW"
454*e4b17023SJohn Marino  "pf<maxmin_float>\t{%2, %0|%0, %2}"
455*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
456*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
457*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
458*e4b17023SJohn Marino
459*e4b17023SJohn Marino(define_insn "mmx_rcpv2sf2"
460*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
461*e4b17023SJohn Marino        (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")]
462*e4b17023SJohn Marino		     UNSPEC_PFRCP))]
463*e4b17023SJohn Marino  "TARGET_3DNOW"
464*e4b17023SJohn Marino  "pfrcp\t{%1, %0|%0, %1}"
465*e4b17023SJohn Marino  [(set_attr "type" "mmx")
466*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
467*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
468*e4b17023SJohn Marino
469*e4b17023SJohn Marino(define_insn "mmx_rcpit1v2sf3"
470*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
471*e4b17023SJohn Marino	(unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
472*e4b17023SJohn Marino		      (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
473*e4b17023SJohn Marino		     UNSPEC_PFRCPIT1))]
474*e4b17023SJohn Marino  "TARGET_3DNOW"
475*e4b17023SJohn Marino  "pfrcpit1\t{%2, %0|%0, %2}"
476*e4b17023SJohn Marino  [(set_attr "type" "mmx")
477*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
478*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
479*e4b17023SJohn Marino
480*e4b17023SJohn Marino(define_insn "mmx_rcpit2v2sf3"
481*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
482*e4b17023SJohn Marino	(unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
483*e4b17023SJohn Marino		      (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
484*e4b17023SJohn Marino		     UNSPEC_PFRCPIT2))]
485*e4b17023SJohn Marino  "TARGET_3DNOW"
486*e4b17023SJohn Marino  "pfrcpit2\t{%2, %0|%0, %2}"
487*e4b17023SJohn Marino  [(set_attr "type" "mmx")
488*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
489*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
490*e4b17023SJohn Marino
491*e4b17023SJohn Marino(define_insn "mmx_rsqrtv2sf2"
492*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
493*e4b17023SJohn Marino	(unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")]
494*e4b17023SJohn Marino		     UNSPEC_PFRSQRT))]
495*e4b17023SJohn Marino  "TARGET_3DNOW"
496*e4b17023SJohn Marino  "pfrsqrt\t{%1, %0|%0, %1}"
497*e4b17023SJohn Marino  [(set_attr "type" "mmx")
498*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
499*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
500*e4b17023SJohn Marino
501*e4b17023SJohn Marino(define_insn "mmx_rsqit1v2sf3"
502*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
503*e4b17023SJohn Marino	(unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
504*e4b17023SJohn Marino		      (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
505*e4b17023SJohn Marino		     UNSPEC_PFRSQIT1))]
506*e4b17023SJohn Marino  "TARGET_3DNOW"
507*e4b17023SJohn Marino  "pfrsqit1\t{%2, %0|%0, %2}"
508*e4b17023SJohn Marino  [(set_attr "type" "mmx")
509*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
510*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
511*e4b17023SJohn Marino
512*e4b17023SJohn Marino(define_insn "mmx_haddv2sf3"
513*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
514*e4b17023SJohn Marino	(vec_concat:V2SF
515*e4b17023SJohn Marino	  (plus:SF
516*e4b17023SJohn Marino	    (vec_select:SF
517*e4b17023SJohn Marino	      (match_operand:V2SF 1 "register_operand" "0")
518*e4b17023SJohn Marino	      (parallel [(const_int  0)]))
519*e4b17023SJohn Marino	    (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
520*e4b17023SJohn Marino	  (plus:SF
521*e4b17023SJohn Marino            (vec_select:SF
522*e4b17023SJohn Marino	      (match_operand:V2SF 2 "nonimmediate_operand" "ym")
523*e4b17023SJohn Marino	      (parallel [(const_int  0)]))
524*e4b17023SJohn Marino	    (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))))]
525*e4b17023SJohn Marino  "TARGET_3DNOW"
526*e4b17023SJohn Marino  "pfacc\t{%2, %0|%0, %2}"
527*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
528*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
529*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
530*e4b17023SJohn Marino
531*e4b17023SJohn Marino(define_insn "mmx_hsubv2sf3"
532*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
533*e4b17023SJohn Marino	(vec_concat:V2SF
534*e4b17023SJohn Marino	  (minus:SF
535*e4b17023SJohn Marino	    (vec_select:SF
536*e4b17023SJohn Marino	      (match_operand:V2SF 1 "register_operand" "0")
537*e4b17023SJohn Marino	      (parallel [(const_int  0)]))
538*e4b17023SJohn Marino	    (vec_select:SF (match_dup 1) (parallel [(const_int 1)])))
539*e4b17023SJohn Marino	  (minus:SF
540*e4b17023SJohn Marino            (vec_select:SF
541*e4b17023SJohn Marino	      (match_operand:V2SF 2 "nonimmediate_operand" "ym")
542*e4b17023SJohn Marino	      (parallel [(const_int  0)]))
543*e4b17023SJohn Marino	    (vec_select:SF (match_dup 2) (parallel [(const_int 1)])))))]
544*e4b17023SJohn Marino  "TARGET_3DNOW_A"
545*e4b17023SJohn Marino  "pfnacc\t{%2, %0|%0, %2}"
546*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
547*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
548*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
549*e4b17023SJohn Marino
550*e4b17023SJohn Marino(define_insn "mmx_addsubv2sf3"
551*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
552*e4b17023SJohn Marino        (vec_merge:V2SF
553*e4b17023SJohn Marino          (plus:V2SF
554*e4b17023SJohn Marino            (match_operand:V2SF 1 "register_operand" "0")
555*e4b17023SJohn Marino            (match_operand:V2SF 2 "nonimmediate_operand" "ym"))
556*e4b17023SJohn Marino          (minus:V2SF (match_dup 1) (match_dup 2))
557*e4b17023SJohn Marino          (const_int 1)))]
558*e4b17023SJohn Marino  "TARGET_3DNOW_A"
559*e4b17023SJohn Marino  "pfpnacc\t{%2, %0|%0, %2}"
560*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
561*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
562*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
563*e4b17023SJohn Marino
564*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
565*e4b17023SJohn Marino;;
566*e4b17023SJohn Marino;; Parallel single-precision floating point comparisons
567*e4b17023SJohn Marino;;
568*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
569*e4b17023SJohn Marino
570*e4b17023SJohn Marino(define_expand "mmx_eqv2sf3"
571*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "")
572*e4b17023SJohn Marino	(eq:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "")
573*e4b17023SJohn Marino		 (match_operand:V2SF 2 "nonimmediate_operand" "")))]
574*e4b17023SJohn Marino  "TARGET_3DNOW"
575*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (EQ, V2SFmode, operands);")
576*e4b17023SJohn Marino
577*e4b17023SJohn Marino(define_insn "*mmx_eqv2sf3"
578*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "=y")
579*e4b17023SJohn Marino	(eq:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "%0")
580*e4b17023SJohn Marino		 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
581*e4b17023SJohn Marino  "TARGET_3DNOW && ix86_binary_operator_ok (EQ, V2SFmode, operands)"
582*e4b17023SJohn Marino  "pfcmpeq\t{%2, %0|%0, %2}"
583*e4b17023SJohn Marino  [(set_attr "type" "mmxcmp")
584*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
585*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
586*e4b17023SJohn Marino
587*e4b17023SJohn Marino(define_insn "mmx_gtv2sf3"
588*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "=y")
589*e4b17023SJohn Marino	(gt:V2SI (match_operand:V2SF 1 "register_operand" "0")
590*e4b17023SJohn Marino		 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
591*e4b17023SJohn Marino  "TARGET_3DNOW"
592*e4b17023SJohn Marino  "pfcmpgt\t{%2, %0|%0, %2}"
593*e4b17023SJohn Marino  [(set_attr "type" "mmxcmp")
594*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
595*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
596*e4b17023SJohn Marino
597*e4b17023SJohn Marino(define_insn "mmx_gev2sf3"
598*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "=y")
599*e4b17023SJohn Marino	(ge:V2SI (match_operand:V2SF 1 "register_operand" "0")
600*e4b17023SJohn Marino		 (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
601*e4b17023SJohn Marino  "TARGET_3DNOW"
602*e4b17023SJohn Marino  "pfcmpge\t{%2, %0|%0, %2}"
603*e4b17023SJohn Marino  [(set_attr "type" "mmxcmp")
604*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
605*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
606*e4b17023SJohn Marino
607*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
608*e4b17023SJohn Marino;;
609*e4b17023SJohn Marino;; Parallel single-precision floating point conversion operations
610*e4b17023SJohn Marino;;
611*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
612*e4b17023SJohn Marino
613*e4b17023SJohn Marino(define_insn "mmx_pf2id"
614*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "=y")
615*e4b17023SJohn Marino	(fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))]
616*e4b17023SJohn Marino  "TARGET_3DNOW"
617*e4b17023SJohn Marino  "pf2id\t{%1, %0|%0, %1}"
618*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
619*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
620*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
621*e4b17023SJohn Marino
622*e4b17023SJohn Marino(define_insn "mmx_pf2iw"
623*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "=y")
624*e4b17023SJohn Marino	(sign_extend:V2SI
625*e4b17023SJohn Marino	  (ss_truncate:V2HI
626*e4b17023SJohn Marino	    (fix:V2SI
627*e4b17023SJohn Marino	      (match_operand:V2SF 1 "nonimmediate_operand" "ym")))))]
628*e4b17023SJohn Marino  "TARGET_3DNOW_A"
629*e4b17023SJohn Marino  "pf2iw\t{%1, %0|%0, %1}"
630*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
631*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
632*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
633*e4b17023SJohn Marino
634*e4b17023SJohn Marino(define_insn "mmx_pi2fw"
635*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
636*e4b17023SJohn Marino	(float:V2SF
637*e4b17023SJohn Marino	  (sign_extend:V2SI
638*e4b17023SJohn Marino	    (truncate:V2HI
639*e4b17023SJohn Marino	      (match_operand:V2SI 1 "nonimmediate_operand" "ym")))))]
640*e4b17023SJohn Marino  "TARGET_3DNOW_A"
641*e4b17023SJohn Marino  "pi2fw\t{%1, %0|%0, %1}"
642*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
643*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
644*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
645*e4b17023SJohn Marino
646*e4b17023SJohn Marino(define_insn "mmx_floatv2si2"
647*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
648*e4b17023SJohn Marino	(float:V2SF (match_operand:V2SI 1 "nonimmediate_operand" "ym")))]
649*e4b17023SJohn Marino  "TARGET_3DNOW"
650*e4b17023SJohn Marino  "pi2fd\t{%1, %0|%0, %1}"
651*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
652*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
653*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
654*e4b17023SJohn Marino
655*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
656*e4b17023SJohn Marino;;
657*e4b17023SJohn Marino;; Parallel single-precision floating point element swizzling
658*e4b17023SJohn Marino;;
659*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
660*e4b17023SJohn Marino
661*e4b17023SJohn Marino(define_insn "mmx_pswapdv2sf2"
662*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
663*e4b17023SJohn Marino	(vec_select:V2SF (match_operand:V2SF 1 "nonimmediate_operand" "ym")
664*e4b17023SJohn Marino			 (parallel [(const_int 1) (const_int 0)])))]
665*e4b17023SJohn Marino  "TARGET_3DNOW_A"
666*e4b17023SJohn Marino  "pswapd\t{%1, %0|%0, %1}"
667*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
668*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
669*e4b17023SJohn Marino   (set_attr "mode" "V2SF")])
670*e4b17023SJohn Marino
671*e4b17023SJohn Marino(define_insn "*vec_dupv2sf"
672*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand" "=y")
673*e4b17023SJohn Marino	(vec_duplicate:V2SF
674*e4b17023SJohn Marino	  (match_operand:SF 1 "register_operand" "0")))]
675*e4b17023SJohn Marino  "TARGET_MMX"
676*e4b17023SJohn Marino  "punpckldq\t%0, %0"
677*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
678*e4b17023SJohn Marino   (set_attr "mode" "DI")])
679*e4b17023SJohn Marino
680*e4b17023SJohn Marino(define_insn "*mmx_concatv2sf"
681*e4b17023SJohn Marino  [(set (match_operand:V2SF 0 "register_operand"     "=y,y")
682*e4b17023SJohn Marino	(vec_concat:V2SF
683*e4b17023SJohn Marino	  (match_operand:SF 1 "nonimmediate_operand" " 0,rm")
684*e4b17023SJohn Marino	  (match_operand:SF 2 "vector_move_operand"  "ym,C")))]
685*e4b17023SJohn Marino  "TARGET_MMX && !TARGET_SSE"
686*e4b17023SJohn Marino  "@
687*e4b17023SJohn Marino   punpckldq\t{%2, %0|%0, %2}
688*e4b17023SJohn Marino   movd\t{%1, %0|%0, %1}"
689*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt,mmxmov")
690*e4b17023SJohn Marino   (set_attr "mode" "DI")])
691*e4b17023SJohn Marino
692*e4b17023SJohn Marino(define_expand "vec_setv2sf"
693*e4b17023SJohn Marino  [(match_operand:V2SF 0 "register_operand" "")
694*e4b17023SJohn Marino   (match_operand:SF 1 "register_operand" "")
695*e4b17023SJohn Marino   (match_operand 2 "const_int_operand" "")]
696*e4b17023SJohn Marino  "TARGET_MMX"
697*e4b17023SJohn Marino{
698*e4b17023SJohn Marino  ix86_expand_vector_set (false, operands[0], operands[1],
699*e4b17023SJohn Marino			  INTVAL (operands[2]));
700*e4b17023SJohn Marino  DONE;
701*e4b17023SJohn Marino})
702*e4b17023SJohn Marino
703*e4b17023SJohn Marino;; Avoid combining registers from different units in a single alternative,
704*e4b17023SJohn Marino;; see comment above inline_secondary_memory_needed function in i386.c
705*e4b17023SJohn Marino(define_insn_and_split "*vec_extractv2sf_0"
706*e4b17023SJohn Marino  [(set (match_operand:SF 0 "nonimmediate_operand"     "=x, m,y ,m,f,r")
707*e4b17023SJohn Marino	(vec_select:SF
708*e4b17023SJohn Marino	  (match_operand:V2SF 1 "nonimmediate_operand" " xm,x,ym,y,m,m")
709*e4b17023SJohn Marino	  (parallel [(const_int 0)])))]
710*e4b17023SJohn Marino  "TARGET_MMX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
711*e4b17023SJohn Marino  "#"
712*e4b17023SJohn Marino  "&& reload_completed"
713*e4b17023SJohn Marino  [(const_int 0)]
714*e4b17023SJohn Marino{
715*e4b17023SJohn Marino  rtx op1 = operands[1];
716*e4b17023SJohn Marino  if (REG_P (op1))
717*e4b17023SJohn Marino    op1 = gen_rtx_REG (SFmode, REGNO (op1));
718*e4b17023SJohn Marino  else
719*e4b17023SJohn Marino    op1 = gen_lowpart (SFmode, op1);
720*e4b17023SJohn Marino  emit_move_insn (operands[0], op1);
721*e4b17023SJohn Marino  DONE;
722*e4b17023SJohn Marino})
723*e4b17023SJohn Marino
724*e4b17023SJohn Marino;; Avoid combining registers from different units in a single alternative,
725*e4b17023SJohn Marino;; see comment above inline_secondary_memory_needed function in i386.c
726*e4b17023SJohn Marino(define_insn "*vec_extractv2sf_1"
727*e4b17023SJohn Marino  [(set (match_operand:SF 0 "nonimmediate_operand"     "=y,x,y,x,f,r")
728*e4b17023SJohn Marino	(vec_select:SF
729*e4b17023SJohn Marino	  (match_operand:V2SF 1 "nonimmediate_operand" " 0,0,o,o,o,o")
730*e4b17023SJohn Marino	  (parallel [(const_int 1)])))]
731*e4b17023SJohn Marino  "TARGET_MMX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
732*e4b17023SJohn Marino  "@
733*e4b17023SJohn Marino   punpckhdq\t%0, %0
734*e4b17023SJohn Marino   unpckhps\t%0, %0
735*e4b17023SJohn Marino   #
736*e4b17023SJohn Marino   #
737*e4b17023SJohn Marino   #
738*e4b17023SJohn Marino   #"
739*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt,sselog1,mmxmov,ssemov,fmov,imov")
740*e4b17023SJohn Marino   (set_attr "mode" "DI,V4SF,SF,SF,SF,SF")])
741*e4b17023SJohn Marino
742*e4b17023SJohn Marino(define_split
743*e4b17023SJohn Marino  [(set (match_operand:SF 0 "register_operand" "")
744*e4b17023SJohn Marino	(vec_select:SF
745*e4b17023SJohn Marino	  (match_operand:V2SF 1 "memory_operand" "")
746*e4b17023SJohn Marino	  (parallel [(const_int 1)])))]
747*e4b17023SJohn Marino  "TARGET_MMX && reload_completed"
748*e4b17023SJohn Marino  [(const_int 0)]
749*e4b17023SJohn Marino{
750*e4b17023SJohn Marino  operands[1] = adjust_address (operands[1], SFmode, 4);
751*e4b17023SJohn Marino  emit_move_insn (operands[0], operands[1]);
752*e4b17023SJohn Marino  DONE;
753*e4b17023SJohn Marino})
754*e4b17023SJohn Marino
755*e4b17023SJohn Marino(define_expand "vec_extractv2sf"
756*e4b17023SJohn Marino  [(match_operand:SF 0 "register_operand" "")
757*e4b17023SJohn Marino   (match_operand:V2SF 1 "register_operand" "")
758*e4b17023SJohn Marino   (match_operand 2 "const_int_operand" "")]
759*e4b17023SJohn Marino  "TARGET_MMX"
760*e4b17023SJohn Marino{
761*e4b17023SJohn Marino  ix86_expand_vector_extract (false, operands[0], operands[1],
762*e4b17023SJohn Marino			      INTVAL (operands[2]));
763*e4b17023SJohn Marino  DONE;
764*e4b17023SJohn Marino})
765*e4b17023SJohn Marino
766*e4b17023SJohn Marino(define_expand "vec_initv2sf"
767*e4b17023SJohn Marino  [(match_operand:V2SF 0 "register_operand" "")
768*e4b17023SJohn Marino   (match_operand 1 "" "")]
769*e4b17023SJohn Marino  "TARGET_SSE"
770*e4b17023SJohn Marino{
771*e4b17023SJohn Marino  ix86_expand_vector_init (false, operands[0], operands[1]);
772*e4b17023SJohn Marino  DONE;
773*e4b17023SJohn Marino})
774*e4b17023SJohn Marino
775*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
776*e4b17023SJohn Marino;;
777*e4b17023SJohn Marino;; Parallel integral arithmetic
778*e4b17023SJohn Marino;;
779*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
780*e4b17023SJohn Marino
781*e4b17023SJohn Marino(define_expand "mmx_<plusminus_insn><mode>3"
782*e4b17023SJohn Marino  [(set (match_operand:MMXMODEI8 0 "register_operand" "")
783*e4b17023SJohn Marino	(plusminus:MMXMODEI8
784*e4b17023SJohn Marino	  (match_operand:MMXMODEI8 1 "nonimmediate_operand" "")
785*e4b17023SJohn Marino	  (match_operand:MMXMODEI8 2 "nonimmediate_operand" "")))]
786*e4b17023SJohn Marino  "TARGET_MMX || (TARGET_SSE2 && <MODE>mode == V1DImode)"
787*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
788*e4b17023SJohn Marino
789*e4b17023SJohn Marino(define_insn "*mmx_<plusminus_insn><mode>3"
790*e4b17023SJohn Marino  [(set (match_operand:MMXMODEI8 0 "register_operand" "=y")
791*e4b17023SJohn Marino        (plusminus:MMXMODEI8
792*e4b17023SJohn Marino	  (match_operand:MMXMODEI8 1 "nonimmediate_operand" "<comm>0")
793*e4b17023SJohn Marino	  (match_operand:MMXMODEI8 2 "nonimmediate_operand" "ym")))]
794*e4b17023SJohn Marino  "(TARGET_MMX || (TARGET_SSE2 && <MODE>mode == V1DImode))
795*e4b17023SJohn Marino   && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
796*e4b17023SJohn Marino  "p<plusminus_mnemonic><mmxvecsize>\t{%2, %0|%0, %2}"
797*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
798*e4b17023SJohn Marino   (set_attr "mode" "DI")])
799*e4b17023SJohn Marino
800*e4b17023SJohn Marino(define_expand "mmx_<plusminus_insn><mode>3"
801*e4b17023SJohn Marino  [(set (match_operand:MMXMODE12 0 "register_operand" "")
802*e4b17023SJohn Marino	(sat_plusminus:MMXMODE12
803*e4b17023SJohn Marino	  (match_operand:MMXMODE12 1 "nonimmediate_operand" "")
804*e4b17023SJohn Marino	  (match_operand:MMXMODE12 2 "nonimmediate_operand" "")))]
805*e4b17023SJohn Marino  "TARGET_MMX"
806*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
807*e4b17023SJohn Marino
808*e4b17023SJohn Marino(define_insn "*mmx_<plusminus_insn><mode>3"
809*e4b17023SJohn Marino  [(set (match_operand:MMXMODE12 0 "register_operand" "=y")
810*e4b17023SJohn Marino        (sat_plusminus:MMXMODE12
811*e4b17023SJohn Marino	  (match_operand:MMXMODE12 1 "nonimmediate_operand" "<comm>0")
812*e4b17023SJohn Marino	  (match_operand:MMXMODE12 2 "nonimmediate_operand" "ym")))]
813*e4b17023SJohn Marino  "TARGET_MMX && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
814*e4b17023SJohn Marino  "p<plusminus_mnemonic><mmxvecsize>\t{%2, %0|%0, %2}"
815*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
816*e4b17023SJohn Marino   (set_attr "mode" "DI")])
817*e4b17023SJohn Marino
818*e4b17023SJohn Marino(define_expand "mmx_mulv4hi3"
819*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "")
820*e4b17023SJohn Marino        (mult:V4HI (match_operand:V4HI 1 "nonimmediate_operand" "")
821*e4b17023SJohn Marino		   (match_operand:V4HI 2 "nonimmediate_operand" "")))]
822*e4b17023SJohn Marino  "TARGET_MMX"
823*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (MULT, V4HImode, operands);")
824*e4b17023SJohn Marino
825*e4b17023SJohn Marino(define_insn "*mmx_mulv4hi3"
826*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
827*e4b17023SJohn Marino        (mult:V4HI (match_operand:V4HI 1 "nonimmediate_operand" "%0")
828*e4b17023SJohn Marino		   (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
829*e4b17023SJohn Marino  "TARGET_MMX && ix86_binary_operator_ok (MULT, V4HImode, operands)"
830*e4b17023SJohn Marino  "pmullw\t{%2, %0|%0, %2}"
831*e4b17023SJohn Marino  [(set_attr "type" "mmxmul")
832*e4b17023SJohn Marino   (set_attr "mode" "DI")])
833*e4b17023SJohn Marino
834*e4b17023SJohn Marino(define_expand "mmx_smulv4hi3_highpart"
835*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "")
836*e4b17023SJohn Marino	(truncate:V4HI
837*e4b17023SJohn Marino	  (lshiftrt:V4SI
838*e4b17023SJohn Marino	    (mult:V4SI
839*e4b17023SJohn Marino	      (sign_extend:V4SI
840*e4b17023SJohn Marino		(match_operand:V4HI 1 "nonimmediate_operand" ""))
841*e4b17023SJohn Marino	      (sign_extend:V4SI
842*e4b17023SJohn Marino		(match_operand:V4HI 2 "nonimmediate_operand" "")))
843*e4b17023SJohn Marino	    (const_int 16))))]
844*e4b17023SJohn Marino  "TARGET_MMX"
845*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (MULT, V4HImode, operands);")
846*e4b17023SJohn Marino
847*e4b17023SJohn Marino(define_insn "*mmx_smulv4hi3_highpart"
848*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
849*e4b17023SJohn Marino	(truncate:V4HI
850*e4b17023SJohn Marino	  (lshiftrt:V4SI
851*e4b17023SJohn Marino	    (mult:V4SI
852*e4b17023SJohn Marino	      (sign_extend:V4SI
853*e4b17023SJohn Marino		(match_operand:V4HI 1 "nonimmediate_operand" "%0"))
854*e4b17023SJohn Marino	      (sign_extend:V4SI
855*e4b17023SJohn Marino		(match_operand:V4HI 2 "nonimmediate_operand" "ym")))
856*e4b17023SJohn Marino	    (const_int 16))))]
857*e4b17023SJohn Marino  "TARGET_MMX && ix86_binary_operator_ok (MULT, V4HImode, operands)"
858*e4b17023SJohn Marino  "pmulhw\t{%2, %0|%0, %2}"
859*e4b17023SJohn Marino  [(set_attr "type" "mmxmul")
860*e4b17023SJohn Marino   (set_attr "mode" "DI")])
861*e4b17023SJohn Marino
862*e4b17023SJohn Marino(define_expand "mmx_umulv4hi3_highpart"
863*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "")
864*e4b17023SJohn Marino	(truncate:V4HI
865*e4b17023SJohn Marino	  (lshiftrt:V4SI
866*e4b17023SJohn Marino	    (mult:V4SI
867*e4b17023SJohn Marino	      (zero_extend:V4SI
868*e4b17023SJohn Marino		(match_operand:V4HI 1 "nonimmediate_operand" ""))
869*e4b17023SJohn Marino	      (zero_extend:V4SI
870*e4b17023SJohn Marino		(match_operand:V4HI 2 "nonimmediate_operand" "")))
871*e4b17023SJohn Marino	    (const_int 16))))]
872*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
873*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (MULT, V4HImode, operands);")
874*e4b17023SJohn Marino
875*e4b17023SJohn Marino(define_insn "*mmx_umulv4hi3_highpart"
876*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
877*e4b17023SJohn Marino	(truncate:V4HI
878*e4b17023SJohn Marino	  (lshiftrt:V4SI
879*e4b17023SJohn Marino	    (mult:V4SI
880*e4b17023SJohn Marino	      (zero_extend:V4SI
881*e4b17023SJohn Marino		(match_operand:V4HI 1 "nonimmediate_operand" "%0"))
882*e4b17023SJohn Marino	      (zero_extend:V4SI
883*e4b17023SJohn Marino		(match_operand:V4HI 2 "nonimmediate_operand" "ym")))
884*e4b17023SJohn Marino	  (const_int 16))))]
885*e4b17023SJohn Marino  "(TARGET_SSE || TARGET_3DNOW_A)
886*e4b17023SJohn Marino   && ix86_binary_operator_ok (MULT, V4HImode, operands)"
887*e4b17023SJohn Marino  "pmulhuw\t{%2, %0|%0, %2}"
888*e4b17023SJohn Marino  [(set_attr "type" "mmxmul")
889*e4b17023SJohn Marino   (set_attr "mode" "DI")])
890*e4b17023SJohn Marino
891*e4b17023SJohn Marino(define_expand "mmx_pmaddwd"
892*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "")
893*e4b17023SJohn Marino        (plus:V2SI
894*e4b17023SJohn Marino	  (mult:V2SI
895*e4b17023SJohn Marino	    (sign_extend:V2SI
896*e4b17023SJohn Marino	      (vec_select:V2HI
897*e4b17023SJohn Marino		(match_operand:V4HI 1 "nonimmediate_operand" "")
898*e4b17023SJohn Marino		(parallel [(const_int 0) (const_int 2)])))
899*e4b17023SJohn Marino	    (sign_extend:V2SI
900*e4b17023SJohn Marino	      (vec_select:V2HI
901*e4b17023SJohn Marino		(match_operand:V4HI 2 "nonimmediate_operand" "")
902*e4b17023SJohn Marino		(parallel [(const_int 0) (const_int 2)]))))
903*e4b17023SJohn Marino	  (mult:V2SI
904*e4b17023SJohn Marino	    (sign_extend:V2SI
905*e4b17023SJohn Marino	      (vec_select:V2HI (match_dup 1)
906*e4b17023SJohn Marino		(parallel [(const_int 1) (const_int 3)])))
907*e4b17023SJohn Marino	    (sign_extend:V2SI
908*e4b17023SJohn Marino	      (vec_select:V2HI (match_dup 2)
909*e4b17023SJohn Marino		(parallel [(const_int 1) (const_int 3)]))))))]
910*e4b17023SJohn Marino  "TARGET_MMX"
911*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (MULT, V4HImode, operands);")
912*e4b17023SJohn Marino
913*e4b17023SJohn Marino(define_insn "*mmx_pmaddwd"
914*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "=y")
915*e4b17023SJohn Marino        (plus:V2SI
916*e4b17023SJohn Marino	  (mult:V2SI
917*e4b17023SJohn Marino	    (sign_extend:V2SI
918*e4b17023SJohn Marino	      (vec_select:V2HI
919*e4b17023SJohn Marino		(match_operand:V4HI 1 "nonimmediate_operand" "%0")
920*e4b17023SJohn Marino		(parallel [(const_int 0) (const_int 2)])))
921*e4b17023SJohn Marino	    (sign_extend:V2SI
922*e4b17023SJohn Marino	      (vec_select:V2HI
923*e4b17023SJohn Marino		(match_operand:V4HI 2 "nonimmediate_operand" "ym")
924*e4b17023SJohn Marino		(parallel [(const_int 0) (const_int 2)]))))
925*e4b17023SJohn Marino	  (mult:V2SI
926*e4b17023SJohn Marino	    (sign_extend:V2SI
927*e4b17023SJohn Marino	      (vec_select:V2HI (match_dup 1)
928*e4b17023SJohn Marino		(parallel [(const_int 1) (const_int 3)])))
929*e4b17023SJohn Marino	    (sign_extend:V2SI
930*e4b17023SJohn Marino	      (vec_select:V2HI (match_dup 2)
931*e4b17023SJohn Marino		(parallel [(const_int 1) (const_int 3)]))))))]
932*e4b17023SJohn Marino  "TARGET_MMX && ix86_binary_operator_ok (MULT, V4HImode, operands)"
933*e4b17023SJohn Marino  "pmaddwd\t{%2, %0|%0, %2}"
934*e4b17023SJohn Marino  [(set_attr "type" "mmxmul")
935*e4b17023SJohn Marino   (set_attr "mode" "DI")])
936*e4b17023SJohn Marino
937*e4b17023SJohn Marino(define_expand "mmx_pmulhrwv4hi3"
938*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "")
939*e4b17023SJohn Marino	(truncate:V4HI
940*e4b17023SJohn Marino	  (lshiftrt:V4SI
941*e4b17023SJohn Marino	    (plus:V4SI
942*e4b17023SJohn Marino	      (mult:V4SI
943*e4b17023SJohn Marino	        (sign_extend:V4SI
944*e4b17023SJohn Marino		  (match_operand:V4HI 1 "nonimmediate_operand" ""))
945*e4b17023SJohn Marino	        (sign_extend:V4SI
946*e4b17023SJohn Marino		  (match_operand:V4HI 2 "nonimmediate_operand" "")))
947*e4b17023SJohn Marino	      (const_vector:V4SI [(const_int 32768) (const_int 32768)
948*e4b17023SJohn Marino				  (const_int 32768) (const_int 32768)]))
949*e4b17023SJohn Marino	    (const_int 16))))]
950*e4b17023SJohn Marino  "TARGET_3DNOW"
951*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (MULT, V4HImode, operands);")
952*e4b17023SJohn Marino
953*e4b17023SJohn Marino(define_insn "*mmx_pmulhrwv4hi3"
954*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
955*e4b17023SJohn Marino	(truncate:V4HI
956*e4b17023SJohn Marino	  (lshiftrt:V4SI
957*e4b17023SJohn Marino	    (plus:V4SI
958*e4b17023SJohn Marino	      (mult:V4SI
959*e4b17023SJohn Marino	        (sign_extend:V4SI
960*e4b17023SJohn Marino		  (match_operand:V4HI 1 "nonimmediate_operand" "%0"))
961*e4b17023SJohn Marino	        (sign_extend:V4SI
962*e4b17023SJohn Marino		  (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
963*e4b17023SJohn Marino	      (const_vector:V4SI [(const_int 32768) (const_int 32768)
964*e4b17023SJohn Marino				  (const_int 32768) (const_int 32768)]))
965*e4b17023SJohn Marino	    (const_int 16))))]
966*e4b17023SJohn Marino  "TARGET_3DNOW && ix86_binary_operator_ok (MULT, V4HImode, operands)"
967*e4b17023SJohn Marino  "pmulhrw\t{%2, %0|%0, %2}"
968*e4b17023SJohn Marino  [(set_attr "type" "mmxmul")
969*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
970*e4b17023SJohn Marino   (set_attr "mode" "DI")])
971*e4b17023SJohn Marino
972*e4b17023SJohn Marino(define_expand "sse2_umulv1siv1di3"
973*e4b17023SJohn Marino  [(set (match_operand:V1DI 0 "register_operand" "")
974*e4b17023SJohn Marino        (mult:V1DI
975*e4b17023SJohn Marino	  (zero_extend:V1DI
976*e4b17023SJohn Marino	    (vec_select:V1SI
977*e4b17023SJohn Marino	      (match_operand:V2SI 1 "nonimmediate_operand" "")
978*e4b17023SJohn Marino	      (parallel [(const_int 0)])))
979*e4b17023SJohn Marino	  (zero_extend:V1DI
980*e4b17023SJohn Marino	    (vec_select:V1SI
981*e4b17023SJohn Marino	      (match_operand:V2SI 2 "nonimmediate_operand" "")
982*e4b17023SJohn Marino	      (parallel [(const_int 0)])))))]
983*e4b17023SJohn Marino  "TARGET_SSE2"
984*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (MULT, V2SImode, operands);")
985*e4b17023SJohn Marino
986*e4b17023SJohn Marino(define_insn "*sse2_umulv1siv1di3"
987*e4b17023SJohn Marino  [(set (match_operand:V1DI 0 "register_operand" "=y")
988*e4b17023SJohn Marino        (mult:V1DI
989*e4b17023SJohn Marino	  (zero_extend:V1DI
990*e4b17023SJohn Marino	    (vec_select:V1SI
991*e4b17023SJohn Marino	      (match_operand:V2SI 1 "nonimmediate_operand" "%0")
992*e4b17023SJohn Marino	      (parallel [(const_int 0)])))
993*e4b17023SJohn Marino	  (zero_extend:V1DI
994*e4b17023SJohn Marino	    (vec_select:V1SI
995*e4b17023SJohn Marino	      (match_operand:V2SI 2 "nonimmediate_operand" "ym")
996*e4b17023SJohn Marino	      (parallel [(const_int 0)])))))]
997*e4b17023SJohn Marino  "TARGET_SSE2 && ix86_binary_operator_ok (MULT, V2SImode, operands)"
998*e4b17023SJohn Marino  "pmuludq\t{%2, %0|%0, %2}"
999*e4b17023SJohn Marino  [(set_attr "type" "mmxmul")
1000*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1001*e4b17023SJohn Marino
1002*e4b17023SJohn Marino(define_expand "mmx_<code>v4hi3"
1003*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "")
1004*e4b17023SJohn Marino        (smaxmin:V4HI
1005*e4b17023SJohn Marino	  (match_operand:V4HI 1 "nonimmediate_operand" "")
1006*e4b17023SJohn Marino	  (match_operand:V4HI 2 "nonimmediate_operand" "")))]
1007*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
1008*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (<CODE>, V4HImode, operands);")
1009*e4b17023SJohn Marino
1010*e4b17023SJohn Marino(define_insn "*mmx_<code>v4hi3"
1011*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
1012*e4b17023SJohn Marino        (smaxmin:V4HI
1013*e4b17023SJohn Marino	  (match_operand:V4HI 1 "nonimmediate_operand" "%0")
1014*e4b17023SJohn Marino	  (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
1015*e4b17023SJohn Marino  "(TARGET_SSE || TARGET_3DNOW_A)
1016*e4b17023SJohn Marino   && ix86_binary_operator_ok (<CODE>, V4HImode, operands)"
1017*e4b17023SJohn Marino  "p<maxmin_int>w\t{%2, %0|%0, %2}"
1018*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
1019*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1020*e4b17023SJohn Marino
1021*e4b17023SJohn Marino(define_expand "mmx_<code>v8qi3"
1022*e4b17023SJohn Marino  [(set (match_operand:V8QI 0 "register_operand" "")
1023*e4b17023SJohn Marino        (umaxmin:V8QI
1024*e4b17023SJohn Marino	  (match_operand:V8QI 1 "nonimmediate_operand" "")
1025*e4b17023SJohn Marino	  (match_operand:V8QI 2 "nonimmediate_operand" "")))]
1026*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
1027*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (<CODE>, V8QImode, operands);")
1028*e4b17023SJohn Marino
1029*e4b17023SJohn Marino(define_insn "*mmx_<code>v8qi3"
1030*e4b17023SJohn Marino  [(set (match_operand:V8QI 0 "register_operand" "=y")
1031*e4b17023SJohn Marino        (umaxmin:V8QI
1032*e4b17023SJohn Marino	  (match_operand:V8QI 1 "nonimmediate_operand" "%0")
1033*e4b17023SJohn Marino	  (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
1034*e4b17023SJohn Marino  "(TARGET_SSE || TARGET_3DNOW_A)
1035*e4b17023SJohn Marino   && ix86_binary_operator_ok (<CODE>, V8QImode, operands)"
1036*e4b17023SJohn Marino  "p<maxmin_int>b\t{%2, %0|%0, %2}"
1037*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
1038*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1039*e4b17023SJohn Marino
1040*e4b17023SJohn Marino(define_insn "mmx_ashr<mode>3"
1041*e4b17023SJohn Marino  [(set (match_operand:MMXMODE24 0 "register_operand" "=y")
1042*e4b17023SJohn Marino        (ashiftrt:MMXMODE24
1043*e4b17023SJohn Marino	  (match_operand:MMXMODE24 1 "register_operand" "0")
1044*e4b17023SJohn Marino	  (match_operand:SI 2 "nonmemory_operand" "yN")))]
1045*e4b17023SJohn Marino  "TARGET_MMX"
1046*e4b17023SJohn Marino  "psra<mmxvecsize>\t{%2, %0|%0, %2}"
1047*e4b17023SJohn Marino  [(set_attr "type" "mmxshft")
1048*e4b17023SJohn Marino   (set (attr "length_immediate")
1049*e4b17023SJohn Marino     (if_then_else (match_operand 2 "const_int_operand" "")
1050*e4b17023SJohn Marino       (const_string "1")
1051*e4b17023SJohn Marino       (const_string "0")))
1052*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1053*e4b17023SJohn Marino
1054*e4b17023SJohn Marino(define_insn "mmx_<shift_insn><mode>3"
1055*e4b17023SJohn Marino  [(set (match_operand:MMXMODE248 0 "register_operand" "=y")
1056*e4b17023SJohn Marino        (any_lshift:MMXMODE248
1057*e4b17023SJohn Marino	  (match_operand:MMXMODE248 1 "register_operand" "0")
1058*e4b17023SJohn Marino	  (match_operand:SI 2 "nonmemory_operand" "yN")))]
1059*e4b17023SJohn Marino  "TARGET_MMX"
1060*e4b17023SJohn Marino  "p<vshift><mmxvecsize>\t{%2, %0|%0, %2}"
1061*e4b17023SJohn Marino  [(set_attr "type" "mmxshft")
1062*e4b17023SJohn Marino   (set (attr "length_immediate")
1063*e4b17023SJohn Marino     (if_then_else (match_operand 2 "const_int_operand" "")
1064*e4b17023SJohn Marino       (const_string "1")
1065*e4b17023SJohn Marino       (const_string "0")))
1066*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1067*e4b17023SJohn Marino
1068*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1069*e4b17023SJohn Marino;;
1070*e4b17023SJohn Marino;; Parallel integral comparisons
1071*e4b17023SJohn Marino;;
1072*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1073*e4b17023SJohn Marino
1074*e4b17023SJohn Marino(define_expand "mmx_eq<mode>3"
1075*e4b17023SJohn Marino  [(set (match_operand:MMXMODEI 0 "register_operand" "")
1076*e4b17023SJohn Marino        (eq:MMXMODEI
1077*e4b17023SJohn Marino	  (match_operand:MMXMODEI 1 "nonimmediate_operand" "")
1078*e4b17023SJohn Marino	  (match_operand:MMXMODEI 2 "nonimmediate_operand" "")))]
1079*e4b17023SJohn Marino  "TARGET_MMX"
1080*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (EQ, <MODE>mode, operands);")
1081*e4b17023SJohn Marino
1082*e4b17023SJohn Marino(define_insn "*mmx_eq<mode>3"
1083*e4b17023SJohn Marino  [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
1084*e4b17023SJohn Marino        (eq:MMXMODEI
1085*e4b17023SJohn Marino	  (match_operand:MMXMODEI 1 "nonimmediate_operand" "%0")
1086*e4b17023SJohn Marino	  (match_operand:MMXMODEI 2 "nonimmediate_operand" "ym")))]
1087*e4b17023SJohn Marino  "TARGET_MMX && ix86_binary_operator_ok (EQ, <MODE>mode, operands)"
1088*e4b17023SJohn Marino  "pcmpeq<mmxvecsize>\t{%2, %0|%0, %2}"
1089*e4b17023SJohn Marino  [(set_attr "type" "mmxcmp")
1090*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1091*e4b17023SJohn Marino
1092*e4b17023SJohn Marino(define_insn "mmx_gt<mode>3"
1093*e4b17023SJohn Marino  [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
1094*e4b17023SJohn Marino        (gt:MMXMODEI
1095*e4b17023SJohn Marino	  (match_operand:MMXMODEI 1 "register_operand" "0")
1096*e4b17023SJohn Marino	  (match_operand:MMXMODEI 2 "nonimmediate_operand" "ym")))]
1097*e4b17023SJohn Marino  "TARGET_MMX"
1098*e4b17023SJohn Marino  "pcmpgt<mmxvecsize>\t{%2, %0|%0, %2}"
1099*e4b17023SJohn Marino  [(set_attr "type" "mmxcmp")
1100*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1101*e4b17023SJohn Marino
1102*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1103*e4b17023SJohn Marino;;
1104*e4b17023SJohn Marino;; Parallel integral logical operations
1105*e4b17023SJohn Marino;;
1106*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1107*e4b17023SJohn Marino
1108*e4b17023SJohn Marino(define_insn "mmx_andnot<mode>3"
1109*e4b17023SJohn Marino  [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
1110*e4b17023SJohn Marino	(and:MMXMODEI
1111*e4b17023SJohn Marino	  (not:MMXMODEI (match_operand:MMXMODEI 1 "register_operand" "0"))
1112*e4b17023SJohn Marino	  (match_operand:MMXMODEI 2 "nonimmediate_operand" "ym")))]
1113*e4b17023SJohn Marino  "TARGET_MMX"
1114*e4b17023SJohn Marino  "pandn\t{%2, %0|%0, %2}"
1115*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
1116*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1117*e4b17023SJohn Marino
1118*e4b17023SJohn Marino(define_expand "mmx_<code><mode>3"
1119*e4b17023SJohn Marino  [(set (match_operand:MMXMODEI 0 "register_operand" "")
1120*e4b17023SJohn Marino	(any_logic:MMXMODEI
1121*e4b17023SJohn Marino	  (match_operand:MMXMODEI 1 "nonimmediate_operand" "")
1122*e4b17023SJohn Marino	  (match_operand:MMXMODEI 2 "nonimmediate_operand" "")))]
1123*e4b17023SJohn Marino  "TARGET_MMX"
1124*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (<CODE>, <MODE>mode, operands);")
1125*e4b17023SJohn Marino
1126*e4b17023SJohn Marino(define_insn "*mmx_<code><mode>3"
1127*e4b17023SJohn Marino  [(set (match_operand:MMXMODEI 0 "register_operand" "=y")
1128*e4b17023SJohn Marino        (any_logic:MMXMODEI
1129*e4b17023SJohn Marino	  (match_operand:MMXMODEI 1 "nonimmediate_operand" "%0")
1130*e4b17023SJohn Marino	  (match_operand:MMXMODEI 2 "nonimmediate_operand" "ym")))]
1131*e4b17023SJohn Marino  "TARGET_MMX && ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
1132*e4b17023SJohn Marino  "p<logic>\t{%2, %0|%0, %2}"
1133*e4b17023SJohn Marino  [(set_attr "type" "mmxadd")
1134*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1135*e4b17023SJohn Marino
1136*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1137*e4b17023SJohn Marino;;
1138*e4b17023SJohn Marino;; Parallel integral element swizzling
1139*e4b17023SJohn Marino;;
1140*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1141*e4b17023SJohn Marino
1142*e4b17023SJohn Marino(define_insn "mmx_packsswb"
1143*e4b17023SJohn Marino  [(set (match_operand:V8QI 0 "register_operand" "=y")
1144*e4b17023SJohn Marino	(vec_concat:V8QI
1145*e4b17023SJohn Marino	  (ss_truncate:V4QI
1146*e4b17023SJohn Marino	    (match_operand:V4HI 1 "register_operand" "0"))
1147*e4b17023SJohn Marino	  (ss_truncate:V4QI
1148*e4b17023SJohn Marino	    (match_operand:V4HI 2 "nonimmediate_operand" "ym"))))]
1149*e4b17023SJohn Marino  "TARGET_MMX"
1150*e4b17023SJohn Marino  "packsswb\t{%2, %0|%0, %2}"
1151*e4b17023SJohn Marino  [(set_attr "type" "mmxshft")
1152*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1153*e4b17023SJohn Marino
1154*e4b17023SJohn Marino(define_insn "mmx_packssdw"
1155*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
1156*e4b17023SJohn Marino	(vec_concat:V4HI
1157*e4b17023SJohn Marino	  (ss_truncate:V2HI
1158*e4b17023SJohn Marino	    (match_operand:V2SI 1 "register_operand" "0"))
1159*e4b17023SJohn Marino	  (ss_truncate:V2HI
1160*e4b17023SJohn Marino	    (match_operand:V2SI 2 "nonimmediate_operand" "ym"))))]
1161*e4b17023SJohn Marino  "TARGET_MMX"
1162*e4b17023SJohn Marino  "packssdw\t{%2, %0|%0, %2}"
1163*e4b17023SJohn Marino  [(set_attr "type" "mmxshft")
1164*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1165*e4b17023SJohn Marino
1166*e4b17023SJohn Marino(define_insn "mmx_packuswb"
1167*e4b17023SJohn Marino  [(set (match_operand:V8QI 0 "register_operand" "=y")
1168*e4b17023SJohn Marino	(vec_concat:V8QI
1169*e4b17023SJohn Marino	  (us_truncate:V4QI
1170*e4b17023SJohn Marino	    (match_operand:V4HI 1 "register_operand" "0"))
1171*e4b17023SJohn Marino	  (us_truncate:V4QI
1172*e4b17023SJohn Marino	    (match_operand:V4HI 2 "nonimmediate_operand" "ym"))))]
1173*e4b17023SJohn Marino  "TARGET_MMX"
1174*e4b17023SJohn Marino  "packuswb\t{%2, %0|%0, %2}"
1175*e4b17023SJohn Marino  [(set_attr "type" "mmxshft")
1176*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1177*e4b17023SJohn Marino
1178*e4b17023SJohn Marino(define_insn "mmx_punpckhbw"
1179*e4b17023SJohn Marino  [(set (match_operand:V8QI 0 "register_operand" "=y")
1180*e4b17023SJohn Marino	(vec_select:V8QI
1181*e4b17023SJohn Marino	  (vec_concat:V16QI
1182*e4b17023SJohn Marino	    (match_operand:V8QI 1 "register_operand" "0")
1183*e4b17023SJohn Marino	    (match_operand:V8QI 2 "nonimmediate_operand" "ym"))
1184*e4b17023SJohn Marino          (parallel [(const_int 4) (const_int 12)
1185*e4b17023SJohn Marino                     (const_int 5) (const_int 13)
1186*e4b17023SJohn Marino                     (const_int 6) (const_int 14)
1187*e4b17023SJohn Marino                     (const_int 7) (const_int 15)])))]
1188*e4b17023SJohn Marino  "TARGET_MMX"
1189*e4b17023SJohn Marino  "punpckhbw\t{%2, %0|%0, %2}"
1190*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1191*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1192*e4b17023SJohn Marino
1193*e4b17023SJohn Marino(define_insn "mmx_punpcklbw"
1194*e4b17023SJohn Marino  [(set (match_operand:V8QI 0 "register_operand" "=y")
1195*e4b17023SJohn Marino	(vec_select:V8QI
1196*e4b17023SJohn Marino	  (vec_concat:V16QI
1197*e4b17023SJohn Marino	    (match_operand:V8QI 1 "register_operand" "0")
1198*e4b17023SJohn Marino	    (match_operand:V8QI 2 "nonimmediate_operand" "ym"))
1199*e4b17023SJohn Marino          (parallel [(const_int 0) (const_int 8)
1200*e4b17023SJohn Marino                     (const_int 1) (const_int 9)
1201*e4b17023SJohn Marino                     (const_int 2) (const_int 10)
1202*e4b17023SJohn Marino                     (const_int 3) (const_int 11)])))]
1203*e4b17023SJohn Marino  "TARGET_MMX"
1204*e4b17023SJohn Marino  "punpcklbw\t{%2, %0|%0, %2}"
1205*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1206*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1207*e4b17023SJohn Marino
1208*e4b17023SJohn Marino(define_insn "mmx_punpckhwd"
1209*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
1210*e4b17023SJohn Marino	(vec_select:V4HI
1211*e4b17023SJohn Marino	  (vec_concat:V8HI
1212*e4b17023SJohn Marino	    (match_operand:V4HI 1 "register_operand" "0")
1213*e4b17023SJohn Marino	    (match_operand:V4HI 2 "nonimmediate_operand" "ym"))
1214*e4b17023SJohn Marino          (parallel [(const_int 2) (const_int 6)
1215*e4b17023SJohn Marino                     (const_int 3) (const_int 7)])))]
1216*e4b17023SJohn Marino  "TARGET_MMX"
1217*e4b17023SJohn Marino  "punpckhwd\t{%2, %0|%0, %2}"
1218*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1219*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1220*e4b17023SJohn Marino
1221*e4b17023SJohn Marino(define_insn "mmx_punpcklwd"
1222*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
1223*e4b17023SJohn Marino	(vec_select:V4HI
1224*e4b17023SJohn Marino	  (vec_concat:V8HI
1225*e4b17023SJohn Marino	    (match_operand:V4HI 1 "register_operand" "0")
1226*e4b17023SJohn Marino	    (match_operand:V4HI 2 "nonimmediate_operand" "ym"))
1227*e4b17023SJohn Marino          (parallel [(const_int 0) (const_int 4)
1228*e4b17023SJohn Marino                     (const_int 1) (const_int 5)])))]
1229*e4b17023SJohn Marino  "TARGET_MMX"
1230*e4b17023SJohn Marino  "punpcklwd\t{%2, %0|%0, %2}"
1231*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1232*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1233*e4b17023SJohn Marino
1234*e4b17023SJohn Marino(define_insn "mmx_punpckhdq"
1235*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "=y")
1236*e4b17023SJohn Marino	(vec_select:V2SI
1237*e4b17023SJohn Marino	  (vec_concat:V4SI
1238*e4b17023SJohn Marino	    (match_operand:V2SI 1 "register_operand" "0")
1239*e4b17023SJohn Marino	    (match_operand:V2SI 2 "nonimmediate_operand" "ym"))
1240*e4b17023SJohn Marino	  (parallel [(const_int 1)
1241*e4b17023SJohn Marino		     (const_int 3)])))]
1242*e4b17023SJohn Marino  "TARGET_MMX"
1243*e4b17023SJohn Marino  "punpckhdq\t{%2, %0|%0, %2}"
1244*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1245*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1246*e4b17023SJohn Marino
1247*e4b17023SJohn Marino(define_insn "mmx_punpckldq"
1248*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "=y")
1249*e4b17023SJohn Marino	(vec_select:V2SI
1250*e4b17023SJohn Marino	  (vec_concat:V4SI
1251*e4b17023SJohn Marino	    (match_operand:V2SI 1 "register_operand" "0")
1252*e4b17023SJohn Marino	    (match_operand:V2SI 2 "nonimmediate_operand" "ym"))
1253*e4b17023SJohn Marino	  (parallel [(const_int 0)
1254*e4b17023SJohn Marino		     (const_int 2)])))]
1255*e4b17023SJohn Marino  "TARGET_MMX"
1256*e4b17023SJohn Marino  "punpckldq\t{%2, %0|%0, %2}"
1257*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1258*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1259*e4b17023SJohn Marino
1260*e4b17023SJohn Marino(define_expand "mmx_pinsrw"
1261*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "")
1262*e4b17023SJohn Marino        (vec_merge:V4HI
1263*e4b17023SJohn Marino          (vec_duplicate:V4HI
1264*e4b17023SJohn Marino            (match_operand:SI 2 "nonimmediate_operand" ""))
1265*e4b17023SJohn Marino	  (match_operand:V4HI 1 "register_operand" "")
1266*e4b17023SJohn Marino          (match_operand:SI 3 "const_0_to_3_operand" "")))]
1267*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
1268*e4b17023SJohn Marino{
1269*e4b17023SJohn Marino  operands[2] = gen_lowpart (HImode, operands[2]);
1270*e4b17023SJohn Marino  operands[3] = GEN_INT (1 << INTVAL (operands[3]));
1271*e4b17023SJohn Marino})
1272*e4b17023SJohn Marino
1273*e4b17023SJohn Marino(define_insn "*mmx_pinsrw"
1274*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
1275*e4b17023SJohn Marino        (vec_merge:V4HI
1276*e4b17023SJohn Marino          (vec_duplicate:V4HI
1277*e4b17023SJohn Marino            (match_operand:HI 2 "nonimmediate_operand" "rm"))
1278*e4b17023SJohn Marino	  (match_operand:V4HI 1 "register_operand" "0")
1279*e4b17023SJohn Marino          (match_operand:SI 3 "const_int_operand" "")))]
1280*e4b17023SJohn Marino  "(TARGET_SSE || TARGET_3DNOW_A)
1281*e4b17023SJohn Marino   && ((unsigned) exact_log2 (INTVAL (operands[3]))
1282*e4b17023SJohn Marino       < GET_MODE_NUNITS (V4HImode))"
1283*e4b17023SJohn Marino{
1284*e4b17023SJohn Marino  operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
1285*e4b17023SJohn Marino  if (MEM_P (operands[2]))
1286*e4b17023SJohn Marino    return "pinsrw\t{%3, %2, %0|%0, %2, %3}";
1287*e4b17023SJohn Marino  else
1288*e4b17023SJohn Marino    return "pinsrw\t{%3, %k2, %0|%0, %k2, %3}";
1289*e4b17023SJohn Marino}
1290*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1291*e4b17023SJohn Marino   (set_attr "length_immediate" "1")
1292*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1293*e4b17023SJohn Marino
1294*e4b17023SJohn Marino(define_insn "mmx_pextrw"
1295*e4b17023SJohn Marino  [(set (match_operand:SI 0 "register_operand" "=r")
1296*e4b17023SJohn Marino        (zero_extend:SI
1297*e4b17023SJohn Marino	  (vec_select:HI
1298*e4b17023SJohn Marino	    (match_operand:V4HI 1 "register_operand" "y")
1299*e4b17023SJohn Marino	    (parallel [(match_operand:SI 2 "const_0_to_3_operand" "n")]))))]
1300*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
1301*e4b17023SJohn Marino  "pextrw\t{%2, %1, %0|%0, %1, %2}"
1302*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1303*e4b17023SJohn Marino   (set_attr "length_immediate" "1")
1304*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1305*e4b17023SJohn Marino
1306*e4b17023SJohn Marino(define_expand "mmx_pshufw"
1307*e4b17023SJohn Marino  [(match_operand:V4HI 0 "register_operand" "")
1308*e4b17023SJohn Marino   (match_operand:V4HI 1 "nonimmediate_operand" "")
1309*e4b17023SJohn Marino   (match_operand:SI 2 "const_int_operand" "")]
1310*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
1311*e4b17023SJohn Marino{
1312*e4b17023SJohn Marino  int mask = INTVAL (operands[2]);
1313*e4b17023SJohn Marino  emit_insn (gen_mmx_pshufw_1 (operands[0], operands[1],
1314*e4b17023SJohn Marino                               GEN_INT ((mask >> 0) & 3),
1315*e4b17023SJohn Marino                               GEN_INT ((mask >> 2) & 3),
1316*e4b17023SJohn Marino                               GEN_INT ((mask >> 4) & 3),
1317*e4b17023SJohn Marino                               GEN_INT ((mask >> 6) & 3)));
1318*e4b17023SJohn Marino  DONE;
1319*e4b17023SJohn Marino})
1320*e4b17023SJohn Marino
1321*e4b17023SJohn Marino(define_insn "mmx_pshufw_1"
1322*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
1323*e4b17023SJohn Marino        (vec_select:V4HI
1324*e4b17023SJohn Marino          (match_operand:V4HI 1 "nonimmediate_operand" "ym")
1325*e4b17023SJohn Marino          (parallel [(match_operand 2 "const_0_to_3_operand" "")
1326*e4b17023SJohn Marino                     (match_operand 3 "const_0_to_3_operand" "")
1327*e4b17023SJohn Marino                     (match_operand 4 "const_0_to_3_operand" "")
1328*e4b17023SJohn Marino                     (match_operand 5 "const_0_to_3_operand" "")])))]
1329*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
1330*e4b17023SJohn Marino{
1331*e4b17023SJohn Marino  int mask = 0;
1332*e4b17023SJohn Marino  mask |= INTVAL (operands[2]) << 0;
1333*e4b17023SJohn Marino  mask |= INTVAL (operands[3]) << 2;
1334*e4b17023SJohn Marino  mask |= INTVAL (operands[4]) << 4;
1335*e4b17023SJohn Marino  mask |= INTVAL (operands[5]) << 6;
1336*e4b17023SJohn Marino  operands[2] = GEN_INT (mask);
1337*e4b17023SJohn Marino
1338*e4b17023SJohn Marino  return "pshufw\t{%2, %1, %0|%0, %1, %2}";
1339*e4b17023SJohn Marino}
1340*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1341*e4b17023SJohn Marino   (set_attr "length_immediate" "1")
1342*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1343*e4b17023SJohn Marino
1344*e4b17023SJohn Marino(define_insn "mmx_pswapdv2si2"
1345*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "=y")
1346*e4b17023SJohn Marino	(vec_select:V2SI
1347*e4b17023SJohn Marino	  (match_operand:V2SI 1 "nonimmediate_operand" "ym")
1348*e4b17023SJohn Marino	  (parallel [(const_int 1) (const_int 0)])))]
1349*e4b17023SJohn Marino  "TARGET_3DNOW_A"
1350*e4b17023SJohn Marino  "pswapd\t{%1, %0|%0, %1}"
1351*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1352*e4b17023SJohn Marino   (set_attr "prefix_extra" "1")
1353*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1354*e4b17023SJohn Marino
1355*e4b17023SJohn Marino(define_insn "*vec_dupv4hi"
1356*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
1357*e4b17023SJohn Marino	(vec_duplicate:V4HI
1358*e4b17023SJohn Marino	  (truncate:HI
1359*e4b17023SJohn Marino	    (match_operand:SI 1 "register_operand" "0"))))]
1360*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
1361*e4b17023SJohn Marino  "pshufw\t{$0, %0, %0|%0, %0, 0}"
1362*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1363*e4b17023SJohn Marino   (set_attr "length_immediate" "1")
1364*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1365*e4b17023SJohn Marino
1366*e4b17023SJohn Marino(define_insn "*vec_dupv2si"
1367*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand" "=y")
1368*e4b17023SJohn Marino	(vec_duplicate:V2SI
1369*e4b17023SJohn Marino	  (match_operand:SI 1 "register_operand" "0")))]
1370*e4b17023SJohn Marino  "TARGET_MMX"
1371*e4b17023SJohn Marino  "punpckldq\t%0, %0"
1372*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1373*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1374*e4b17023SJohn Marino
1375*e4b17023SJohn Marino(define_insn "*mmx_concatv2si"
1376*e4b17023SJohn Marino  [(set (match_operand:V2SI 0 "register_operand"     "=y,y")
1377*e4b17023SJohn Marino	(vec_concat:V2SI
1378*e4b17023SJohn Marino	  (match_operand:SI 1 "nonimmediate_operand" " 0,rm")
1379*e4b17023SJohn Marino	  (match_operand:SI 2 "vector_move_operand"  "ym,C")))]
1380*e4b17023SJohn Marino  "TARGET_MMX && !TARGET_SSE"
1381*e4b17023SJohn Marino  "@
1382*e4b17023SJohn Marino   punpckldq\t{%2, %0|%0, %2}
1383*e4b17023SJohn Marino   movd\t{%1, %0|%0, %1}"
1384*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt,mmxmov")
1385*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1386*e4b17023SJohn Marino
1387*e4b17023SJohn Marino(define_expand "vec_setv2si"
1388*e4b17023SJohn Marino  [(match_operand:V2SI 0 "register_operand" "")
1389*e4b17023SJohn Marino   (match_operand:SI 1 "register_operand" "")
1390*e4b17023SJohn Marino   (match_operand 2 "const_int_operand" "")]
1391*e4b17023SJohn Marino  "TARGET_MMX"
1392*e4b17023SJohn Marino{
1393*e4b17023SJohn Marino  ix86_expand_vector_set (false, operands[0], operands[1],
1394*e4b17023SJohn Marino			  INTVAL (operands[2]));
1395*e4b17023SJohn Marino  DONE;
1396*e4b17023SJohn Marino})
1397*e4b17023SJohn Marino
1398*e4b17023SJohn Marino;; Avoid combining registers from different units in a single alternative,
1399*e4b17023SJohn Marino;; see comment above inline_secondary_memory_needed function in i386.c
1400*e4b17023SJohn Marino(define_insn_and_split "*vec_extractv2si_0"
1401*e4b17023SJohn Marino  [(set (match_operand:SI 0 "nonimmediate_operand"     "=x,m,y, m,r")
1402*e4b17023SJohn Marino	(vec_select:SI
1403*e4b17023SJohn Marino	  (match_operand:V2SI 1 "nonimmediate_operand" "xm,x,ym,y,m")
1404*e4b17023SJohn Marino	  (parallel [(const_int 0)])))]
1405*e4b17023SJohn Marino  "TARGET_MMX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1406*e4b17023SJohn Marino  "#"
1407*e4b17023SJohn Marino  "&& reload_completed"
1408*e4b17023SJohn Marino  [(const_int 0)]
1409*e4b17023SJohn Marino{
1410*e4b17023SJohn Marino  rtx op1 = operands[1];
1411*e4b17023SJohn Marino  if (REG_P (op1))
1412*e4b17023SJohn Marino    op1 = gen_rtx_REG (SImode, REGNO (op1));
1413*e4b17023SJohn Marino  else
1414*e4b17023SJohn Marino    op1 = gen_lowpart (SImode, op1);
1415*e4b17023SJohn Marino  emit_move_insn (operands[0], op1);
1416*e4b17023SJohn Marino  DONE;
1417*e4b17023SJohn Marino})
1418*e4b17023SJohn Marino
1419*e4b17023SJohn Marino;; Avoid combining registers from different units in a single alternative,
1420*e4b17023SJohn Marino;; see comment above inline_secondary_memory_needed function in i386.c
1421*e4b17023SJohn Marino(define_insn "*vec_extractv2si_1"
1422*e4b17023SJohn Marino  [(set (match_operand:SI 0 "nonimmediate_operand"     "=y,x,x,x,y,x,r")
1423*e4b17023SJohn Marino	(vec_select:SI
1424*e4b17023SJohn Marino	  (match_operand:V2SI 1 "nonimmediate_operand" " 0,0,x,0,o,o,o")
1425*e4b17023SJohn Marino	  (parallel [(const_int 1)])))]
1426*e4b17023SJohn Marino  "TARGET_MMX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1427*e4b17023SJohn Marino  "@
1428*e4b17023SJohn Marino   punpckhdq\t%0, %0
1429*e4b17023SJohn Marino   punpckhdq\t%0, %0
1430*e4b17023SJohn Marino   pshufd\t{$85, %1, %0|%0, %1, 85}
1431*e4b17023SJohn Marino   unpckhps\t%0, %0
1432*e4b17023SJohn Marino   #
1433*e4b17023SJohn Marino   #
1434*e4b17023SJohn Marino   #"
1435*e4b17023SJohn Marino  [(set (attr "isa")
1436*e4b17023SJohn Marino     (if_then_else (eq_attr "alternative" "1,2")
1437*e4b17023SJohn Marino       (const_string "sse2")
1438*e4b17023SJohn Marino       (const_string "*")))
1439*e4b17023SJohn Marino   (set_attr "type" "mmxcvt,sselog1,sselog1,sselog1,mmxmov,ssemov,imov")
1440*e4b17023SJohn Marino   (set_attr "length_immediate" "*,*,1,*,*,*,*")
1441*e4b17023SJohn Marino   (set_attr "mode" "DI,TI,TI,V4SF,SI,SI,SI")])
1442*e4b17023SJohn Marino
1443*e4b17023SJohn Marino(define_split
1444*e4b17023SJohn Marino  [(set (match_operand:SI 0 "register_operand" "")
1445*e4b17023SJohn Marino	(vec_select:SI
1446*e4b17023SJohn Marino	  (match_operand:V2SI 1 "memory_operand" "")
1447*e4b17023SJohn Marino	  (parallel [(const_int 1)])))]
1448*e4b17023SJohn Marino  "TARGET_MMX && reload_completed"
1449*e4b17023SJohn Marino  [(const_int 0)]
1450*e4b17023SJohn Marino{
1451*e4b17023SJohn Marino  operands[1] = adjust_address (operands[1], SImode, 4);
1452*e4b17023SJohn Marino  emit_move_insn (operands[0], operands[1]);
1453*e4b17023SJohn Marino  DONE;
1454*e4b17023SJohn Marino})
1455*e4b17023SJohn Marino
1456*e4b17023SJohn Marino(define_expand "vec_extractv2si"
1457*e4b17023SJohn Marino  [(match_operand:SI 0 "register_operand" "")
1458*e4b17023SJohn Marino   (match_operand:V2SI 1 "register_operand" "")
1459*e4b17023SJohn Marino   (match_operand 2 "const_int_operand" "")]
1460*e4b17023SJohn Marino  "TARGET_MMX"
1461*e4b17023SJohn Marino{
1462*e4b17023SJohn Marino  ix86_expand_vector_extract (false, operands[0], operands[1],
1463*e4b17023SJohn Marino			      INTVAL (operands[2]));
1464*e4b17023SJohn Marino  DONE;
1465*e4b17023SJohn Marino})
1466*e4b17023SJohn Marino
1467*e4b17023SJohn Marino(define_expand "vec_initv2si"
1468*e4b17023SJohn Marino  [(match_operand:V2SI 0 "register_operand" "")
1469*e4b17023SJohn Marino   (match_operand 1 "" "")]
1470*e4b17023SJohn Marino  "TARGET_SSE"
1471*e4b17023SJohn Marino{
1472*e4b17023SJohn Marino  ix86_expand_vector_init (false, operands[0], operands[1]);
1473*e4b17023SJohn Marino  DONE;
1474*e4b17023SJohn Marino})
1475*e4b17023SJohn Marino
1476*e4b17023SJohn Marino(define_expand "vec_setv4hi"
1477*e4b17023SJohn Marino  [(match_operand:V4HI 0 "register_operand" "")
1478*e4b17023SJohn Marino   (match_operand:HI 1 "register_operand" "")
1479*e4b17023SJohn Marino   (match_operand 2 "const_int_operand" "")]
1480*e4b17023SJohn Marino  "TARGET_MMX"
1481*e4b17023SJohn Marino{
1482*e4b17023SJohn Marino  ix86_expand_vector_set (false, operands[0], operands[1],
1483*e4b17023SJohn Marino			  INTVAL (operands[2]));
1484*e4b17023SJohn Marino  DONE;
1485*e4b17023SJohn Marino})
1486*e4b17023SJohn Marino
1487*e4b17023SJohn Marino(define_expand "vec_extractv4hi"
1488*e4b17023SJohn Marino  [(match_operand:HI 0 "register_operand" "")
1489*e4b17023SJohn Marino   (match_operand:V4HI 1 "register_operand" "")
1490*e4b17023SJohn Marino   (match_operand 2 "const_int_operand" "")]
1491*e4b17023SJohn Marino  "TARGET_MMX"
1492*e4b17023SJohn Marino{
1493*e4b17023SJohn Marino  ix86_expand_vector_extract (false, operands[0], operands[1],
1494*e4b17023SJohn Marino			      INTVAL (operands[2]));
1495*e4b17023SJohn Marino  DONE;
1496*e4b17023SJohn Marino})
1497*e4b17023SJohn Marino
1498*e4b17023SJohn Marino(define_expand "vec_initv4hi"
1499*e4b17023SJohn Marino  [(match_operand:V4HI 0 "register_operand" "")
1500*e4b17023SJohn Marino   (match_operand 1 "" "")]
1501*e4b17023SJohn Marino  "TARGET_SSE"
1502*e4b17023SJohn Marino{
1503*e4b17023SJohn Marino  ix86_expand_vector_init (false, operands[0], operands[1]);
1504*e4b17023SJohn Marino  DONE;
1505*e4b17023SJohn Marino})
1506*e4b17023SJohn Marino
1507*e4b17023SJohn Marino(define_expand "vec_setv8qi"
1508*e4b17023SJohn Marino  [(match_operand:V8QI 0 "register_operand" "")
1509*e4b17023SJohn Marino   (match_operand:QI 1 "register_operand" "")
1510*e4b17023SJohn Marino   (match_operand 2 "const_int_operand" "")]
1511*e4b17023SJohn Marino  "TARGET_MMX"
1512*e4b17023SJohn Marino{
1513*e4b17023SJohn Marino  ix86_expand_vector_set (false, operands[0], operands[1],
1514*e4b17023SJohn Marino			  INTVAL (operands[2]));
1515*e4b17023SJohn Marino  DONE;
1516*e4b17023SJohn Marino})
1517*e4b17023SJohn Marino
1518*e4b17023SJohn Marino(define_expand "vec_extractv8qi"
1519*e4b17023SJohn Marino  [(match_operand:QI 0 "register_operand" "")
1520*e4b17023SJohn Marino   (match_operand:V8QI 1 "register_operand" "")
1521*e4b17023SJohn Marino   (match_operand 2 "const_int_operand" "")]
1522*e4b17023SJohn Marino  "TARGET_MMX"
1523*e4b17023SJohn Marino{
1524*e4b17023SJohn Marino  ix86_expand_vector_extract (false, operands[0], operands[1],
1525*e4b17023SJohn Marino			      INTVAL (operands[2]));
1526*e4b17023SJohn Marino  DONE;
1527*e4b17023SJohn Marino})
1528*e4b17023SJohn Marino
1529*e4b17023SJohn Marino(define_expand "vec_initv8qi"
1530*e4b17023SJohn Marino  [(match_operand:V8QI 0 "register_operand" "")
1531*e4b17023SJohn Marino   (match_operand 1 "" "")]
1532*e4b17023SJohn Marino  "TARGET_SSE"
1533*e4b17023SJohn Marino{
1534*e4b17023SJohn Marino  ix86_expand_vector_init (false, operands[0], operands[1]);
1535*e4b17023SJohn Marino  DONE;
1536*e4b17023SJohn Marino})
1537*e4b17023SJohn Marino
1538*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1539*e4b17023SJohn Marino;;
1540*e4b17023SJohn Marino;; Miscellaneous
1541*e4b17023SJohn Marino;;
1542*e4b17023SJohn Marino;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1543*e4b17023SJohn Marino
1544*e4b17023SJohn Marino(define_expand "mmx_uavgv8qi3"
1545*e4b17023SJohn Marino  [(set (match_operand:V8QI 0 "register_operand" "")
1546*e4b17023SJohn Marino	(truncate:V8QI
1547*e4b17023SJohn Marino	  (lshiftrt:V8HI
1548*e4b17023SJohn Marino	    (plus:V8HI
1549*e4b17023SJohn Marino	      (plus:V8HI
1550*e4b17023SJohn Marino		(zero_extend:V8HI
1551*e4b17023SJohn Marino		  (match_operand:V8QI 1 "nonimmediate_operand" ""))
1552*e4b17023SJohn Marino		(zero_extend:V8HI
1553*e4b17023SJohn Marino		  (match_operand:V8QI 2 "nonimmediate_operand" "")))
1554*e4b17023SJohn Marino	      (const_vector:V8HI [(const_int 1) (const_int 1)
1555*e4b17023SJohn Marino				  (const_int 1) (const_int 1)
1556*e4b17023SJohn Marino				  (const_int 1) (const_int 1)
1557*e4b17023SJohn Marino				  (const_int 1) (const_int 1)]))
1558*e4b17023SJohn Marino	    (const_int 1))))]
1559*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW"
1560*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (PLUS, V8QImode, operands);")
1561*e4b17023SJohn Marino
1562*e4b17023SJohn Marino(define_insn "*mmx_uavgv8qi3"
1563*e4b17023SJohn Marino  [(set (match_operand:V8QI 0 "register_operand" "=y")
1564*e4b17023SJohn Marino	(truncate:V8QI
1565*e4b17023SJohn Marino	  (lshiftrt:V8HI
1566*e4b17023SJohn Marino	    (plus:V8HI
1567*e4b17023SJohn Marino	      (plus:V8HI
1568*e4b17023SJohn Marino		(zero_extend:V8HI
1569*e4b17023SJohn Marino		  (match_operand:V8QI 1 "nonimmediate_operand" "%0"))
1570*e4b17023SJohn Marino		(zero_extend:V8HI
1571*e4b17023SJohn Marino		  (match_operand:V8QI 2 "nonimmediate_operand" "ym")))
1572*e4b17023SJohn Marino	      (const_vector:V8HI [(const_int 1) (const_int 1)
1573*e4b17023SJohn Marino				  (const_int 1) (const_int 1)
1574*e4b17023SJohn Marino				  (const_int 1) (const_int 1)
1575*e4b17023SJohn Marino				  (const_int 1) (const_int 1)]))
1576*e4b17023SJohn Marino	    (const_int 1))))]
1577*e4b17023SJohn Marino  "(TARGET_SSE || TARGET_3DNOW)
1578*e4b17023SJohn Marino   && ix86_binary_operator_ok (PLUS, V8QImode, operands)"
1579*e4b17023SJohn Marino{
1580*e4b17023SJohn Marino  /* These two instructions have the same operation, but their encoding
1581*e4b17023SJohn Marino     is different.  Prefer the one that is de facto standard.  */
1582*e4b17023SJohn Marino  if (TARGET_SSE || TARGET_3DNOW_A)
1583*e4b17023SJohn Marino    return "pavgb\t{%2, %0|%0, %2}";
1584*e4b17023SJohn Marino  else
1585*e4b17023SJohn Marino    return "pavgusb\t{%2, %0|%0, %2}";
1586*e4b17023SJohn Marino}
1587*e4b17023SJohn Marino  [(set_attr "type" "mmxshft")
1588*e4b17023SJohn Marino   (set (attr "prefix_extra")
1589*e4b17023SJohn Marino     (if_then_else
1590*e4b17023SJohn Marino       (not (ior (match_test "TARGET_SSE")
1591*e4b17023SJohn Marino		 (match_test "TARGET_3DNOW_A")))
1592*e4b17023SJohn Marino       (const_string "1")
1593*e4b17023SJohn Marino       (const_string "*")))
1594*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1595*e4b17023SJohn Marino
1596*e4b17023SJohn Marino(define_expand "mmx_uavgv4hi3"
1597*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "")
1598*e4b17023SJohn Marino	(truncate:V4HI
1599*e4b17023SJohn Marino	  (lshiftrt:V4SI
1600*e4b17023SJohn Marino	    (plus:V4SI
1601*e4b17023SJohn Marino	      (plus:V4SI
1602*e4b17023SJohn Marino		(zero_extend:V4SI
1603*e4b17023SJohn Marino		  (match_operand:V4HI 1 "nonimmediate_operand" ""))
1604*e4b17023SJohn Marino		(zero_extend:V4SI
1605*e4b17023SJohn Marino		  (match_operand:V4HI 2 "nonimmediate_operand" "")))
1606*e4b17023SJohn Marino	      (const_vector:V4SI [(const_int 1) (const_int 1)
1607*e4b17023SJohn Marino				  (const_int 1) (const_int 1)]))
1608*e4b17023SJohn Marino	    (const_int 1))))]
1609*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
1610*e4b17023SJohn Marino  "ix86_fixup_binary_operands_no_copy (PLUS, V4HImode, operands);")
1611*e4b17023SJohn Marino
1612*e4b17023SJohn Marino(define_insn "*mmx_uavgv4hi3"
1613*e4b17023SJohn Marino  [(set (match_operand:V4HI 0 "register_operand" "=y")
1614*e4b17023SJohn Marino	(truncate:V4HI
1615*e4b17023SJohn Marino	  (lshiftrt:V4SI
1616*e4b17023SJohn Marino	    (plus:V4SI
1617*e4b17023SJohn Marino	      (plus:V4SI
1618*e4b17023SJohn Marino		(zero_extend:V4SI
1619*e4b17023SJohn Marino		  (match_operand:V4HI 1 "nonimmediate_operand" "%0"))
1620*e4b17023SJohn Marino		(zero_extend:V4SI
1621*e4b17023SJohn Marino		  (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
1622*e4b17023SJohn Marino	      (const_vector:V4SI [(const_int 1) (const_int 1)
1623*e4b17023SJohn Marino				  (const_int 1) (const_int 1)]))
1624*e4b17023SJohn Marino	    (const_int 1))))]
1625*e4b17023SJohn Marino  "(TARGET_SSE || TARGET_3DNOW_A)
1626*e4b17023SJohn Marino   && ix86_binary_operator_ok (PLUS, V4HImode, operands)"
1627*e4b17023SJohn Marino  "pavgw\t{%2, %0|%0, %2}"
1628*e4b17023SJohn Marino  [(set_attr "type" "mmxshft")
1629*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1630*e4b17023SJohn Marino
1631*e4b17023SJohn Marino(define_insn "mmx_psadbw"
1632*e4b17023SJohn Marino  [(set (match_operand:V1DI 0 "register_operand" "=y")
1633*e4b17023SJohn Marino        (unspec:V1DI [(match_operand:V8QI 1 "register_operand" "0")
1634*e4b17023SJohn Marino		      (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
1635*e4b17023SJohn Marino		     UNSPEC_PSADBW))]
1636*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
1637*e4b17023SJohn Marino  "psadbw\t{%2, %0|%0, %2}"
1638*e4b17023SJohn Marino  [(set_attr "type" "mmxshft")
1639*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1640*e4b17023SJohn Marino
1641*e4b17023SJohn Marino(define_insn "mmx_pmovmskb"
1642*e4b17023SJohn Marino  [(set (match_operand:SI 0 "register_operand" "=r")
1643*e4b17023SJohn Marino	(unspec:SI [(match_operand:V8QI 1 "register_operand" "y")]
1644*e4b17023SJohn Marino		   UNSPEC_MOVMSK))]
1645*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
1646*e4b17023SJohn Marino  "pmovmskb\t{%1, %0|%0, %1}"
1647*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1648*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1649*e4b17023SJohn Marino
1650*e4b17023SJohn Marino(define_expand "mmx_maskmovq"
1651*e4b17023SJohn Marino  [(set (match_operand:V8QI 0 "memory_operand" "")
1652*e4b17023SJohn Marino	(unspec:V8QI [(match_operand:V8QI 1 "register_operand" "")
1653*e4b17023SJohn Marino		      (match_operand:V8QI 2 "register_operand" "")
1654*e4b17023SJohn Marino		      (match_dup 0)]
1655*e4b17023SJohn Marino		     UNSPEC_MASKMOV))]
1656*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A")
1657*e4b17023SJohn Marino
1658*e4b17023SJohn Marino(define_insn "*mmx_maskmovq"
1659*e4b17023SJohn Marino  [(set (mem:V8QI (match_operand:P 0 "register_operand" "D"))
1660*e4b17023SJohn Marino	(unspec:V8QI [(match_operand:V8QI 1 "register_operand" "y")
1661*e4b17023SJohn Marino		      (match_operand:V8QI 2 "register_operand" "y")
1662*e4b17023SJohn Marino		      (mem:V8QI (match_dup 0))]
1663*e4b17023SJohn Marino		     UNSPEC_MASKMOV))]
1664*e4b17023SJohn Marino  "TARGET_SSE || TARGET_3DNOW_A"
1665*e4b17023SJohn Marino  ;; @@@ check ordering of operands in intel/nonintel syntax
1666*e4b17023SJohn Marino  "maskmovq\t{%2, %1|%1, %2}"
1667*e4b17023SJohn Marino  [(set_attr "type" "mmxcvt")
1668*e4b17023SJohn Marino   (set_attr "mode" "DI")])
1669*e4b17023SJohn Marino
1670*e4b17023SJohn Marino(define_expand "mmx_emms"
1671*e4b17023SJohn Marino  [(match_par_dup 0 [(const_int 0)])]
1672*e4b17023SJohn Marino  "TARGET_MMX"
1673*e4b17023SJohn Marino{
1674*e4b17023SJohn Marino  int regno;
1675*e4b17023SJohn Marino
1676*e4b17023SJohn Marino  operands[0] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (17));
1677*e4b17023SJohn Marino
1678*e4b17023SJohn Marino  XVECEXP (operands[0], 0, 0)
1679*e4b17023SJohn Marino    = gen_rtx_UNSPEC_VOLATILE (VOIDmode, gen_rtvec (1, const0_rtx),
1680*e4b17023SJohn Marino			       UNSPECV_EMMS);
1681*e4b17023SJohn Marino
1682*e4b17023SJohn Marino  for (regno = 0; regno < 8; regno++)
1683*e4b17023SJohn Marino    {
1684*e4b17023SJohn Marino      XVECEXP (operands[0], 0, regno + 1)
1685*e4b17023SJohn Marino	= gen_rtx_CLOBBER (VOIDmode,
1686*e4b17023SJohn Marino			   gen_rtx_REG (XFmode, FIRST_STACK_REG + regno));
1687*e4b17023SJohn Marino
1688*e4b17023SJohn Marino      XVECEXP (operands[0], 0, regno + 9)
1689*e4b17023SJohn Marino	= gen_rtx_CLOBBER (VOIDmode,
1690*e4b17023SJohn Marino			   gen_rtx_REG (DImode, FIRST_MMX_REG + regno));
1691*e4b17023SJohn Marino    }
1692*e4b17023SJohn Marino})
1693*e4b17023SJohn Marino
1694*e4b17023SJohn Marino(define_insn "*mmx_emms"
1695*e4b17023SJohn Marino  [(match_parallel 0 "emms_operation"
1696*e4b17023SJohn Marino    [(unspec_volatile [(const_int 0)] UNSPECV_EMMS)])]
1697*e4b17023SJohn Marino  "TARGET_MMX"
1698*e4b17023SJohn Marino  "emms"
1699*e4b17023SJohn Marino  [(set_attr "type" "mmx")
1700*e4b17023SJohn Marino   (set_attr "modrm" "0")
1701*e4b17023SJohn Marino   (set_attr "memory" "none")])
1702*e4b17023SJohn Marino
1703*e4b17023SJohn Marino(define_expand "mmx_femms"
1704*e4b17023SJohn Marino  [(match_par_dup 0 [(const_int 0)])]
1705*e4b17023SJohn Marino  "TARGET_3DNOW"
1706*e4b17023SJohn Marino{
1707*e4b17023SJohn Marino  int regno;
1708*e4b17023SJohn Marino
1709*e4b17023SJohn Marino  operands[0] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (17));
1710*e4b17023SJohn Marino
1711*e4b17023SJohn Marino  XVECEXP (operands[0], 0, 0)
1712*e4b17023SJohn Marino    = gen_rtx_UNSPEC_VOLATILE (VOIDmode, gen_rtvec (1, const0_rtx),
1713*e4b17023SJohn Marino			       UNSPECV_FEMMS);
1714*e4b17023SJohn Marino
1715*e4b17023SJohn Marino  for (regno = 0; regno < 8; regno++)
1716*e4b17023SJohn Marino    {
1717*e4b17023SJohn Marino      XVECEXP (operands[0], 0, regno + 1)
1718*e4b17023SJohn Marino	= gen_rtx_CLOBBER (VOIDmode,
1719*e4b17023SJohn Marino			   gen_rtx_REG (XFmode, FIRST_STACK_REG + regno));
1720*e4b17023SJohn Marino
1721*e4b17023SJohn Marino      XVECEXP (operands[0], 0, regno + 9)
1722*e4b17023SJohn Marino	= gen_rtx_CLOBBER (VOIDmode,
1723*e4b17023SJohn Marino			   gen_rtx_REG (DImode, FIRST_MMX_REG + regno));
1724*e4b17023SJohn Marino    }
1725*e4b17023SJohn Marino})
1726*e4b17023SJohn Marino
1727*e4b17023SJohn Marino(define_insn "*mmx_femms"
1728*e4b17023SJohn Marino  [(match_parallel 0 "emms_operation"
1729*e4b17023SJohn Marino    [(unspec_volatile [(const_int 0)] UNSPECV_FEMMS)])]
1730*e4b17023SJohn Marino  "TARGET_3DNOW"
1731*e4b17023SJohn Marino  "femms"
1732*e4b17023SJohn Marino  [(set_attr "type" "mmx")
1733*e4b17023SJohn Marino   (set_attr "modrm" "0")
1734*e4b17023SJohn Marino   (set_attr "memory" "none")])
1735