Simplify trivial VEC_COND_EXPR in expander.
authorliuhongt <hongtao.liu@intel.com>
Wed, 21 Oct 2020 05:05:16 +0000 (13:05 +0800)
committerliuhongt <hongtao.liu@intel.com>
Wed, 21 Oct 2020 09:33:53 +0000 (17:33 +0800)
gcc/ChangeLog:

PR target/97506
* config/i386/i386-expand.c (ix86_expand_sse_movcc): Move
op_true to dest directly when op_true equals op_false.

gcc/testsuite/ChangeLog:

PR target/97506
* gcc.target/i386/pr97506.c: New test.

gcc/config/i386/i386-expand.c
gcc/testsuite/gcc.target/i386/pr97506.c [new file with mode: 0644]

index 02d5ca5..d0d7a96 100644 (file)
@@ -3525,6 +3525,13 @@ ix86_expand_sse_movcc (rtx dest, rtx cmp, rtx op_true, rtx op_false)
   machine_mode mode = GET_MODE (dest);
   machine_mode cmpmode = GET_MODE (cmp);
 
+  /* Simplify trivial VEC_COND_EXPR to avoid ICE in pr97506.  */
+  if (rtx_equal_p (op_true, op_false))
+    {
+      emit_move_insn (dest, op_true);
+      return;
+    }
+
   /* In AVX512F the result of comparison is an integer mask.  */
   bool maskcmp = mode != cmpmode && ix86_valid_mask_cmp_mode (mode);
 
diff --git a/gcc/testsuite/gcc.target/i386/pr97506.c b/gcc/testsuite/gcc.target/i386/pr97506.c
new file mode 100644 (file)
index 0000000..74714cf
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR target/97506  */
+/* { dg-do compile } */
+/* { dg-options "-Og -finline-functions-called-once -fno-tree-ccp -mavx512vbmi -mavx512vl" } */
+
+typedef unsigned char __attribute__ ((__vector_size__ (16))) U;
+typedef int __attribute__ ((__vector_size__ (4))) V;
+U u;
+
+void
+bar (int i, V v)
+{
+  u += (char) i & (char) i > (U){};
+}
+
+void
+foo (void)
+{
+  bar (0, (V){});
+}