diff --git a/gcc/testsuite/gcc.dg/vect/vect-live-5.c b/gcc/testsuite/gcc.dg/vect/vect-live-5.c
index f475ca822b18874c5beca7465ae2094281644d96..188e4faf71334a6045296a7a98fa34274895955c 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-live-5.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-live-5.c
@@ -46,5 +46,4 @@ main (void)
 }
 
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "vec_stmt_relevant_p: stmt live but not relevant" 1 "vect" } } */
-/* { dg-final { scan-tree-dump "statement is simple and uses invariant.  Leaving in place" "vect" } } */
+/* { dg-final { scan-tree-dump-not "vec_stmt_relevant_p: stmt live but not relevant" "vect" } } */
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index f72ac37ad29d00fba3af3c04f8048d8a943d10b8..08b1c0ebfdabf525a2fda8335a92285c0c79b970 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -6343,11 +6343,12 @@ vectorizable_live_operation (gimple *stmt,
   if (nested_in_vect_loop_p (loop, stmt))
     return false;
 
-  /* If STMT is a simple assignment and its inputs are invariant, then it can
-     remain in place, unvectorized.  The original last scalar value that it
-     computes will be used.  */
-  if (is_simple_and_all_uses_invariant (stmt, loop_vinfo))
+  /* If STMT is not relevant and it is a simple assignment and its inputs are
+     invariant then it can remain in place, unvectorized.  The original last
+     scalar value that it computes will be used.  */
+  if (!STMT_VINFO_RELEVANT_P (stmt_info))
     {
+      gcc_assert (is_simple_and_all_uses_invariant (stmt, loop_vinfo));
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
 			 "statement is simple and uses invariant.  Leaving in "
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index cd7a1719c43b4df0e48cdbaedc0fc04167567217..1ef924a4aa07aa626a603f5fb59bf991a89c1d9a 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -335,7 +335,8 @@ vect_stmt_relevant_p (gimple *stmt, loop_vec_info loop_vinfo,
 	}
     }
 
-  if (*live_p && *relevant == vect_unused_in_scope)
+  if (*live_p && *relevant == vect_unused_in_scope
+      && !is_simple_and_all_uses_invariant (stmt, loop_vinfo))
     {
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
