i386: Do not emit mask compares for mode sizes < 16 [PR100445]

Message ID CAFULd4Z8_85+jGgXTUEY60cb77zNcAT9TDNxdXki2bK_auYCGw@mail.gmail.com
State New
Headers show
Series
  • i386: Do not emit mask compares for mode sizes < 16 [PR100445]
Related show

Commit Message

Andre Vehreschild via Gcc-patches May 7, 2021, 9:18 a.m.
Recent addition of v*cond* patterns for MMXMODEI modes allows 64bit MMX
modes to enter ix86_expand_sse_cmp. ix86_use_mask_cmp_p was not prepared
to reject mode sizes < 16, resulting in ICE due to unavailability of 64bit
masked PCOM instructions.

2021-05-07  UroŇ° Bizjak  <ubizjak@gmail.com>

gcc/
    PR target/100445
    * config/i386/i386-expand.c (ix86_use_mask_cmp_p):
    Return false for mode sizes < 16.

gcc/testsuite/

    PR target/100445
    * gcc.target/i386/pr100445-1.c: New test.

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 4dfe7d6c282..61b2f921f41 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -3490,7 +3490,11 @@  static bool
 ix86_use_mask_cmp_p (machine_mode mode, machine_mode cmp_mode,
 		     rtx op_true, rtx op_false)
 {
-  if (GET_MODE_SIZE (mode) == 64)
+  int vector_size = GET_MODE_SIZE (mode);
+
+  if (vector_size < 16)
+    return false;
+  else if (vector_size == 64)
     return true;
 
   /* When op_true is NULL, op_false must be NULL, or vice versa.  */
diff --git a/gcc/testsuite/gcc.target/i386/pr100445-1.c b/gcc/testsuite/gcc.target/i386/pr100445-1.c
new file mode 100644
index 00000000000..a1c18aff0f9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr100445-1.c
@@ -0,0 +1,5 @@ 
+/* PR target/100445 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -mavx512vl" } */
+
+#include "pr96827.c"