diff mbox

[i386] : Use pextr for TARGET_SSE4_1 when creating STV scalar copy

Message ID CAFULd4Yfi5p=wPzb5-Fv9bocETwY+Pz5vojOzqgxHSCyMAxykA@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Feb. 3, 2017, 6:59 p.m. UTC
Hello!

This patch fixes asymmetry for TARGET_SSE4_1, where pinsr was used to
create vector copy, but not pextr when creating scalar copy with
-mstv.

2017-02-03  Uros Bizjak  <ubizjak@gmail.com>

    * config/i386/i386.c (dimode_scalar_chain::convert_reg):
    Use pextrd for TARGET_SSE4_1 when creating scalar copy.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32},
configured with --with-arch=core-avx-i.

Committed to mainline SVN.

Uros.
diff mbox

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 01a05c6..3a65945 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3622,11 +3622,26 @@  dimode_scalar_chain::convert_reg (unsigned regno)
 
       if (scalar_copy)
 	{
-	  rtx vcopy = gen_reg_rtx (V2DImode);
-
 	  start_sequence ();
-	  if (TARGET_INTER_UNIT_MOVES_FROM_VEC)
+	  if (TARGET_SSE4_1)
+	    {
+	      rtx tmp = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (1, const0_rtx));
+	      emit_insn
+		(gen_rtx_SET
+		 (gen_rtx_SUBREG (SImode, scopy, 0),
+		  gen_rtx_VEC_SELECT (SImode,
+				      gen_rtx_SUBREG (V4SImode, reg, 0), tmp)));
+
+	      tmp = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (1, const1_rtx));
+	      emit_insn
+		(gen_rtx_SET
+		 (gen_rtx_SUBREG (SImode, scopy, 4),
+		  gen_rtx_VEC_SELECT (SImode,
+				      gen_rtx_SUBREG (V4SImode, reg, 0), tmp)));
+	    }
+	  else if (TARGET_INTER_UNIT_MOVES_FROM_VEC)
 	    {
+	      rtx vcopy = gen_reg_rtx (V2DImode);
 	      emit_move_insn (vcopy, gen_rtx_SUBREG (V2DImode, reg, 0));
 	      emit_move_insn (gen_rtx_SUBREG (SImode, scopy, 0),
 			      gen_rtx_SUBREG (SImode, vcopy, 0));