This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][ix86/gcc-4_2-branch] committed, Initial Barcelona patches


I backported the initial Barcelona changes to the ix86/gcc-4_2-branch:

[gcc changes]
2007-11-09  Michael Meissner  <michael.meissner@amd.com>
	    Dwarakanath Rajagopal  <dwarak.rajagopal@amd.com>

	(patch backported from GCC 4.3)
	* doc/extend.texi (_mm_stream_sd): New SSE4a intrinsic function.
	(_mm_stream_ss): Ditto.
	(_mm_extract_si64): Ditto.
	(_mm_extracti_si64): Ditto.
	(_mm_insert_si64): Ditto.
	(_mm_inserti_si64): Ditto.

	* doc/invoke.texi (-msse4a): Document the AMD Barcelona switches.
	(-mno-sse4a): Ditto.
	(-mpopcnt): Ditto.
	(-mno-popcnt): Ditto.
	(-mabm): Ditto.
	(-mno-abm): Ditto.
	(-march=barcelona, -march=amdfam10): Ditto.
	(-mtune=barcelona, -mtune=amdfam10): Ditto.

	* config.gcc (i[34567]86-*-*): Add ammintrin.h include file.  Add
	support for --with-cpu=amdfam10 and --with-cpu=barcelona.
	(x86_64-*-*): Ditto.

	* config/i386/i386.h (TARGET_AMDFAM10): New macro for Barcelona.
	(TARGET_CPU_DEFAULT_amdfam10): Ditto.
	(x86_sse_unaligned_move_optimal): Add support for unalgined SSE
	memory operations.
	(TARGET_SSE_UNALIGNED_MOVE_OPTIMAL): Ditto.
	(TARGET_CPU_CPP_BUILTINS): Add Barcelona support.
	(TARGET_CPU_DEFAULT_NAMES): Ditto.
	(processor_type enum): Ditto.

	* config/i386/i386.md (UNSPEC_EXTRQI): New constant for SSE4A.
	(UNSPEC_EXTRQ): Ditto.
	(UNSPEC_INSERTQI): Ditto.
	(UNSPEC_INSERTQ): Ditto.
	(cpu attribute): Add amdfam10 support.
	(type attribute): Add bitmanip, sseins attributes.
	(unit attribute): Add amdfam10 support.
	(memory attribute): Ditto.
	(x86_sahf_1): Set amdfam10_decode.
	(cmpfp_i_mixed): Ditto.
	(cmpfp_i_sse): Ditto.
	(cmpfp_i_i387): Ditto.
	(cmpfp_iu_mixed): Ditto.
	(cmpfp_iu_sse): Ditto.
	(cmpfp_iu_387): Ditto.
	(swapsi): Ditto.
	(swaphi_1): Ditto.
	(swapqi_1): Ditto.
	(swapdi_rex64): Ditto.
	(fix_truncsfdi_sse): Ditto.
	(fix_truncdfdi_sse): Ditto.
	(fix_truncsfsi_sse): Ditto.
	(fix_truncdfsi_sse): Ditto.
	(x86_fldcw_1): Ditto.
	(floatsisf2_mixed): Ditto.
	(floatsisf2_sse): Ditto.
	(floatdisf2_mixed): Ditto.
	(floatdisf2_sse): Ditto.
	(floatsidf2_mixed): Ditto.
	(floatsidf2_sse): Ditto.
	(floatdidf2_mixed): Ditto.
	(floatdidf2_sse): Ditto.
	(muldi3_1_rex64): Ditto.
	(mulsi3_1): Ditto.
	(mulsi3_1_zext): Ditto.
	(mulhi3_1): Ditto.
	(mulqi3_1): Ditto.
	(umulqihi3_1): Ditto.
	(mulqihi3_insn): Ditto.
	(umulditi3_insn): Ditto.
	(umulsidi3_insn): Ditto.
	(mulditi3_insn): Ditto.
	(mulsidi3_insn): Ditto.
	(umuldi3_highpart_rex64): Ditto.
	(umulsi3_highpart_insn): Ditto.
	(umulsi3_highpart_zext): Ditto.
	(umulsi3_highpart_zext): Ditto.
	(smuldi3_highpart_rex64): Ditto.
	(smulsi3_highpart_insn): Ditto.
	(smulsi3_highpart_zext): Ditto.
	(x86_64_shld): Ditto.
	(x86_64_shld_1): Ditto.
	(x86_64_shrd): Ditto.
	(sqrtsf2_mixed): Ditto.
	(sqrtsf2_sse): Ditto.
	(sqrtsf2_i387): Ditto.
	(sqrtdf2_mixed): Ditto.
	(sqrtdf2_sse): Ditto.
	(sqrtdf2_i387): Ditto.
	(sqrtextendsfdf2_i387): Ditto.
	(sqrtxf2): Ditto.
	(sqrtextendsfxf2_i387): Ditto.
	(sqrtextenddfxf2_i387): Ditto.
	(imul peepholes): Know imul by constant is not direct on AMDFAM10.
	(clzsi2): If TARGET_ABM, generate lzcnt instruction.
	(clzsi2_abm): Ditto.
	(clzdi2): Ditto.
	(clzdi2_abm): Ditto.
	(clzhi2): Ditto.
	(clzhi2_abm): Ditto.
	(bsrhi): New insn, modeled after bsr.
	(popcountsi2): Add popcnt support if TARGET_POPCNT.
	(popcountsi2_cmp): Ditto.
	(popcountsi2_cmp_zext): Ditto.
	(popcountdi2): Ditto.
	(popcountdi2_cmp): Ditto.
	(popcounthi2): Ditto.
	(popcounthi2_cmp): Ditto.

	* config/i386/athlon.md (amdfam10_decode): New attribute for
	Barcelona.
	(athlon_branch): Add Barcelona support.
	(athlon_call_amdfam10): Ditto.
	(athlon_pop_amdfam10): Ditto.
	(athlon_leave_k8): Ditto.
	(athlon_lea_amdfam10): Ditto.
	(athlon_imul_k8_DI): Ditto.
	(athlon_imul_k8): Ditto.
	(athlon_imul_amdfam10_HI): Ditto.
	(athlon_imul_mem_k8_DI): Ditto.
	(athlon_imul_mem_k8): Ditto.
	(athlon_idiv): Ditto.
	(athlon_idiv_mem): Ditto.
	(athlon_str): Ditto.
	(athlon_idirect_amdfam10): Ditto.
	(athlon_ivector_amdfam10): Ditto.
	(athlon_idirect_loadmov): Ditto.
	(athlon_idirect_load_amdfam10): Ditto.
	(athlon_idirect_movstore): Ditto.
	(athlon_idirect_both_amdfam10): Ditto.
	(athlon_ivector_both_amdfam10): Ditto.
	(athlon_idirect_store_amdfam10): Ditto.
	(athlon_ivector_store_amdfam10): Ditto.
	(athlon_fldxf_k8): Ditto.
	(athlon_fld_k8): Ditto.
	(athlon_fstxf_k8): Ditto.
	(athlon_fst_k8): Ditto.
	(athlon_fist): Ditto.
	(athlon_fmov): Ditto.
	(athlon_fadd_load_k8): Ditto.
	(athlon_fadd): Ditto.
	(athlon_fmul_load_k8): Ditto.
	(athlon_fmul): Ditto.
	(athlon_fsgn): Ditto.
	(athlon_fdiv_load_k8): Ditto.
	(athlon_fdiv_k8): Ditto.
	(athlon_fpspc_load): Ditto.
	(athlon_fpspc): Ditto.
	(athlon_fcmov_load_k8): Ditto.
	(athlon_fcmov_k8): Ditto.
	(athlon_fcomi_load_k8): Ditto.
	(athlon_fcomi): Ditto.
	(athlon_fcom_load_k8): Ditto.
	(athlon_fcom): Ditto.
	(athlon_fxch): Ditto.
	(athlon_sseld_amdfam10): Ditto.
	(athlon_mmxld_amdfam10): Ditto.
	(athlon_ssest_amdfam10): Ditto.
	(athlon_mmxssest_short_amdfam10): Ditto.
	(athlon_movaps_k8): Ditto.
	(athlon_sselog_load_amdfam10): Ditto.
	(athlon_sselog_amdfam10): Ditto.
	(athlon_ssecmp_load_k8): Ditto.
	(athlon_ssecmp): Ditto.
	(athlon_ssecmpvector_load_amdfam10): Ditto.
	(athlon_ssecmpvector_amdfam10): Ditto.
	(athlon_ssecomi_load_amdfam10): Ditto.
	(athlon_ssecomi_amdfam10): Ditto.
	(athlon_sseadd_load_k8): Ditto.
	(athlon_sseadd): Ditto.
	(athlon_sseaddvector_load_amdfam10): Ditto.
	(athlon_sseaddvector_amdfam10): Ditto.
	(athlon_ssecvt_cvtss2sd_load_amdfam10): Ditto.
	(athlon_ssecvt_cvtss2sd_amdfam10): Ditto.
	(athlon_ssecvt_cvtps2pd_load_amdfam10): Ditto.
	(athlon_ssecvt_cvtps2pd_amdfam10): Ditto.
	(athlon_sseicvt_cvtsi2sd_load_amdfam10): Ditto.
	(athlon_sseicvt_cvtsi2ss_load_amdfam10): Ditto.
	(athlon_sseicvt_cvtsi2sd_amdfam10): Ditto.
	(athlon_sseicvt_cvtsi2ss_amdfam10): Ditto.
	(athlon_ssecvt_cvtsd2ss_load_amdfam10): Ditto.
	(athlon_ssecvt_cvtpd2ps_amdfam10): Ditto.
	(athlon_secvt_cvtsX2si_load_amdfam10): Ditto.
	(athlon_ssecvt_cvtsX2si_amdfam10): Ditto.
	(athlon_sseicvt_cvtpd2dq_load_amdfam10): Ditto.
	(athlon_sseicvt_cvtpd2dq_amdfam10): Ditto.
	(athlon_ssemul_load_k8): Ditto.
	(athlon_ssemul): Ditto.
	(athlon_ssemulvector_load_amdfam10): Ditto.
	(athlon_ssemulvector): Ditto.
	(athlon_ssemulvector_amdfam10): Ditto.
	(athlon_ssediv_load_k8): Ditto.
	(athlon_ssediv): Ditto.
	(athlon_ssedivvector_load_amdfam10): Ditto.
	(athlon_ssedivvector): Ditto.
	(athlon_ssedivvector_amdfam10): Ditto.
	(athlon_sseins_amdfam10): Ditto.

	* config/i386/pmmintrin.h: Add checking for __SSE3__.

	* config/i386/xmmintrin.h: Add checking for __SSE2__.

	* config/i386/sse.md (sse_cvtsi2ss): Set amdfam10_decode
	properly.
	(sse_cvtsi2ssq): Ditto.
	(sse_cvtss2si): Ditto.
	(sse_cvtss2siq): Ditto.
	(sse_cvttss2si): Ditto.
	(sse_cvstss2siq): Ditto.
	(sse2_cvtsi2sd): Ditto.
	(sse2_cvtsi2sdq): Ditto.
	(sse2_cvtsd2si): Ditto.
	(sse2_cvtsd2siq): Ditto.
	(sse2_cvttsd2si): Ditto.
	(sse2_cvttsd2siq): Ditto.
	(sse2_cvtpd2dq): Ditto.
	(sse2_cvttpd2dq): Ditto.
	(sse2_cvtsd2ss): Ditto.
	(sse2_cvtss2sd): Ditto.
	(*sse2_cvtpd2ps): Ditto.
	(sse2_cvtps2pd): Ditto.
	(sse4a_vmmovntv2df): New SSE4A insn.
	(sse4a_movntdf): Ditto.
	(sse4a_vmmovntv4sf): Ditto.
	(sse4a_movntsf): Ditto.
	(sse4a_extrqi): Ditto.
	(sse4a_extrq): Ditto.
	(sse4a_insertqi): Ditto.
	(sse4a_insertq): Ditto.

	* config/i386/i386.opt (-msse4a): New switch for Barcelona.
	(-mpopcnt): Ditto.
	(-mabm): Ditto.

	* config/i386/ammintrin.h: New file for Barcelona.

	* config/i386/emmintrin.h: Add check for __SSE2__.

	* config/i386/driver-i386.c (bit_SSE4a): Define SSE4a bit.
	(host_dectect_local_cpu): Detect Barcelona CPU.

	* config/i386/i386.c (amdfam10_cost): Define Barcelona costs.
	(m_AMDFAM10): New macro for Barcelona.
	(m_ATHLON_K8_AMDFAM10): Ditto.
	(x86_use_leave): Add Barcelona support.
	(x86_push_memory): Ditto.
	(x86_movx): Ditto.
	(x86_unroll_strlen): Ditto.
	(x86_cmove): Ditto.
	(x86_3dnow_a): Ditto.
	(x86_use_simode_fiop): Ditto.
	(x86_promote_QImode): Ditto.
	(x86_sub_esp_4): Ditto.
	(x86_sub_esp_8): Ditto.
	(x86_add_esp_4): Ditto.
	(x86_add_esp_8): Ditto.
	(x86_integer_DFmode_moves): Ditto.
	(x86_partial_reg_dependency): Ditto.
	(x86_memory_mismatch_stall): Ditto.
	(x86_accumulate_outgoing_args): Ditto.
	(x86_arch_always_fancy_math_387): Ditto.
	(x86_sse_partial_reg_dependency): Ditto.
	(x86_sse_split_regs): Ditto.
	(x86_sse_unaligned_move_optimal): Ditto.
	(x86_use_ffreep): Ditto.
	(x86_four_jump_limit): Ditto.
	(x86_schedule): Ditto.
	(x86_use_bt): Ditto.
	(x86_pad_returns): Ditto.
	(ix86_handle_options): Ditto.
	(processor_alias_table): Ditto.
	(override_options): Ditto.
	(ix86_expand_vector_move_misalign): Ditto.
	(ix86_issue_rate): Ditto.
	(ix86_adjust_cost): Ditto.
	(ix86_init_mmx_sse_builtins): Ditto.
	(ix86_expand_builtin): Ditto.
	(pta_flags enum): Add PTA_CX16, PTA_POPCNT, PTA_ABM, PTA_SSE4A.
	(ix86_builtin): Add IX86_BUILTIN_MOVNTSD, IX86_BUILTIN_MOVNTSS,
	IX86_BUILTIN_EXTRQI, IX86_BUILTIN_EXTRQ, IX86_BUILTIN_INSERTQI,
	IX86_BUILTIN_INSERTQ.

[gcc/testsuite changes]
2007-11-09  Michael Meissner  <michael.meissner@amd.com>
	    Dwarakanath Rajagopal  <dwarak.rajagopal@amd.com>

	(patch backported from GCC 4.3)
	* gcc.target/i386/sse4a-extract.c: New test for SSE4A.
	* gcc.target/i386/sse4a-montss.c: Ditto.
	* gcc.target/i386/sse4a-insert.c: Ditto.
	* gcc.target/i386/sse4a-montsd.c: Ditto.

	* gcc.dg/i386-cpuid.h (bit_SSE4a): Add bit for SSE4A.

*** gcc/doc/extend.texi.~1~	2007-11-08 14:17:28.923608000 -0500
--- gcc/doc/extend.texi	2007-11-09 12:11:07.950915000 -0500
*************** The following built-in functions are ava
*** 7220,7225 ****
--- 7220,7242 ----
  Generates the @code{movddup} machine instruction as a load from memory.
  @end table
  
+ The following built-in functions are available when @option{-msse4a} is used.
+ 
+ @smallexample
+ void             _mm_stream_sd (double*,__m128d);
+ Generates the @code{movntsd} machine instruction.
+ void             _mm_stream_ss (float*,__m128);
+ Generates the @code{movntss} machine instruction.
+ __m128i          _mm_extract_si64 (__m128i, __m128i);
+ Generates the @code{extrq} machine instruction with only SSE register operands.
+ __m128i          _mm_extracti_si64 (__m128i, int, int);
+ Generates the @code{extrq} machine instruction with SSE register and immediate operands.
+ __m128i          _mm_insert_si64 (__m128i, __m128i);
+ Generates the @code{insertq} machine instruction with only SSE register operands.
+ __m128i          _mm_inserti_si64 (__m128i, __m128i, int, int);
+ Generates the @code{insertq} machine instruction with SSE register and immediate operands.
+ @end smallexample
+ 
  The following built-in functions are available when @option{-m3dnow} is used.
  All of them generate the machine instruction that is part of the name.
  
*** gcc/doc/invoke.texi.~1~	2007-11-08 14:17:29.294335000 -0500
--- gcc/doc/invoke.texi	2007-11-09 12:11:08.026985000 -0500
*************** Objective-C and Objective-C++ Dialects}.
*** 535,541 ****
  -mno-fp-ret-in-387  -msoft-float  -msvr3-shlib @gol
  -mno-wide-multiply  -mrtd  -malign-double @gol
  -mpreferred-stack-boundary=@var{num} @gol
! -mmmx  -msse  -msse2 -msse3 -m3dnow @gol
  -mthreads  -mno-align-stringops  -minline-all-stringops @gol
  -mpush-args  -maccumulate-outgoing-args  -m128bit-long-double @gol
  -m96bit-long-double  -mregparm=@var{num}  -msseregparm @gol
--- 535,541 ----
  -mno-fp-ret-in-387  -msoft-float  -msvr3-shlib @gol
  -mno-wide-multiply  -mrtd  -malign-double @gol
  -mpreferred-stack-boundary=@var{num} @gol
! -mmmx  -msse  -msse2 -msse3 -msse4a -m3dnow -mpopcnt -mabm @gol
  -mthreads  -mno-align-stringops  -minline-all-stringops @gol
  -mpush-args  -maccumulate-outgoing-args  -m128bit-long-double @gol
  -m96bit-long-double  -mregparm=@var{num}  -msseregparm @gol
*************** instruction set support.
*** 9409,9414 ****
--- 9409,9418 ----
  @item k8, opteron, athlon64, athlon-fx
  AMD K8 core based CPUs with x86-64 instruction set support.  (This supersets
  MMX, SSE, SSE2, 3dNOW!, enhanced 3dNOW! and 64-bit instruction set extensions.)
+ @item amdfam10, barcelona
+ AMD Family 10h core based CPUs with x86-64 instruction set support.  (This
+ supersets MMX, SSE, SSE2, SSE3, SSE4A, 3dNOW!, enhanced 3dNOW!, ABM and 64-bit
+ instruction set extensions.)
  @item winchip-c6
  IDT Winchip C6 CPU, dealt in same way as i486 with additional MMX instruction
  set support.
*************** preferred alignment to @option{-mpreferr
*** 9699,9706 ****
--- 9703,9716 ----
  @itemx -mno-sse2
  @item -msse3
  @itemx -mno-sse3
+ @item -msse4a
+ @item -mno-sse4a
  @item -m3dnow
  @itemx -mno-3dnow
+ @item -mpopcnt
+ @itemx -mno-popcnt
+ @item -mabm
+ @itemx -mno-abm
  @opindex mmmx
  @opindex mno-mmx
  @opindex msse
*************** preferred alignment to @option{-mpreferr
*** 9708,9714 ****
  @opindex m3dnow
  @opindex mno-3dnow
  These switches enable or disable the use of instructions in the MMX,
! SSE, SSE2 or 3DNow! extended instruction sets.  These extensions are
  also available as built-in functions: see @ref{X86 Built-in Functions},
  for details of the functions enabled and disabled by these switches.
  
--- 9718,9724 ----
  @opindex m3dnow
  @opindex mno-3dnow
  These switches enable or disable the use of instructions in the MMX,
! SSE, SSE2, SSE3, SSE4A, ABM or 3DNow! extended instruction sets.  These extensions are
  also available as built-in functions: see @ref{X86 Built-in Functions},
  for details of the functions enabled and disabled by these switches.
  
*** gcc/testsuite/gcc.target/i386/sse4a-extract.c.~1~	2007-11-09 12:11:08.058016000 -0500
--- gcc/testsuite/gcc.target/i386/sse4a-extract.c	2007-11-09 13:24:03.990928000 -0500
***************
*** 0 ****
--- 1,100 ----
+ /* { dg-do run { target i?86-*-* x86_64-*-* } } */
+ /* { dg-options "-O2 -msse4a" } */
+ #include <ammintrin.h>
+ #include <stdlib.h>
+ #include "../../gcc.dg/i386-cpuid.h"
+ 
+ static void sse4a_test (void);
+ 
+ typedef union
+ {
+   long long i[2];
+   __m128i vec;
+ } LI;
+ 
+ int
+ main ()
+ {  
+   unsigned long cpu_facilities;
+ 
+   cpu_facilities = i386_extended_cpuid_ecx ();
+ 
+   /* Run SSE4a test only if host has SSE4a support.  */
+   if ((cpu_facilities & bit_SSE4a))
+     sse4a_test ();
+ 
+   exit (0);
+ }
+ 
+ static long long 
+ sse4a_test_extrq (long long in)
+ {
+   __m128i v1, v2;
+   long long index_length, pad;
+   LI v_out;
+   index_length = 0x0000000000000810LL; 
+   pad = 0x0;
+   v1 = _mm_set_epi64x (pad, in);
+   v2 = _mm_set_epi64x (pad, index_length); 
+   v_out.vec = _mm_extract_si64 (v1, v2);
+   return (v_out.i[0]); 
+ }
+ 
+ static long long 
+ sse4a_test_extrqi (long long in)
+ {
+   __m128i v1;
+   long long pad =0x0;
+   LI v_out;
+   v1 = _mm_set_epi64x (pad, in);
+   v_out.vec = _mm_extracti_si64 (v1, (unsigned int) 0x10,(unsigned int) 0x08);
+   return (v_out.i[0]);
+ }
+ 
+ static chk (long long i1, long long i2)
+ {
+   int n_fails =0;
+   if (i1 != i2) 
+     n_fails +=1;
+   return n_fails;
+ }
+ 
+ long long vals_in[5] =
+   {
+     0x1234567887654321LL,
+     0x1456782093002490LL,
+     0x2340909123990390LL,
+     0x9595959599595999LL,
+     0x9099038798000029LL
+   };
+ 
+ long long vals_out[5] =
+   {
+     0x0000000000006543LL,
+     0x0000000000000024LL,
+     0x0000000000009903LL,
+     0x0000000000005959LL,
+     0x0000000000000000LL
+   };
+ 
+ static void
+ sse4a_test (void)
+ {
+   int i;
+   int fail = 0;
+   long long out;
+ 
+   for (i = 0; i < 5; i += 1)
+     {
+       out = sse4a_test_extrq (vals_in[i]);
+       fail += chk(out, vals_out[i]);
+ 
+       out = sse4a_test_extrqi (vals_in[i]);
+       fail += chk(out, vals_out[i]);
+     }
+ 
+   if (fail != 0)
+     abort ();
+ 
+   exit (0);
+ }
*** gcc/testsuite/gcc.target/i386/sse4a-montss.c.~1~	2007-11-09 12:11:08.106063000 -0500
--- gcc/testsuite/gcc.target/i386/sse4a-montss.c	2007-11-09 12:11:08.107064000 -0500
***************
*** 0 ****
--- 1,64 ----
+ /* { dg-do run { target i?86-*-* x86_64-*-* } } */
+ /* { dg-options "-O2 -msse4a" } */
+ #include <ammintrin.h>
+ #include <stdlib.h>
+ #include "../../gcc.dg/i386-cpuid.h"
+ 
+ static void sse4a_test (void);
+ 
+ int
+ main ()
+ {  
+   unsigned long cpu_facilities;
+ 
+   cpu_facilities = i386_extended_cpuid_ecx ();
+ 
+   /* Run SSE4a test only if host has SSE4a support.  */
+   if ((cpu_facilities & bit_SSE4a))
+     sse4a_test ();
+ 
+   exit (0);
+ }
+ 
+ static void 
+ sse4a_test_movntss (float *out, float *in)
+ {
+   __m128 in_v4sf = _mm_load_ss (in);
+   _mm_stream_ss (out, in_v4sf);
+ }
+ 
+ static int 
+ chk_ss (float *v1, float *v2)
+ {
+   int n_fails = 0;
+   if (v1[0] != v2[0])
+     n_fails += 1;
+   return n_fails;
+ }
+ 
+ float vals[10] =
+   {
+     100.0,  200.0, 300.0, 400.0, 5.0, 
+     -1.0, .345, -21.5, 9.32,  8.41
+   };
+ 
+ static void
+ sse4a_test (void)
+ {
+   int i;
+   int fail = 0;
+   float *out;
+ 
+   out = (float *) malloc (sizeof (float));
+   for (i = 0; i < 10; i += 1)
+     {
+       sse4a_test_movntss (out, &vals[i]);
+       
+       fail += chk_ss (out, &vals[i]);
+     }
+ 
+   if (fail != 0)
+     abort ();
+ 
+   exit (0);
+ }
*** gcc/testsuite/gcc.target/i386/sse4a-insert.c.~1~	2007-11-09 12:11:08.082039000 -0500
--- gcc/testsuite/gcc.target/i386/sse4a-insert.c	2007-11-09 13:24:45.549875000 -0500
***************
*** 0 ****
--- 1,110 ----
+ /* { dg-do run { target i?86-*-* x86_64-*-* } } */
+ /* { dg-options "-O2 -msse4a" } */
+ #include <ammintrin.h>
+ #include <stdlib.h>
+ #include "../../gcc.dg/i386-cpuid.h"
+ 
+ static void sse4a_test (void);
+ 
+ typedef union
+ {
+   long long i[2];
+   __m128i vec;
+ } LI;
+ 
+ int
+ main ()
+ {  
+   unsigned long cpu_facilities;
+ 
+   cpu_facilities = i386_extended_cpuid_ecx ();
+ 
+   /* Run SSE4a test only if host has SSE4a support.  */
+   if ((cpu_facilities & bit_SSE4a))
+     sse4a_test ();
+ 
+   exit (0);
+ }
+ 
+ static long long
+ sse4a_test_insert (long long in1, long long in2)
+ {
+   __m128i v1,v2;
+   long long index_length, pad;
+   LI v_out;
+   index_length = 0x0000000000000810LL;
+   pad = 0x0;
+   v1 = _mm_set_epi64x (pad, in1);
+   v2 = _mm_set_epi64x (index_length, in2); 
+   v_out.vec = _mm_insert_si64 (v1, v2);
+   return (v_out.i[0]);
+ }
+ 
+ static long long
+ sse4a_test_inserti (long long in1, long long in2)
+ {
+   __m128i v1,v2;
+   long long pad = 0x0;
+   LI v_out;
+   v1 = _mm_set_epi64x (pad, in1);
+   v2 = _mm_set_epi64x (pad, in2); 
+   v_out.vec = _mm_inserti_si64 (v1, v2, (unsigned int) 0x10, (unsigned int) 0x08);
+   return (v_out.i[0]);  
+ }
+ 
+ static chk (long long i1, long long i2)
+ {
+   int n_fails =0;
+   if (i1 != i2) 
+     n_fails +=1;
+   return n_fails;
+ }
+ 
+ long long vals_in1[5] =
+   {
+     0x1234567887654321LL,
+     0x1456782093002490LL,
+     0x2340909123990390LL,
+     0x9595959599595999LL,
+     0x9099038798000029LL
+   };
+ 
+ long long vals_in2[5] =
+   {
+     0x9ABCDEF00FEDCBA9LL,
+     0x234567097289672ALL,
+     0x45476453097BD342LL,
+     0x23569012AE586FF0LL,
+     0x432567ABCDEF765DLL
+   };
+ 
+ long long vals_out[5] =
+   {
+     0x1234567887CBA921LL,
+     0x1456782093672A90LL,
+     0x2340909123D34290LL,
+     0x95959595996FF099LL,
+     0x9099038798765D29LL
+   };
+ 
+ static void
+ sse4a_test (void)
+ {
+   int i;
+   int fail = 0;
+   long long out;
+ 
+   for (i = 0; i < 5; i += 1)
+     {
+       out = sse4a_test_insert (vals_in1[i], vals_in2[i]);
+       fail += chk(out, vals_out[i]);
+ 
+       out = sse4a_test_inserti (vals_in1[i], vals_in2[i]);
+       fail += chk(out, vals_out[i]);
+     }
+ 
+   if (fail != 0)
+     abort ();
+ 
+   exit (0);
+ }
*** gcc/testsuite/gcc.target/i386/sse4a-montsd.c.~1~	2007-11-09 12:11:08.096054000 -0500
--- gcc/testsuite/gcc.target/i386/sse4a-montsd.c	2007-11-09 12:11:08.097055000 -0500
***************
*** 0 ****
--- 1,64 ----
+ /* { dg-do run { target i?86-*-* x86_64-*-* } } */
+ /* { dg-options "-O2 -msse4a" } */
+ #include <ammintrin.h>
+ #include <stdlib.h>
+ #include "../../gcc.dg/i386-cpuid.h"
+ 
+ static void sse4a_test (void);
+ 
+ int
+ main ()
+ {  
+   unsigned long cpu_facilities;
+ 
+   cpu_facilities = i386_extended_cpuid_ecx ();
+ 
+   /* Run SSE4a test only if host has SSE4a support.  */
+   if ((cpu_facilities & bit_SSE4a))
+     sse4a_test ();
+ 
+   exit (0);
+ }
+   
+ static void 
+ sse4a_test_movntsd (double *out, double *in)
+ {
+   __m128d in_v2df = _mm_load_sd (in);
+   _mm_stream_sd (out, in_v2df);
+ }
+ 
+ static int 
+ chk_sd (double *v1, double *v2)
+ {
+   int n_fails = 0;
+   if (v1[0] != v2[0])
+     n_fails += 1;
+   return n_fails;
+ }
+ 
+ double vals[10] =
+   {
+     100.0,  200.0, 300.0, 400.0, 5.0, 
+     -1.0, .345, -21.5, 9.32,  8.41
+   };
+ 
+ static void
+ sse4a_test (void)
+ {
+   int i;
+   int fail = 0;
+   double *out;
+ 
+   out = (double *) malloc (sizeof (double));
+   for (i = 0; i < 10; i += 1)
+     {
+       sse4a_test_movntsd (out, &vals[i]);
+       
+       fail += chk_sd (out, &vals[i]);
+     }
+ 
+   if (fail != 0)
+     abort ();
+ 
+   exit (0);
+ }
*** gcc/testsuite/gcc.dg/i386-cpuid.h.~1~	2007-11-08 14:19:59.517887000 -0500
--- gcc/testsuite/gcc.dg/i386-cpuid.h	2007-11-09 12:11:08.054012000 -0500
***************
*** 11,16 ****
--- 11,20 ----
  #define bit_SSE (1 << 25)
  #define bit_SSE2 (1 << 26)
  
+ /* Extended Features */
+ /* %ecx */
+ #define bit_SSE4a (1 << 6)
+ 
  #ifndef NOINLINE
  #define NOINLINE __attribute__ ((noinline))
  #endif
*************** i386_get_cpuid (unsigned int *ecx, unsig
*** 59,66 ****
--- 63,105 ----
    return 1;
  }
  
+ static inline unsigned int
+ i386_get_extended_cpuid (unsigned int *ecx, unsigned int *edx)
+ {
+   int fl1;
+   if (!(i386_get_cpuid (ecx, edx)))
+     return 0;
+ 
+   /* Invoke CPUID(0x80000000) to get the highest supported extended function
+      number */
+ #ifdef __x86_64__
+   __asm__ ("cpuid"
+ 	   : "=a" (fl1) : "0" (0x80000000) : "edx", "ecx", "ebx");
+ #else
+   __asm__ ("pushl %%ebx; cpuid; popl %%ebx"
+ 	   : "=a" (fl1) : "0" (0x80000000) : "edx", "ecx");
+ #endif
+   /* Check if highest supported extended function used below are supported */
+   if (fl1 < 0x80000001)
+     return 0;  
+ 
+   /* Invoke CPUID(0x80000001), return %ecx and %edx; caller can examine bits to
+      determine what's supported.  */
+ #ifdef __x86_64__
+   __asm__ ("cpuid"
+ 	   : "=c" (*ecx), "=d" (*edx), "=a" (fl1) : "2" (0x80000001) : "ebx");
+ #else
+   __asm__ ("pushl %%ebx; cpuid; popl %%ebx"
+ 	   : "=c" (*ecx), "=d" (*edx), "=a" (fl1) : "2" (0x80000001));
+ #endif
+   return 1;
+ }
+ 
+ 
  unsigned int i386_cpuid_ecx (void) NOINLINE;
  unsigned int i386_cpuid_edx (void) NOINLINE;
+ unsigned int i386_extended_cpuid_ecx (void) NOINLINE;
+ unsigned int i386_extended_cpuid_edx (void) NOINLINE;
  
  unsigned int NOINLINE
  i386_cpuid_ecx (void)
*************** i386_cpuid_edx (void)
*** 82,87 ****
--- 121,146 ----
      return 0;
  }
  
+ unsigned int NOINLINE
+ i386_extended_cpuid_ecx (void)
+ {
+   unsigned int ecx, edx;
+   if (i386_get_extended_cpuid (&ecx, &edx))
+     return ecx;
+   else
+     return 0;
+ }
+ 
+ unsigned int NOINLINE
+ i386_extended_cpuid_edx (void)
+ {
+   unsigned int ecx, edx;
+   if (i386_get_extended_cpuid (&ecx, &edx))
+     return edx;
+   else
+     return 0;
+ }
+ 
  static inline unsigned int
  i386_cpuid (void)
  {
*** gcc/config.gcc.~1~	2007-11-08 14:27:48.255010000 -0500
--- gcc/config.gcc	2007-11-09 12:11:07.880841000 -0500
*************** xscale-*-*)
*** 267,277 ****
  	;;
  i[34567]86-*-*)
  	cpu_type=i386
! 	extra_headers="mmintrin.h mm3dnow.h xmmintrin.h emmintrin.h pmmintrin.h"
  	;;
  x86_64-*-*)
  	cpu_type=i386
! 	extra_headers="mmintrin.h mm3dnow.h xmmintrin.h emmintrin.h pmmintrin.h"
  	need_64bit_hwint=yes
  	;;
  ia64-*-*)
--- 267,277 ----
  	;;
  i[34567]86-*-*)
  	cpu_type=i386
! 	extra_headers="mmintrin.h mm3dnow.h xmmintrin.h emmintrin.h pmmintrin.h ammintrin.h"
  	;;
  x86_64-*-*)
  	cpu_type=i386
! 	extra_headers="mmintrin.h mm3dnow.h xmmintrin.h emmintrin.h pmmintrin.h ammintrin.h"
  	need_64bit_hwint=yes
  	;;
  ia64-*-*)
*************** i[34567]86-*-solaris2*)
*** 1206,1219 ****
  		# FIXME: -m64 for i[34567]86-*-* should be allowed just
  		# like -m32 for x86_64-*-*.
  		case X"${with_cpu}" in
! 		Xgeneric|Xnocona|Xx86-64|Xk8|Xopteron|Xathlon64|Xathlon-fx)
  			;;
  		X)
  			with_cpu=generic
  			;;
  		*)
  			echo "Unsupported CPU used in --with-cpu=$with_cpu, supported values:" 1>&2
! 			echo "generic nocona x86-64 k8 opteron athlon64 athlon-fx" 1>&2
  			exit 1
  			;;
  		esac
--- 1206,1219 ----
  		# FIXME: -m64 for i[34567]86-*-* should be allowed just
  		# like -m32 for x86_64-*-*.
  		case X"${with_cpu}" in
! 		Xgeneric|Xnocona|Xx86-64|Xamdfam10|Xbarcelona|Xk8|Xopteron|Xathlon64|Xathlon-fx)
  			;;
  		X)
  			with_cpu=generic
  			;;
  		*)
  			echo "Unsupported CPU used in --with-cpu=$with_cpu, supported values:" 1>&2
! 			echo "generic nocona x86-64 amdfam10 barcelona k8 opteron athlon64 athlon-fx" 1>&2
  			exit 1
  			;;
  		esac
*************** if test x$with_cpu = x ; then
*** 2512,2517 ****
--- 2512,2520 ----
        ;;
      i686-*-* | i786-*-*)
        case ${target_noncanonical} in
+         amdfam10-*|barcelona-*)
+           with_cpu=amdfam10
+           ;;
          k8-*|opteron-*|athlon_64-*)
            with_cpu=k8
            ;;
*************** if test x$with_cpu = x ; then
*** 2549,2554 ****
--- 2552,2560 ----
        ;;
      x86_64-*-*)
        case ${target_noncanonical} in
+         amdfam10-*|barcelona-*)
+           with_cpu=amdfam10
+           ;;
          k8-*|opteron-*|athlon_64-*)
            with_cpu=k8
            ;;
*************** case "${target}" in
*** 2786,2792 ****
  				esac
  				# OK
  				;;
! 			"" | k8 | opteron | athlon64 | athlon-fx | nocona | generic)
  				# OK
  				;;
  			*)
--- 2792,2798 ----
  				esac
  				# OK
  				;;
! 			"" | barcelona | amdfam10 | k8 | opteron | athlon64 | athlon-fx | nocona | generic)
  				# OK
  				;;
  			*)
*** gcc/config/i386/i386.h.~1~	2007-11-08 14:27:20.877599000 -0500
--- gcc/config/i386/i386.h	2007-11-09 12:11:07.538500000 -0500
*************** extern const struct processor_costs *ix8
*** 138,143 ****
--- 138,144 ----
  #define TARGET_GENERIC32 (ix86_tune == PROCESSOR_GENERIC32)
  #define TARGET_GENERIC64 (ix86_tune == PROCESSOR_GENERIC64)
  #define TARGET_GENERIC (TARGET_GENERIC32 || TARGET_GENERIC64)
+ #define TARGET_AMDFAM10 (ix86_tune == PROCESSOR_AMDFAM10)
  
  #define TUNEMASK (1 << ix86_tune)
  extern const int x86_use_leave, x86_push_memory, x86_zero_extend_with_and;
*************** extern const int x86_accumulate_outgoing
*** 156,161 ****
--- 157,163 ----
  extern const int x86_epilogue_using_move, x86_decompose_lea;
  extern const int x86_arch_always_fancy_math_387, x86_shift1;
  extern const int x86_sse_partial_reg_dependency, x86_sse_split_regs;
+ extern const int x86_sse_unaligned_move_optimal;
  extern const int x86_sse_typeless_stores, x86_sse_load0_by_pxor;
  extern const int x86_use_ffreep;
  extern const int x86_inter_unit_moves, x86_schedule;
*************** extern int x86_prefetch_sse;
*** 204,209 ****
--- 206,213 ----
  #define TARGET_PARTIAL_REG_DEPENDENCY (x86_partial_reg_dependency & TUNEMASK)
  #define TARGET_SSE_PARTIAL_REG_DEPENDENCY \
  				      (x86_sse_partial_reg_dependency & TUNEMASK)
+ #define TARGET_SSE_UNALIGNED_MOVE_OPTIMAL \
+ 				      (x86_sse_unaligned_move_optimal & TUNEMASK)
  #define TARGET_SSE_SPLIT_REGS (x86_sse_split_regs & TUNEMASK)
  #define TARGET_SSE_TYPELESS_STORES (x86_sse_typeless_stores & TUNEMASK)
  #define TARGET_SSE_LOAD0_BY_PXOR (x86_sse_load0_by_pxor & TUNEMASK)
*************** extern const char *host_detect_local_cpu
*** 392,397 ****
--- 396,403 ----
  	}							\
        else if (TARGET_K8)					\
  	builtin_define ("__tune_k8__");				\
+       else if (TARGET_AMDFAM10)					\
+ 	builtin_define ("__tune_amdfam10__");			\
        else if (TARGET_PENTIUM4)					\
  	builtin_define ("__tune_pentium4__");			\
        else if (TARGET_NOCONA)					\
*************** extern const char *host_detect_local_cpu
*** 409,414 ****
--- 415,422 ----
  	builtin_define ("__SSE2__");				\
        if (TARGET_SSE3)						\
  	builtin_define ("__SSE3__");				\
+       if (TARGET_SSE4A)                                         \
+  	builtin_define ("__SSE4A__");		                \
        if (TARGET_SSE_MATH && TARGET_SSE)			\
  	builtin_define ("__SSE_MATH__");			\
        if (TARGET_SSE_MATH && TARGET_SSE2)			\
*************** extern const char *host_detect_local_cpu
*** 459,464 ****
--- 467,477 ----
  	  builtin_define ("__k8");				\
  	  builtin_define ("__k8__");				\
  	}							\
+       else if (ix86_arch == PROCESSOR_AMDFAM10)			\
+ 	{							\
+ 	  builtin_define ("__amdfam10");			\
+ 	  builtin_define ("__amdfam10__");			\
+ 	}							\
        else if (ix86_arch == PROCESSOR_PENTIUM4)			\
  	{							\
  	  builtin_define ("__pentium4");			\
*************** extern const char *host_detect_local_cpu
*** 490,502 ****
  #define TARGET_CPU_DEFAULT_prescott 15
  #define TARGET_CPU_DEFAULT_nocona 16
  #define TARGET_CPU_DEFAULT_generic 17
  
  #define TARGET_CPU_DEFAULT_NAMES {"i386", "i486", "pentium", "pentium-mmx",\
  				  "pentiumpro", "pentium2", "pentium3", \
  				  "pentium4", "k6", "k6-2", "k6-3",\
  				  "athlon", "athlon-4", "k8", \
  				  "pentium-m", "prescott", "nocona", \
! 				  "generic"}
  
  #ifndef CC1_SPEC
  #define CC1_SPEC "%(cc1_cpu) "
--- 503,516 ----
  #define TARGET_CPU_DEFAULT_prescott 15
  #define TARGET_CPU_DEFAULT_nocona 16
  #define TARGET_CPU_DEFAULT_generic 17
+ #define TARGET_CPU_DEFAULT_amdfam10 18
  
  #define TARGET_CPU_DEFAULT_NAMES {"i386", "i486", "pentium", "pentium-mmx",\
  				  "pentiumpro", "pentium2", "pentium3", \
  				  "pentium4", "k6", "k6-2", "k6-3",\
  				  "athlon", "athlon-4", "k8", \
  				  "pentium-m", "prescott", "nocona", \
! 				  "generic", "amdfam10"}
  
  #ifndef CC1_SPEC
  #define CC1_SPEC "%(cc1_cpu) "
*************** enum processor_type
*** 2081,2086 ****
--- 2095,2101 ----
    PROCESSOR_NOCONA,
    PROCESSOR_GENERIC32,
    PROCESSOR_GENERIC64,
+   PROCESSOR_AMDFAM10,
    PROCESSOR_max
  };
  
*** gcc/config/i386/i386.md.~1~	2007-11-08 14:27:20.961602000 -0500
--- gcc/config/i386/i386.md	2007-11-09 12:11:07.609569000 -0500
***************
*** 147,152 ****
--- 147,159 ----
     (UNSPEC_SP_TEST		101)
     (UNSPEC_SP_TLS_SET		102)
     (UNSPEC_SP_TLS_TEST		103)
+ 
+    ; For SSE4A support
+    (UNSPEC_EXTRQI               110)
+    (UNSPEC_EXTRQ                111)   
+    (UNSPEC_INSERTQI             112)
+    (UNSPEC_INSERTQ              113)  
+ 
    ])
  
  (define_constants
***************
*** 186,192 ****
  
  ;; Processor type.  This attribute must exactly match the processor_type
  ;; enumeration in i386.h.
! (define_attr "cpu" "i386,i486,pentium,pentiumpro,k6,athlon,pentium4,k8,nocona,generic32,generic64"
    (const (symbol_ref "ix86_tune")))
  
  ;; A basic instruction type.  Refinements due to arguments to be
--- 193,199 ----
  
  ;; Processor type.  This attribute must exactly match the processor_type
  ;; enumeration in i386.h.
! (define_attr "cpu" "i386,i486,pentium,pentiumpro,k6,athlon,pentium4,k8,nocona,generic32,generic64,amdfam10"
    (const (symbol_ref "ix86_tune")))
  
  ;; A basic instruction type.  Refinements due to arguments to be
***************
*** 197,206 ****
     incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
     icmp,test,ibr,setcc,icmov,
     push,pop,call,callv,leave,
!    str,cld,
     fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
     sselog,sselog1,sseiadd,sseishft,sseimul,
!    sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv,
     mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
    (const_string "other"))
  
--- 204,213 ----
     incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
     icmp,test,ibr,setcc,icmov,
     push,pop,call,callv,leave,
!    str,cld,bitmanip,
     fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
     sselog,sselog1,sseiadd,sseishft,sseimul,
!    sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv,sseins,
     mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
    (const_string "other"))
  
***************
*** 214,220 ****
    (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
  	   (const_string "i387")
  	 (eq_attr "type" "sselog,sselog1,sseiadd,sseishft,sseimul,
! 			  sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv")
  	   (const_string "sse")
  	 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
  	   (const_string "mmx")
--- 221,227 ----
    (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
  	   (const_string "i387")
  	 (eq_attr "type" "sselog,sselog1,sseiadd,sseishft,sseimul,
! 			  sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv,sseins")
  	   (const_string "sse")
  	 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
  	   (const_string "mmx")
***************
*** 224,230 ****
  
  ;; The (bounding maximum) length of an instruction immediate.
  (define_attr "length_immediate" ""
!   (cond [(eq_attr "type" "incdec,setcc,icmov,str,cld,lea,other,multi,idiv,leave")
  	   (const_int 0)
  	 (eq_attr "unit" "i387,sse,mmx")
  	   (const_int 0)
--- 231,237 ----
  
  ;; The (bounding maximum) length of an instruction immediate.
  (define_attr "length_immediate" ""
!   (cond [(eq_attr "type" "incdec,setcc,icmov,str,cld,lea,other,multi,idiv,leave,bitmanip")
  	   (const_int 0)
  	 (eq_attr "unit" "i387,sse,mmx")
  	   (const_int 0)
***************
*** 278,284 ****
  ;; Set when 0f opcode prefix is used.
  (define_attr "prefix_0f" ""
    (if_then_else 
!     (ior (eq_attr "type" "imovx,setcc,icmov")
  	 (eq_attr "unit" "sse,mmx"))
      (const_int 1)
      (const_int 0)))
--- 285,291 ----
  ;; Set when 0f opcode prefix is used.
  (define_attr "prefix_0f" ""
    (if_then_else 
!     (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
  	 (eq_attr "unit" "sse,mmx"))
      (const_int 1)
      (const_int 0)))
***************
*** 407,413 ****
  	   (const_string "load")
  	 (and (eq_attr "type"
  		 "!alu1,negnot,ishift1,
! 		   imov,imovx,icmp,test,
  		   fmov,fcmp,fsgn,
  		   sse,ssemov,ssecmp,ssecomi,ssecvt,sseicvt,sselog1,
  		   mmx,mmxmov,mmxcmp,mmxcvt")
--- 414,420 ----
  	   (const_string "load")
  	 (and (eq_attr "type"
  		 "!alu1,negnot,ishift1,
! 		   imov,imovx,icmp,test,bitmanip,
  		   fmov,fcmp,fsgn,
  		   sse,ssemov,ssecmp,ssecomi,ssecvt,sseicvt,sselog1,
  		   mmx,mmxmov,mmxcmp,mmxcvt")
***************
*** 961,970 ****
    "sahf"
    [(set_attr "length" "1")
     (set_attr "athlon_decode" "vector")
     (set_attr "mode" "SI")])
  
  ;; Pentium Pro can do steps 1 through 3 in one go.
! 
  (define_insn "*cmpfp_i_mixed"
    [(set (reg:CCFP FLAGS_REG)
  	(compare:CCFP (match_operand 0 "register_operand" "f,x")
--- 968,978 ----
    "sahf"
    [(set_attr "length" "1")
     (set_attr "athlon_decode" "vector")
+    (set_attr "amdfam10_decode" "direct")
     (set_attr "mode" "SI")])
  
  ;; Pentium Pro can do steps 1 through 3 in one go.
! ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes) 
  (define_insn "*cmpfp_i_mixed"
    [(set (reg:CCFP FLAGS_REG)
  	(compare:CCFP (match_operand 0 "register_operand" "f,x")
***************
*** 978,984 ****
       (if_then_else (match_operand:SF 1 "" "")
          (const_string "SF")
          (const_string "DF")))
!    (set_attr "athlon_decode" "vector")])
  
  (define_insn "*cmpfp_i_sse"
    [(set (reg:CCFP FLAGS_REG)
--- 986,993 ----
       (if_then_else (match_operand:SF 1 "" "")
          (const_string "SF")
          (const_string "DF")))
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "direct")])
  
  (define_insn "*cmpfp_i_sse"
    [(set (reg:CCFP FLAGS_REG)
***************
*** 993,999 ****
       (if_then_else (match_operand:SF 1 "" "")
          (const_string "SF")
          (const_string "DF")))
!    (set_attr "athlon_decode" "vector")])
  
  (define_insn "*cmpfp_i_i387"
    [(set (reg:CCFP FLAGS_REG)
--- 1002,1009 ----
       (if_then_else (match_operand:SF 1 "" "")
          (const_string "SF")
          (const_string "DF")))
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "direct")])
  
  (define_insn "*cmpfp_i_i387"
    [(set (reg:CCFP FLAGS_REG)
***************
*** 1012,1018 ****
  	      (const_string "DF")
  	   ]
  	   (const_string "XF")))
!    (set_attr "athlon_decode" "vector")])
  
  (define_insn "*cmpfp_iu_mixed"
    [(set (reg:CCFPU FLAGS_REG)
--- 1022,1029 ----
  	      (const_string "DF")
  	   ]
  	   (const_string "XF")))
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "direct")])
  
  (define_insn "*cmpfp_iu_mixed"
    [(set (reg:CCFPU FLAGS_REG)
***************
*** 1027,1033 ****
       (if_then_else (match_operand:SF 1 "" "")
          (const_string "SF")
          (const_string "DF")))
!    (set_attr "athlon_decode" "vector")])
  
  (define_insn "*cmpfp_iu_sse"
    [(set (reg:CCFPU FLAGS_REG)
--- 1038,1045 ----
       (if_then_else (match_operand:SF 1 "" "")
          (const_string "SF")
          (const_string "DF")))
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "direct")])
  
  (define_insn "*cmpfp_iu_sse"
    [(set (reg:CCFPU FLAGS_REG)
***************
*** 1042,1048 ****
       (if_then_else (match_operand:SF 1 "" "")
          (const_string "SF")
          (const_string "DF")))
!    (set_attr "athlon_decode" "vector")])
  
  (define_insn "*cmpfp_iu_387"
    [(set (reg:CCFPU FLAGS_REG)
--- 1054,1061 ----
       (if_then_else (match_operand:SF 1 "" "")
          (const_string "SF")
          (const_string "DF")))
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "direct")])
  
  (define_insn "*cmpfp_iu_387"
    [(set (reg:CCFPU FLAGS_REG)
***************
*** 1061,1067 ****
  	      (const_string "DF")
  	   ]
  	   (const_string "XF")))
!    (set_attr "athlon_decode" "vector")])
  
  ;; Move instructions.
  
--- 1074,1081 ----
  	      (const_string "DF")
  	   ]
  	   (const_string "XF")))
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "direct")])
  
  ;; Move instructions.
  
***************
*** 1267,1273 ****
    [(set_attr "type" "imov")
     (set_attr "mode" "SI")
     (set_attr "pent_pair" "np")
!    (set_attr "athlon_decode" "vector")])
  
  (define_expand "movhi"
    [(set (match_operand:HI 0 "nonimmediate_operand" "")
--- 1281,1288 ----
    [(set_attr "type" "imov")
     (set_attr "mode" "SI")
     (set_attr "pent_pair" "np")
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "double")])   
  
  (define_expand "movhi"
    [(set (match_operand:HI 0 "nonimmediate_operand" "")
***************
*** 1384,1391 ****
    [(set_attr "type" "imov")
     (set_attr "mode" "SI")
     (set_attr "pent_pair" "np")
!    (set_attr "athlon_decode" "vector")])
  
  (define_insn "*swaphi_2"
    [(set (match_operand:HI 0 "register_operand" "+r")
  	(match_operand:HI 1 "register_operand" "+r"))
--- 1399,1408 ----
    [(set_attr "type" "imov")
     (set_attr "mode" "SI")
     (set_attr "pent_pair" "np")
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "double")])   
  
+ ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
  (define_insn "*swaphi_2"
    [(set (match_operand:HI 0 "register_operand" "+r")
  	(match_operand:HI 1 "register_operand" "+r"))
***************
*** 1558,1565 ****
    [(set_attr "type" "imov")
     (set_attr "mode" "SI")
     (set_attr "pent_pair" "np")
!    (set_attr "athlon_decode" "vector")])
  
  (define_insn "*swapqi_2"
    [(set (match_operand:QI 0 "register_operand" "+q")
  	(match_operand:QI 1 "register_operand" "+q"))
--- 1575,1584 ----
    [(set_attr "type" "imov")
     (set_attr "mode" "SI")
     (set_attr "pent_pair" "np")
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "vector")])   
  
+ ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
  (define_insn "*swapqi_2"
    [(set (match_operand:QI 0 "register_operand" "+q")
  	(match_operand:QI 1 "register_operand" "+q"))
***************
*** 2113,2119 ****
    [(set_attr "type" "imov")
     (set_attr "mode" "DI")
     (set_attr "pent_pair" "np")
!    (set_attr "athlon_decode" "vector")])
  
  (define_expand "movti"
    [(set (match_operand:TI 0 "nonimmediate_operand" "")
--- 2132,2139 ----
    [(set_attr "type" "imov")
     (set_attr "mode" "DI")
     (set_attr "pent_pair" "np")
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "double")])   
  
  (define_expand "movti"
    [(set (match_operand:TI 0 "nonimmediate_operand" "")
***************
*** 4143,4149 ****
    "cvttss2si{q}\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "SF")
!    (set_attr "athlon_decode" "double,vector")])
  
  (define_insn "fix_truncdfdi_sse"
    [(set (match_operand:DI 0 "register_operand" "=r,r")
--- 4163,4170 ----
    "cvttss2si{q}\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "SF")
!    (set_attr "athlon_decode" "double,vector")
!    (set_attr "amdfam10_decode" "double,double")])
  
  (define_insn "fix_truncdfdi_sse"
    [(set (match_operand:DI 0 "register_operand" "=r,r")
***************
*** 4152,4158 ****
    "cvttsd2si{q}\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "double,vector")])
  
  (define_insn "fix_truncsfsi_sse"
    [(set (match_operand:SI 0 "register_operand" "=r,r")
--- 4173,4180 ----
    "cvttsd2si{q}\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "double,vector")
!    (set_attr "amdfam10_decode" "double,double")])
  
  (define_insn "fix_truncsfsi_sse"
    [(set (match_operand:SI 0 "register_operand" "=r,r")
***************
*** 4161,4167 ****
    "cvttss2si\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "double,vector")])
  
  (define_insn "fix_truncdfsi_sse"
    [(set (match_operand:SI 0 "register_operand" "=r,r")
--- 4183,4190 ----
    "cvttss2si\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "double,vector")
!    (set_attr "amdfam10_decode" "double,double")])
  
  (define_insn "fix_truncdfsi_sse"
    [(set (match_operand:SI 0 "register_operand" "=r,r")
***************
*** 4170,4176 ****
    "cvttsd2si\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "double,vector")])
  
  ;; Avoid vector decoded forms of the instruction.
  (define_peephole2
--- 4193,4200 ----
    "cvttsd2si\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "double,vector")
!    (set_attr "amdfam10_decode" "double,double")])
  
  ;; Avoid vector decoded forms of the instruction.
  (define_peephole2
***************
*** 4431,4437 ****
    [(set_attr "length" "2")
     (set_attr "mode" "HI")
     (set_attr "unit" "i387")
!    (set_attr "athlon_decode" "vector")])
  
  ;; Conversion between fixed point and floating point.
  
--- 4455,4462 ----
    [(set_attr "length" "2")
     (set_attr "mode" "HI")
     (set_attr "unit" "i387")
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "vector")])   
  
  ;; Conversion between fixed point and floating point.
  
***************
*** 4482,4487 ****
--- 4507,4513 ----
     (set_attr "mode" "SF")
     (set_attr "unit" "*,i387,*,*")
     (set_attr "athlon_decode" "*,*,vector,double")
+    (set_attr "amdfam10_decode" "*,*,vector,double")
     (set_attr "fp_int_src" "true")])
  
  (define_insn "*floatsisf2_sse"
***************
*** 4492,4497 ****
--- 4518,4524 ----
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "SF")
     (set_attr "athlon_decode" "vector,double")
+    (set_attr "amdfam10_decode" "vector,double")
     (set_attr "fp_int_src" "true")])
  
  (define_insn "*floatsisf2_i387"
***************
*** 4525,4530 ****
--- 4552,4558 ----
     (set_attr "mode" "SF")
     (set_attr "unit" "*,i387,*,*")
     (set_attr "athlon_decode" "*,*,vector,double")
+    (set_attr "amdfam10_decode" "*,*,vector,double")
     (set_attr "fp_int_src" "true")])
  
  (define_insn "*floatdisf2_sse"
***************
*** 4535,4540 ****
--- 4563,4569 ----
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "SF")
     (set_attr "athlon_decode" "vector,double")
+    (set_attr "amdfam10_decode" "vector,double")
     (set_attr "fp_int_src" "true")])
  
  (define_insn "*floatdisf2_i387"
***************
*** 4593,4598 ****
--- 4622,4628 ----
     (set_attr "mode" "DF")
     (set_attr "unit" "*,i387,*,*")
     (set_attr "athlon_decode" "*,*,double,direct")
+    (set_attr "amdfam10_decode" "*,*,vector,double")
     (set_attr "fp_int_src" "true")])
  
  (define_insn "*floatsidf2_sse"
***************
*** 4603,4608 ****
--- 4633,4639 ----
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
     (set_attr "athlon_decode" "double,direct")
+    (set_attr "amdfam10_decode" "vector,double")
     (set_attr "fp_int_src" "true")])
  
  (define_insn "*floatsidf2_i387"
***************
*** 4636,4641 ****
--- 4667,4673 ----
     (set_attr "mode" "DF")
     (set_attr "unit" "*,i387,*,*")
     (set_attr "athlon_decode" "*,*,double,direct")
+    (set_attr "amdfam10_decode" "*,*,vector,double")
     (set_attr "fp_int_src" "true")])
  
  (define_insn "*floatdidf2_sse"
***************
*** 4646,4651 ****
--- 4678,4684 ----
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
     (set_attr "athlon_decode" "double,direct")
+    (set_attr "amdfam10_decode" "vector,double")
     (set_attr "fp_int_src" "true")])
  
  (define_insn "*floatdidf2_i387"
***************
*** 6853,6858 ****
--- 6886,6899 ----
    "TARGET_64BIT"
    "")
  
+ ;; On AMDFAM10 
+ ;; IMUL reg64, reg64, imm8 	Direct
+ ;; IMUL reg64, mem64, imm8 	VectorPath
+ ;; IMUL reg64, reg64, imm32 	Direct
+ ;; IMUL reg64, mem64, imm32 	VectorPath 
+ ;; IMUL reg64, reg64 		Direct
+ ;; IMUL reg64, mem64 		Direct
+ 
  (define_insn "*muldi3_1_rex64"
    [(set (match_operand:DI 0 "register_operand" "=r,r,r")
  	(mult:DI (match_operand:DI 1 "nonimmediate_operand" "%rm,rm,0")
***************
*** 6875,6880 ****
--- 6916,6926 ----
  		    (match_operand 1 "memory_operand" ""))
  		  (const_string "vector")]
  	      (const_string "direct")))
+    (set (attr "amdfam10_decode")
+ 	(cond [(and (eq_attr "alternative" "0,1")
+ 		    (match_operand 1 "memory_operand" ""))
+ 		  (const_string "vector")]
+ 	      (const_string "direct")))	      
     (set_attr "mode" "DI")])
  
  (define_expand "mulsi3"
***************
*** 6885,6890 ****
--- 6931,6944 ----
    ""
    "")
  
+ ;; On AMDFAM10 
+ ;; IMUL reg32, reg32, imm8 	Direct
+ ;; IMUL reg32, mem32, imm8 	VectorPath
+ ;; IMUL reg32, reg32, imm32 	Direct
+ ;; IMUL reg32, mem32, imm32 	VectorPath
+ ;; IMUL reg32, reg32 		Direct
+ ;; IMUL reg32, mem32 		Direct
+ 
  (define_insn "*mulsi3_1"
    [(set (match_operand:SI 0 "register_operand" "=r,r,r")
  	(mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,rm,0")
***************
*** 6906,6911 ****
--- 6960,6970 ----
  		    (match_operand 1 "memory_operand" ""))
  		  (const_string "vector")]
  	      (const_string "direct")))
+    (set (attr "amdfam10_decode")
+ 	(cond [(and (eq_attr "alternative" "0,1")
+ 		    (match_operand 1 "memory_operand" ""))
+ 		  (const_string "vector")]
+ 	      (const_string "direct")))	      
     (set_attr "mode" "SI")])
  
  (define_insn "*mulsi3_1_zext"
***************
*** 6931,6936 ****
--- 6990,7000 ----
  		    (match_operand 1 "memory_operand" ""))
  		  (const_string "vector")]
  	      (const_string "direct")))
+    (set (attr "amdfam10_decode")
+ 	(cond [(and (eq_attr "alternative" "0,1")
+ 		    (match_operand 1 "memory_operand" ""))
+ 		  (const_string "vector")]
+ 	      (const_string "direct")))	      
     (set_attr "mode" "SI")])
  
  (define_expand "mulhi3"
***************
*** 6941,6946 ****
--- 7005,7017 ----
    "TARGET_HIMODE_MATH"
    "")
  
+ ;; On AMDFAM10
+ ;; IMUL reg16, reg16, imm8 	VectorPath
+ ;; IMUL reg16, mem16, imm8 	VectorPath
+ ;; IMUL reg16, reg16, imm16 	VectorPath
+ ;; IMUL reg16, mem16, imm16 	VectorPath
+ ;; IMUL reg16, reg16 		Direct
+ ;; IMUL reg16, mem16 		Direct
  (define_insn "*mulhi3_1"
    [(set (match_operand:HI 0 "register_operand" "=r,r,r")
  	(mult:HI (match_operand:HI 1 "nonimmediate_operand" "%rm,rm,0")
***************
*** 6959,6964 ****
--- 7030,7039 ----
  	       (eq_attr "alternative" "1,2")
  		  (const_string "vector")]
  	      (const_string "direct")))
+    (set (attr "amdfam10_decode")
+ 	(cond [(eq_attr "alternative" "0,1")
+ 		  (const_string "vector")]
+ 	      (const_string "direct")))
     (set_attr "mode" "HI")])
  
  (define_expand "mulqi3"
***************
*** 6969,6974 ****
--- 7044,7053 ----
    "TARGET_QIMODE_MATH"
    "")
  
+ ;;On AMDFAM10
+ ;; MUL reg8 	Direct
+ ;; MUL mem8 	Direct
+ 
  (define_insn "*mulqi3_1"
    [(set (match_operand:QI 0 "register_operand" "=a")
  	(mult:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
***************
*** 6983,6988 ****
--- 7062,7068 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "direct")))
+    (set_attr "amdfam10_decode" "direct")        
     (set_attr "mode" "QI")])
  
  (define_expand "umulqihi3"
***************
*** 7009,7014 ****
--- 7089,7095 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "direct")))
+    (set_attr "amdfam10_decode" "direct")        
     (set_attr "mode" "QI")])
  
  (define_expand "mulqihi3"
***************
*** 7033,7038 ****
--- 7114,7120 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "direct")))
+    (set_attr "amdfam10_decode" "direct")        
     (set_attr "mode" "QI")])
  
  (define_expand "umulditi3"
***************
*** 7059,7064 ****
--- 7141,7147 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "double")))
+    (set_attr "amdfam10_decode" "double")        
     (set_attr "mode" "DI")])
  
  ;; We can't use this pattern in 64bit mode, since it results in two separate 32bit registers
***************
*** 7086,7091 ****
--- 7169,7175 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "double")))
+    (set_attr "amdfam10_decode" "double")        
     (set_attr "mode" "SI")])
  
  (define_expand "mulditi3"
***************
*** 7112,7117 ****
--- 7196,7202 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "double")))
+    (set_attr "amdfam10_decode" "double")
     (set_attr "mode" "DI")])
  
  (define_expand "mulsidi3"
***************
*** 7138,7143 ****
--- 7223,7229 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "double")))
+    (set_attr "amdfam10_decode" "double")        
     (set_attr "mode" "SI")])
  
  (define_expand "umuldi3_highpart"
***************
*** 7174,7179 ****
--- 7260,7266 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "double")))
+    (set_attr "amdfam10_decode" "double")        
     (set_attr "mode" "DI")])
  
  (define_expand "umulsi3_highpart"
***************
*** 7209,7214 ****
--- 7296,7302 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "double")))
+    (set_attr "amdfam10_decode" "double")
     (set_attr "mode" "SI")])
  
  (define_insn "*umulsi3_highpart_zext"
***************
*** 7231,7236 ****
--- 7319,7325 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "double")))
+    (set_attr "amdfam10_decode" "double")
     (set_attr "mode" "SI")])
  
  (define_expand "smuldi3_highpart"
***************
*** 7266,7271 ****
--- 7355,7361 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "double")))
+    (set_attr "amdfam10_decode" "double")
     (set_attr "mode" "DI")])
  
  (define_expand "smulsi3_highpart"
***************
*** 7300,7305 ****
--- 7390,7396 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "double")))
+    (set_attr "amdfam10_decode" "double")
     (set_attr "mode" "SI")])
  
  (define_insn "*smulsi3_highpart_zext"
***************
*** 7321,7326 ****
--- 7412,7418 ----
       (if_then_else (eq_attr "cpu" "athlon")
          (const_string "vector")
          (const_string "double")))
+    (set_attr "amdfam10_decode" "double")
     (set_attr "mode" "SI")])
  
  ;; The patterns that match these are at the end of this file.
***************
*** 10302,10308 ****
    [(set_attr "type" "ishift")
     (set_attr "prefix_0f" "1")
     (set_attr "mode" "DI")
!    (set_attr "athlon_decode" "vector")])
  
  (define_expand "x86_64_shift_adj"
    [(set (reg:CCZ FLAGS_REG)
--- 10394,10401 ----
    [(set_attr "type" "ishift")
     (set_attr "prefix_0f" "1")
     (set_attr "mode" "DI")
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "vector")])   
  
  (define_expand "x86_64_shift_adj"
    [(set (reg:CCZ FLAGS_REG)
***************
*** 10517,10523 ****
     (set_attr "prefix_0f" "1")
     (set_attr "mode" "SI")
     (set_attr "pent_pair" "np")
!    (set_attr "athlon_decode" "vector")])
  
  (define_expand "x86_shift_adj_1"
    [(set (reg:CCZ FLAGS_REG)
--- 10610,10617 ----
     (set_attr "prefix_0f" "1")
     (set_attr "mode" "SI")
     (set_attr "pent_pair" "np")
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "vector")])   
  
  (define_expand "x86_shift_adj_1"
    [(set (reg:CCZ FLAGS_REG)
***************
*** 11277,11283 ****
    [(set_attr "type" "ishift")
     (set_attr "prefix_0f" "1")
     (set_attr "mode" "DI")
!    (set_attr "athlon_decode" "vector")])
  
  (define_expand "ashrdi3"
    [(set (match_operand:DI 0 "shiftdi_operand" "")
--- 11371,11378 ----
    [(set_attr "type" "ishift")
     (set_attr "prefix_0f" "1")
     (set_attr "mode" "DI")
!    (set_attr "athlon_decode" "vector")
!    (set_attr "amdfam10_decode" "vector")])   
  
  (define_expand "ashrdi3"
    [(set (match_operand:DI 0 "shiftdi_operand" "")
***************
*** 14551,14557 ****
       [(set (match_dup 0) (xor:SI (match_dup 0) (const_int 31)))
        (clobber (reg:CC FLAGS_REG))])]
    ""
!   "")
  
  (define_insn "*bsr"
    [(set (match_operand:SI 0 "register_operand" "=r")
--- 14646,14668 ----
       [(set (match_dup 0) (xor:SI (match_dup 0) (const_int 31)))
        (clobber (reg:CC FLAGS_REG))])]
    ""
! {
!   if (TARGET_ABM)
!     {
!       emit_insn (gen_clzsi2_abm (operands[0], operands[1]));
!       DONE;
!     }
! })
! 
! (define_insn "clzsi2_abm"
!   [(set (match_operand:SI 0 "register_operand" "=r")
!         (clz:SI (match_operand:SI 1 "nonimmediate_operand" "")))
!    (clobber (reg:CC FLAGS_REG))]
!   "TARGET_ABM"
!   "lzcnt{l}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_rep" "1")
!    (set_attr "type" "bitmanip")
!    (set_attr "mode" "SI")])
  
  (define_insn "*bsr"
    [(set (match_operand:SI 0 "register_operand" "=r")
***************
*** 14560,14566 ****
     (clobber (reg:CC FLAGS_REG))]
    ""
    "bsr{l}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_0f" "1")])
  
  (define_expand "clzdi2"
    [(parallel
--- 14671,14714 ----
     (clobber (reg:CC FLAGS_REG))]
    ""
    "bsr{l}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_0f" "1")
!    (set_attr "mode" "SI")])
! 
! (define_insn "popcountsi2"
!   [(set (match_operand:SI 0 "register_operand" "=r")
! 	(popcount:SI (match_operand:SI 1 "nonimmediate_operand" "")))
!    (clobber (reg:CC FLAGS_REG))]
!   "TARGET_POPCNT"
!   "popcnt{l}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_rep" "1")
!    (set_attr "type" "bitmanip")
!    (set_attr "mode" "SI")])
! 
! (define_insn "*popcountsi2_cmp"
!   [(set (reg FLAGS_REG)
! 	(compare
! 	  (popcount:SI (match_operand:SI 1 "nonimmediate_operand" "rm"))
! 	  (const_int 0)))
!    (set (match_operand:SI 0 "register_operand" "=r")
! 	(popcount:SI (match_dup 1)))]
!   "TARGET_POPCNT && ix86_match_ccmode (insn, CCZmode)"
!   "popcnt{l}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_rep" "1")
!    (set_attr "type" "bitmanip")
!    (set_attr "mode" "SI")])
! 
! (define_insn "*popcountsi2_cmp_zext"
!   [(set (reg FLAGS_REG)
!         (compare
!           (popcount:SI (match_operand:SI 1 "nonimmediate_operand" "rm"))
!           (const_int 0)))
!    (set (match_operand:DI 0 "register_operand" "=r")
!         (zero_extend:DI(popcount:SI (match_dup 1))))]
!   "TARGET_64BIT && TARGET_POPCNT && ix86_match_ccmode (insn, CCZmode)"
!   "popcnt{l}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_rep" "1")
!    (set_attr "type" "bitmanip")
!    (set_attr "mode" "SI")])
  
  (define_expand "clzdi2"
    [(parallel
***************
*** 14572,14578 ****
       [(set (match_dup 0) (xor:DI (match_dup 0) (const_int 63)))
        (clobber (reg:CC FLAGS_REG))])]
    "TARGET_64BIT"
!   "")
  
  (define_insn "*bsr_rex64"
    [(set (match_operand:DI 0 "register_operand" "=r")
--- 14720,14742 ----
       [(set (match_dup 0) (xor:DI (match_dup 0) (const_int 63)))
        (clobber (reg:CC FLAGS_REG))])]
    "TARGET_64BIT"
! {
!   if (TARGET_ABM)
!     {
!       emit_insn (gen_clzdi2_abm (operands[0], operands[1]));
!       DONE;
!     }
! })
! 
! (define_insn "clzdi2_abm"
!   [(set (match_operand:DI 0 "register_operand" "=r")
! 	(clz:DI (match_operand:DI 1 "nonimmediate_operand" "")))
!    (clobber (reg:CC FLAGS_REG))]
!   "TARGET_64BIT && TARGET_ABM"
!   "lzcnt{q}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_rep" "1")
!    (set_attr "type" "bitmanip")
!    (set_attr "mode" "DI")])
  
  (define_insn "*bsr_rex64"
    [(set (match_operand:DI 0 "register_operand" "=r")
***************
*** 14581,14587 ****
     (clobber (reg:CC FLAGS_REG))]
    "TARGET_64BIT"
    "bsr{q}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_0f" "1")])
  
  ;; Thread-local storage patterns for ELF.
  ;;
--- 14745,14836 ----
     (clobber (reg:CC FLAGS_REG))]
    "TARGET_64BIT"
    "bsr{q}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_0f" "1")
!    (set_attr "mode" "DI")])
! 
! (define_insn "popcountdi2"
!   [(set (match_operand:DI 0 "register_operand" "=r")
! 	(popcount:DI (match_operand:DI 1 "nonimmediate_operand" "")))
!    (clobber (reg:CC FLAGS_REG))]
!   "TARGET_64BIT && TARGET_POPCNT"
!   "popcnt{q}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_rep" "1")
!    (set_attr "type" "bitmanip")
!    (set_attr "mode" "DI")])
! 
! (define_insn "*popcountdi2_cmp"
!   [(set (reg FLAGS_REG)
! 	(compare
! 	  (popcount:DI (match_operand:DI 1 "nonimmediate_operand" "rm"))
! 	  (const_int 0)))
!    (set (match_operand:DI 0 "register_operand" "=r")
! 	(popcount:DI (match_dup 1)))]
!   "TARGET_64BIT && TARGET_POPCNT && ix86_match_ccmode (insn, CCZmode)"
!   "popcnt{q}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_rep" "1")
!    (set_attr "type" "bitmanip")
!    (set_attr "mode" "DI")])
! 
! (define_expand "clzhi2"
!   [(parallel
!      [(set (match_operand:HI 0 "register_operand" "")
! 	   (minus:HI (const_int 15)
! 		     (clz:HI (match_operand:HI 1 "nonimmediate_operand" ""))))
!       (clobber (reg:CC FLAGS_REG))])
!    (parallel
!      [(set (match_dup 0) (xor:HI (match_dup 0) (const_int 15)))
!       (clobber (reg:CC FLAGS_REG))])]
!   ""
! {
!   if (TARGET_ABM)
!     {
!       emit_insn (gen_clzhi2_abm (operands[0], operands[1]));
!       DONE;
!     }
! })
! 
! (define_insn "clzhi2_abm"
!   [(set (match_operand:HI 0 "register_operand" "=r")
! 	(clz:HI (match_operand:HI 1 "nonimmediate_operand" "")))
!    (clobber (reg:CC FLAGS_REG))]
!   "TARGET_ABM"
!   "lzcnt{w}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_rep" "1")
!    (set_attr "type" "bitmanip")
!    (set_attr "mode" "HI")])
! 
! (define_insn "*bsrhi"
!   [(set (match_operand:HI 0 "register_operand" "=r")
! 	(minus:HI (const_int 15)
! 		  (clz:HI (match_operand:HI 1 "nonimmediate_operand" "rm"))))
!    (clobber (reg:CC FLAGS_REG))]
!   ""
!   "bsr{w}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_0f" "1")
!    (set_attr "mode" "HI")])
! 
! (define_insn "popcounthi2"
!   [(set (match_operand:HI 0 "register_operand" "=r")
! 	(popcount:HI (match_operand:HI 1 "nonimmediate_operand" "")))
!    (clobber (reg:CC FLAGS_REG))]
!   "TARGET_POPCNT"
!   "popcnt{w}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_rep" "1")
!    (set_attr "type" "bitmanip")
!    (set_attr "mode" "HI")])
! 
! (define_insn "*popcounthi2_cmp"
!   [(set (reg FLAGS_REG)
!         (compare
!           (popcount:HI (match_operand:HI 1 "nonimmediate_operand" "rm"))
!           (const_int 0)))
!    (set (match_operand:HI 0 "register_operand" "=r")
!         (popcount:HI (match_dup 1)))]
!   "TARGET_POPCNT && ix86_match_ccmode (insn, CCZmode)"
!   "popcnt{w}\t{%1, %0|%0, %1}"
!   [(set_attr "prefix_rep" "1")
!    (set_attr "type" "bitmanip")
!    (set_attr "mode" "HI")])
  
  ;; Thread-local storage patterns for ELF.
  ;;
***************
*** 15487,15493 ****
     sqrtss\t{%1, %0|%0, %1}"
    [(set_attr "type" "fpspc,sse")
     (set_attr "mode" "SF,SF")
!    (set_attr "athlon_decode" "direct,*")])
  
  (define_insn "*sqrtsf2_sse"
    [(set (match_operand:SF 0 "register_operand" "=x")
--- 15736,15743 ----
     sqrtss\t{%1, %0|%0, %1}"
    [(set_attr "type" "fpspc,sse")
     (set_attr "mode" "SF,SF")
!    (set_attr "athlon_decode" "direct,*")
!    (set_attr "amdfam10_decode" "direct,*")])
  
  (define_insn "*sqrtsf2_sse"
    [(set (match_operand:SF 0 "register_operand" "=x")
***************
*** 15496,15502 ****
    "sqrtss\t{%1, %0|%0, %1}"
    [(set_attr "type" "sse")
     (set_attr "mode" "SF")
!    (set_attr "athlon_decode" "*")])
  
  (define_insn "*sqrtsf2_i387"
    [(set (match_operand:SF 0 "register_operand" "=f")
--- 15746,15753 ----
    "sqrtss\t{%1, %0|%0, %1}"
    [(set_attr "type" "sse")
     (set_attr "mode" "SF")
!    (set_attr "athlon_decode" "*")
!    (set_attr "amdfam10_decode" "*")])
  
  (define_insn "*sqrtsf2_i387"
    [(set (match_operand:SF 0 "register_operand" "=f")
***************
*** 15505,15511 ****
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "SF")
!    (set_attr "athlon_decode" "direct")])
  
  (define_expand "sqrtdf2"
    [(set (match_operand:DF 0 "register_operand" "")
--- 15756,15763 ----
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "SF")
!    (set_attr "athlon_decode" "direct")
!    (set_attr "amdfam10_decode" "direct")])
  
  (define_expand "sqrtdf2"
    [(set (match_operand:DF 0 "register_operand" "")
***************
*** 15525,15531 ****
     sqrtsd\t{%1, %0|%0, %1}"
    [(set_attr "type" "fpspc,sse")
     (set_attr "mode" "DF,DF")
!    (set_attr "athlon_decode" "direct,*")])
  
  (define_insn "*sqrtdf2_sse"
    [(set (match_operand:DF 0 "register_operand" "=Y")
--- 15777,15784 ----
     sqrtsd\t{%1, %0|%0, %1}"
    [(set_attr "type" "fpspc,sse")
     (set_attr "mode" "DF,DF")
!    (set_attr "athlon_decode" "direct,*")
!    (set_attr "amdfam10_decode" "direct,*")])
  
  (define_insn "*sqrtdf2_sse"
    [(set (match_operand:DF 0 "register_operand" "=Y")
***************
*** 15534,15540 ****
    "sqrtsd\t{%1, %0|%0, %1}"
    [(set_attr "type" "sse")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "*")])
  
  (define_insn "*sqrtdf2_i387"
    [(set (match_operand:DF 0 "register_operand" "=f")
--- 15787,15794 ----
    "sqrtsd\t{%1, %0|%0, %1}"
    [(set_attr "type" "sse")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "*")
!    (set_attr "amdfam10_decode" "*")])
  
  (define_insn "*sqrtdf2_i387"
    [(set (match_operand:DF 0 "register_operand" "=f")
***************
*** 15543,15549 ****
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "direct")])
  
  (define_insn "*sqrtextendsfdf2_i387"
    [(set (match_operand:DF 0 "register_operand" "=f")
--- 15797,15804 ----
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "direct")
!    (set_attr "amdfam10_decode" "direct")])
  
  (define_insn "*sqrtextendsfdf2_i387"
    [(set (match_operand:DF 0 "register_operand" "=f")
***************
*** 15554,15560 ****
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "direct")])
  
  (define_insn "sqrtxf2"
    [(set (match_operand:XF 0 "register_operand" "=f")
--- 15809,15816 ----
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "direct")
!    (set_attr "amdfam10_decode" "direct")])
  
  (define_insn "sqrtxf2"
    [(set (match_operand:XF 0 "register_operand" "=f")
***************
*** 15563,15569 ****
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "XF")
!    (set_attr "athlon_decode" "direct")])
  
  (define_insn "*sqrtextendsfxf2_i387"
    [(set (match_operand:XF 0 "register_operand" "=f")
--- 15819,15826 ----
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "XF")
!    (set_attr "athlon_decode" "direct")
!    (set_attr "amdfam10_decode" "direct")])
  
  (define_insn "*sqrtextendsfxf2_i387"
    [(set (match_operand:XF 0 "register_operand" "=f")
***************
*** 15573,15579 ****
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "XF")
!    (set_attr "athlon_decode" "direct")])
  
  (define_insn "*sqrtextenddfxf2_i387"
    [(set (match_operand:XF 0 "register_operand" "=f")
--- 15830,15837 ----
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "XF")
!    (set_attr "athlon_decode" "direct")   
!    (set_attr "amdfam10_decode" "direct")])
  
  (define_insn "*sqrtextenddfxf2_i387"
    [(set (match_operand:XF 0 "register_operand" "=f")
***************
*** 15583,15589 ****
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "XF")
!    (set_attr "athlon_decode" "direct")])
  
  (define_insn "fpremxf4"
    [(set (match_operand:XF 0 "register_operand" "=f")
--- 15841,15848 ----
    "fsqrt"
    [(set_attr "type" "fpspc")
     (set_attr "mode" "XF")
!    (set_attr "athlon_decode" "direct")
!    (set_attr "amdfam10_decode" "direct")])
  
  (define_insn "fpremxf4"
    [(set (match_operand:XF 0 "register_operand" "=f")
***************
*** 20402,20408 ****
  		   (mult:DI (match_operand:DI 1 "memory_operand" "")
  			    (match_operand:DI 2 "immediate_operand" "")))
  	      (clobber (reg:CC FLAGS_REG))])]
!   "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size
     && !satisfies_constraint_K (operands[2])"
    [(set (match_dup 3) (match_dup 1))
     (parallel [(set (match_dup 0) (mult:DI (match_dup 3) (match_dup 2)))
--- 20661,20667 ----
  		   (mult:DI (match_operand:DI 1 "memory_operand" "")
  			    (match_operand:DI 2 "immediate_operand" "")))
  	      (clobber (reg:CC FLAGS_REG))])]
!   "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size
     && !satisfies_constraint_K (operands[2])"
    [(set (match_dup 3) (match_dup 1))
     (parallel [(set (match_dup 0) (mult:DI (match_dup 3) (match_dup 2)))
***************
*** 20415,20421 ****
  		   (mult:SI (match_operand:SI 1 "memory_operand" "")
  			    (match_operand:SI 2 "immediate_operand" "")))
  	      (clobber (reg:CC FLAGS_REG))])]
!   "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size
     && !satisfies_constraint_K (operands[2])"
    [(set (match_dup 3) (match_dup 1))
     (parallel [(set (match_dup 0) (mult:SI (match_dup 3) (match_dup 2)))
--- 20674,20680 ----
  		   (mult:SI (match_operand:SI 1 "memory_operand" "")
  			    (match_operand:SI 2 "immediate_operand" "")))
  	      (clobber (reg:CC FLAGS_REG))])]
!   "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size
     && !satisfies_constraint_K (operands[2])"
    [(set (match_dup 3) (match_dup 1))
     (parallel [(set (match_dup 0) (mult:SI (match_dup 3) (match_dup 2)))
***************
*** 20429,20435 ****
  		     (mult:SI (match_operand:SI 1 "memory_operand" "")
  			      (match_operand:SI 2 "immediate_operand" ""))))
  	      (clobber (reg:CC FLAGS_REG))])]
!   "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size
     && !satisfies_constraint_K (operands[2])"
    [(set (match_dup 3) (match_dup 1))
     (parallel [(set (match_dup 0) (zero_extend:DI (mult:SI (match_dup 3) (match_dup 2))))
--- 20688,20694 ----
  		     (mult:SI (match_operand:SI 1 "memory_operand" "")
  			      (match_operand:SI 2 "immediate_operand" ""))))
  	      (clobber (reg:CC FLAGS_REG))])]
!   "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size
     && !satisfies_constraint_K (operands[2])"
    [(set (match_dup 3) (match_dup 1))
     (parallel [(set (match_dup 0) (zero_extend:DI (mult:SI (match_dup 3) (match_dup 2))))
***************
*** 20446,20452 ****
  			    (match_operand:DI 2 "const_int_operand" "")))
  	      (clobber (reg:CC FLAGS_REG))])
     (match_scratch:DI 3 "r")]
!   "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size
     && satisfies_constraint_K (operands[2])"
    [(set (match_dup 3) (match_dup 2))
     (parallel [(set (match_dup 0) (mult:DI (match_dup 0) (match_dup 3)))
--- 20705,20711 ----
  			    (match_operand:DI 2 "const_int_operand" "")))
  	      (clobber (reg:CC FLAGS_REG))])
     (match_scratch:DI 3 "r")]
!   "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size
     && satisfies_constraint_K (operands[2])"
    [(set (match_dup 3) (match_dup 2))
     (parallel [(set (match_dup 0) (mult:DI (match_dup 0) (match_dup 3)))
***************
*** 20462,20468 ****
  			    (match_operand:SI 2 "const_int_operand" "")))
  	      (clobber (reg:CC FLAGS_REG))])
     (match_scratch:SI 3 "r")]
!   "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size
     && satisfies_constraint_K (operands[2])"
    [(set (match_dup 3) (match_dup 2))
     (parallel [(set (match_dup 0) (mult:SI (match_dup 0) (match_dup 3)))
--- 20721,20727 ----
  			    (match_operand:SI 2 "const_int_operand" "")))
  	      (clobber (reg:CC FLAGS_REG))])
     (match_scratch:SI 3 "r")]
!   "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size
     && satisfies_constraint_K (operands[2])"
    [(set (match_dup 3) (match_dup 2))
     (parallel [(set (match_dup 0) (mult:SI (match_dup 0) (match_dup 3)))
***************
*** 20478,20484 ****
  			    (match_operand:HI 2 "immediate_operand" "")))
  	      (clobber (reg:CC FLAGS_REG))])
     (match_scratch:HI 3 "r")]
!   "(TARGET_K8 || TARGET_GENERIC64) && !optimize_size"
    [(set (match_dup 3) (match_dup 2))
     (parallel [(set (match_dup 0) (mult:HI (match_dup 0) (match_dup 3)))
  	      (clobber (reg:CC FLAGS_REG))])]
--- 20737,20743 ----
  			    (match_operand:HI 2 "immediate_operand" "")))
  	      (clobber (reg:CC FLAGS_REG))])
     (match_scratch:HI 3 "r")]
!   "(TARGET_K8 || TARGET_GENERIC64 || TARGET_AMDFAM10) && !optimize_size"
    [(set (match_dup 3) (match_dup 2))
     (parallel [(set (match_dup 0) (mult:HI (match_dup 0) (match_dup 3)))
  	      (clobber (reg:CC FLAGS_REG))])]
*** gcc/config/i386/athlon.md.~1~	2007-11-08 14:27:21.332365000 -0500
--- gcc/config/i386/athlon.md	2007-11-09 12:10:58.866836000 -0500
***************
*** 29,34 ****
--- 29,36 ----
  	   (const_string "vector")]
  	(const_string "direct")))
  
+ (define_attr "amdfam10_decode" "direct,vector,double"
+   (const_string "direct"))
  ;;
  ;;           decode0 decode1 decode2
  ;;                 \    |   /
***************
*** 131,148 ****
  
  ;; Jump instructions are executed in the branch unit completely transparent to us
  (define_insn_reservation "athlon_branch" 0
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "ibr"))
  			 "athlon-direct,athlon-ieu")
  (define_insn_reservation "athlon_call" 0
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "call,callv"))
  			 "athlon-vector,athlon-ieu")
  
  ;; Latency of push operation is 3 cycles, but ESP value is available
  ;; earlier
  (define_insn_reservation "athlon_push" 2
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "push"))
  			 "athlon-direct,athlon-agu,athlon-store")
  (define_insn_reservation "athlon_pop" 4
--- 133,154 ----
  
  ;; Jump instructions are executed in the branch unit completely transparent to us
  (define_insn_reservation "athlon_branch" 0
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (eq_attr "type" "ibr"))
  			 "athlon-direct,athlon-ieu")
  (define_insn_reservation "athlon_call" 0
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "call,callv"))
  			 "athlon-vector,athlon-ieu")
+ (define_insn_reservation "athlon_call_amdfam10" 0
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (eq_attr "type" "call,callv"))
+ 			 "athlon-double,athlon-ieu")
  
  ;; Latency of push operation is 3 cycles, but ESP value is available
  ;; earlier
  (define_insn_reservation "athlon_push" 2
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (eq_attr "type" "push"))
  			 "athlon-direct,athlon-agu,athlon-store")
  (define_insn_reservation "athlon_pop" 4
***************
*** 153,164 ****
  			 (and (eq_attr "cpu" "k8,generic64")
  			      (eq_attr "type" "pop"))
  			 "athlon-double,(athlon-ieu+athlon-load)")
  (define_insn_reservation "athlon_leave" 3
  			 (and (eq_attr "cpu" "athlon")
  			      (eq_attr "type" "leave"))
  			 "athlon-vector,(athlon-ieu+athlon-load)")
  (define_insn_reservation "athlon_leave_k8" 3
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (eq_attr "type" "leave"))
  			 "athlon-double,(athlon-ieu+athlon-load)")
  
--- 159,174 ----
  			 (and (eq_attr "cpu" "k8,generic64")
  			      (eq_attr "type" "pop"))
  			 "athlon-double,(athlon-ieu+athlon-load)")
+ (define_insn_reservation "athlon_pop_amdfam10" 3
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (eq_attr "type" "pop"))
+ 			 "athlon-direct,(athlon-ieu+athlon-load)")
  (define_insn_reservation "athlon_leave" 3
  			 (and (eq_attr "cpu" "athlon")
  			      (eq_attr "type" "leave"))
  			 "athlon-vector,(athlon-ieu+athlon-load)")
  (define_insn_reservation "athlon_leave_k8" 3
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (eq_attr "type" "leave"))
  			 "athlon-double,(athlon-ieu+athlon-load)")
  
***************
*** 167,172 ****
--- 177,187 ----
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "lea"))
  			 "athlon-direct,athlon-agu,nothing")
+ ;; Lea executes in AGU unit with 1 cycle latency on AMDFAM10
+ (define_insn_reservation "athlon_lea_amdfam10" 1
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (eq_attr "type" "lea"))
+ 			 "athlon-direct,athlon-agu,nothing")
  
  ;; Mul executes in special multiplier unit attached to IEU0
  (define_insn_reservation "athlon_imul" 5
***************
*** 176,204 ****
  			 "athlon-vector,athlon-ieu0,athlon-mult,nothing,nothing,athlon-ieu0")
  ;; ??? Widening multiply is vector or double.
  (define_insn_reservation "athlon_imul_k8_DI" 4
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "imul")
  				   (and (eq_attr "mode" "DI")
  					(eq_attr "memory" "none,unknown"))))
  			 "athlon-direct0,athlon-ieu0,athlon-mult,nothing,athlon-ieu0")
  (define_insn_reservation "athlon_imul_k8" 3
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "imul")
  				   (eq_attr "memory" "none,unknown")))
  			 "athlon-direct0,athlon-ieu0,athlon-mult,athlon-ieu0")
  (define_insn_reservation "athlon_imul_mem" 8
  			 (and (eq_attr "cpu" "athlon")
  			      (and (eq_attr "type" "imul")
  				   (eq_attr "memory" "load,both")))
  			 "athlon-vector,athlon-load,athlon-ieu,athlon-mult,nothing,nothing,athlon-ieu")
  (define_insn_reservation "athlon_imul_mem_k8_DI" 7
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "imul")
  				   (and (eq_attr "mode" "DI")
  					(eq_attr "memory" "load,both"))))
  			 "athlon-vector,athlon-load,athlon-ieu,athlon-mult,nothing,athlon-ieu")
  (define_insn_reservation "athlon_imul_mem_k8" 6
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "imul")
  				   (eq_attr "memory" "load,both")))
  			 "athlon-vector,athlon-load,athlon-ieu,athlon-mult,athlon-ieu")
--- 191,225 ----
  			 "athlon-vector,athlon-ieu0,athlon-mult,nothing,nothing,athlon-ieu0")
  ;; ??? Widening multiply is vector or double.
  (define_insn_reservation "athlon_imul_k8_DI" 4
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "imul")
  				   (and (eq_attr "mode" "DI")
  					(eq_attr "memory" "none,unknown"))))
  			 "athlon-direct0,athlon-ieu0,athlon-mult,nothing,athlon-ieu0")
  (define_insn_reservation "athlon_imul_k8" 3
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "imul")
  				   (eq_attr "memory" "none,unknown")))
  			 "athlon-direct0,athlon-ieu0,athlon-mult,athlon-ieu0")
+ (define_insn_reservation "athlon_imul_amdfam10_HI" 4
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "imul")
+ 				   (and (eq_attr "mode" "HI")
+ 					(eq_attr "memory" "none,unknown"))))
+ 			 "athlon-vector,athlon-ieu0,athlon-mult,nothing,athlon-ieu0")			 
  (define_insn_reservation "athlon_imul_mem" 8
  			 (and (eq_attr "cpu" "athlon")
  			      (and (eq_attr "type" "imul")
  				   (eq_attr "memory" "load,both")))
  			 "athlon-vector,athlon-load,athlon-ieu,athlon-mult,nothing,nothing,athlon-ieu")
  (define_insn_reservation "athlon_imul_mem_k8_DI" 7
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "imul")
  				   (and (eq_attr "mode" "DI")
  					(eq_attr "memory" "load,both"))))
  			 "athlon-vector,athlon-load,athlon-ieu,athlon-mult,nothing,athlon-ieu")
  (define_insn_reservation "athlon_imul_mem_k8" 6
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "imul")
  				   (eq_attr "memory" "load,both")))
  			 "athlon-vector,athlon-load,athlon-ieu,athlon-mult,athlon-ieu")
***************
*** 209,229 ****
  ;; other instructions.
  ;; ??? Experiments show that the idiv can overlap with roughly 6 cycles
  ;; of the other code
  
  (define_insn_reservation "athlon_idiv" 6
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "idiv")
  				   (eq_attr "memory" "none,unknown")))
  			 "athlon-vector,(athlon-ieu0*6+(athlon-fpsched,athlon-fvector))")
  (define_insn_reservation "athlon_idiv_mem" 9
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "idiv")
  				   (eq_attr "memory" "load,both")))
  			 "athlon-vector,((athlon-load,athlon-ieu0*6)+(athlon-fpsched,athlon-fvector))")
  ;; The parallelism of string instructions is not documented.  Model it same way
  ;; as idiv to create smaller automata.  This probably does not matter much.
  (define_insn_reservation "athlon_str" 6
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "str")
  				   (eq_attr "memory" "load,both,store")))
  			 "athlon-vector,athlon-load,athlon-ieu0*6")
--- 230,252 ----
  ;; other instructions.
  ;; ??? Experiments show that the idiv can overlap with roughly 6 cycles
  ;; of the other code
+ ;; Using the same heuristics for amdfam10 as K8 with idiv
  
  (define_insn_reservation "athlon_idiv" 6
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (and (eq_attr "type" "idiv")
  				   (eq_attr "memory" "none,unknown")))
  			 "athlon-vector,(athlon-ieu0*6+(athlon-fpsched,athlon-fvector))")
  (define_insn_reservation "athlon_idiv_mem" 9
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (and (eq_attr "type" "idiv")
  				   (eq_attr "memory" "load,both")))
  			 "athlon-vector,((athlon-load,athlon-ieu0*6)+(athlon-fpsched,athlon-fvector))")
  ;; The parallelism of string instructions is not documented.  Model it same way
  ;; as idiv to create smaller automata.  This probably does not matter much.
+ ;; Using the same heuristics for amdfam10 as K8 with idiv
  (define_insn_reservation "athlon_str" 6
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (and (eq_attr "type" "str")
  				   (eq_attr "memory" "load,both,store")))
  			 "athlon-vector,athlon-load,athlon-ieu0*6")
***************
*** 234,267 ****
  				   (and (eq_attr "unit" "integer,unknown")
  					(eq_attr "memory" "none,unknown"))))
  			 "athlon-direct,athlon-ieu")
  (define_insn_reservation "athlon_ivector" 2
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "vector")
  				   (and (eq_attr "unit" "integer,unknown")
  					(eq_attr "memory" "none,unknown"))))
  			 "athlon-vector,athlon-ieu,athlon-ieu")
  (define_insn_reservation "athlon_idirect_loadmov" 3
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "imov")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-load")
  (define_insn_reservation "athlon_idirect_load" 4
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "direct")
  				   (and (eq_attr "unit" "integer,unknown")
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-load,athlon-ieu")
  (define_insn_reservation "athlon_ivector_load" 6
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "vector")
  				   (and (eq_attr "unit" "integer,unknown")
  					(eq_attr "memory" "load"))))
  			 "athlon-vector,athlon-load,athlon-ieu,athlon-ieu")
  (define_insn_reservation "athlon_idirect_movstore" 1
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "imov")
  				   (eq_attr "memory" "store")))
  			 "athlon-direct,athlon-agu,athlon-store")
  (define_insn_reservation "athlon_idirect_both" 4
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "direct")
--- 257,318 ----
  				   (and (eq_attr "unit" "integer,unknown")
  					(eq_attr "memory" "none,unknown"))))
  			 "athlon-direct,athlon-ieu")
+ (define_insn_reservation "athlon_idirect_amdfam10" 1
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "amdfam10_decode" "direct")
+ 				   (and (eq_attr "unit" "integer,unknown")
+ 					(eq_attr "memory" "none,unknown"))))
+ 			 "athlon-direct,athlon-ieu")
  (define_insn_reservation "athlon_ivector" 2
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "vector")
  				   (and (eq_attr "unit" "integer,unknown")
  					(eq_attr "memory" "none,unknown"))))
  			 "athlon-vector,athlon-ieu,athlon-ieu")
+ (define_insn_reservation "athlon_ivector_amdfam10" 2
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "amdfam10_decode" "vector")
+ 				   (and (eq_attr "unit" "integer,unknown")
+ 					(eq_attr "memory" "none,unknown"))))
+ 			 "athlon-vector,athlon-ieu,athlon-ieu")
+ 
  (define_insn_reservation "athlon_idirect_loadmov" 3
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (and (eq_attr "type" "imov")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-load")
+ 
  (define_insn_reservation "athlon_idirect_load" 4
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "direct")
  				   (and (eq_attr "unit" "integer,unknown")
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-load,athlon-ieu")
+ (define_insn_reservation "athlon_idirect_load_amdfam10" 4
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "amdfam10_decode" "direct")
+ 				   (and (eq_attr "unit" "integer,unknown")
+ 					(eq_attr "memory" "load"))))
+ 			 "athlon-direct,athlon-load,athlon-ieu")
  (define_insn_reservation "athlon_ivector_load" 6
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "vector")
  				   (and (eq_attr "unit" "integer,unknown")
  					(eq_attr "memory" "load"))))
  			 "athlon-vector,athlon-load,athlon-ieu,athlon-ieu")
+ (define_insn_reservation "athlon_ivector_load_amdfam10" 6
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "amdfam10_decode" "vector")
+ 				   (and (eq_attr "unit" "integer,unknown")
+ 					(eq_attr "memory" "load"))))
+ 			 "athlon-vector,athlon-load,athlon-ieu,athlon-ieu")
+ 
  (define_insn_reservation "athlon_idirect_movstore" 1
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (and (eq_attr "type" "imov")
  				   (eq_attr "memory" "store")))
  			 "athlon-direct,athlon-agu,athlon-store")
+ 
  (define_insn_reservation "athlon_idirect_both" 4
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "direct")
***************
*** 270,275 ****
--- 321,335 ----
  			 "athlon-direct,athlon-load,
  			  athlon-ieu,athlon-store,
  			  athlon-store")
+ (define_insn_reservation "athlon_idirect_both_amdfam10" 4
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "amdfam10_decode" "direct")
+ 				   (and (eq_attr "unit" "integer,unknown")
+ 					(eq_attr "memory" "both"))))
+ 			 "athlon-direct,athlon-load,
+ 			  athlon-ieu,athlon-store,
+ 			  athlon-store")			  
+ 
  (define_insn_reservation "athlon_ivector_both" 6
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "vector")
***************
*** 279,284 ****
--- 339,354 ----
  			  athlon-ieu,
  			  athlon-ieu,
  			  athlon-store")
+ (define_insn_reservation "athlon_ivector_both_amdfam10" 6
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "amdfam10_decode" "vector")
+ 				   (and (eq_attr "unit" "integer,unknown")
+ 					(eq_attr "memory" "both"))))
+ 			 "athlon-vector,athlon-load,
+ 			  athlon-ieu,
+ 			  athlon-ieu,
+ 			  athlon-store")
+ 
  (define_insn_reservation "athlon_idirect_store" 1
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "direct")
***************
*** 286,291 ****
--- 356,369 ----
  					(eq_attr "memory" "store"))))
  			 "athlon-direct,(athlon-ieu+athlon-agu),
  			  athlon-store")
+ (define_insn_reservation "athlon_idirect_store_amdfam10" 1
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "amdfam10_decode" "direct")
+ 				   (and (eq_attr "unit" "integer,unknown")
+ 					(eq_attr "memory" "store"))))
+ 			 "athlon-direct,(athlon-ieu+athlon-agu),
+ 			  athlon-store")
+ 
  (define_insn_reservation "athlon_ivector_store" 2
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "vector")
***************
*** 293,298 ****
--- 371,383 ----
  					(eq_attr "memory" "store"))))
  			 "athlon-vector,(athlon-ieu+athlon-agu),athlon-ieu,
  			  athlon-store")
+ (define_insn_reservation "athlon_ivector_store_amdfam10" 2
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "amdfam10_decode" "vector")
+ 				   (and (eq_attr "unit" "integer,unknown")
+ 					(eq_attr "memory" "store"))))
+ 			 "athlon-vector,(athlon-ieu+athlon-agu),athlon-ieu,
+ 			  athlon-store")
  
  ;; Athlon floatin point unit
  (define_insn_reservation "athlon_fldxf" 12
***************
*** 302,308 ****
  					(eq_attr "mode" "XF"))))
  			 "athlon-vector,athlon-fpload2,athlon-fvector*9")
  (define_insn_reservation "athlon_fldxf_k8" 13
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "fmov")
  				   (and (eq_attr "memory" "load")
  					(eq_attr "mode" "XF"))))
--- 387,393 ----
  					(eq_attr "mode" "XF"))))
  			 "athlon-vector,athlon-fpload2,athlon-fvector*9")
  (define_insn_reservation "athlon_fldxf_k8" 13
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "fmov")
  				   (and (eq_attr "memory" "load")
  					(eq_attr "mode" "XF"))))
***************
*** 314,320 ****
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fpload,athlon-fany")
  (define_insn_reservation "athlon_fld_k8" 2
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "fmov")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fploadk8,athlon-fstore")
--- 399,405 ----
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fpload,athlon-fany")
  (define_insn_reservation "athlon_fld_k8" 2
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "fmov")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fploadk8,athlon-fstore")
***************
*** 326,332 ****
  					(eq_attr "mode" "XF"))))
  			 "athlon-vector,(athlon-fpsched+athlon-agu),(athlon-store2+(athlon-fvector*7))")
  (define_insn_reservation "athlon_fstxf_k8" 8
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "fmov")
  				   (and (eq_attr "memory" "store,both")
  					(eq_attr "mode" "XF"))))
--- 411,417 ----
  					(eq_attr "mode" "XF"))))
  			 "athlon-vector,(athlon-fpsched+athlon-agu),(athlon-store2+(athlon-fvector*7))")
  (define_insn_reservation "athlon_fstxf_k8" 8
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "fmov")
  				   (and (eq_attr "memory" "store,both")
  					(eq_attr "mode" "XF"))))
***************
*** 337,352 ****
  				   (eq_attr "memory" "store,both")))
  			 "athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
  (define_insn_reservation "athlon_fst_k8" 2
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "fmov")
  				   (eq_attr "memory" "store,both")))
  			 "athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
  (define_insn_reservation "athlon_fist" 4
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "fistp,fisttp"))
  			 "athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
  (define_insn_reservation "athlon_fmov" 2
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "fmov"))
  			 "athlon-direct,athlon-fpsched,athlon-faddmul")
  (define_insn_reservation "athlon_fadd_load" 4
--- 422,437 ----
  				   (eq_attr "memory" "store,both")))
  			 "athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
  (define_insn_reservation "athlon_fst_k8" 2
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "fmov")
  				   (eq_attr "memory" "store,both")))
  			 "athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
  (define_insn_reservation "athlon_fist" 4
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (eq_attr "type" "fistp,fisttp"))
  			 "athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
  (define_insn_reservation "athlon_fmov" 2
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (eq_attr "type" "fmov"))
  			 "athlon-direct,athlon-fpsched,athlon-faddmul")
  (define_insn_reservation "athlon_fadd_load" 4
***************
*** 355,366 ****
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fpload,athlon-fadd")
  (define_insn_reservation "athlon_fadd_load_k8" 6
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "fop")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_fadd" 4
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "fop"))
  			 "athlon-direct,athlon-fpsched,athlon-fadd")
  (define_insn_reservation "athlon_fmul_load" 4
--- 440,451 ----
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fpload,athlon-fadd")
  (define_insn_reservation "athlon_fadd_load_k8" 6
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "fop")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_fadd" 4
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (eq_attr "type" "fop"))
  			 "athlon-direct,athlon-fpsched,athlon-fadd")
  (define_insn_reservation "athlon_fmul_load" 4
***************
*** 369,384 ****
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fpload,athlon-fmul")
  (define_insn_reservation "athlon_fmul_load_k8" 6
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "fmul")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fploadk8,athlon-fmul")
  (define_insn_reservation "athlon_fmul" 4
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "fmul"))
  			 "athlon-direct,athlon-fpsched,athlon-fmul")
  (define_insn_reservation "athlon_fsgn" 2
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "fsgn"))
  			 "athlon-direct,athlon-fpsched,athlon-fmul")
  (define_insn_reservation "athlon_fdiv_load" 24
--- 454,469 ----
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fpload,athlon-fmul")
  (define_insn_reservation "athlon_fmul_load_k8" 6
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "fmul")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fploadk8,athlon-fmul")
  (define_insn_reservation "athlon_fmul" 4
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (eq_attr "type" "fmul"))
  			 "athlon-direct,athlon-fpsched,athlon-fmul")
  (define_insn_reservation "athlon_fsgn" 2
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (eq_attr "type" "fsgn"))
  			 "athlon-direct,athlon-fpsched,athlon-fmul")
  (define_insn_reservation "athlon_fdiv_load" 24
***************
*** 387,393 ****
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fpload,athlon-fmul")
  (define_insn_reservation "athlon_fdiv_load_k8" 13
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "fdiv")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fploadk8,athlon-fmul")
--- 472,478 ----
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fpload,athlon-fmul")
  (define_insn_reservation "athlon_fdiv_load_k8" 13
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "fdiv")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fploadk8,athlon-fmul")
***************
*** 396,411 ****
  			      (eq_attr "type" "fdiv"))
  			 "athlon-direct,athlon-fpsched,athlon-fmul")
  (define_insn_reservation "athlon_fdiv_k8" 11
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (eq_attr "type" "fdiv"))
  			 "athlon-direct,athlon-fpsched,athlon-fmul")
  (define_insn_reservation "athlon_fpspc_load" 103
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "fpspc")
  				   (eq_attr "memory" "load")))
  			 "athlon-vector,athlon-fpload,athlon-fvector")
  (define_insn_reservation "athlon_fpspc" 100
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "fpspc"))
  			 "athlon-vector,athlon-fpsched,athlon-fvector")
  (define_insn_reservation "athlon_fcmov_load" 7
--- 481,496 ----
  			      (eq_attr "type" "fdiv"))
  			 "athlon-direct,athlon-fpsched,athlon-fmul")
  (define_insn_reservation "athlon_fdiv_k8" 11
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (eq_attr "type" "fdiv"))
  			 "athlon-direct,athlon-fpsched,athlon-fmul")
  (define_insn_reservation "athlon_fpspc_load" 103
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (and (eq_attr "type" "fpspc")
  				   (eq_attr "memory" "load")))
  			 "athlon-vector,athlon-fpload,athlon-fvector")
  (define_insn_reservation "athlon_fpspc" 100
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (eq_attr "type" "fpspc"))
  			 "athlon-vector,athlon-fpsched,athlon-fvector")
  (define_insn_reservation "athlon_fcmov_load" 7
***************
*** 418,429 ****
  			      (eq_attr "type" "fcmov"))
  			 "athlon-vector,athlon-fpsched,athlon-fvector")
  (define_insn_reservation "athlon_fcmov_load_k8" 17
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "fcmov")
  				   (eq_attr "memory" "load")))
  			 "athlon-vector,athlon-fploadk8,athlon-fvector")
  (define_insn_reservation "athlon_fcmov_k8" 15
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (eq_attr "type" "fcmov"))
  			 "athlon-vector,athlon-fpsched,athlon-fvector")
  ;; fcomi is vector decoded by uses only one pipe.
--- 503,514 ----
  			      (eq_attr "type" "fcmov"))
  			 "athlon-vector,athlon-fpsched,athlon-fvector")
  (define_insn_reservation "athlon_fcmov_load_k8" 17
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "fcmov")
  				   (eq_attr "memory" "load")))
  			 "athlon-vector,athlon-fploadk8,athlon-fvector")
  (define_insn_reservation "athlon_fcmov_k8" 15
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (eq_attr "type" "fcmov"))
  			 "athlon-vector,athlon-fpsched,athlon-fvector")
  ;; fcomi is vector decoded by uses only one pipe.
***************
*** 434,446 ****
  				        (eq_attr "memory" "load"))))
  			 "athlon-vector,athlon-fpload,athlon-fadd")
  (define_insn_reservation "athlon_fcomi_load_k8" 5
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "fcmp")
  				   (and (eq_attr "athlon_decode" "vector")
  				        (eq_attr "memory" "load"))))
  			 "athlon-vector,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_fcomi" 3
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "athlon_decode" "vector")
  				   (eq_attr "type" "fcmp")))
  			 "athlon-vector,athlon-fpsched,athlon-fadd")
--- 519,531 ----
  				        (eq_attr "memory" "load"))))
  			 "athlon-vector,athlon-fpload,athlon-fadd")
  (define_insn_reservation "athlon_fcomi_load_k8" 5
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "fcmp")
  				   (and (eq_attr "athlon_decode" "vector")
  				        (eq_attr "memory" "load"))))
  			 "athlon-vector,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_fcomi" 3
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (and (eq_attr "athlon_decode" "vector")
  				   (eq_attr "type" "fcmp")))
  			 "athlon-vector,athlon-fpsched,athlon-fadd")
***************
*** 450,467 ****
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fpload,athlon-fadd")
  (define_insn_reservation "athlon_fcom_load_k8" 4
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "fcmp")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_fcom" 2
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "fcmp"))
  			 "athlon-direct,athlon-fpsched,athlon-fadd")
  ;; Never seen by the scheduler because we still don't do post reg-stack
  ;; scheduling.
  ;(define_insn_reservation "athlon_fxch" 2
! ;			 (and (eq_attr "cpu" "athlon,k8,generic64")
  ;			      (eq_attr "type" "fxch"))
  ;			 "athlon-direct,athlon-fpsched,athlon-fany")
  
--- 535,552 ----
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fpload,athlon-fadd")
  (define_insn_reservation "athlon_fcom_load_k8" 4
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "fcmp")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_fcom" 2
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (eq_attr "type" "fcmp"))
  			 "athlon-direct,athlon-fpsched,athlon-fadd")
  ;; Never seen by the scheduler because we still don't do post reg-stack
  ;; scheduling.
  ;(define_insn_reservation "athlon_fxch" 2
! ;			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  ;			      (eq_attr "type" "fxch"))
  ;			 "athlon-direct,athlon-fpsched,athlon-fany")
  
***************
*** 516,521 ****
--- 601,623 ----
  			      (and (eq_attr "type" "mmxmov,ssemov")
  				   (eq_attr "memory" "load")))
  			 "athlon-direct,athlon-fploadk8,athlon-fstore")
+ ;; On AMDFAM10 all double, single and integer packed and scalar SSEx data
+ ;; loads  generated are direct path, latency of 2 and do not use any FP
+ ;; executions units. No seperate entries for movlpx/movhpx loads, which
+ ;; are direct path, latency of 4 and use the FADD/FMUL FP execution units,
+ ;; as they will not be generated.
+ (define_insn_reservation "athlon_sseld_amdfam10" 2
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssemov")
+ 				   (eq_attr "memory" "load")))
+ 			 "athlon-direct,athlon-fploadk8")
+ ;; On AMDFAM10 MMX data loads  generated are direct path, latency of 4
+ ;; and can use any  FP executions units
+ (define_insn_reservation "athlon_mmxld_amdfam10" 4
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "mmxmov")
+ 				   (eq_attr "memory" "load")))
+ 			 "athlon-direct,athlon-fploadk8, athlon-fany")			 
  (define_insn_reservation "athlon_mmxssest" 3
  			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "mmxmov,ssemov")
***************
*** 533,538 ****
--- 635,659 ----
  			      (and (eq_attr "type" "mmxmov,ssemov")
  				   (eq_attr "memory" "store,both")))
  			 "athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
+ ;; On AMDFAM10 all double, single and integer packed SSEx data stores
+ ;; generated are all double path, latency of 2 and use the FSTORE FP
+ ;; execution unit. No entries seperate for movupx/movdqu, which are
+ ;; vector path, latency of 3 and use the FSTORE*2 FP execution unit,
+ ;; as they will not be generated.
+ (define_insn_reservation "athlon_ssest_amdfam10" 2
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssemov")
+ 				   (and (eq_attr "mode" "V4SF,V2DF,TI")
+ 					(eq_attr "memory" "store,both"))))
+ 			 "athlon-double,(athlon-fpsched+athlon-agu),((athlon-fstore+athlon-store)*2)")
+ ;; On AMDFAM10 all double, single and integer scalar SSEx and MMX
+ ;; data stores generated are all direct path, latency of 2 and use
+ ;; the FSTORE FP execution unit
+ (define_insn_reservation "athlon_mmxssest_short_amdfam10" 2
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "mmxmov,ssemov")
+ 				   (eq_attr "memory" "store,both")))
+ 			 "athlon-direct,(athlon-fpsched+athlon-agu),(athlon-fstore+athlon-store)")
  (define_insn_reservation "athlon_movaps_k8" 2
  			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "ssemov")
***************
*** 578,583 ****
--- 699,709 ----
  			      (and (eq_attr "type" "sselog,sselog1")
  				   (eq_attr "memory" "load")))
  			 "athlon-double,athlon-fpload2k8,(athlon-fmul*2)")
+ (define_insn_reservation "athlon_sselog_load_amdfam10" 4
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "sselog,sselog1")
+ 				   (eq_attr "memory" "load")))
+ 			 "athlon-direct,athlon-fploadk8,(athlon-fadd|athlon-fmul)")
  (define_insn_reservation "athlon_sselog" 3
  			 (and (eq_attr "cpu" "athlon")
  			      (eq_attr "type" "sselog,sselog1"))
***************
*** 586,591 ****
--- 712,722 ----
  			 (and (eq_attr "cpu" "k8,generic64")
  			      (eq_attr "type" "sselog,sselog1"))
  			 "athlon-double,athlon-fpsched,athlon-fmul")
+ (define_insn_reservation "athlon_sselog_amdfam10" 2
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (eq_attr "type" "sselog,sselog1"))
+ 			 "athlon-direct,athlon-fpsched,(athlon-fadd|athlon-fmul)")
+ 
  ;; ??? pcmp executes in addmul, probably not worthwhile to bother about that.
  (define_insn_reservation "athlon_ssecmp_load" 2
  			 (and (eq_attr "cpu" "athlon")
***************
*** 594,606 ****
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fpload,athlon-fadd")
  (define_insn_reservation "athlon_ssecmp_load_k8" 4
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "ssecmp")
  				   (and (eq_attr "mode" "SF,DF,DI,TI")
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_ssecmp" 2
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "ssecmp")
  				   (eq_attr "mode" "SF,DF,DI,TI")))
  			 "athlon-direct,athlon-fpsched,athlon-fadd")
--- 725,737 ----
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fpload,athlon-fadd")
  (define_insn_reservation "athlon_ssecmp_load_k8" 4
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "ssecmp")
  				   (and (eq_attr "mode" "SF,DF,DI,TI")
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_ssecmp" 2
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (and (eq_attr "type" "ssecmp")
  				   (eq_attr "mode" "SF,DF,DI,TI")))
  			 "athlon-direct,athlon-fpsched,athlon-fadd")
***************
*** 614,619 ****
--- 745,755 ----
  			      (and (eq_attr "type" "ssecmp")
  				   (eq_attr "memory" "load")))
  			 "athlon-double,athlon-fpload2k8,(athlon-fadd*2)")
+ (define_insn_reservation "athlon_ssecmpvector_load_amdfam10" 4
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssecmp")
+ 				   (eq_attr "memory" "load")))
+ 			 "athlon-direct,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_ssecmpvector" 3
  			 (and (eq_attr "cpu" "athlon")
  			      (eq_attr "type" "ssecmp"))
***************
*** 622,627 ****
--- 758,767 ----
  			 (and (eq_attr "cpu" "k8,generic64")
  			      (eq_attr "type" "ssecmp"))
  			 "athlon-double,athlon-fpsched,(athlon-fadd*2)")
+ (define_insn_reservation "athlon_ssecmpvector_amdfam10" 2
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (eq_attr "type" "ssecmp"))
+ 			 "athlon-direct,athlon-fpsched,athlon-fadd")
  (define_insn_reservation "athlon_ssecomi_load" 4
  			 (and (eq_attr "cpu" "athlon")
  			      (and (eq_attr "type" "ssecomi")
***************
*** 632,641 ****
--- 772,791 ----
  			      (and (eq_attr "type" "ssecomi")
  				   (eq_attr "memory" "load")))
  			 "athlon-vector,athlon-fploadk8,athlon-fadd")
+ (define_insn_reservation "athlon_ssecomi_load_amdfam10" 5
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssecomi")
+ 				   (eq_attr "memory" "load")))
+ 			 "athlon-direct,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_ssecomi" 4
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (eq_attr "type" "ssecmp"))
  			 "athlon-vector,athlon-fpsched,athlon-fadd")
+ (define_insn_reservation "athlon_ssecomi_amdfam10" 3
+ 			 (and (eq_attr "cpu" "amdfam10")
+ ;; It seems athlon_ssecomi has a bug in the attr_type, fixed for amdfam10
+ 			      (eq_attr "type" "ssecomi"))
+ 			 "athlon-direct,athlon-fpsched,athlon-fadd")
  (define_insn_reservation "athlon_sseadd_load" 4
  			 (and (eq_attr "cpu" "athlon")
  			      (and (eq_attr "type" "sseadd")
***************
*** 643,655 ****
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fpload,athlon-fadd")
  (define_insn_reservation "athlon_sseadd_load_k8" 6
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "sseadd")
  				   (and (eq_attr "mode" "SF,DF,DI")
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_sseadd" 4
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "sseadd")
  				   (eq_attr "mode" "SF,DF,DI")))
  			 "athlon-direct,athlon-fpsched,athlon-fadd")
--- 793,805 ----
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fpload,athlon-fadd")
  (define_insn_reservation "athlon_sseadd_load_k8" 6
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "sseadd")
  				   (and (eq_attr "mode" "SF,DF,DI")
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_sseadd" 4
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (and (eq_attr "type" "sseadd")
  				   (eq_attr "mode" "SF,DF,DI")))
  			 "athlon-direct,athlon-fpsched,athlon-fadd")
***************
*** 663,668 ****
--- 813,823 ----
  			      (and (eq_attr "type" "sseadd")
  				   (eq_attr "memory" "load")))
  			 "athlon-double,athlon-fpload2k8,(athlon-fadd*2)")
+ (define_insn_reservation "athlon_sseaddvector_load_amdfam10" 6
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "sseadd")
+ 				   (eq_attr "memory" "load")))
+ 			 "athlon-direct,athlon-fploadk8,athlon-fadd")
  (define_insn_reservation "athlon_sseaddvector" 5
  			 (and (eq_attr "cpu" "athlon")
  			      (eq_attr "type" "sseadd"))
***************
*** 671,676 ****
--- 826,835 ----
  			 (and (eq_attr "cpu" "k8,generic64")
  			      (eq_attr "type" "sseadd"))
  			 "athlon-double,athlon-fpsched,(athlon-fadd*2)")
+ (define_insn_reservation "athlon_sseaddvector_amdfam10" 4
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (eq_attr "type" "sseadd"))
+ 			 "athlon-direct,athlon-fpsched,athlon-fadd")
  
  ;; Conversions behaves very irregularly and the scheduling is critical here.
  ;; Take each instruction separately.  Assume that the mode is always set to the
***************
*** 684,695 ****
--- 843,867 ----
  					(and (eq_attr "mode" "DF")
  					     (eq_attr "memory" "load")))))
  			 "athlon-direct,athlon-fploadk8,athlon-fstore")
+ (define_insn_reservation "athlon_ssecvt_cvtss2sd_load_amdfam10" 7
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssecvt")
+ 				   (and (eq_attr "amdfam10_decode" "double")
+ 					(and (eq_attr "mode" "DF")
+ 					     (eq_attr "memory" "load")))))
+ 			 "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
  (define_insn_reservation "athlon_ssecvt_cvtss2sd" 2
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "ssecvt")
  				   (and (eq_attr "athlon_decode" "direct")
  					(eq_attr "mode" "DF"))))
  			 "athlon-direct,athlon-fpsched,athlon-fstore")
+ (define_insn_reservation "athlon_ssecvt_cvtss2sd_amdfam10" 7
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssecvt")
+ 				   (and (eq_attr "amdfam10_decode" "vector")
+ 					(eq_attr "mode" "DF"))))
+ 			 "athlon-vector,athlon-fpsched,athlon-faddmul,(athlon-fstore*2)")
  ;; cvtps2pd.  Model same way the other double decoded FP conversions.
  (define_insn_reservation "athlon_ssecvt_cvtps2pd_load_k8" 5
  			 (and (eq_attr "cpu" "k8,athlon,generic64")
***************
*** 698,709 ****
--- 870,894 ----
  					(and (eq_attr "mode" "V2DF,V4SF,TI")
  					     (eq_attr "memory" "load")))))
  			 "athlon-double,athlon-fpload2k8,(athlon-fstore*2)")
+ (define_insn_reservation "athlon_ssecvt_cvtps2pd_load_amdfam10" 4
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssecvt")
+ 				   (and (eq_attr "amdfam10_decode" "direct")
+ 					(and (eq_attr "mode" "V2DF,V4SF,TI")
+ 					     (eq_attr "memory" "load")))))
+ 			 "athlon-direct,athlon-fploadk8,athlon-fstore")
  (define_insn_reservation "athlon_ssecvt_cvtps2pd_k8" 3
  			 (and (eq_attr "cpu" "k8,athlon,generic64")
  			      (and (eq_attr "type" "ssecvt")
  				   (and (eq_attr "athlon_decode" "double")
  					(eq_attr "mode" "V2DF,V4SF,TI"))))
  			 "athlon-double,athlon-fpsched,athlon-fstore,athlon-fstore")
+ (define_insn_reservation "athlon_ssecvt_cvtps2pd_amdfam10" 2
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssecvt")
+ 				   (and (eq_attr "amdfam10_decode" "direct")
+ 					(eq_attr "mode" "V2DF,V4SF,TI"))))
+ 			 "athlon-direct,athlon-fpsched,athlon-fstore")
  ;; cvtsi2sd mem,reg is directpath path  (cvtsi2sd reg,reg is doublepath)
  ;; cvtsi2sd has troughput 1 and is executed in store unit with latency of 6
  (define_insn_reservation "athlon_sseicvt_cvtsi2sd_load" 6
***************
*** 713,718 ****
--- 898,910 ----
  					(and (eq_attr "mode" "SF,DF")
  					     (eq_attr "memory" "load")))))
  			 "athlon-direct,athlon-fploadk8,athlon-fstore")
+ (define_insn_reservation "athlon_sseicvt_cvtsi2sd_load_amdfam10" 9
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "sseicvt")
+ 				   (and (eq_attr "amdfam10_decode" "double")
+ 					(and (eq_attr "mode" "SF,DF")
+ 					     (eq_attr "memory" "load")))))
+ 			 "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
  ;; cvtsi2ss mem, reg is doublepath
  (define_insn_reservation "athlon_sseicvt_cvtsi2ss_load" 9
  			 (and (eq_attr "cpu" "athlon")
***************
*** 728,733 ****
--- 920,932 ----
  					(and (eq_attr "mode" "SF,DF")
  					     (eq_attr "memory" "load")))))
  			 "athlon-double,athlon-fploadk8,(athlon-fstore*2)")
+ (define_insn_reservation "athlon_sseicvt_cvtsi2ss_load_amdfam10" 9
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "sseicvt")
+ 				   (and (eq_attr "amdfam10_decode" "double")
+ 					(and (eq_attr "mode" "SF,DF")
+ 					     (eq_attr "memory" "load")))))
+ 			 "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")			 
  ;; cvtsi2sd reg,reg is double decoded (vector on Athlon)
  (define_insn_reservation "athlon_sseicvt_cvtsi2sd_k8" 11
  			 (and (eq_attr "cpu" "k8,athlon,generic64")
***************
*** 736,741 ****
--- 935,947 ----
  					(and (eq_attr "mode" "SF,DF")
  					     (eq_attr "memory" "none")))))
  			 "athlon-double,athlon-fploadk8,athlon-fstore")
+ (define_insn_reservation "athlon_sseicvt_cvtsi2sd_amdfam10" 14
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "sseicvt")
+ 				   (and (eq_attr "amdfam10_decode" "vector")
+ 					(and (eq_attr "mode" "SF,DF")
+ 					     (eq_attr "memory" "none")))))
+ 			 "athlon-vector,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
  ;; cvtsi2ss reg, reg is doublepath
  (define_insn_reservation "athlon_sseicvt_cvtsi2ss" 14
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
***************
*** 744,749 ****
--- 950,962 ----
  					(and (eq_attr "mode" "SF,DF")
  					     (eq_attr "memory" "none")))))
  			 "athlon-vector,athlon-fploadk8,(athlon-fvector*2)")
+ (define_insn_reservation "athlon_sseicvt_cvtsi2ss_amdfam10" 14
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "sseicvt")
+ 				   (and (eq_attr "amdfam10_decode" "vector")
+ 					(and (eq_attr "mode" "SF,DF")
+ 					     (eq_attr "memory" "none")))))
+ 			 "athlon-vector,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
  ;; cvtsd2ss mem,reg is doublepath, troughput unknown, latency 9
  (define_insn_reservation "athlon_ssecvt_cvtsd2ss_load_k8" 9
  			 (and (eq_attr "cpu" "k8,athlon,generic64")
***************
*** 752,757 ****
--- 965,977 ----
  					(and (eq_attr "mode" "SF")
  					     (eq_attr "memory" "load")))))
  			 "athlon-double,athlon-fploadk8,(athlon-fstore*3)")
+ (define_insn_reservation "athlon_ssecvt_cvtsd2ss_load_amdfam10" 9
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssecvt")
+ 				   (and (eq_attr "amdfam10_decode" "double")
+ 					(and (eq_attr "mode" "SF")
+ 					     (eq_attr "memory" "load")))))
+ 			 "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
  ;; cvtsd2ss reg,reg is vectorpath, troughput unknown, latency 12
  (define_insn_reservation "athlon_ssecvt_cvtsd2ss" 12
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
***************
*** 760,765 ****
--- 980,992 ----
  					(and (eq_attr "mode" "SF")
  					     (eq_attr "memory" "none")))))
  			 "athlon-vector,athlon-fpsched,(athlon-fvector*3)")
+ (define_insn_reservation "athlon_ssecvt_cvtsd2ss_amdfam10" 8
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssecvt")
+ 				   (and (eq_attr "amdfam10_decode" "vector")
+ 					(and (eq_attr "mode" "SF")
+ 					     (eq_attr "memory" "none")))))
+ 			 "athlon-vector,athlon-fpsched,athlon-faddmul,(athlon-fstore*2)")
  (define_insn_reservation "athlon_ssecvt_cvtpd2ps_load_k8" 8
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "ssecvt")
***************
*** 767,772 ****
--- 994,1006 ----
  					(and (eq_attr "mode" "V4SF,V2DF,TI")
  					     (eq_attr "memory" "load")))))
  			 "athlon-double,athlon-fpload2k8,(athlon-fstore*3)")
+ (define_insn_reservation "athlon_ssecvt_cvtpd2ps_load_amdfam10" 9
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssecvt")
+ 				   (and (eq_attr "amdfam10_decode" "double")
+ 					(and (eq_attr "mode" "V4SF,V2DF,TI")
+ 					     (eq_attr "memory" "load")))))
+ 			 "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
  ;; cvtpd2ps mem,reg is vectorpath, troughput unknown, latency 10
  ;; ??? Why it is fater than cvtsd2ss?
  (define_insn_reservation "athlon_ssecvt_cvtpd2ps" 8
***************
*** 776,781 ****
--- 1010,1022 ----
  					(and (eq_attr "mode" "V4SF,V2DF,TI")
  					     (eq_attr "memory" "none")))))
  			 "athlon-vector,athlon-fpsched,athlon-fvector*2")
+ (define_insn_reservation "athlon_ssecvt_cvtpd2ps_amdfam10" 7
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssecvt")
+ 				   (and (eq_attr "amdfam10_decode" "double")
+ 					(and (eq_attr "mode" "V4SF,V2DF,TI")
+ 					     (eq_attr "memory" "none")))))
+ 			 "athlon-double,athlon-fpsched,(athlon-faddmul+athlon-fstore)")
  ;; cvtsd2si mem,reg is doublepath, troughput 1, latency 9
  (define_insn_reservation "athlon_secvt_cvtsX2si_load" 9
  			 (and (eq_attr "cpu" "athlon,k8,generic64")
***************
*** 784,789 ****
--- 1025,1037 ----
  					(and (eq_attr "mode" "SI,DI")
  					     (eq_attr "memory" "load")))))
  			 "athlon-vector,athlon-fploadk8,athlon-fvector")
+ (define_insn_reservation "athlon_secvt_cvtsX2si_load_amdfam10" 10
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "sseicvt")
+ 				   (and (eq_attr "amdfam10_decode" "double")
+ 					(and (eq_attr "mode" "SI,DI")
+ 					     (eq_attr "memory" "load")))))
+ 			 "athlon-double,athlon-fploadk8,(athlon-fadd+athlon-fstore)")
  ;; cvtsd2si reg,reg is doublepath, troughput 1, latency 9
  (define_insn_reservation "athlon_ssecvt_cvtsX2si" 9
  			 (and (eq_attr "cpu" "athlon")
***************
*** 799,804 ****
--- 1047,1075 ----
  					(and (eq_attr "mode" "SI,DI")
  					     (eq_attr "memory" "none")))))
  			 "athlon-double,athlon-fpsched,athlon-fstore")
+ (define_insn_reservation "athlon_ssecvt_cvtsX2si_amdfam10" 8
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "sseicvt")
+ 				   (and (eq_attr "amdfam10_decode" "double")
+ 					(and (eq_attr "mode" "SI,DI")
+ 					     (eq_attr "memory" "none")))))
+ 			 "athlon-double,athlon-fpsched,(athlon-fadd+athlon-fstore)")
+ ;; cvtpd2dq reg,mem is doublepath, troughput 1, latency 9 on amdfam10
+ (define_insn_reservation "athlon_sseicvt_cvtpd2dq_load_amdfam10" 9
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "sseicvt")
+ 				   (and (eq_attr "amdfam10_decode" "double")
+ 					(and (eq_attr "mode" "TI")
+ 					     (eq_attr "memory" "load")))))
+ 			 "athlon-double,athlon-fploadk8,(athlon-faddmul+athlon-fstore)")
+ ;; cvtpd2dq reg,mem is doublepath, troughput 1, latency 7 on amdfam10
+ (define_insn_reservation "athlon_sseicvt_cvtpd2dq_amdfam10" 7
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "sseicvt")
+ 				   (and (eq_attr "amdfam10_decode" "double")
+ 					(and (eq_attr "mode" "TI")
+ 					     (eq_attr "memory" "none")))))
+ 			 "athlon-double,athlon-fpsched,(athlon-faddmul+athlon-fstore)")
  
  
  (define_insn_reservation "athlon_ssemul_load" 4
***************
*** 808,820 ****
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fpload,athlon-fmul")
  (define_insn_reservation "athlon_ssemul_load_k8" 6
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "ssemul")
  				   (and (eq_attr "mode" "SF,DF")
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fploadk8,athlon-fmul")
  (define_insn_reservation "athlon_ssemul" 4
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "ssemul")
  				   (eq_attr "mode" "SF,DF")))
  			 "athlon-direct,athlon-fpsched,athlon-fmul")
--- 1079,1091 ----
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fpload,athlon-fmul")
  (define_insn_reservation "athlon_ssemul_load_k8" 6
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "ssemul")
  				   (and (eq_attr "mode" "SF,DF")
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fploadk8,athlon-fmul")
  (define_insn_reservation "athlon_ssemul" 4
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (and (eq_attr "type" "ssemul")
  				   (eq_attr "mode" "SF,DF")))
  			 "athlon-direct,athlon-fpsched,athlon-fmul")
***************
*** 828,833 ****
--- 1099,1109 ----
  			      (and (eq_attr "type" "ssemul")
  				   (eq_attr "memory" "load")))
  			 "athlon-double,athlon-fpload2k8,(athlon-fmul*2)")
+ (define_insn_reservation "athlon_ssemulvector_load_amdfam10" 6
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssemul")
+ 				   (eq_attr "memory" "load")))
+ 			 "athlon-direct,athlon-fploadk8,athlon-fmul")
  (define_insn_reservation "athlon_ssemulvector" 5
  			 (and (eq_attr "cpu" "athlon")
  			      (eq_attr "type" "ssemul"))
***************
*** 836,841 ****
--- 1112,1121 ----
  			 (and (eq_attr "cpu" "k8,generic64")
  			      (eq_attr "type" "ssemul"))
  			 "athlon-double,athlon-fpsched,(athlon-fmul*2)")
+ (define_insn_reservation "athlon_ssemulvector_amdfam10" 4
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (eq_attr "type" "ssemul"))
+ 			 "athlon-direct,athlon-fpsched,athlon-fmul")			 
  ;; divsd timings.  divss is faster
  (define_insn_reservation "athlon_ssediv_load" 20
  			 (and (eq_attr "cpu" "athlon")
***************
*** 844,856 ****
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fpload,athlon-fmul*17")
  (define_insn_reservation "athlon_ssediv_load_k8" 22
! 			 (and (eq_attr "cpu" "k8,generic64")
  			      (and (eq_attr "type" "ssediv")
  				   (and (eq_attr "mode" "SF,DF")
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fploadk8,athlon-fmul*17")
  (define_insn_reservation "athlon_ssediv" 20
! 			 (and (eq_attr "cpu" "athlon,k8,generic64")
  			      (and (eq_attr "type" "ssediv")
  				   (eq_attr "mode" "SF,DF")))
  			 "athlon-direct,athlon-fpsched,athlon-fmul*17")
--- 1124,1136 ----
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fpload,athlon-fmul*17")
  (define_insn_reservation "athlon_ssediv_load_k8" 22
! 			 (and (eq_attr "cpu" "k8,generic64,amdfam10")
  			      (and (eq_attr "type" "ssediv")
  				   (and (eq_attr "mode" "SF,DF")
  					(eq_attr "memory" "load"))))
  			 "athlon-direct,athlon-fploadk8,athlon-fmul*17")
  (define_insn_reservation "athlon_ssediv" 20
! 			 (and (eq_attr "cpu" "athlon,k8,generic64,amdfam10")
  			      (and (eq_attr "type" "ssediv")
  				   (eq_attr "mode" "SF,DF")))
  			 "athlon-direct,athlon-fpsched,athlon-fmul*17")
***************
*** 864,869 ****
--- 1144,1154 ----
  			      (and (eq_attr "type" "ssediv")
  				   (eq_attr "memory" "load")))
  			 "athlon-double,athlon-fpload2k8,athlon-fmul*34")
+ (define_insn_reservation "athlon_ssedivvector_load_amdfam10" 22
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (and (eq_attr "type" "ssediv")
+ 				   (eq_attr "memory" "load")))
+ 			 "athlon-direct,athlon-fploadk8,athlon-fmul*17")			 
  (define_insn_reservation "athlon_ssedivvector" 39
  			 (and (eq_attr "cpu" "athlon")
  			      (eq_attr "type" "ssediv"))
***************
*** 872,874 ****
--- 1157,1168 ----
  			 (and (eq_attr "cpu" "k8,generic64")
  			      (eq_attr "type" "ssediv"))
  			 "athlon-double,athlon-fmul*34")
+ (define_insn_reservation "athlon_ssedivvector_amdfam10" 20
+ 			 (and (eq_attr "cpu" "amdfam10")
+ 			      (eq_attr "type" "ssediv"))
+ 			 "athlon-direct,athlon-fmul*17")
+ (define_insn_reservation "athlon_sseins_amdfam10" 5
+                          (and (eq_attr "cpu" "amdfam10")
+                               (and (eq_attr "type" "sseins")
+                                    (eq_attr "mode" "TI")))
+                          "athlon-vector,athlon-fpsched,athlon-faddmul")
*** gcc/config/i386/pmmintrin.h.~1~	2007-11-08 14:27:21.494202000 -0500
--- gcc/config/i386/pmmintrin.h	2007-11-09 12:11:07.652613000 -0500
***************
*** 1,4 ****
! /* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  
     This file is part of GCC.
  
--- 1,4 ----
! /* Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
  
     This file is part of GCC.
  
***************
*** 30,36 ****
  #ifndef _PMMINTRIN_H_INCLUDED
  #define _PMMINTRIN_H_INCLUDED
  
! #ifdef __SSE3__
  #include <xmmintrin.h>
  #include <emmintrin.h>
  
--- 30,40 ----
  #ifndef _PMMINTRIN_H_INCLUDED
  #define _PMMINTRIN_H_INCLUDED
  
! #ifndef __SSE3__
! # error "SSE3 instruction set not enabled"
! #else
! 
! /* We need definitions from the SSE2 and SSE header files*/
  #include <xmmintrin.h>
  #include <emmintrin.h>
  
*** gcc/config/i386/xmmintrin.h.~1~	2007-11-08 14:27:21.552145000 -0500
--- gcc/config/i386/xmmintrin.h	2007-11-09 12:11:07.710669000 -0500
*************** do {									\
*** 1243,1249 ****
--- 1243,1251 ----
  } while (0)
  
  /* For backward source compatibility.  */
+ #ifdef __SSE2__
  #include <emmintrin.h>
+ #endif
  
  #endif /* __SSE__ */
  #endif /* _XMMINTRIN_H_INCLUDED */
*** gcc/config/i386/sse.md.~1~	2007-11-08 14:27:21.674027000 -0500
--- gcc/config/i386/sse.md	2007-11-09 12:11:07.695654000 -0500
***************
*** 918,923 ****
--- 918,924 ----
    "cvtsi2ss\t{%2, %0|%0, %2}"
    [(set_attr "type" "sseicvt")
     (set_attr "athlon_decode" "vector,double")
+    (set_attr "amdfam10_decode" "vector,double")
     (set_attr "mode" "SF")])
  
  (define_insn "sse_cvtsi2ssq"
***************
*** 931,936 ****
--- 932,938 ----
    "cvtsi2ssq\t{%2, %0|%0, %2}"
    [(set_attr "type" "sseicvt")
     (set_attr "athlon_decode" "vector,double")
+    (set_attr "amdfam10_decode" "vector,double")
     (set_attr "mode" "SF")])
  
  (define_insn "sse_cvtss2si"
***************
*** 944,949 ****
--- 946,952 ----
    "cvtss2si\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "athlon_decode" "double,vector")
+    (set_attr "amdfam10_decode" "double,double")
     (set_attr "mode" "SI")])
  
  (define_insn "sse_cvtss2siq"
***************
*** 957,962 ****
--- 960,966 ----
    "cvtss2siq\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "athlon_decode" "double,vector")
+    (set_attr "amdfam10_decode" "double,double")
     (set_attr "mode" "DI")])
  
  (define_insn "sse_cvttss2si"
***************
*** 969,974 ****
--- 973,979 ----
    "cvttss2si\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "athlon_decode" "double,vector")
+    (set_attr "amdfam10_decode" "double,double")
     (set_attr "mode" "SI")])
  
  (define_insn "sse_cvttss2siq"
***************
*** 981,986 ****
--- 986,992 ----
    "cvttss2siq\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "athlon_decode" "double,vector")
+    (set_attr "amdfam10_decode" "double,double")
     (set_attr "mode" "DI")])
  
  (define_insn "sse2_cvtdq2ps"
***************
*** 1850,1856 ****
    "cvtsi2sd\t{%2, %0|%0, %2}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "double,direct")])
  
  (define_insn "sse2_cvtsi2sdq"
    [(set (match_operand:V2DF 0 "register_operand" "=x,x")
--- 1856,1863 ----
    "cvtsi2sd\t{%2, %0|%0, %2}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "double,direct")
!    (set_attr "amdfam10_decode" "vector,double")])
  
  (define_insn "sse2_cvtsi2sdq"
    [(set (match_operand:V2DF 0 "register_operand" "=x,x")
***************
*** 1863,1869 ****
    "cvtsi2sdq\t{%2, %0|%0, %2}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "double,direct")])
  
  (define_insn "sse2_cvtsd2si"
    [(set (match_operand:SI 0 "register_operand" "=r,r")
--- 1870,1877 ----
    "cvtsi2sdq\t{%2, %0|%0, %2}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DF")
!    (set_attr "athlon_decode" "double,direct")
!    (set_attr "amdfam10_decode" "vector,double")])
  
  (define_insn "sse2_cvtsd2si"
    [(set (match_operand:SI 0 "register_operand" "=r,r")
***************
*** 1876,1881 ****
--- 1884,1890 ----
    "cvtsd2si\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "athlon_decode" "double,vector")
+    (set_attr "amdfam10_decode" "double,double")
     (set_attr "mode" "SI")])
  
  (define_insn "sse2_cvtsd2siq"
***************
*** 1889,1894 ****
--- 1898,1904 ----
    "cvtsd2siq\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "athlon_decode" "double,vector")
+    (set_attr "amdfam10_decode" "double,double")
     (set_attr "mode" "DI")])
  
  (define_insn "sse2_cvttsd2si"
***************
*** 1901,1907 ****
    "cvttsd2si\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "SI")
!    (set_attr "athlon_decode" "double,vector")])
  
  (define_insn "sse2_cvttsd2siq"
    [(set (match_operand:DI 0 "register_operand" "=r,r")
--- 1911,1918 ----
    "cvttsd2si\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "SI")
!    (set_attr "athlon_decode" "double,vector")
!    (set_attr "amdfam10_decode" "double,double")])
  
  (define_insn "sse2_cvttsd2siq"
    [(set (match_operand:DI 0 "register_operand" "=r,r")
***************
*** 1913,1919 ****
    "cvttsd2siq\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DI")
!    (set_attr "athlon_decode" "double,vector")])
  
  (define_insn "sse2_cvtdq2pd"
    [(set (match_operand:V2DF 0 "register_operand" "=x")
--- 1924,1931 ----
    "cvttsd2siq\t{%1, %0|%0, %1}"
    [(set_attr "type" "sseicvt")
     (set_attr "mode" "DI")
!    (set_attr "athlon_decode" "double,vector")
!    (set_attr "amdfam10_decode" "double,double")])
  
  (define_insn "sse2_cvtdq2pd"
    [(set (match_operand:V2DF 0 "register_operand" "=x")
***************
*** 1944,1950 ****
    "TARGET_SSE2"
    "cvtpd2dq\t{%1, %0|%0, %1}"
    [(set_attr "type" "ssecvt")
!    (set_attr "mode" "TI")])
  
  (define_expand "sse2_cvttpd2dq"
    [(set (match_operand:V4SI 0 "register_operand" "")
--- 1956,1963 ----
    "TARGET_SSE2"
    "cvtpd2dq\t{%1, %0|%0, %1}"
    [(set_attr "type" "ssecvt")
!    (set_attr "mode" "TI")
!    (set_attr "amdfam10_decode" "double")])
  
  (define_expand "sse2_cvttpd2dq"
    [(set (match_operand:V4SI 0 "register_operand" "")
***************
*** 1962,1968 ****
    "TARGET_SSE2"
    "cvttpd2dq\t{%1, %0|%0, %1}"
    [(set_attr "type" "ssecvt")
!    (set_attr "mode" "TI")])
  
  (define_insn "sse2_cvtsd2ss"
    [(set (match_operand:V4SF 0 "register_operand" "=x,x")
--- 1975,1982 ----
    "TARGET_SSE2"
    "cvttpd2dq\t{%1, %0|%0, %1}"
    [(set_attr "type" "ssecvt")
!    (set_attr "mode" "TI")
!    (set_attr "amdfam10_decode" "double")])
  
  (define_insn "sse2_cvtsd2ss"
    [(set (match_operand:V4SF 0 "register_operand" "=x,x")
***************
*** 1976,1995 ****
    "cvtsd2ss\t{%2, %0|%0, %2}"
    [(set_attr "type" "ssecvt")
     (set_attr "athlon_decode" "vector,double")
     (set_attr "mode" "SF")])
  
  (define_insn "sse2_cvtss2sd"
!   [(set (match_operand:V2DF 0 "register_operand" "=x")
  	(vec_merge:V2DF
  	  (float_extend:V2DF
  	    (vec_select:V2SF
! 	      (match_operand:V4SF 2 "nonimmediate_operand" "xm")
  	      (parallel [(const_int 0) (const_int 1)])))
! 	  (match_operand:V2DF 1 "register_operand" "0")
  	  (const_int 1)))]
    "TARGET_SSE2"
    "cvtss2sd\t{%2, %0|%0, %2}"
    [(set_attr "type" "ssecvt")
     (set_attr "mode" "DF")])
  
  (define_expand "sse2_cvtpd2ps"
--- 1990,2011 ----
    "cvtsd2ss\t{%2, %0|%0, %2}"
    [(set_attr "type" "ssecvt")
     (set_attr "athlon_decode" "vector,double")
+    (set_attr "amdfam10_decode" "vector,double")
     (set_attr "mode" "SF")])
  
  (define_insn "sse2_cvtss2sd"
!   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
  	(vec_merge:V2DF
  	  (float_extend:V2DF
  	    (vec_select:V2SF
! 	      (match_operand:V4SF 2 "nonimmediate_operand" "x,m")
  	      (parallel [(const_int 0) (const_int 1)])))
! 	  (match_operand:V2DF 1 "register_operand" "0,0")
  	  (const_int 1)))]
    "TARGET_SSE2"
    "cvtss2sd\t{%2, %0|%0, %2}"
    [(set_attr "type" "ssecvt")
+    (set_attr "amdfam10_decode" "vector,double")
     (set_attr "mode" "DF")])
  
  (define_expand "sse2_cvtpd2ps"
***************
*** 2010,2016 ****
    "TARGET_SSE2"
    "cvtpd2ps\t{%1, %0|%0, %1}"
    [(set_attr "type" "ssecvt")
!    (set_attr "mode" "V4SF")])
  
  (define_insn "sse2_cvtps2pd"
    [(set (match_operand:V2DF 0 "register_operand" "=x")
--- 2026,2033 ----
    "TARGET_SSE2"
    "cvtpd2ps\t{%1, %0|%0, %1}"
    [(set_attr "type" "ssecvt")
!    (set_attr "mode" "V4SF")
!    (set_attr "amdfam10_decode" "double")])
  
  (define_insn "sse2_cvtps2pd"
    [(set (match_operand:V2DF 0 "register_operand" "=x")
***************
*** 2021,2027 ****
    "TARGET_SSE2"
    "cvtps2pd\t{%1, %0|%0, %1}"
    [(set_attr "type" "ssecvt")
!    (set_attr "mode" "V2DF")])
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;
--- 2038,2045 ----
    "TARGET_SSE2"
    "cvtps2pd\t{%1, %0|%0, %1}"
    [(set_attr "type" "ssecvt")
!    (set_attr "mode" "V2DF")
!    (set_attr "amdfam10_decode" "direct")])
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;
***************
*** 3943,3945 ****
--- 3961,4053 ----
  ;; zero extended to 64bit, we only need to set up 32bit registers.
    "monitor"
    [(set_attr "length" "3")])
+ 
+ 
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;;
+ ;; AMD SSE4A instructions
+ ;;
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ 
+ (define_insn "sse4a_vmmovntv2df"
+   [(set (match_operand:DF 0 "memory_operand" "=m")
+         (unspec:DF [(vec_select:DF 
+                       (match_operand:V2DF 1 "register_operand" "x")
+                       (parallel [(const_int 0)]))]
+                    UNSPEC_MOVNT))]
+   "TARGET_SSE4A"
+   "movntsd\t{%1, %0|%0, %1}"
+   [(set_attr "type" "ssemov")
+    (set_attr "mode" "DF")])
+ 
+ (define_insn "sse4a_movntdf"
+   [(set (match_operand:DF 0 "memory_operand" "=m")
+         (unspec:DF [(match_operand:DF 1 "register_operand" "x")]
+                    UNSPEC_MOVNT))]
+   "TARGET_SSE4A"
+   "movntsd\t{%1, %0|%0, %1}"
+   [(set_attr "type" "ssemov")
+    (set_attr "mode" "DF")])
+ 
+ (define_insn "sse4a_vmmovntv4sf"
+   [(set (match_operand:SF 0 "memory_operand" "=m")
+ 	(unspec:SF [(vec_select:SF 
+ 	              (match_operand:V4SF 1 "register_operand" "x")
+ 		      (parallel [(const_int 0)]))]
+ 		   UNSPEC_MOVNT))]
+   "TARGET_SSE4A"
+   "movntss\t{%1, %0|%0, %1}"
+   [(set_attr "type" "ssemov")
+    (set_attr "mode" "SF")])
+ 
+ (define_insn "sse4a_movntsf"
+   [(set (match_operand:SF 0 "memory_operand" "=m")
+ 	(unspec:SF [(match_operand:SF 1 "register_operand" "x")]
+ 		   UNSPEC_MOVNT))]
+   "TARGET_SSE4A"
+   "movntss\t{%1, %0|%0, %1}"
+   [(set_attr "type" "ssemov")
+    (set_attr "mode" "SF")])
+ 
+ (define_insn "sse4a_extrqi"
+   [(set (match_operand:V2DI 0 "register_operand" "=x")
+         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
+                       (match_operand 2 "const_int_operand" "")
+                       (match_operand 3 "const_int_operand" "")]
+                      UNSPEC_EXTRQI))]
+   "TARGET_SSE4A"
+   "extrq\t{%3, %2, %0|%0, %2, %3}"
+   [(set_attr "type" "sse")
+    (set_attr "mode" "TI")])
+ 
+ (define_insn "sse4a_extrq"
+   [(set (match_operand:V2DI 0 "register_operand" "=x")
+         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
+                       (match_operand:V16QI 2 "register_operand" "x")]
+                      UNSPEC_EXTRQ))]
+   "TARGET_SSE4A"
+   "extrq\t{%2, %0|%0, %2}"
+   [(set_attr "type" "sse")
+    (set_attr "mode" "TI")])
+ 
+ (define_insn "sse4a_insertqi"
+   [(set (match_operand:V2DI 0 "register_operand" "=x")
+         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
+         	      (match_operand:V2DI 2 "register_operand" "x")
+                       (match_operand 3 "const_int_operand" "")
+                       (match_operand 4 "const_int_operand" "")]
+                      UNSPEC_INSERTQI))]
+   "TARGET_SSE4A"
+   "insertq\t{%4, %3, %2, %0|%0, %2, %3, %4}"
+   [(set_attr "type" "sseins")
+    (set_attr "mode" "TI")])
+ 
+ (define_insn "sse4a_insertq"
+   [(set (match_operand:V2DI 0 "register_operand" "=x")
+         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "0")
+         	      (match_operand:V2DI 2 "register_operand" "x")]
+         	     UNSPEC_INSERTQ))]
+   "TARGET_SSE4A"
+   "insertq\t{%2, %0|%0, %2}"
+   [(set_attr "type" "sseins")
+    (set_attr "mode" "TI")])
*** gcc/config/i386/i386.opt.~1~	2007-11-08 14:27:21.683016000 -0500
--- gcc/config/i386/i386.opt	2007-11-09 12:11:07.636595000 -0500
*************** msse3
*** 196,201 ****
--- 196,217 ----
  Target Report Mask(SSE3)
  Support MMX, SSE, SSE2 and SSE3 built-in functions and code generation
  
+ msse4a
+ Target Report Mask(SSE4A)
+ Support MMX, SSE, SSE2, SSE3 and SSE4A built-in functions and code generation
+ 
+ mpopcnt
+ Target Report Mask(POPCNT)
+ Support code generation of popcount instruction for popcount built-ins 
+ namely __builtin_popcount, __builtin_popcountl and __builtin_popcountll
+ 
+ mabm
+ Target Report Mask(ABM)
+ Support code generation of Advanced Bit Manipulation (ABM) instructions,
+ which include popcnt and lzcnt instructions, for popcount and clz built-ins
+ namely __builtin_popcount, __builtin_popcountl, __builtin_popcountll and
+ __builtin_clz, __builtin_clzl, __builtin_clzll
+ 
  msseregparm
  Target RejectNegative Mask(SSEREGPARM)
  Use SSE register passing conventions for SF and DF mode
*** gcc/config/i386/ammintrin.h.~1~	2007-11-09 12:10:58.816785000 -0500
--- gcc/config/i386/ammintrin.h	2007-11-09 12:10:58.837804000 -0500
***************
*** 0 ****
--- 1,73 ----
+ /* Copyright (C) 2007 Free Software Foundation, Inc.
+ 
+    This file is part of GCC.
+ 
+    GCC is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2, or (at your option)
+    any later version.
+ 
+    GCC is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with GCC; see the file COPYING.  If not, write to
+    the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.  */
+ 
+ /* As a special exception, if you include this header file into source
+    files compiled by GCC, this header file does not by itself cause
+    the resulting executable to be covered by the GNU General Public
+    License.  This exception does not however invalidate any other
+    reasons why the executable file might be covered by the GNU General
+    Public License.  */
+ 
+ /* Implemented from the specification included in the AMD Programmers
+    Manual Update, version 2.x */
+ 
+ #ifndef _AMMINTRIN_H_INCLUDED
+ #define _AMMINTRIN_H_INCLUDED
+ 
+ #ifndef __SSE4A__
+ # error "SSE4A instruction set not enabled"
+ #else
+ 
+ /* We need definitions from the SSE3, SSE2 and SSE header files*/
+ #include <pmmintrin.h>
+ 
+ static __inline void __attribute__((__always_inline__))
+ _mm_stream_sd (double * __P, __m128d __Y)
+ {
+   __builtin_ia32_movntsd (__P, (__v2df) __Y);
+ }
+ 
+ static __inline void __attribute__((__always_inline__))
+ _mm_stream_ss (float * __P, __m128 __Y)
+ {
+   __builtin_ia32_movntss (__P, (__v4sf) __Y);
+ }
+ 
+ static __inline __m128i __attribute__((__always_inline__))
+ _mm_extract_si64 (__m128i __X, __m128i __Y)
+ {
+   return (__m128i) __builtin_ia32_extrq ((__v2di) __X, (__v16qi) __Y);
+ }
+ 
+ #define _mm_extracti_si64(X, I, L) \
+ ((__m128i) __builtin_ia32_extrqi ((__v2di)(X), I, L))
+ 
+ static __inline __m128i __attribute__((__always_inline__))
+ _mm_insert_si64 (__m128i __X,__m128i __Y)
+ {
+   return (__m128i) __builtin_ia32_insertq ((__v2di)__X, (__v2di)__Y);
+ }
+ 
+ #define _mm_inserti_si64(X, Y, I, L) \
+ ((__m128i) __builtin_ia32_insertqi ((__v2di)(X), (__v2di)(Y), I, L))
+ 
+ 
+ #endif /* __SSE4A__ */
+ 
+ #endif /* _AMMINTRIN_H_INCLUDED */
*** gcc/config/i386/emmintrin.h.~1~	2007-11-08 14:27:21.893916000 -0500
--- gcc/config/i386/emmintrin.h	2007-11-09 12:11:07.439400000 -0500
***************
*** 30,36 ****
  #ifndef _EMMINTRIN_H_INCLUDED
  #define _EMMINTRIN_H_INCLUDED
  
! #ifdef __SSE2__
  #include <xmmintrin.h>
  
  /* SSE2 */
--- 30,38 ----
  #ifndef _EMMINTRIN_H_INCLUDED
  #define _EMMINTRIN_H_INCLUDED
  
! #ifndef __SSE2__
! # error "SSE2 instruction set not enabled"
! #else
  #include <xmmintrin.h>
  
  /* SSE2 */
*** gcc/config/i386/driver-i386.c.~1~	2007-11-08 14:27:22.183829000 -0500
--- gcc/config/i386/driver-i386.c	2007-11-09 12:16:01.798463000 -0500
*************** const char *host_detect_local_cpu (int a
*** 38,43 ****
--- 38,44 ----
  #define bit_SSE2 (1 << 26)
  
  #define bit_SSE3 (1 << 0)
+ #define bit_SSE4a (1 << 6)
  #define bit_CMPXCHG16B (1 << 13)
  
  #define bit_3DNOW (1 << 31)
*************** const char *host_detect_local_cpu (int a
*** 66,72 ****
    unsigned int ext_level;
    unsigned char has_mmx = 0, has_3dnow = 0, has_3dnowp = 0, has_sse = 0;
    unsigned char has_sse2 = 0, has_sse3 = 0, has_cmov = 0;
!   unsigned char has_longmode = 0, has_cmpxchg8b = 0;
    unsigned char is_amd = 0;
    unsigned int family = 0;
    bool arch;
--- 67,73 ----
    unsigned int ext_level;
    unsigned char has_mmx = 0, has_3dnow = 0, has_3dnowp = 0, has_sse = 0;
    unsigned char has_sse2 = 0, has_sse3 = 0, has_cmov = 0;
!   unsigned char has_longmode = 0, has_cmpxchg8b = 0, has_sse4a = 0;
    unsigned char is_amd = 0;
    unsigned int family = 0;
    bool arch;
*************** const char *host_detect_local_cpu (int a
*** 117,122 ****
--- 118,124 ----
        has_3dnow = !!(edx & bit_3DNOW);
        has_3dnowp = !!(edx & bit_3DNOWP);
        has_longmode = !!(edx & bit_LM);
+       has_sse4a = !!(ecx & bit_SSE4a);
      }
  
    is_amd = vendor == *(unsigned int*)"Auth";
*************** const char *host_detect_local_cpu (int a
*** 129,134 ****
--- 131,138 ----
  	processor = PROCESSOR_ATHLON;
        if (has_sse2 || has_longmode)
  	processor = PROCESSOR_K8;
+       if (has_sse4a)
+ 	processor = PROCESSOR_AMDFAM10;
      }
    else
      {
*************** const char *host_detect_local_cpu (int a
*** 258,263 ****
--- 262,270 ----
      case PROCESSOR_NOCONA:
        cpu = "nocona";
        break;
+     case PROCESSOR_AMDFAM10:
+       cpu = "amdfam10";
+       break;
      case PROCESSOR_GENERIC32:
      case PROCESSOR_GENERIC64:
        cpu = "generic";
*** gcc/config/i386/i386.c.~1~	2007-11-08 14:27:22.244772000 -0500
--- gcc/config/i386/i386.c	2007-11-09 12:11:07.527489000 -0500
*************** struct processor_costs k8_cost = {
*** 491,496 ****
--- 491,561 ----
    COSTS_N_INSNS (35),			/* cost of FSQRT instruction.  */
  };
  
+ struct processor_costs amdfam10_cost = {
+   COSTS_N_INSNS (1),                    /* cost of an add instruction */
+   COSTS_N_INSNS (2),                    /* cost of a lea instruction */
+   COSTS_N_INSNS (1),                    /* variable shift costs */
+   COSTS_N_INSNS (1),                    /* constant shift costs */
+   {COSTS_N_INSNS (3),                   /* cost of starting multiply for QI */
+    COSTS_N_INSNS (4),                   /*                               HI */
+    COSTS_N_INSNS (3),                   /*                               SI */
+    COSTS_N_INSNS (4),                   /*                               DI */
+    COSTS_N_INSNS (5)},                  /*                               other */
+   0,                                    /* cost of multiply per each bit set */
+   {COSTS_N_INSNS (19),                  /* cost of a divide/mod for QI */
+    COSTS_N_INSNS (35),                  /*                          HI */
+    COSTS_N_INSNS (51),                  /*                          SI */
+    COSTS_N_INSNS (83),                  /*                          DI */
+    COSTS_N_INSNS (83)},                 /*                          other */
+   COSTS_N_INSNS (1),			/* cost of movsx */
+   COSTS_N_INSNS (1),			/* cost of movzx */
+   8,					/* "large" insn */
+   9,					/* MOVE_RATIO */
+   4,					/* cost for loading QImode using movzbl */
+   {3, 4, 3},				/* cost of loading integer registers
+ 					   in QImode, HImode and SImode.
+ 					   Relative to reg-reg move (2).  */
+   {3, 4, 3},				/* cost of storing integer registers */
+   4,					/* cost of reg,reg fld/fst */
+   {4, 4, 12},				/* cost of loading fp registers
+ 		   			   in SFmode, DFmode and XFmode */
+   {6, 6, 8},				/* cost of storing fp registers
+  		   			   in SFmode, DFmode and XFmode */
+   2,					/* cost of moving MMX register */
+   {3, 3},				/* cost of loading MMX registers
+ 					   in SImode and DImode */
+   {4, 4},				/* cost of storing MMX registers
+ 					   in SImode and DImode */
+   2,					/* cost of moving SSE register */
+   {4, 4, 3},				/* cost of loading SSE registers
+ 					   in SImode, DImode and TImode */
+   {4, 4, 5},				/* cost of storing SSE registers
+ 					   in SImode, DImode and TImode */
+   3,					/* MMX or SSE register to integer */
+   					/* On K8
+   					    MOVD reg64, xmmreg 	Double	FSTORE 4
+ 					    MOVD reg32, xmmreg 	Double	FSTORE 4
+ 					   On AMDFAM10
+ 					    MOVD reg64, xmmreg 	Double	FADD 3
+                                                                 1/1  1/1
+ 					    MOVD reg32, xmmreg 	Double	FADD 3
+                                                                 1/1  1/1 */
+   64,					/* size of prefetch block */
+   /* New AMD processors never drop prefetches; if they cannot be performed
+      immediately, they are queued.  We set number of simultaneous prefetches
+      to a large constant to reflect this (it probably is not a good idea not
+      to limit number of prefetches at all, as their execution also takes some
+      time).  */
+   100,					/* number of parallel prefetches */
+   5,					/* Branch cost */
+   COSTS_N_INSNS (4),			/* cost of FADD and FSUB insns.  */
+   COSTS_N_INSNS (4),			/* cost of FMUL instruction.  */
+   COSTS_N_INSNS (19),			/* cost of FDIV instruction.  */
+   COSTS_N_INSNS (2),			/* cost of FABS instruction.  */
+   COSTS_N_INSNS (2),			/* cost of FCHS instruction.  */
+   COSTS_N_INSNS (35),			/* cost of FSQRT instruction.  */
+ };
+ 
  static const
  struct processor_costs pentium4_cost = {
    COSTS_N_INSNS (1),			/* cost of an add instruction */
*************** const struct processor_costs *ix86_cost 
*** 723,732 ****
--- 788,799 ----
  #define m_PENT4  (1<<PROCESSOR_PENTIUM4)
  #define m_K8  (1<<PROCESSOR_K8)
  #define m_ATHLON_K8  (m_K8 | m_ATHLON)
+ #define m_AMDFAM10  (1<<PROCESSOR_AMDFAM10)
  #define m_NOCONA  (1<<PROCESSOR_NOCONA)
  #define m_GENERIC32 (1<<PROCESSOR_GENERIC32)
  #define m_GENERIC64 (1<<PROCESSOR_GENERIC64)
  #define m_GENERIC (m_GENERIC32 | m_GENERIC64)
+ #define m_ATHLON_K8_AMDFAM10  (m_K8 | m_ATHLON | m_AMDFAM10)
  
  /* Generic instruction choice should be common subset of supported CPUs
     (PPro/PENT4/NOCONA/Athlon/K8).  */
*************** const struct processor_costs *ix86_cost 
*** 734,749 ****
  /* Leave is not affecting Nocona SPEC2000 results negatively, so enabling for
     Generic64 seems like good code size tradeoff.  We can't enable it for 32bit
     generic because it is not working well with PPro base chips.  */
! const int x86_use_leave = m_386 | m_K6 | m_ATHLON_K8 | m_GENERIC64;
! const int x86_push_memory = m_386 | m_K6 | m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_GENERIC;
  const int x86_zero_extend_with_and = m_486 | m_PENT;
! const int x86_movx = m_ATHLON_K8 | m_PPRO | m_PENT4 | m_NOCONA | m_GENERIC /* m_386 | m_K6 */;
  const int x86_double_with_add = ~m_386;
  const int x86_use_bit_test = m_386;
! const int x86_unroll_strlen = m_486 | m_PENT | m_PPRO | m_ATHLON_K8 | m_K6 | m_GENERIC;
! const int x86_cmove = m_PPRO | m_ATHLON_K8 | m_PENT4 | m_NOCONA;
! const int x86_3dnow_a = m_ATHLON_K8;
! const int x86_deep_branch = m_PPRO | m_K6 | m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_GENERIC;
  /* Branch hints were put in P4 based on simulation result. But
     after P4 was made, no performance benefit was observed with
     branch hints. It also increases the code size. As the result,
--- 801,816 ----
  /* Leave is not affecting Nocona SPEC2000 results negatively, so enabling for
     Generic64 seems like good code size tradeoff.  We can't enable it for 32bit
     generic because it is not working well with PPro base chips.  */
! const int x86_use_leave = m_386 | m_K6 | m_GENERIC64 | m_ATHLON_K8_AMDFAM10;
! const int x86_push_memory = m_386 | m_K6 |  m_PENT4 | m_NOCONA | m_GENERIC | m_ATHLON_K8_AMDFAM10;
  const int x86_zero_extend_with_and = m_486 | m_PENT;
! const int x86_movx = m_ATHLON_K8_AMDFAM10 | m_PPRO | m_PENT4 | m_NOCONA | m_GENERIC /* m_386 | m_K6 */;
  const int x86_double_with_add = ~m_386;
  const int x86_use_bit_test = m_386;
! const int x86_unroll_strlen = m_486 | m_PENT | m_PPRO | m_ATHLON_K8_AMDFAM10 | m_K6 | m_GENERIC;
! const int x86_cmove = m_PPRO | m_ATHLON_K8_AMDFAM10 | m_PENT4 | m_NOCONA;
! const int x86_3dnow_a = m_ATHLON_K8_AMDFAM10;
! const int x86_deep_branch = m_PPRO | m_K6 | m_ATHLON_K8_AMDFAM10 | m_PENT4 | m_NOCONA | m_GENERIC;
  /* Branch hints were put in P4 based on simulation result. But
     after P4 was made, no performance benefit was observed with
     branch hints. It also increases the code size. As the result,
*************** const int x86_use_sahf = m_PPRO | m_K6 |
*** 761,773 ****
  const int x86_partial_reg_stall = m_PPRO;
  const int x86_partial_flag_reg_stall = m_GENERIC;
  const int x86_use_himode_fiop = m_386 | m_486 | m_K6;
! const int x86_use_simode_fiop = ~(m_PPRO | m_ATHLON_K8 | m_PENT | m_GENERIC);
  const int x86_use_mov0 = m_K6;
  const int x86_use_cltd = ~(m_PENT | m_K6 | m_GENERIC);
  const int x86_read_modify_write = ~m_PENT;
  const int x86_read_modify = ~(m_PENT | m_PPRO);
  const int x86_split_long_moves = m_PPRO;
! const int x86_promote_QImode = m_K6 | m_PENT | m_386 | m_486 | m_ATHLON_K8 | m_GENERIC; /* m_PENT4 ? */
  const int x86_fast_prefix = ~(m_PENT | m_486 | m_386);
  const int x86_single_stringop = m_386 | m_PENT4 | m_NOCONA;
  const int x86_qimode_math = ~(0);
--- 828,840 ----
  const int x86_partial_reg_stall = m_PPRO;
  const int x86_partial_flag_reg_stall = m_GENERIC;
  const int x86_use_himode_fiop = m_386 | m_486 | m_K6;
! const int x86_use_simode_fiop = ~(m_PPRO | m_ATHLON_K8_AMDFAM10 | m_PENT | m_GENERIC);
  const int x86_use_mov0 = m_K6;
  const int x86_use_cltd = ~(m_PENT | m_K6 | m_GENERIC);
  const int x86_read_modify_write = ~m_PENT;
  const int x86_read_modify = ~(m_PENT | m_PPRO);
  const int x86_split_long_moves = m_PPRO;
! const int x86_promote_QImode = m_K6 | m_PENT | m_386 | m_486 | m_ATHLON_K8_AMDFAM10 | m_GENERIC; /* m_PENT4 ? */
  const int x86_fast_prefix = ~(m_PENT | m_486 | m_386);
  const int x86_single_stringop = m_386 | m_PENT4 | m_NOCONA;
  const int x86_qimode_math = ~(0);
*************** const int x86_promote_qi_regs = 0;
*** 777,794 ****
     if our scheme for avoiding partial stalls was more effective.  */
  const int x86_himode_math = ~(m_PPRO);
  const int x86_promote_hi_regs = m_PPRO;
! const int x86_sub_esp_4 = m_ATHLON_K8 | m_PPRO | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_sub_esp_8 = m_ATHLON_K8 | m_PPRO | m_386 | m_486 | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_add_esp_4 = m_ATHLON_K8 | m_K6 | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_add_esp_8 = m_ATHLON_K8 | m_PPRO | m_K6 | m_386 | m_486 | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_integer_DFmode_moves = ~(m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_PPRO | m_GENERIC);
! const int x86_partial_reg_dependency = m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_memory_mismatch_stall = m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_accumulate_outgoing_args = m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_PPRO | m_GENERIC;
  const int x86_prologue_using_move = m_ATHLON_K8 | m_PPRO | m_GENERIC;
  const int x86_epilogue_using_move = m_ATHLON_K8 | m_PPRO | m_GENERIC;
  const int x86_shift1 = ~m_486;
! const int x86_arch_always_fancy_math_387 = m_PENT | m_PPRO | m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_GENERIC;
  /* In Generic model we have an conflict here in between PPro/Pentium4 based chips
     that thread 128bit SSE registers as single units versus K8 based chips that
     divide SSE registers to two 64bit halves.
--- 844,868 ----
     if our scheme for avoiding partial stalls was more effective.  */
  const int x86_himode_math = ~(m_PPRO);
  const int x86_promote_hi_regs = m_PPRO;
! const int x86_sub_esp_4 = m_ATHLON_K8_AMDFAM10 | m_PPRO | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_sub_esp_8 = m_ATHLON_K8_AMDFAM10 | m_PPRO | m_386 | m_486 | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_add_esp_4 = m_ATHLON_K8_AMDFAM10 | m_K6 | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_add_esp_8 = m_ATHLON_K8_AMDFAM10 | m_PPRO | m_K6 | m_386 | m_486 | m_PENT4 | m_NOCONA | m_GENERIC;
! /* Enable if integer moves are preferred for DFmode copies */
! const int x86_integer_DFmode_moves = ~(m_ATHLON_K8_AMDFAM10 | m_PENT4 | m_NOCONA | m_PPRO | m_GENERIC);
! const int x86_partial_reg_dependency = m_ATHLON_K8_AMDFAM10 | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_memory_mismatch_stall = m_ATHLON_K8_AMDFAM10 | m_PENT4 | m_NOCONA | m_GENERIC;
! /* If ACCUMULATE_OUTGOING_ARGS is enabled, the maximum amount of space required
!    for outgoing arguments will be computed and placed into the variable
!    `current_function_outgoing_args_size'. No space will be pushed onto the stack
!    for each call; instead, the function prologue should increase the stack frame
!    size by this amount. Setting both PUSH_ARGS and ACCUMULATE_OUTGOING_ARGS is
!    not proper. */
! const int x86_accumulate_outgoing_args = m_ATHLON_K8_AMDFAM10 | m_PENT4 | m_NOCONA | m_PPRO | m_GENERIC;
  const int x86_prologue_using_move = m_ATHLON_K8 | m_PPRO | m_GENERIC;
  const int x86_epilogue_using_move = m_ATHLON_K8 | m_PPRO | m_GENERIC;
  const int x86_shift1 = ~m_486;
! const int x86_arch_always_fancy_math_387 = m_PENT | m_PPRO | m_ATHLON_K8_AMDFAM10 | m_PENT4 | m_NOCONA | m_GENERIC;
  /* In Generic model we have an conflict here in between PPro/Pentium4 based chips
     that thread 128bit SSE registers as single units versus K8 based chips that
     divide SSE registers to two 64bit halves.
*************** const int x86_arch_always_fancy_math_387
*** 798,812 ****
     this option on P4 brings over 20% SPECfp regression, while enabling it on
     K8 brings roughly 2.4% regression that can be partly masked by careful scheduling
     of moves.  */
! const int x86_sse_partial_reg_dependency = m_PENT4 | m_NOCONA | m_PPRO | m_GENERIC;
  /* Set for machines where the type and dependencies are resolved on SSE
     register parts instead of whole registers, so we may maintain just
     lower part of scalar values in proper format leaving the upper part
     undefined.  */
  const int x86_sse_split_regs = m_ATHLON_K8;
  const int x86_sse_typeless_stores = m_ATHLON_K8;
  const int x86_sse_load0_by_pxor = m_PPRO | m_PENT4 | m_NOCONA;
! const int x86_use_ffreep = m_ATHLON_K8;
  const int x86_rep_movl_optimal = m_386 | m_PENT | m_PPRO | m_K6;
  const int x86_use_incdec = ~(m_PENT4 | m_NOCONA | m_GENERIC);
  
--- 872,935 ----
     this option on P4 brings over 20% SPECfp regression, while enabling it on
     K8 brings roughly 2.4% regression that can be partly masked by careful scheduling
     of moves.  */
! const int x86_sse_partial_reg_dependency = m_PENT4 | m_NOCONA | m_PPRO | m_GENERIC | m_AMDFAM10;
  /* Set for machines where the type and dependencies are resolved on SSE
     register parts instead of whole registers, so we may maintain just
     lower part of scalar values in proper format leaving the upper part
     undefined.  */
  const int x86_sse_split_regs = m_ATHLON_K8;
+ /* Code generation for scalar reg-reg moves of single and double precision data:
+      if (x86_sse_partial_reg_dependency == true | x86_sse_split_regs == true)
+        movaps reg, reg
+      else
+        movss reg, reg
+      if (x86_sse_partial_reg_dependency == true)
+        movapd reg, reg
+      else
+        movsd reg, reg
+ 
+    Code generation for scalar loads of double precision data:
+      if (x86_sse_split_regs == true)
+        movlpd mem, reg      (gas syntax)
+      else
+        movsd mem, reg
+  
+    Code generation for unaligned packed loads of single precision data
+    (x86_sse_unaligned_move_optimal overrides x86_sse_partial_reg_dependency):
+      if (x86_sse_unaligned_move_optimal)
+        movups mem, reg
+ 
+      if (x86_sse_partial_reg_dependency == true)
+        {
+          xorps  reg, reg
+          movlps mem, reg
+          movhps mem+8, reg
+        }
+      else
+        {
+          movlps mem, reg
+          movhps mem+8, reg
+        }
+ 
+    Code generation for unaligned packed loads of double precision data
+    (x86_sse_unaligned_move_optimal overrides x86_sse_split_regs):
+      if (x86_sse_unaligned_move_optimal)
+        movupd mem, reg
+ 
+      if (x86_sse_split_regs == true)
+        {
+          movlpd mem, reg
+          movhpd mem+8, reg
+        }
+      else
+        {
+          movsd  mem, reg
+          movhpd mem+8, reg
+        } */
+ const int x86_sse_unaligned_move_optimal = m_AMDFAM10;
  const int x86_sse_typeless_stores = m_ATHLON_K8;
  const int x86_sse_load0_by_pxor = m_PPRO | m_PENT4 | m_NOCONA;
! const int x86_use_ffreep = m_ATHLON_K8_AMDFAM10;
  const int x86_rep_movl_optimal = m_386 | m_PENT | m_PPRO | m_K6;
  const int x86_use_incdec = ~(m_PENT4 | m_NOCONA | m_GENERIC);
  
*************** const int x86_inter_unit_moves = 0 /* ~(
*** 817,825 ****
  const int x86_ext_80387_constants = m_K6 | m_ATHLON | m_PENT4 | m_NOCONA | m_PPRO | m_GENERIC32;
  /* Some CPU cores are not able to predict more than 4 branch instructions in
     the 16 byte window.  */
! const int x86_four_jump_limit = m_PPRO | m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_schedule = m_PPRO | m_ATHLON_K8 | m_K6 | m_PENT | m_GENERIC;
! const int x86_use_bt = m_ATHLON_K8;
  /* Compare and exchange was added for 80486.  */
  const int x86_cmpxchg = ~m_386;
  /* Compare and exchange 8 bytes was added for pentium.  */
--- 940,948 ----
  const int x86_ext_80387_constants = m_K6 | m_ATHLON | m_PENT4 | m_NOCONA | m_PPRO | m_GENERIC32;
  /* Some CPU cores are not able to predict more than 4 branch instructions in
     the 16 byte window.  */
! const int x86_four_jump_limit = m_PPRO | m_ATHLON_K8_AMDFAM10 | m_PENT4 | m_NOCONA | m_GENERIC;
! const int x86_schedule = m_PPRO | m_ATHLON_K8_AMDFAM10 | m_K6 | m_PENT | m_GENERIC;
! const int x86_use_bt = m_ATHLON_K8_AMDFAM10;
  /* Compare and exchange was added for 80486.  */
  const int x86_cmpxchg = ~m_386;
  /* Compare and exchange 8 bytes was added for pentium.  */
*************** const int x86_cmpxchg8b = ~(m_386 | m_48
*** 828,834 ****
  const int x86_cmpxchg16b = m_NOCONA;
  /* Exchange and add was added for 80486.  */
  const int x86_xadd = ~m_386;
! const int x86_pad_returns = m_ATHLON_K8 | m_GENERIC;
  
  /* In case the average insn count for single function invocation is
     lower than this constant, emit fast (but longer) prologue and
--- 951,957 ----
  const int x86_cmpxchg16b = m_NOCONA;
  /* Exchange and add was added for 80486.  */
  const int x86_xadd = ~m_386;
! const int x86_pad_returns = m_ATHLON_K8_AMDFAM10 | m_GENERIC;
  
  /* In case the average insn count for single function invocation is
     lower than this constant, emit fast (but longer) prologue and
*************** ix86_handle_option (size_t code, const c
*** 1399,1414 ****
      case OPT_msse:
        if (!value)
  	{
! 	  target_flags &= ~(MASK_SSE2 | MASK_SSE3);
! 	  target_flags_explicit |= MASK_SSE2 | MASK_SSE3;
  	}
        return true;
  
      case OPT_msse2:
        if (!value)
  	{
! 	  target_flags &= ~MASK_SSE3;
! 	  target_flags_explicit |= MASK_SSE3;
  	}
        return true;
  
--- 1522,1545 ----
      case OPT_msse:
        if (!value)
  	{
! 	  target_flags &= ~(MASK_SSE2 | MASK_SSE3 | MASK_SSE4A);
! 	  target_flags_explicit |= MASK_SSE2 | MASK_SSE3 | MASK_SSE4A;
  	}
        return true;
  
      case OPT_msse2:
        if (!value)
  	{
! 	  target_flags &= ~(MASK_SSE3 | MASK_SSE4A);
! 	  target_flags_explicit |= MASK_SSE3 | MASK_SSE4A;
! 	}
!       return true;
! 
!     case OPT_msse3:
!       if (!value)
! 	{
! 	  target_flags &= ~MASK_SSE4A;
! 	  target_flags_explicit |= MASK_SSE4A;
  	}
        return true;
  
*************** override_options (void)
*** 1458,1464 ****
        {&k8_cost, 0, 0, 16, 7, 16, 7, 16},
        {&nocona_cost, 0, 0, 0, 0, 0, 0, 0},
        {&generic32_cost, 0, 0, 16, 7, 16, 7, 16},
!       {&generic64_cost, 0, 0, 16, 7, 16, 7, 16}
      };
  
    static const char * const cpu_names[] = TARGET_CPU_DEFAULT_NAMES;
--- 1589,1596 ----
        {&k8_cost, 0, 0, 16, 7, 16, 7, 16},
        {&nocona_cost, 0, 0, 0, 0, 0, 0, 0},
        {&generic32_cost, 0, 0, 16, 7, 16, 7, 16},
!       {&generic64_cost, 0, 0, 16, 7, 16, 7, 16},
!       {&amdfam10_cost, 0, 0, 32, 24, 32, 7, 32}
      };
  
    static const char * const cpu_names[] = TARGET_CPU_DEFAULT_NAMES;
*************** override_options (void)
*** 1475,1481 ****
  	  PTA_PREFETCH_SSE = 16,
  	  PTA_3DNOW = 32,
  	  PTA_3DNOW_A = 64,
! 	  PTA_64BIT = 128
  	} flags;
      }
    const processor_alias_table[] =
--- 1607,1617 ----
  	  PTA_PREFETCH_SSE = 16,
  	  PTA_3DNOW = 32,
  	  PTA_3DNOW_A = 64,
! 	  PTA_64BIT = 128,
! 	  PTA_CX16 = 256,
!  	  PTA_POPCNT = 512,
!  	  PTA_ABM = 1024,
!   	  PTA_SSE4A = 2048
  	} flags;
      }
    const processor_alias_table[] =
*************** override_options (void)
*** 1526,1531 ****
--- 1662,1675 ----
  				      | PTA_3DNOW_A | PTA_SSE | PTA_SSE2},
        {"athlon-fx", PROCESSOR_K8, PTA_MMX | PTA_PREFETCH_SSE | PTA_3DNOW | PTA_64BIT
  				      | PTA_3DNOW_A | PTA_SSE | PTA_SSE2},
+       {"amdfam10", PROCESSOR_AMDFAM10, PTA_MMX | PTA_PREFETCH_SSE | PTA_3DNOW
+                                        | PTA_64BIT | PTA_3DNOW_A | PTA_SSE
+                                        | PTA_SSE2 | PTA_SSE3 | PTA_POPCNT
+                                        | PTA_ABM | PTA_SSE4A | PTA_CX16},
+       {"barcelona", PROCESSOR_AMDFAM10, PTA_MMX | PTA_PREFETCH_SSE | PTA_3DNOW
+                                        | PTA_64BIT | PTA_3DNOW_A | PTA_SSE
+                                        | PTA_SSE2 | PTA_SSE3 | PTA_POPCNT
+        | PTA_ABM | PTA_SSE4A | PTA_CX16},
        {"generic32", PROCESSOR_GENERIC32, 0 /* flags are only used for -march switch.  */ },
        {"generic64", PROCESSOR_GENERIC64, PTA_64BIT /* flags are only used for -march switch.  */ },
      };
*************** override_options (void)
*** 1685,1690 ****
--- 1829,1843 ----
  	  target_flags |= MASK_SSE3;
  	if (processor_alias_table[i].flags & PTA_PREFETCH_SSE)
  	  x86_prefetch_sse = true;
+  	if (processor_alias_table[i].flags & PTA_POPCNT
+  	    && !(target_flags_explicit & MASK_POPCNT))
+  	  target_flags |= MASK_POPCNT;
+  	if (processor_alias_table[i].flags & PTA_ABM
+  	    && !(target_flags_explicit & MASK_ABM))
+  	  target_flags |= MASK_ABM;
+ 	if (processor_alias_table[i].flags & PTA_SSE4A
+  	    && !(target_flags_explicit & MASK_SSE4A))
+  	  target_flags |= MASK_SSE4A;	
  	if (TARGET_64BIT && !(processor_alias_table[i].flags & PTA_64BIT))
  	  error ("CPU you selected does not support x86-64 "
  		 "instruction set");
*************** override_options (void)
*** 1859,1864 ****
--- 2012,2021 ----
    if (!TARGET_80387)
      target_flags |= MASK_NO_FANCY_MATH_387;
  
+   /* Turn on SSE3 builtins for -msse4a.  */
+   if (TARGET_SSE4A)
+     target_flags |= MASK_SSE3;
+ 
    /* Turn on SSE2 builtins for -msse3.  */
    if (TARGET_SSE3)
      target_flags |= MASK_SSE2;
*************** override_options (void)
*** 1878,1883 ****
--- 2035,2044 ----
    if (TARGET_3DNOW)
      target_flags |= MASK_MMX;
  
+   /* Turn on POPCNT builtins for -mabm.  */
+   if (TARGET_ABM)
+     target_flags |= MASK_POPCNT;
+ 
    if (TARGET_64BIT)
      {
        if (TARGET_ALIGN_DOUBLE)
*************** ix86_expand_vector_move_misalign (enum m
*** 9106,9111 ****
--- 9267,9280 ----
  	{
  	  rtx zero;
  
+           if (TARGET_SSE_UNALIGNED_MOVE_OPTIMAL)
+             {
+               op0 = gen_lowpart (V2DFmode, op0);
+               op1 = gen_lowpart (V2DFmode, op1);
+               emit_insn (gen_sse2_movupd (op0, op1));
+               return;
+             }
+ 
  	  /* When SSE registers are split into halves, we can avoid
  	     writing to the top half twice.  */
  	  if (TARGET_SSE_SPLIT_REGS)
*************** ix86_expand_vector_move_misalign (enum m
*** 9133,9138 ****
--- 9302,9315 ----
  	}
        else
  	{
+           if (TARGET_SSE_UNALIGNED_MOVE_OPTIMAL)
+             {
+               op0 = gen_lowpart (V4SFmode, op0);
+               op1 = gen_lowpart (V4SFmode, op1);
+               emit_insn (gen_sse_movups (op0, op1));
+               return;
+             }
+ 
  	  if (TARGET_SSE_PARTIAL_REG_DEPENDENCY)
  	    emit_move_insn (op0, CONST0_RTX (mode));
  	  else
*************** ix86_issue_rate (void)
*** 13689,13694 ****
--- 13866,13872 ----
      case PROCESSOR_PENTIUM4:
      case PROCESSOR_ATHLON:
      case PROCESSOR_K8:
+     case PROCESSOR_AMDFAM10:
      case PROCESSOR_NOCONA:
      case PROCESSOR_GENERIC32:
      case PROCESSOR_GENERIC64:
*************** ix86_adjust_cost (rtx insn, rtx link, rt
*** 13884,13889 ****
--- 14062,14068 ----
  
      case PROCESSOR_ATHLON:
      case PROCESSOR_K8:
+     case PROCESSOR_AMDFAM10:
      case PROCESSOR_GENERIC32:
      case PROCESSOR_GENERIC64:
        memory = get_attr_memory (insn);
*************** enum ix86_builtins
*** 14561,14566 ****
--- 14740,14753 ----
    IX86_BUILTIN_MONITOR,
    IX86_BUILTIN_MWAIT,
  
+   /* AMDFAM10 - SSE4A New Instructions.  */
+   IX86_BUILTIN_MOVNTSD,
+   IX86_BUILTIN_MOVNTSS,
+   IX86_BUILTIN_EXTRQI,
+   IX86_BUILTIN_EXTRQ,
+   IX86_BUILTIN_INSERTQI,
+   IX86_BUILTIN_INSERTQ,
+ 
    IX86_BUILTIN_VEC_INIT_V2SI,
    IX86_BUILTIN_VEC_INIT_V4HI,
    IX86_BUILTIN_VEC_INIT_V8QI,
*************** ix86_init_mmx_sse_builtins (void)
*** 15232,15237 ****
--- 15419,15436 ----
      = build_function_type_list (void_type_node,
  			        pchar_type_node, V16QI_type_node, NULL_TREE);
  
+   tree v2di_ftype_v2di_unsigned_unsigned
+     = build_function_type_list (V2DI_type_node, V2DI_type_node,
+                                 unsigned_type_node, unsigned_type_node,
+                                 NULL_TREE);
+   tree v2di_ftype_v2di_v2di_unsigned_unsigned
+     = build_function_type_list (V2DI_type_node, V2DI_type_node, V2DI_type_node,
+                                 unsigned_type_node, unsigned_type_node,
+                                 NULL_TREE);
+   tree v2di_ftype_v2di_v16qi
+     = build_function_type_list (V2DI_type_node, V2DI_type_node, V16QI_type_node,
+                                 NULL_TREE);
+ 
    tree float80_type;
    tree float128_type;
    tree ftype;
*************** ix86_init_mmx_sse_builtins (void)
*** 15518,15523 ****
--- 15717,15736 ----
    def_builtin (MASK_SSE3, "__builtin_ia32_lddqu",
  	       v16qi_ftype_pcchar, IX86_BUILTIN_LDDQU);
  
+   /* AMDFAM10 SSE4A New built-ins  */
+   def_builtin (MASK_SSE4A, "__builtin_ia32_movntsd", 
+                void_ftype_pdouble_v2df, IX86_BUILTIN_MOVNTSD);
+   def_builtin (MASK_SSE4A, "__builtin_ia32_movntss", 
+                void_ftype_pfloat_v4sf, IX86_BUILTIN_MOVNTSS);
+   def_builtin (MASK_SSE4A, "__builtin_ia32_extrqi", 
+                v2di_ftype_v2di_unsigned_unsigned, IX86_BUILTIN_EXTRQI);
+   def_builtin (MASK_SSE4A, "__builtin_ia32_extrq",
+                v2di_ftype_v2di_v16qi,  IX86_BUILTIN_EXTRQ);
+   def_builtin (MASK_SSE4A, "__builtin_ia32_insertqi",
+                v2di_ftype_v2di_v2di_unsigned_unsigned, IX86_BUILTIN_INSERTQI);
+   def_builtin (MASK_SSE4A, "__builtin_ia32_insertq",
+                v2di_ftype_v2di_v2di, IX86_BUILTIN_INSERTQ);
+ 
    /* Access to the vec_init patterns.  */
    ftype = build_function_type_list (V2SI_type_node, integer_type_node,
  				    integer_type_node, NULL_TREE);
*************** ix86_expand_builtin (tree exp, rtx targe
*** 16014,16022 ****
    enum insn_code icode;
    tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    tree arglist = TREE_OPERAND (exp, 1);
!   tree arg0, arg1, arg2;
!   rtx op0, op1, op2, pat;
!   enum machine_mode tmode, mode0, mode1, mode2;
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
  
    switch (fcode)
--- 16227,16235 ----
    enum insn_code icode;
    tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
    tree arglist = TREE_OPERAND (exp, 1);
!   tree arg0, arg1, arg2, arg3;
!   rtx op0, op1, op2, op3, pat;
!   enum machine_mode tmode, mode0, mode1, mode2, mode3, mode4;
    unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
  
    switch (fcode)
*************** ix86_expand_builtin (tree exp, rtx targe
*** 16446,16451 ****
--- 16659,16772 ----
        return ix86_expand_unop_builtin (CODE_FOR_sse3_lddqu, arglist,
  				       target, 1);
  
+     case IX86_BUILTIN_MOVNTSD:
+       return ix86_expand_store_builtin (CODE_FOR_sse4a_vmmovntv2df, arglist);
+ 
+     case IX86_BUILTIN_MOVNTSS:
+       return ix86_expand_store_builtin (CODE_FOR_sse4a_vmmovntv4sf, arglist);
+ 
+     case IX86_BUILTIN_INSERTQ:
+     case IX86_BUILTIN_EXTRQ:
+       icode = (fcode == IX86_BUILTIN_EXTRQ
+                ? CODE_FOR_sse4a_extrq
+                : CODE_FOR_sse4a_insertq);
+       arg0 = TREE_VALUE (arglist);
+       arg1 = TREE_VALUE (TREE_CHAIN (arglist));
+       op0 = expand_normal (arg0);
+       op1 = expand_normal (arg1);
+       tmode = insn_data[icode].operand[0].mode;
+       mode1 = insn_data[icode].operand[1].mode;
+       mode2 = insn_data[icode].operand[2].mode;
+       if (! (*insn_data[icode].operand[1].predicate) (op0, mode1))
+         op0 = copy_to_mode_reg (mode1, op0);
+       if (! (*insn_data[icode].operand[2].predicate) (op1, mode2))
+         op1 = copy_to_mode_reg (mode2, op1);
+       if (optimize || target == 0
+           || GET_MODE (target) != tmode
+           || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
+         target = gen_reg_rtx (tmode);
+       pat = GEN_FCN (icode) (target, op0, op1);
+       if (! pat)
+         return NULL_RTX;
+       emit_insn (pat);
+       return target;
+ 
+     case IX86_BUILTIN_EXTRQI:
+       icode = CODE_FOR_sse4a_extrqi;
+       arg0 = TREE_VALUE (arglist);
+       arg1 = TREE_VALUE (TREE_CHAIN (arglist));
+       arg2 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
+       op0 = expand_normal (arg0);
+       op1 = expand_normal (arg1);
+       op2 = expand_normal (arg2);
+       tmode = insn_data[icode].operand[0].mode;
+       mode1 = insn_data[icode].operand[1].mode;
+       mode2 = insn_data[icode].operand[2].mode;
+       mode3 = insn_data[icode].operand[3].mode;
+       if (! (*insn_data[icode].operand[1].predicate) (op0, mode1))
+         op0 = copy_to_mode_reg (mode1, op0);
+       if (! (*insn_data[icode].operand[2].predicate) (op1, mode2))
+         {
+           error ("index mask must be an immediate");
+           return gen_reg_rtx (tmode);
+         }
+       if (! (*insn_data[icode].operand[3].predicate) (op2, mode3))
+         {
+           error ("length mask must be an immediate");
+           return gen_reg_rtx (tmode);
+         }
+       if (optimize || target == 0
+           || GET_MODE (target) != tmode
+           || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
+         target = gen_reg_rtx (tmode);
+       pat = GEN_FCN (icode) (target, op0, op1, op2);
+       if (! pat)
+         return NULL_RTX;
+       emit_insn (pat);
+       return target;
+ 
+     case IX86_BUILTIN_INSERTQI:
+       icode = CODE_FOR_sse4a_insertqi;
+       arg0 = TREE_VALUE (arglist);
+       arg1 = TREE_VALUE (TREE_CHAIN (arglist));
+       arg2 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist)));
+       arg3 = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (arglist))));
+       op0 = expand_normal (arg0);
+       op1 = expand_normal (arg1);
+       op2 = expand_normal (arg2);
+       op3 = expand_normal (arg3);
+       tmode = insn_data[icode].operand[0].mode;
+       mode1 = insn_data[icode].operand[1].mode;
+       mode2 = insn_data[icode].operand[2].mode;
+       mode3 = insn_data[icode].operand[3].mode;
+       mode4 = insn_data[icode].operand[4].mode;
+ 
+       if (! (*insn_data[icode].operand[1].predicate) (op0, mode1))
+         op0 = copy_to_mode_reg (mode1, op0);
+ 
+       if (! (*insn_data[icode].operand[2].predicate) (op1, mode2))
+         op1 = copy_to_mode_reg (mode2, op1);
+ 
+       if (! (*insn_data[icode].operand[3].predicate) (op2, mode3))
+         {
+           error ("index mask must be an immediate");
+           return gen_reg_rtx (tmode);
+         }
+       if (! (*insn_data[icode].operand[4].predicate) (op3, mode4))
+         {
+           error ("length mask must be an immediate");
+           return gen_reg_rtx (tmode);
+         }
+       if (optimize || target == 0
+           || GET_MODE (target) != tmode
+           || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
+         target = gen_reg_rtx (tmode);
+       pat = GEN_FCN (icode) (target, op0, op1, op2, op3);
+       if (! pat)
+         return NULL_RTX;
+       emit_insn (pat);
+       return target;
+ 
      case IX86_BUILTIN_VEC_INIT_V2SI:
      case IX86_BUILTIN_VEC_INIT_V4HI:
      case IX86_BUILTIN_VEC_INIT_V8QI:

-- 
Michael Meissner, AMD
90 Central Street, MS 83-29, Boxborough, MA, 01719, USA
michael.meissner@amd.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]