i386: Improve variable permutation insn avoidance [PR101021]

Message ID CAFULd4b=K9n4waBh7reScF72Nmj+d6tOpmFPkurQFRyAVF9p_A@mail.gmail.com
State New
Headers show
Series
  • i386: Improve variable permutation insn avoidance [PR101021]
Related show

Commit Message

H.J. Lu via Gcc-patches June 13, 2021, 7:53 p.m.
Emit constant permutation insn directly from expand_vec_perm_shufb.

2021-06-13  UroŇ° Bizjak  <ubizjak@gmail.com>

gcc/
    PR target/101021
    * config/i386/i386-expand.c (expand_vec_perm_pshufb):
    Emit constant permutation insn directly from here.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Pushed to master.

Uros.

Patch

diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index 2fa3a18dc6a..6e33f6f8196 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -17593,13 +17593,16 @@  expand_vec_perm_pshufb (struct expand_vec_perm_d *d)
 	return false;
     }
 
-  /* Try to avoid variable permutation instruction.  */
-  if (canonicalize_vector_int_perm (d, &nd) && expand_vec_perm_1 (&nd))
-    return false;
-
   if (d->testing_p)
     return true;
 
+  /* Try to avoid variable permutation instruction.  */
+  if (canonicalize_vector_int_perm (d, &nd) && expand_vec_perm_1 (&nd))
+    {
+      emit_move_insn (d->target, gen_lowpart (d->vmode, nd.target));
+      return true;
+    }
+
   if (vmode == V8SImode)
     for (i = 0; i < 8; ++i)
       rperm[i] = GEN_INT ((d->perm[i * nelt / 8] * 8 / nelt) & 7);